[英]R: wireframe like 3D plot for categorical variables
I want to develop wireframe like plot with non-numeric on X, Y axis however numeric in Z axis. 我想在X,Y轴上使用非数字开发线框,但在Z轴上使用数字。
# mydata
set.seed(123)
yv <- rnorm(20, 10, 3)
gen <- rep(paste("G", 1:5, sep= ""), 4)
env <- c(rep(c("CA","MN","SD", "WI"), each = 5))
mdf <- data.frame(yv, gen, env)
I tried using lattice: 我试过用格子:
require(lattice)
wireframe(yv,gen, env, data = mdf)
Error in UseMethod("wireframe") :
no applicable method for 'wireframe' applied to
an object of class "c('double', 'numeric')"
Any suggestions appreciated. 任何建议赞赏。
This appears to work: 这似乎有效:
set.seed(123)
mdf <- data.frame(yv=rnorm(20, 10, 3),
gen=rep(paste("G", 1:5, sep= ""), 4),
env=c(rep(c("CA","MN","SD", "WI"), each = 5)))
library(lattice)
wireframe(yv~gen*env,data=mdf,scales=list(arrows=FALSE))
The easiest way to use the functions in lattice
is to use the formula interface. 在
lattice
使用函数的最简单方法是使用公式接口。
Assuming that yv
is your independent variable: 假设
yv
是你的自变量:
wireframe(yv ~ gen + env, data = mdf)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.