Top "R" questions

R is a free, open-source programming language and software environment for statistical computing, bioinformatics, visualization, and general computing.

Remove rows with all or some NAs (missing values) in data.frame

I'd like to remove the lines in this data frame that: a) contain NAs across all columns. Below is my …

r dataframe filter missing-data r-faq
Drop data frame columns by name

I have a number of columns that I would like to remove from a data frame. I know that we …

r dataframe r-faq
Changing column names of a data frame

I have a data frame called "newprice" (see below) and I want to change the column names in my program …

r dataframe rename
Plot two graphs in same plot in R

I would like to plot y1 and y2 in the same plot. x <- seq(-2, 2, 0.05) y1 <- …

r plot ggplot2 r-faq
How do I replace NA values with zeros in an R dataframe?

I have a data frame and some columns have NA values. How do I replace these NA values with zeroes?

r dataframe na missing-data imputation
How to join (merge) data frames (inner, outer, left, right)

Given two data frames: df1 = data.frame(CustomerId = c(1:6), Product = c(rep("Toaster", 3), rep("Radio", 3))) df2 = data.frame(CustomerId = c(2, 4, 6), …

r join merge dataframe r-faq
How do I delete rows in a data frame?

I have a data frame named "mydata" that looks like this this: A B C D 1. 5 4 4 4 2. 5 4 4 4 3. 5 4 4 4 4. 5 4 4 4 5. 5 4 4 4 6. 5 4 4 4 7. 5 4 4 4 I'd like to delete …

r row
Counting the number of elements with the values of x in a vector

I have a vector of numbers: numbers <- c(4,23,4,23,5,43,54,56,657,67,67,435, 453,435,324,34,456,56,567,65,34,435) How can I have R count the number of times …

r vector count r-faq
How to sort a dataframe by multiple column(s)

I want to sort a data.frame by multiple columns. For example, with the data.frame below I would like …

r sorting dataframe r-faq
Extracting specific columns from a data frame

I have an R data frame with 6 columns, and I want to create a new dataframe that only has three …

r dataframe r-faq