Displaying 2 results from an estimated 2 matches for "groupfactor".
2010 Apr 09
6
How to run Shapiro-Wilk test for each grouped variable?
I want to run Shapiro-Wilk test for each variable in my dataset, each
grouped by variable groupFactor.
I have these working commands:
> data.n<-names(data) # put names into a vector called data.n
> by(eval(parse(text=(paste("data",data.n[3],sep="$")))), data$factor, shapiro.test) #run shapiro.test
but I must to change the variable number manualy. How to automate this?...
2010 May 25
2
Get output values in a table
Hi,
I use two similar scripts to put p-values of shapiro.test and, respectively,
of wilcox.test in a table:
a)
d <- data.frame(dataset$GroupFactor, dataset[2:11])
# p-values for the shapiro test (by levels of GroupFactor)
with(d, aggregate(d[,-1], list(d[,1]), FUN = function(x)
shapiro.test(x)$p.value))
b)
d <- data.frame(dataset$GroupFactor, dataset[2:11])
with(d, aggregate(d[,-1], list(d[,1]), FUN = function(x)
wilcox.test(x)$p.value))...