[R] 3d plotting with cloud and wireframe
Dennis Murphy
djmuser at gmail.com
Fri Jul 22 06:03:47 CEST 2011
Hi:
This worked for me:
t <- 0:100
DBH <- 10:100
TxDBH<-expand.grid(t, DBH)
rm(t, dbh)
time<-TxDBH[,1]
dbh<-TxDBH[,2]
M <- 4000*(1-exp(-time*(1.104-(0.67*0.7)-0.163*log(dbh))^2))
df <- data.frame(time, dbh, M)
library('lattice')
wireframe(M ~ time + dbh, data = df)
# Check the versions of R and lattice below against yours
# If there's a mismatch, try to upgrade
> sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets grid methods
[8] base
other attached packages:
[1] colorspace_1.1-0 hexbin_1.26.0 rgeos_0.1-8 stringr_0.5
[5] maptools_0.8-9 sp_0.9-83 foreign_0.8-44 quantmod_0.3-15
[9] TTR_0.20-2 xts_0.8-0 zoo_1.7-0 Defaults_1.1-1
[13] RODBC_1.3-2 sos_1.3-1 brew_1.0-6 lattice_0.19-30
[17] ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4 plyr_1.5.2
loaded via a namespace (and not attached):
[1] digest_0.5.0 tools_2.13.1
HTH,
Dennis
On Thu, Jul 21, 2011 at 7:40 PM, Benjamin Caldwell
<btcaldwell at berkeley.edu> wrote:
> Hi,
>
> I'm trying to plot an equation in two variables to get a feel
> for sensitivity to its parameters. I've run expand.grid to get made-up
> vectors of the combinations of the two independent variables, and am trying
> to plot the output of the dependent, M, against both the dependent in a 3d
> space.
>
> t <- 0:100
> DBH <- 10:100
> TxDBH<-expand.grid(t,DBH)
> time<-TxDBH[,1]
> dbh<-TxDBH[,2]
> M <- 4000*(1-exp(-time*(1.104-(0.67*0.7)-0.163*log(dbh))^2))
>
> I've tried wireframe(M~t|DBH, data=TxDBH)
> wireframe(M~time|dbh, data=M)
> wireframe(M~time|dbh)
> also the above model specifications using cloud.
>
> but
>
> I get the following errors:
> Error in latticeParseFormula(formula, data, dimension = 3, subset = subset,
> :
> invalid model
> Error in eval(substitute(groups), data, environment(formula)) :
> numeric 'envir' arg not of length one
>
> any advice much appreciated.
>
> *Ben *
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list