boxplot with frequencies(counts)
On 03/06/2013 12:45 AM, km wrote:
Dear All, I have a table as following position type count 1 2 100 1 3 51 1 5 64 1 8 81 1 6 32 2 2 41 2 3 85 and so on Normally if would have a vector of 2,3,4,5... by position position and plot them by position. But now i have counts of these types. Is there a way to compute boxplot of such kind of data ?
Hi KM, We must assume that the "type" variable is to be used as a value, otherwise you would want something like a frequency plot by two factors of position and type. (If this is the case, I would suggest a nested bar plot). Here is a fairly awful kludge that will get you a boxplot (tdf is your "table"): reprow<-function(x) return(matrix(rep(x[1:2],x[3]),ncol=2,byrow=TRUE)) replist<-apply(as.matrix(tdf),1,reprow) repmat<-replist[[1]] for(rep in 1:length(replist)) repmat<-rbind(repmat,replist[[rep]]) boxplot(repmat[,2],repmat[,1]) With apologies Jim