1
votes

I have a table similar to the following which shows the number of samples which tested positive for viruses within different species:

Species Virus   NoTested    NoPositive  Prevalence  LowerCI UpperCI
1   1   100 46  0.46    0.4 0.5
2   1   80  23  0.29    0.2 0.3
3   1   96  3   0.03    0   0.1
1   2   133 45  0.34    0.2 0.5
2   2   23  10  0.43    0.3 0.5
3   2   75  16  0.21    0.1 0.3
1   3   88  24  0.27    0.2 0.3
2   3   94  12  0.13    0.1 0.2
3   3   65  34  0.52    0.4 0.6

I want to create a grouped bar graph such that I can show the proportion of positive samples for each species, in sets according to virus. I also want to add error bars showing confidence intervals.

I have tried doing this in ggplot using geom_bar(), but it gives me a really ugly stacked plot.

bar1<-ggplot(sppPrev3, aes(Species, Prevalence, colour=Virus))

1
Can you (1) remove the > from your code so we don't have to (2) provide the ggplot code you tried?Tyler Rinker
Hi, sorry this is a really stupid question but how should I format it properly without the > ? I'm a newb...Akos
agstudy took care of it for you. Can you show the ggplot2 code you were using?Tyler Rinker
ok and I think I undid his efforts just now.... Sorry agstudy!!Akos
@AkosuaHeather in your question you talk about postive sample than here you don't even use "NoPositive" variable, and your code don't work (there isn't a geom layer here)...Really asked like that , looks like a homework ...agstudy

1 Answers

2
votes

see: this link a lot of info about graphing.

also, maybe try using barplot(t(dataframe), beside = TRUE)