A Stack plot
- A stack plot with same x-axis but different y-axis
Example with 4 variables for 3 response (categorical)
Please load required libraries
library(reshape2)
library(reshape)
library(lattice)
- Please download data from here: URL https://drive.google.com/open?id=0BzXwqrXOWFTtUFZDNHgxaXphR0k
b.df<-read.csv("......./rhodendron1.csv", header=T)
head(b.df) # cheack data
## species x1 x2 x3 x4
## 1 lepidotum -13 10 38 -422.3
## 2 lepidotum -13 10 38 -422.3
## 3 lepidotum 2 14 27 -113.3
## 4 lepidotum 2 14 27 -113.3
## 5 lepidotum 2 14 27 -113.3
## 6 lepidotum 2 14 27 -113.3
- First need to format the data
m1<- melt(subset(b.df, select=c(species, x1,x2,x3,x4)), id.var="species" )
names(m1)
## [1] "species" "variable" "value"
- Check the data as well, it is long format now.
- Now plt the data
xyplot(value~ species |variable, typle='l', data=m1, scales=list(y=list(relation="free")), layout=c(1,4))
- Change the ~ species| variable to ~ variables|species as per you suit.
No comments:
Post a Comment