[R] Beginner: error when I plot histogram from imported table
jdnewmil at dcn.davis.ca.us
Sun Feb 21 06:18:42 CET 2016
You should compare the output of str(da) with the output of str(1:10)... da is a data.frame that contains one column (a numeric vector). Data.frames are not numeric, they are lists of columns.
Replace da with da$ytsim1 in your call to hist.
Sent from my phone. Please excuse my brevity.
On February 20, 2016 2:10:43 PM PST, Arslan Rehman <goheer_ at hotmail.com> wrote:
>Hello R users,
>#I import a txt file from following code:
>> head(da) ytsim1 3.04497412 -0.95401593 0.25043094 -0.69580895
>#Now, I get error for following code:
>> hist(da,freq=FALSE,nclass=30,ylim=c(0,60),col="blue")Error in
>hist.default(da, freq = FALSE, nclass = 30, ylim = c(0, 60), : 'x'
>must be numeric
>#when I check imported data it mention it is numeric?
>> str(da)'data.frame': 999 obs. of 1 variable: $ ytsim: num 3.045
>-0.954 0.25 -0.696 1.952 ..
>#If not, how do I convert and then plot histogram.
>#I also want to plot a probability density line afterwards
>Any help is appreciated.
> [[alternative HTML version deleted]]
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help