Thank you for your answers, but i still get same error msg ! (the argument is neither numerical nor logical: return of NA)
maybe there's something wrong with recognizing the data ?!
I have a data in CSV format that contains 45 columns ( variables ) and 320 lines
The first column is the samples names and second column is group where sample belong
i imported the data in R using the followning command : data <- read.csv("C:/Users/ut/Desktop/Doctorat_Perpignan/R/MYDATA.csv", row.names = 1, sep=";")
when i wanted to calculate the mean using the following command : mean(data)
i obtained this error : Warning message: In mean.default(data_1) : the argument is neither numerical nor logical: return of NA
how can i solve this error please ?
also i wanted to calculate the the mean of all columns except the first and second columns using the following command : colMeans(data_1[ , 2:45]) , but i obtained the mean of each column and not the mean of all columns
Can you help me please to czlculate the mean of this data, Thank you
The base function mean expects a vector, not a data.frame. You will need to use apply to go over rows or columns, e.g.
rowwise mean would be:
apply(your_df, 1, mean)
For the mean of all values in the object you could do something like:
mean(unlist(c(your_object)))
Thank you for your answers, but i still get same error msg ! (the argument is neither numerical nor logical: return of NA)
maybe there's something wrong with recognizing the data ?!
The function expects that all cells are populated either by numbers or true/false values (numerical or logical). There is something in your data frame that is neither numerical nor logical, which is why you get the error. It is not a big dataset, you should be able to catch it by visually inspecting the file.
Log in to answer this question.
Cross-posted: https://bioinformatics.stackexchange.com/questions/17841/the-argument-is-neither-numerical-nor-logical-return-of-na