i need to create a vector (CBD) and populate it using 12 different normal distributions with various means and so's.
for example:
for all cells that treatment == "wellwaterd" & plantpart =="flower" I would pull 15 samples from a vector x<-rnorm(100,mean=3.6, sd=0.3). I would then pull another 15 samples from y<-rnorm(100,mean=2.2, sd=0.2) to populate treatment=="wellwaterd" & plantpart=="leaves" I would pull another 15 samples from z<-rnorm(100,mean=2.0, sd=0.8) to populate treatment=="wellwaterd" & plantpart=="stems" and so on until all CBD cells were filled based on treatment and plantpart then i need to do the same for another vector named CBDA and do the same process.
rm(list=ls())
plantID<-c(seq(1,45,1))
plantID<-rep(1:45,each=12)
strain<-rep(c("CHPF-01"), 540)
length(strain)
head(strain)
treatment<-rep(c("wellwatered","drought","waterlogged"), each=180)
treatment
plantpart<-rep(c("flower", "leaves", "stem", "seed"),135)
location<-rep(c("high", "mid", "low"), each=180)
CBD<-vector("numeric", length=540)
data<-cbind(plantID, strain, treatment, plantpart, location, CBD
x<-rnorm(100,mean=3.6, sd=0.3)
My attempts:
if (treatment=="wellwatered" & plantpart=="flower")
CBD<-sample(c(x, 15, replace = TRUE))
while (treatment=="wellwatered" & plantpart=="flower") {
CBD<-sample(c(x, 15, replace = TRUE))
}
cbd<-function(n) {
when treatment=="wellwatered"|plantpart=="flower"
sample(x, 15, replace = TRUE)
}
Aucun commentaire:
Enregistrer un commentaire