I have a data.frame that looks like
a = c("sample1", "asd")
b = c("sample2" ,"poua")
c = c("sample3", "asd")
dat <- rbind(a,b,c)
I would like to count column2 string frequencies, and keep column1 name in list/ragged array of counts. i.e. have it look like
asd sample1 sample3
poua sample2
I know table counts frequency, but I wasnt able to get it to keep names, so I would really really appreciate any help!
You could use
tapply:EDIT: If your rownames matter, you can use
identityas the function: