Tag: r-faq

53 votes
18 answers
825 views
How should I deal with "package 'xxx' is not available (for R version x.y.z)" warning?

I tried to install a package, using install.packages("foobarbaz") but received the warning Warning message

avatar
Percy
0 1 0 9
asked 07 September, 2021
44 votes
11 answers
1K views
How can I view the source code for a function?

I want to look at the source code for a function to see how it works. I know I can print a function by typing

avatar
Elicia
0 1 0 9
asked 07 September, 2021
57 votes
16 answers
2.3K views
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 <- pnorm(x) y2 <- pnorm(x

avatar
Lynette
0 1 0 9
asked 07 September, 2021
61 votes
11 answers
1.1K views
How to convert a factor to integer umeric without loss of information?

When I convert a factor to a numeric or integer, I get the underlying level codes, not the values as numbers.

avatar
Royal
0 1 0 9
asked 07 September, 2021
53 votes
8 answers
503 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
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
638 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
698 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