This question already has answers here:
How can I paste 100000 without it being shortened to 1e+05? [duplicate]
(3 answers)
Closed 9 years ago.
The result of function was displayed in scientific notation, I want to change it back to normal, but only for that function, I don't want to change the global setting. Can anyone help?
You can do:
format(functionResult, scientific=FALSE);
or:
as.integer(functionResult);
Related
This question already has answers here:
Erlang: What does question mark syntax mean?
(3 answers)
Closed 2 years ago.
I see alot of code in erlang with a question mark before it, what does it mean? Is it Macros or can it be used in another way? Example:
{Total, Pids} = run(10, 20),
?assertEqual(200, Total),
?assert(processes_stopped(Pids)).
or:
?MODULE
When you try call macros, you need add in start of name ‘?’. Notes: the macros can create with or without arguments.
This question already has answers here:
Replace all particular values in a data frame
(8 answers)
How do I deal with special characters like \^$.?*|+()[{ in my regex?
(2 answers)
Closed 4 years ago.
I have a large data frame with a character value in various columns and rows. The character is [subnet].
I am trying to get rid of it by writing the following code
new_data[]=lapply(new_data, gsub, pattern="[subnet]", replacement='')
However, it seems like although "subnet" is disappearing, I am ending up with
"[]" for every instance of the character.
Any idea or fix would be appreciated.
This question already has an answer here:
grepl not searching correctly in R
(1 answer)
Closed 6 years ago.
I want to know if there is a certain string contained in another string. This works fine here:
grepl("a","a")
However, what I actually want to test is the following and this one doesn't work:
grepl("is.na(x)","is.na(x)")
Can anyone help?
You can escape the special characters like this:
grepl("is\\.na\\(x\\)","is.na(x)")
[1] TRUE
This question already has answers here:
Dynamically select data frame columns using $ and a character value
(10 answers)
Closed 8 years ago.
I apologize since I'm sure this is an obvious issue, but I just can't seem to find the correct search terms to come up with the answer.
If I have a dataframe like this:
example<-cbind(rbind(1,2,3),rbind("a","b","c"))
colnames(example)<-c("a","b")
example<-as.data.frame(example)
And I want to extract the values from column a using a variable x,
x<-a
How do I go about this? When I try:
example$x
I get a null. How do I make this work?
I'm assuming a is a character:
x <- "a"
example[,x]
This question already has answers here:
Comma separator for numbers in R?
(4 answers)
Closed 4 years ago.
I often use RStudio for a simple calculations, something like the following
> (3.456+4.008)*13000+1000000
[1] 1097032
And my question (rather stupid, I assume, but I haven't find an answer) is if it's possible to make the output more friendly? E.g.:
> (3.456+4.008)*13000+1000000
[1] 1'097'032
At the prompt:
?format
As an example
format(12345.6789, digits=9, decimal.mark=",");