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.

Sample random rows in dataframe

I am struggling to find the appropriate function that would return a specified number of rows picked up randomly without …

r dataframe random r-faq
R memory management / cannot allocate vector of size n Mb

I am running into issues trying to use large objects in R. For example: > memory.limit(4000) > a = matrix(…

r matrix vector memory-management r-faq
Error: could not find function ... in R

This is meant to be a FAQ question, so please be as complete as possible. The answer is a community …

r function error-handling r-faq
Error in <my code> : object of type 'closure' is not subsettable

I was finally able to work out the code for my scraping. It seemed to be working fine and then …

r r-faq
Split data frame string column into multiple columns

I'd like to take data of the form before = data.frame(attr = c(1,30,4,6), type=c('foo_and_bar','foo_and_…

r string dataframe split r-faq
Grouping functions (tapply, by, aggregate) and the *apply family

Whenever I want to do something "map"py in R, I usually try to use a function in the apply …

r lapply sapply tapply r-faq
Drop unused factor levels in a subsetted data frame

I have a data frame containing a factor. When I create a subset of this dataframe using subset or another …

r dataframe r-factor r-faq
Combine two or more columns in a dataframe into a new column with a new name

For example if I have this: n = c(2, 3, 5) s = c("aa", "bb", "cc") b = c(TRUE, FALSE, TRUE) df = data.…

r dataframe multiple-columns r-faq
Remove duplicated rows

I have read a CSV file into an R data.frame. Some of the rows have the same element in …

r duplicates r-faq
How to unload a package without restarting R

I'd like to unload a package without having to restart R (mostly because restarting R as I try out different, …

r package r-faq