[R] aggregate() - error message

Paul Emberson email at calidasoft.co.uk
Thu Sep 24 13:27:00 CEST 2009


Hi,

Are you trying to get columns 2 and 3 from TripsData in which case you 
need to say TripsData[,2:3] ?

Paul

Juliane Struve wrote:
> Dear list,
>  
> would anybody be able to tell me why the statement 
>  
> Tripstatistics=aggregate(TripsData[2:3],by=list(Trip=Tripmatch),FUN="mean")
>  
> seems to work well with TripsData 1 but not with TripsData 2 ?
>  
> With TripsData 2 it yields 
>  
> Error in FUN(X[[1L]], ...) : arguments must have same length
> 
> I can't see a difference in the two data sets. Could someone shed light on the error message ? Maybe that would help me figure out where the problem is.
>  
> Thanks very much for any help. 
>  
> Juliane 
>  
> PS: The examples below contain the  first 5 rows  of my two datafiles.  
>  
>  
> TripsData 1 
> 
>            Trip Distance TimeDiff Tripmatch
> 7329 35,36 172.7453   0.0041     35,36
> 7371 36,35 172.7453   0.0004     35,36
> 7372 35,36 172.7453   0.0000     35,36
> 7373 36,35 172.7453   0.0004     35,36
> 7374 35,36 172.7453   0.0001     35,36
> 
>  
> TripsData 2
>  
>             Trip Distance TimeDiff Tripmatch
> 1617 19,20 1087.365   0.0441     19,20
> 1899 20,19 1087.365   0.0207     19,20
> 1915 19,20 1087.365   0.0361     19,20
> 3285 20,19 1087.365   0.0356     19,20
> 3826 19,20 1087.365   0.0697     19,20
> 
> 
> 
> 
> ______________________________________________
> 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.




More information about the R-help mailing list