0
votes

Ive read in my excel data and found the max value for each column and calculated the mean from that.

library(readxl)
exp4 <- read_excel("exp4.xlsx")
View(exp4)

this gives you the highest value in the entire datase

maxpeak <- apply(exp4, MARGIN = 2, function(x) max(x, na.rm=TRUE))
maxpeak
#the mean of all the max peaks in this experiment
mean16052019exp4 <- mean(maxpeak)
mean16052019exp4

I've then taken the original max value and subtracted the baseline values using another excel spreadsheet read in BUT when i now want the mean of these new values:

realmaxpeak <- (maxpeak - exp4baseline)
realmaxpeak
#trying to calculate the mean of the baseline adjusted values
View(realmaxpeak)
mean(realmaxpeak)

I get: Warning message:

In mean.default(realmaxpeak[0.1]) : argument is not numeric or logical: returning NA

Why can i not calculate the mean from the vector (realmaxpeak) i created?

TIA

1
Welcome to SO! Which is the result of class(realmaxpeak)? This should address you, with reading ?mean, on what is not going well.s__
> class(realmaxpeak) [1] "data.frame"kat
apply(realmaxpeak, 1, mean) this seems to have done the trickkat

1 Answers

0
votes

Could you post the summary of the data in realmaxpeak? It could not be recognizing the field as a numeric field. If this is the case, you would utilize as.numeric()