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 select the row with the maximum value in each group

In a dataset with multiple observations for each subject I want to take a subset with only the maximum data …

r dataframe r-faq
Apply several summary functions on several variables by group in one call

I have the following data frame x <- read.table(text = " id1 id2 val1 val2 1 a x 1 9 2 a x 2 4 3 …

r aggregate r-faq
Why is `[` better than `subset`?

When I need to filter a data.frame, i.e., extract rows that meet certain conditions, I prefer to use …

r filter subset r-faq
Group by multiple columns in dplyr, using string vector input

I'm trying to transfer my understanding of plyr into dplyr, but I can't figure out how to group by multiple …

r dplyr r-faq
Split data.frame based on levels of a factor into new data.frames

I'm trying to create separate data.frame objects based on levels of a factor. So if I have: df <…

r dataframe r-faq
Replacing NAs with latest non-NA value

In a data.frame (or data.table), I would like to "fill forward" NAs with the closest previous non-NA value. …

r data.table zoo r-faq
ending "+" prompt in R

I'm fairly new to R and I made a type-o while entering some code and now instead of getting the "&…

r r-faq
Installing older version of R package

I am trying to use Rpy2 and ggplot2 but I get an error. After some searching for the error online, …

r installation version r-faq
Speed up the loop operation in R

I have a big performance problem in R. I wrote a function that iterates over a data.frame object. It …

performance r loops rcpp r-faq
Should I use a data.frame or a matrix?

When should one use a data.frame, and when is it better to use a matrix? Both keep data in …

r matrix dataframe r-faq