'Counting the number of columns with no NA in data frame
I need to count the number of columns with no NA for the coulmns 2:25 in the data frame stats for each raw and store in store.results[i,6].
k= ncol(stats[!is.na(stats$Quinolincacid),])
for (i in 1:length(stats[,1])){
#t.test for row i comparing columns 2-5 to 6-9
z<-t.test(x=stats[i,2:25],y=stats[i,26:63])
#store results for each iteration
store.results[i,1]<-stats[i,1]
store.results[i,6]<-count (stats[i,2:25])
store.results[i,7]<-stats[i,1]
store.results[i,2]<-z$estimate[1] #mean of control group
store.results[i,3]<-z$estimate[2] #mean of treatment group
store.results[i,4]<-z$estimate[1]-z$estimate[2] #difference of treatment from control
store.results[i,5]<-z$p.value #p value
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
