Question: I get only 'NA' values into my loop - Need to find mean of max CR_Art per Experiment per Mussel
0
gravatar for jeff.roemer
3.1 years ago by
jeff.roemer0 wrote:

Importing datafile "Raadata.csv" (Headers: Treatment, Mussel, Experiment, Interval, CR_Art, CR_Rho, CHR_Art, FR_C_Art , CHR_Rho, FR_C_Rho). Some fields are empty. Not all treatments have values in all columns. read.csv2 is used because of European standards, I have to convert comma to dot:

Max_CR_FR <- read.csv2(file="Raadata.csv", header=T, sep=";",skipNul=TRUE)

Grouping data by Mussel & Experiment:

Max_CR_FR$Group= factor(paste(Max_CR_FR$Mussel, Max_CR_FR$Experiment))

Selecting on treatment and de-selecting CR_Art with NA:

Art=subset(Max_CR_FR, Treatment=="Artemia" & !is.na(Max_CR_FR$CR_Art))

Everything works fine until here at least.

Calculating the mean of maximum values of CR_Art for each group:

F<-function(Data){
Exp_max=tapply(Data$CR_Art, Data$Group, max, na.rm=TRUE)
mean(Exp_max)
}

Bootstrapping:

boots=list()
for(i in 1:1000) boots[[i]]=Art[ sample.int(nrow(Art),replace=TRUE) ,]
means= lapply( boots, F)
meanstab = do.call(rbind,means)

Confidence interval:

apply(meanstab,2,quantile,probs=c(0.025,0.975),na.rm=TRUE)
R • 1.1k views
ADD COMMENTlink modified 2.9 years ago by Biostar ♦♦ 20 • written 3.1 years ago by jeff.roemer0
1

Show head of your original csv data.

ADD REPLYlink modified 3.1 years ago • written 3.1 years ago by PoGibas4.8k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1925 users visited in the last hour