I would like to extract the first digit after the decimal point from a number vector in R. Is there a way to do this without turning it into a character string? For example:
x <- c(1.0,1.1,1.2)
I want the function to return a vector:
0,1,2
thanks.
There will be many ways, but here is one of them:
(x %% 1)*10 # [1] 0 1 2
This means that there is only one digit after the decimal point. If this is not the case:
floor((x %% 1)*10)
Source: https://habr.com/ru/post/1527615/More articles:Jade conditions inside script tag - javascriptiOS 7 UIActivityViewController Email Attachments - EmailVisual Studio Browser Link + инструменты для разработчиков Chrome - visual-studio-2013Javascript for a date loop - javascriptHow to deploy war on a remote Tomcat or Jetty server from Maven - mavenjasmine - node - including helper - node.jsIs there a way to insert jquery code into angularjs dom? - javascriptTreat input as hexadecimal values - cGetting started with Tradestation webAPI - pythonHow to read large images as numpy.memmap objects - pythonAll Articles