2016-04-15 55 views
0

我是R初學者 如何在R中顯示相同的這個圖表,以及他們稱之爲什麼? enter image description hereR圖表顯示

回答

0

我認爲這可能對您有用。

## creating a matrix 
> data_frame <- matrix(c(0.8,0.2,0.7,0.3),2,2) 
> data_frame 
    [,1] [,2] 
[1,] 0.8 0.7 
[2,] 0.2 0.3 

## setting the dimension names 
> dimnames(data_frame) <- list(c('Handwash','No Handwash'),c('Female','Male')) 

## plotting the data 

barplot(data_frame,col=rep(c('orange','skyblue'),ncol(data_frame)),legend.text = dimnames(data_frame)[[1]],ylab='Frequency') 

enter image description here