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 do you specifically order ggplot2 x axis instead of alphabetical order?

I'm trying to make a heatmap using ggplot2 using the geom_tiles function here is my code below: p<…

r ggplot2 r-faq
How to find common elements from multiple vectors?

Can anyone tell me how to find the common elements from multiple vectors? a <- c(1,3,5,7,9) b <- …

r vector r-faq
Read an Excel file directly from a R script

How can I read an Excel file directly into R? Or should I first export the data to a text- …

excel r r-faq
Evaluate expression given as a string

I'm curious to know if R can use its eval() function to perform calculations provided by e.g. a string. …

r eval r-faq
Counting unique / distinct values by group in a data frame

Let's say I have the following data frame: > myvec name order_no 1 Amy 12 2 Jack 14 3 Jack 16 4 Dave 11 5 Amy 12 6 Jack 16 7 Tom 19 8 …

r dataframe distinct-values r-faq
Simultaneously merge multiple data.frames in a list

I have a list of many data.frames that I want to merge. The issue here is that each data.…

r list merge dataframe r-faq
Aggregate / summarize multiple variables per group (e.g. sum, mean)

From a data frame, is there a easy way to aggregate (sum, mean, max et c) multiple variables simultaneously? Below …

r dataframe data.table aggregate r-faq
Convert a dataframe to a vector (by rows)

I have a dataframe with numeric entries like this one test <- data.frame(x = c(26, 21, 20), y = c(34, 29, 28)) How …

r dataframe vector r-faq
Only read selected columns

Can anyone please tell me how to read only the first 6 months (7 columns) for each year of the data below, …

r import r-faq
Rename multiple columns by names

Someone should have asked this already, but I couldn't find an answer. Say I have: x = data.frame(q=1,w=2,…

r dataframe rename r-faq