Вопрос

I am trying to use R to show a merged boxplot, I am sure this is easy, I just am missing something:

boxplot(WHO$Male, WHO$Female, ylim=c(0,100))

boxplot(WHO$Female ~ WHO$Year, ylim=c(0,100))
boxplot(WHO$Male ~ WHO$Year, ylim=c(0,100))

All three work, but when I try:

boxplot(WHO$Male ~ WHO$Year, WHO$Female ~ WHO$Year, ylim=c(0,100))

It returns:

Error in as.data.frame.default(data) : 
   cannot coerce class ""formula"" to a data.frame

Note, Year, only contains three numbers, 1990, 2000, 2010

> head(WHO)
  Year WHO.region      Country Male Female
1 1990     Africa      Algeria   66     68
2 1990     Africa       Angola   39     43
3 1990     Africa        Benin   45     50
4 1990     Africa     Botswana   63     66
5 1990     Africa Burkina Faso   45     49
6 1990     Africa      Burundi   47     50
Это было полезно?

Решение

reshape2 package does something similar. Actually there was quite similar question - Plot multiple boxplot in one graph, maybe it will be helpful.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top