2

I have a large set of data frames and would like to conduct a series of t-tests between different columns to find significance. Each data frame has identical headers but a different number of rows.

This is my code:

fileNames <- Sys.glob("*.txt")
for (fileName in fileNames) {
sample <- read.delim(fileName)
print(fileName)
placeholder.1 <- row_t_welch(sample[,c("A284_1", "A284_2")], sample[,c("A285_1", "A285_2") 
}

Where fileNames = a list of: chr [1:383], and _1 & _2 are biological replicates


My code returns the error:

Error in assert_numeric_mat_or_vec(x):
"x" must be a numeric matrix or vector

If I type in the name of the files individually the code works but not when using 'sample'

Can anyone help me? This is an excerpt from one of my files

      seq seq_id A284_1 A284_2 A285_1 A285_2 A286_1 A286_2 A287_1 A287_2 A288_1 A288_2 A289_1 A289_2 A290_1 A290_2 A291_1 A291_2   N2_1   N2_2
1  0.0345 0.0025 0.0134 0.0000 0.0114 0.0064 0.0011 0.0000 0.0000 0.0000 0.0000 0.0132 0.0094 0.0076 0.0000 0.0000 0.0023 0.0213 0.0130 0.0101
2  0.0394 0.0049 0.0015 0.0000 0.0011 0.0010 0.0000 0.0000 0.0015 0.0022 0.0013 0.0014 0.0011 0.0009 0.0000 0.0000 0.0021 0.0014 0.0013 0.0007
3  0.0296 0.0074 0.0000 0.0000 0.0008 0.0005 0.0011 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0038 0.0000 0.0000 0.0003 0.0014 0.0050 0.0032
4  0.0197 0.0099 0.0059 0.0015 0.0030 0.0044 0.0011 0.0075 0.0015 0.0022 0.0017 0.0023 0.0022 0.0023 0.0000 0.0054 0.0027 0.0014 0.0022 0.0022
5  0.0099 0.0123 0.0045 0.0046 0.0038 0.0049 0.0076 0.0000 0.0030 0.0067 0.0039 0.0054 0.0039 0.0067 0.0051 0.0054 0.0071 0.0071 0.0060 0.0052
A. Palmer
  • 139
  • 10
  • `read.delim()` returns a `data.frame` whereas you require a matrix. Try converting it to a matrix. – anotherfred Jan 02 '19 at 23:57
  • Please don't include images of your data. Include the output from `dput(head(data))` or a simple made-up example that we can copy/paste into R – morgan121 Jan 03 '19 at 01:13
  • Thankyou @anotherfred! It now works. What I did was insert `sample <- data.matrix(sample)` under `sample <- read.delim(fileName)` and `print(placeholder.1)` underneath my statistical test. This was as calling the `placeholder.1` variable returned a null result – A. Palmer Jan 03 '19 at 01:45

0 Answers0