[R] help to create a simulated dataset

Peter Wagey peter@w@g|ey09 @end|ng |rom gm@||@com
Wed Sep 30 06:35:01 CEST 2020


Hi R User,
I was trying to create a data matrix with four columns: height, locations
(three locations), temperature (three levels) and slope (three classes) and
used the following code, but it did not work.  I basically wanted to have
20 rows for each class (I have a total of 9 classes). Can you help me to
fix the following code so that I can create the data frame?

daT<-data.frame(height=c(5:15))

minHeight=min(daT$height)

maxHeight=max(daT$height)

height.value= minHeight +(0:20)*(maxHeight-minHeight)/20


daT<-data.frame(height=height.value, location=rep(c("SiteA", "SiteB",
"SiteC"), 20), temperature=rep(c(10,20,30)), slope=rep(c("5deg", "10deg",
"15deg")))


Thanks

	[[alternative HTML version deleted]]



More information about the R-help mailing list