Colourful commenting in RStudio using #' * * [duplicate] - r

This question already has an answer here:
Different Colored Comments
(1 answer)
Closed 1 year ago.
Since when can you do color comments in R?
#'*this some colorful comment*
#'**
-> gives you the ability to annotate in colour .
I found this by sheer accident & couldn't find anything on the internet about this matter ;
Is this meant for something else, or was it just a secret?

thx to Stefan, i now know its Roxygen!

Related

What does "?" mean in Erlang? [duplicate]

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.

Subscript and new Line [duplicate]

This question already has answers here:
Line break in expression()?
(2 answers)
Closed 2 years ago.
I want to make a legend title reading
CO₂-text1
text2
Since paste()/paste0() doesn't seem to work on expression I also tried using bquote() instead, but can't figure a way to add the new line. My most succesfull attempt so far:
expression("CO"[2]*"-text1 \n"*" text2")
, which results in
-text1
CO₂ text2
expression(atop("CO"[2]~"text1",text2))
solved the issue (see question-comments).

R - Weird behavior of grepl [duplicate]

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

what does "foo" and "bar" mean and why people like use them as example case? [duplicate]

This question already has answers here:
What is the origin of foo and bar? [closed]
(2 answers)
Closed 7 years ago.
In many program test case or example case, i always see "bar" and "foo", what is the two word represent for and why choose this two words as example?
Google can answer your question far better than I. From wiki:
The word foo originated as a nonsense word from the 1930s, the military term FUBAR emerged in the 1940s, and the use of foo in a programming context is generally credited to the Tech Model Railroad Club (TMRC) of MIT from circa 1960.[9] However, the precise relationship of these terms is not known with certainty, and several anecdotal theories have been advanced to identify them.
Also, have a look at this question: What is the origin of foo and bar? as well as this one: https://softwareengineering.stackexchange.com/questions/69788/what-is-the-history-of-the-use-of-foo-and-bar-in-source-code-examples

R displays numbers in scientific notation [duplicate]

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);

Resources