Testing multiple columns in R

Morning all!

Sorry, probably another newbie question.

I have n columns of data, exported into 'R'. I want to test each column for normal distribution using Shapiro-Wilk' s test.

I know how to do this for one column, using the filename$columnname argument. However, is there a shorter way of doing this for every column, rather than repeating the code and altering the column name each time?

I know it's not a major hassle to cut and paste each answer into another document and create a table of test stat against each column, but wondered whether R could create this table for me....




Ambassador to the humans
apply(yourdataset, 2, shapiro.test)
The apply function will apply a function across rows or columns. The '2' tells it to apply the function to each column.