> -----Original Message-----
> From: [email protected] [mailto:r-help-bounces@r-
> project.org] On Behalf Of RMSOPS
> Sent: Wednesday, October 26, 2011 9:59 AM
> To: [email protected]
> Subject: [R] Plot complete dataset
>
>
> Hello,
>
> I am a new user of R, so I still have some basic difficulties.
> I'm trying to create a bar graph completely from reading a file.
> The idea was on the x axis have the columns of the table
> Married ,Single,Divorced, widower
> the legend Ages
> 18-34
> 35-45
> 46-64
> 65-69
> 70-74
>
> the dataset
> dataset
> Ages Married Single Divorced widower
> 1 18-34 10.5 35.7 8.5 3.2
> 2 35-45 12.4 22.4 22.2 12.6
> 3 46-64 25.4 22.2 33.4 12.4
> 4 65-69 36.7 31.4 12.4 35.2
> 5 70-74 26.4 15.1 8.5 43.2
>
>
> The code for barplot
>
> barplot(dataset,dataset$Single, col = c(rainbow(dataset$Ages)), legend
> =
> rownames(dataset$Ages), ylim = c(0, 100))
>
> but I am not able to resolve.
>
> Thanks
>
>
You should go back and read the help for barplot. Do you really want to plot
the whole dataset (say as a stacked barplot)? Then something like this should
do it.
barplot(as.matrix(dataset[,2:5]), col = c("lightblue", "mistyrose",
"lightcyan",
"lavender", "cornsilk"),
legend = dataset$Ages, ylim = c(0, 100))
Your values don't add to 100, so I'm not sure what you actually want. If this
isn't what you want then give us more information.
Hope this is helpful,
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
______________________________________________
[email protected] 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.