[R] how do i plot this "hist"?
jim holtman
jholtman at gmail.com
Tue Nov 9 00:48:03 CET 2010
Typing too fast; last line should be:
barplot(t(x.m[, 2:5]), names.arg = x.m[,1], las=2)
On Mon, Nov 8, 2010 at 5:42 PM, casperyc <casperyc at hotmail.co.uk> wrote:
>
> Hi all,
>
> I have the following data in abc.dat
>
> =======================
> 50 0 1 0 0
> 55 1 14 0 1
> 60 7 86 0 3
> 65 22 324 2 3
> 70 58 1035 1 7
> 75 30 2568 0 34
> 80 9 2936 15 162
> 85 27 2169 46 365
> 90 80 1439 212 432
> 95 236 1670 521 281
> 100 332 827 709 172
> 105 156 311 556 103
> 110 69 49 144 44
> 115 26 10 36 17
> 120 2 9 3 3
> 125 1 6 1 1
> 130 0 14 0 0
> 135 0 5 0 0
> 140 0 0 0 0
> 145 0 0 0 0
> 150 0 0 0 0
> 155 0 0 0 0
> 160 0 0 0 0
> 165 0 0 0 0
> 170 0 0 0 0
> 175 0 0 0 0
> 180 0 0 0 0
> 185 0 0 0 0
> 190 0 0 0 1
> 195 0 0 0 0
> 200 0 0 0 0
> 205 0 0 0 0
> 210 0 0 0 0
> =======================
>
> which i have used
>
> abc=read.table("abc.dat")
>
> to read the table into R.
>
> There are two problems:
>
> 1- I want the first column of the data to be
> the 'column names', how should i read the data?
>
> 2- I want to plot the histogram, using the first column as
> 'x' values, and the 2nd,3rd,4th and 5th columns as the frequencies.
>
> How do I plot it?
>
>
> I have tried to add a 'row' of variable names to it,
> and then read with 'header=T', then the first column
> become 'col.names' as I was expecting it to be.
>
> However, when I plot it using 'hist',
> R uses the 2nd column as the 'x value', where it should be used as
> 'frequency'.
> (the 50,55,60,65,70... should be on the x-axis)
>
> Thanks!
>
> Casper
> --
> View this message in context: http://r.789695.n4.nabble.com/how-do-i-plot-this-hist-tp3032796p3032796.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list