Thursday, December 13, 2012

How to create histogram in R using single column data

Lets say you have a data file file.txt with all the values you need the histogram to be generated on.

file.txt
1
2
3
1
1
0


In R, you can simply load the file in a vector and not a data frame using scan
x <- br="br" file.txt="file.txt" scan="scan">

Then run the following
hist(x,breaks=5)

Where breaks is the number of bins you want the histogram to span.


No comments:

Post a Comment