[R] by function with sum does not give what is expected from by function with print

Rasmus Liland jr@| @end|ng |rom po@teo@no
Fri Jul 24 02:42:12 CEST 2020


On 2020-07-24 01:48 +0200, Rasmus Liland wrote:
> 	aggregate(x=list("values"=mydata$values),
> 	          by=list("sex"=mydata$sex,
> 	                  "status"=mydata$status),
> 	          FUN=sum)
> 
> yields
> 
> 	  sex status values
> 	1   0      0    224
> 	2   1      0   5227
> 	3   0      1     11
> 	4   1      1    552

After reading more in ?aggregate, I 
realized this does the same thing ...

	aggregate(formula=formula("values~sex+status"),
	          FUN=sum,
	          data=mydata)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200724/bd9400c1/attachment.sig>


More information about the R-help mailing list