[R] Finding non-normal distributions per row of data frame?

David Winsemius dwinsemius at comcast.net
Fri Feb 4 19:07:46 CET 2011


On Feb 4, 2011, at 10:48 AM, DB1984 wrote:

>
> Thanks for the feedback Patrizio - but your function is performing the
> shapiro.test on columns instead of rows...
>
> I tried:
> nt<-data.frame(#a dataframe with 6 columns and 9 rows)
>
> nr <- nrow(nt)
>
>
> test <- apply(nt, nt[1:nr,], shapiro.test)
>
> Error in ds[-MARGIN] : invalid subscript type 'list'

The second argument to apply needs to be a (short) numeric vector.  
Your request suggest you simply want the number 1, since that would  
tell apply to use the function on rows.


>
> fred<-data.frame(sapply(test,function(x)c(x$statistic, x$p.value)))
>
>
> But picked up the error above. Do I still require a loop to apply  
> this over
> rows?
>
>
> -- 
> View this message in context: http://r.789695.n4.nabble.com/Finding-non-normal-distributions-per-row-of-data-frame-tp3259439p3260412.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list