Top "R-faq" questions

The r-faq tag is created to group a limited number of questions discussing problems that come up regularly on the R tag.

Use of ~ (tilde) in R programming Language

I saw in a tutorial about regression modeling the following command : myFormula <- Species ~ Sepal.Length + Sepal.Width + Petal.…

r r-faq
Converting year and month ("yyyy-mm" format) to a date?

I have a dataset that looks like this: Month count 2009-01 12 2009-02 310 2009-03 2379 2009-04 234 2009-05 14 2009-08 1 2009-09 34 2009-10 2386 I want …

r date posix zoo r-faq
Reshaping data.frame from wide to long format

I have some trouble to convert my data.frame from a wide table to a long table. At the moment …

r dataframe reshape r-faq
How do I deal with special characters like \^$.?*|+()[{ in my regex?

I want to match a regular expression special character, \^$.?*|+()[{. I tried: x <- "a[b" grepl("[", x) ## Error: invalid …

regex r r-faq
How to subtract/add days from/to a date?

I'm trying to build folders to store data pulls. I want to label the folders with the day of that …

r date r-faq
R data formats: RData, Rda, Rds etc

What are the main differences between .RData, .Rda and .Rds files? More specifically: Are there differences in compression etc? When …

r r-faq rdata rda
Pass a data.frame column name to a function

I'm trying to write a function to accept a data.frame (x) and a column from it. The function performs …

r dataframe r-faq
Determine path of the executing script

I have a script called foo.R that includes another script other.R, which is in the same directory: #!/usr/…

r file path rscript r-faq
Use dynamic variable names in `dplyr`

I want to use dplyr::mutate() to create multiple new columns in a data frame. The column names and their …

r dplyr r-faq
How to read data when some numbers contain commas as thousand separator?

I have a csv file where some of the numerical values are expressed as strings with commas as thousand separator, …

r csv r-faq