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.

How to filter a data frame

I have a data frame and tried to select only the observations I'm interested in by this: data[data["Var1"]&…

r filter r-faq
Dynamically select data frame columns using $ and a character value

I have a vector of different column names and I want to be able to loop over each of them …

r dataframe r-faq
Paste multiple columns together

I have a bunch of columns in a dataframe which I want to paste together (seperated by "-") as follows: …

r paste r-faq
Convert UNIX epoch to Date object

I'm plotting and performing calculations on uniformly distributed time series. The timestamps are currently stored as integers representing the number …

r time r-faq
Convert integer to class Date

I have an integer which I want to convert to class Date. I assume I first need to convert it …

r date r-faq
Numbering rows within groups in a data frame

Working with a data frame similar to this: set.seed(100) df <- data.frame(cat = c(rep("aaa", 5), rep("…

r dataframe r-faq
Create an ID (row number) column

I need to create a column with unique ID, basically add the row number as an own column. My current …

r dataframe r-faq
Count number of rows per group and add result to original data frame

Say I have a data.frame object: df <- data.frame(name=c('black','black','black','red','red'), type=…

r count aggregate r-faq
How to name variables on the fly?

Is it possible to create new variable names on the fly? I'd like to read data frames from a list …

r assign r-faq
rank and order in R

i am having trouble understanding the difference between the R function rank and the R function order. they seem to …

r sorting r-faq