Yes, this was my intention. Your way seems more suitable. Thank you!
• 0 views
•
link
I have a tsv file with 61 columns and 18703 lines. I have written the following code:
f<-read.table(file = "GeneExpressionDataset_normalized.tsv", sep="\t", header=TRUE)
m<-as.data.frame(f)
m
for (i in 1:nrow(m)){
wt[i]<-c(sum(m[c(i:i),c(2:11)]))/10
}
wt
for (i in 1:nrow(m)){
TherA[i]<-c(sum(m[c(i:i),c(22:31)]))/10
}
TherA
For some reason the first loop works but the second one produces Error Subject not found. The loops are identical in syntax. What could be wrong?
what you want might be instead
f <- read.table(file = "GeneExpressionDataset_normalized.tsv", sep="\t", header=TRUE)
wt <- apply(f[,2:11], 1, mean)
TherA <- apply(f[,22:31], 1, mean)
(I am guessing that you are looking for the mean of each group for each row)
Yes, this was my intention. Your way seems more suitable. Thank you!
Log in to answer this question.
Why are you using
c(i:i)?