t.test error given on dataset with blank or "NA" cells

206 views Asked by At

image of example dataTrying to run t.test on dataset. Data is read as .csv file. Some cells in .csv are blank (data was not collected at that site on a particular date).

When I read the .csv on R [fix(dataset)] the blank cells are blank for one site, but "NA" for other. The t.test runs fine for the site with the 'NA' blank cells, but the site where cells are blank I receive the following error message:

"Error in var(y) : Calling var(x) on a factor x is defunct. Use something like 'all(duplicated(x)[-1L])' to test for a constant vector. In addition: Warning message: In mean.default(y) : argument is not numeric or logical: returning NA"

Example code:

data=read.csv("WQ Analysis.csv")
fix(data)

library(dplyr)

as.factor(id)
as.numeric(US2_ln)
as.numeric(DS2_ln)    #shows "NA": for blank cells
as.numeric(DS3_ln)    # blank cells shown as blank#

ecoli=data%>%filter(id=='ecoli')     # subset data to isolate a variable 

t.test(US2_ln,DS2_ln, data=ecoli)  # Works fine ---> p-value = 0.04153 #
t.test(US2_ln,DS3_ln, data=ecoli)  # error message received #
0

There are 0 answers