Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difficulties with simple ggplot histogram

Tags:

r

ggplot2

I'm an absolute beginner at R, so please excuse the simplicity of this question. I'm having trouble loading a file in R and making a histogram plot from a column of data. Here's my code:

library('ggplot2')
df <- read.csv('/PATH/TO/FILE', sep=' ', head=FALSE)
vals <- df[,2]
qplot(df, data=vals, geom="histogram")

Error: ggplot2 doesn't know how to deal with data of class numeric

Can anyone show me what the problem is? Thanks in advance for the help.

like image 813
user1728853 Avatar asked Jan 15 '13 13:01

user1728853


1 Answers

If you need frequency histogram, try this code:

ggplot() + aes(vals)+ geom_histogram(binwidth=1, colour="black", fill="white")
like image 168
Stas Prihod'co Avatar answered Oct 18 '22 16:10

Stas Prihod'co