[R] Error in apply(x2, 1, diff) : dim(X) must have a positive length

David Winsemius dwinsemius at comcast.net
Mon Feb 13 02:14:46 CET 2012


On Feb 12, 2012, at 7:05 PM, hithit168 wrote:

> Anyone knows hat might be the cause of this error? Thanks for any  
> help!
>
>> library(MASS)
>> dif.mns = function(x2,tr1=.2,tr2=.3){
> + #generates four different 'means' using
> + #difference scores from x2, an n x 2 matrix
> + #for use w/ bootstrap comparisons
> +     diffs = apply(x2,1,diff)
> +     mn1=mean(diffs)
> +     mn2=mean(diffs,tr=.2)
> +     mn3=mean(diffs,tr=.3)
> +     mn4=median(diffs)
> + mns=c(mn1,mn2,mn3,mn4)
> + list(mnds=round(mns,3)) }
>
>> dif.mns(shoes)
> Error in apply(x2, 1, diff) : dim(X) must have a positive length
>

You have given apply a list.

-- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list