Re: [R] question about sum of (column) elements in R

2012-12-04 Thread arun
t1[,1]),sum))  # V1   x #1  0  12 #2  1  40 #3  2  64 #4  3 111 #5  4  63 A.K. - Original Message - From: T Bal To: r-help@r-project.org Cc: Sent: Tuesday, December 4, 2012 2:59 AM Subject: [R] question about sum of (column) elements in R Hi, I have the following data: 0  12 1 

Re: [R] question about sum of (column) elements in R

2012-12-04 Thread Jose Iparraguirre
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of T Bal Sent: 04 December 2012 07:59 To: r-help@r-project.org Subject: [R] question about sum of (column) elements in R Hi, I have the following data: 0 12 1 10 1 4 1 6 1 7 1 13 2 21 2 23 2

Re: [R] question about sum of (column) elements in R

2012-12-04 Thread Berend Hasselman
On 04-12-2012, at 08:59, T Bal wrote: > Hi, > I have the following data: > > 0 12 > 1 10 > 1 4 > 1 6 > 1 7 > 1 13 > 2 21 > 2 23 > 2 20 > 3 18 > 3 17 > 3 16 > 3 27 > 3 33 > 4 11 > 4 8 > 4 19 > 4 16 > 4 9 > > > In this data file I would like to sum the numbe

Re: [R] question about sum of (column) elements in R

2012-12-04 Thread Gerrit Eichner
Hi, T. Bal, homework? Take a look at ?tapply Regards -- Gerrit On Tue, 4 Dec 2012, T Bal wrote: Hi, I have the following data: 0 12 1 10 1 4 1 6 1 7 1 13 2 21 2 23 2 20 3 18 3 17 3 16 3 27 3 33 4 11 4 8 4 19 4 16 4 9 In this data file I would lik

Re: [R] question about sum of (column) elements in R

2012-12-04 Thread Pascal Oettli
Hi, You can follow this example: test <- structure(list(V1 = c(0L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L), V2 = c(12L, 10L, 4L, 6L, 7L, 13L, 21L, 23L, 20L, 18L, 17L, 16L, 27L, 33L, 11L, 8L, 19L, 16L, 9L)), .Names = c("V1", "V2"), class = "data.frame", row.names =

[R] question about sum of (column) elements in R

2012-12-04 Thread T Bal
Hi, I have the following data: 0 12 1 10 1 4 1 6 1 7 1 13 2 21 2 23 2 20 3 18 3 17 3 16 3 27 3 33 4 11 4 8 4 19 4 16 4 9 In this data file I would like to sum the numbers of second column which belong to the same number in the first column. So the output wou