R

R is a free, open-source programming language and software environment for statistical computing, bioinformatics, visualization and general computing. Provide minimal, reproducible, representative example(s) with your questions. Use dput() for data and specify all non-base packages with library calls. Do not embed pictures for data or code, use indented code blocks.

47 votes
8 answers
776 views
Rotating and spacing axis labels in ggplot2

I have a plot where the x-axis is a factor whose labels are long. While probably not an ideal visualization,

avatar
Rufus
0 1 0 9
asked 07 September, 2021
61 votes
4 answers
2.9K views
data.table vs dplyr: can one do something well the other can't or does poorly?

Overview I'm relatively familiar with data.table, not so much with dplyr. I've read through some d

avatar
Emilia
0 1 0 9
asked 07 September, 2021
53 votes
8 answers
506 views
What are the differences between "=" and "<-" assignment operators in R?

What are the differences between the assignment operators = and <- in R? I know that operators are slight

avatar
Winford
0 1 0 9
asked 07 September, 2021
61 votes
25 answers
2.7K views
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?

avatar
Alba
0 1 0 9
asked 07 September, 2021
60 votes
17 answers
1.7K views
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 exa

avatar
Jefferey
0 1 0 9
asked 07 September, 2021
58 votes
21 answers
1.6K views
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 can delete them indiv

avatar
Hilario
0 1 0 9
asked 07 September, 2021
59 votes
10 answers
642 views
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 family. However,

avatar
Margo
0 1 0 9
asked 07 September, 2021
54 votes
13 answers
2.9K views
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)))

avatar
Dorinda
0 1 0 9
asked 07 September, 2021
64 votes
19 answers
701 views
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 to sort b

avatar
Venice
0 1 0 9
asked 07 September, 2021
52 votes
23 answers
2K views