[R] Summarizing elements for a data.frame
    Christofer Bogaso 
    bogaso.christofer at gmail.com
       
    Tue Dec 18 15:36:42 CET 2012
    
    
  
Hello again, let say we have following data:
Dat1 <- structure(list(factor.sample.LETTERS.1.3...6..replace...T.. =
structure(c(1L,
3L, 2L, 1L, 3L, 3L), .Label = c("A", "B", "C"), class = "factor"),
    factor.sample.letters.1.2...6..replace...T.. = structure(c(2L,
    2L, 1L, 1L, 2L, 1L), .Label = c("a", "b"), class = "factor"),
    X1.6 = 1:6), .Names = c("factor.sample.LETTERS.1.3...6..replace...T..",
"factor.sample.letters.1.2...6..replace...T..", "X1.6"), row.names = c(NA,
-6L), class = "data.frame")
Out of this data.frame, I want to create a Table with rows coming from
1st column of Dat1 and columns are coming from 2nd column of Dat1 and
each entry will be the sum for 3rd column of Dat1, i.e. the element
for (1,1) will be sum for all element in 3rd column corresponding to
(A, a) and so on.
I tried with table() however could not achieve what I wanted.
Can somebody give me some pointer?
Thanks and regards,
    
    
More information about the R-help
mailing list