What is the best way to produce a barplot from my data? I would like the barplot to show each person with the values stacked val1+val2+val3, so there is one bar for each person When I use barplot(data.matrix(realdata)), it shows one bar for each value instead.
To post here, I created an artificical data set, but it works fine. fakedata <- as.data.frame(list(LETTERS[1:3])) colnames(fakedata) <- 'people' fakedata['val1'] = abs(rnorm(3)) fakedata['val2'] = abs(rnorm(3)) fakedata['val3'] = abs(rnorm(3)) barplot(data.matrix(fakedata)) At a glance there is no substantial difference is between my fake data and my real data. > realdata person val1 val2 val3 1 A 221 71 175 2 B 222 85 147 > mydata people val1 val2 val3 1 A 0.75526748 0.445386 0.09186245 2 B 0.06107566 2.008815 2.50269410 3 C 0.47171611 0.592037 0.57612168 However > data.matrix(realdata) person val1 val2 val3 1 NA 221 71 175 2 NA 222 85 147 Warning messages: 1: NAs introduced by coercion 2: NAs introduced by coercion So then I converted 'person' from a list to factors, which removed the coercision error, but barplot() still shows each bar as value instead of a person. My serialized() data subset is here (look at bottom half where there are no line numbers) http://pastebin.com/m6d1e1d79 Thanks in advance, Andrew ______________________________________________ R-help@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.