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 to add leading zeros?

I have a set of data which looks something like this: anim <- c(25499,25500,25501,25502,25503,25504) sex <- c(1,2,2,1,2,1) wt &…

r formatting number-formatting r-faq
Export data from R to Excel

I am writing codes to export database from R into Excel, I have been trying others codes including: write.table(…

r excel r-faq
Count number of rows within each group

I have a dataframe and I would like to count the number of rows within each group. I reguarly use …

r dataframe aggregate r-faq
Fitting a density curve to a histogram in R

Is there a function in R that fits a curve to a histogram? Let's say you had the following histogram …

r histogram curve-fitting r-faq
What does "Error: object '<myvariable>' not found" mean?

I got the error message: Error: object 'x' not found Or a more complex version like Error in mean(x) : …

r r-faq
Warning message: In `...` : invalid factor level, NA generated

I don't understand why I got this warning message. > fixed <- data.frame("Type" = character(3), "Amount" = numeric(3)) > …

r warnings r-faq
Calculating moving average

I'm trying to use R to calculate the moving average over a series of values in a matrix. The normal …

r moving-average r-faq
Order discrete x scale by frequency/value

I am making a dodged bar chart using ggplot with discrete x scale, the x axis are now arranged in …

r ggplot2 r-faq
The difference between bracket [ ] and double bracket [[ ]] for accessing the elements of a list or dataframe

R provides two different methods for accessing the elements of a list or data.frame: [] and [[]]. What is the difference …

r list dataframe extract r-faq
How do I make a list of data frames?

How do I make a list of data frames and how do I access each of those data frames from …

r list dataframe r-faq