Rounding a very small number in character format [closed] - r

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have a very small number like 1.466013e-65,
I want to round it to 3 decimals left while keeping all the 0s, here is the code I used:
round(1.466013e-65,3)
this will get me 0, but I want it to be 0.000.
How to do it?

If you are fine with character, then you can do it using:-
sprintf("%.3f", round(1.466013e-65, 3))
[1] "0.000"

Related

How to add parentheses between numbers? I know how to add dashes, are they doing the same way? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
how to add parentheses between numbers? I know how to add dashes, are they doing the same way? like 123456789 to (123)456789 in R programming?
sub("(\\d{3})", "(\\1)", 123456789)
[1] "(123)456789"

Rstudio rep() and seq() [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I need to iterate a sequence that is being repeated.
Say I have a vector of 1,2,3 I want printed out 5 times.
each time needs to be inceased by one.
so 1,2,3,2,3,4,3,4,5,4,5,6,5,6,7
rep(1:3, 5) + rep(0:4, each=3)
should do the trick

Specific code from SAS to R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am trying to write this (SAS) comand in R. x is a variable with this specific format: j61915035t
x1 = trim(upcase(substr(x,1,1)));
I really appreciate what you are doing in this site!
You want to remove leading/trailing blanks from a character string that is the uppercase first letter of the string x. So this should do it.
library(stringr)
x1 = str_trim(str_to_upper(str_sub(x,1,1)))

R: Vector Group by Defined group [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a vector c("A","B","C",......) and a list list(c("A"),c("B","C"))
I want to get a vector c(1,2,2....)
Is there any function in some basic packages?
we can use merge
merge(stack(setNames(lst, seq_along(lst))), data.frame(values=v1))$ind

Get the corresponding value of 80 % of my data [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to calculate which value correspond to 80% of a column data in order to use this value as a limit value (Xlimit). After that I want to get column data>Xlimit.
Try this
x = data.frame(a=sample(1:10),b=sample(1:10))
aLim = quantile(x$a,0.8)
xUpdated = x[x$a>=aLim,]

Resources