Thanks David! I do get confused sometimes when sth can be easily and directly done in Excel which is what I am familiar with, but I find it takes more time for me to operate that in R.
On Thu, Apr 18, 2013 at 4:27 PM, David Winsemius <dwinsem...@comcast.net>wrote: > > On Apr 18, 2013, at 3:46 PM, Ye Lin wrote: > > > Hey, > > > > Is it possible that R can calculate each options under each column and > > return a summary table? > > > > Suppose I have a table like this: > > > > Gender Age Rate > > Female 0-10 Good > > Male 0-10 Good > > Female 11-20 Bad > > Male 11-20 Bad > > Male >20 N/A > > > > I want to have a summary table including the information that how many > > answers in each category, sth like this: > > Some of the tables simple did not have N/A so it's not appropriate to > append an N/A row for them: > > dat1<-read.table(text=" > Gender Age Rate > Female 0-10 Good > Male 0-10 Good > Female 11-20 Bad > Male 11-20 Bad > Male >20 N/A > ",sep="",header=TRUE) > > sapply(lapply(dat1, table), as.matrix) > > $Gender > [,1] > Female 2 > Male 3 > > $Age > [,1] > >20 1 > 0-10 2 > 11-20 2 > > $Rate > [,1] > Bad 2 > Good 2 > N/A 1 > > > > > > X Gender > > Male 3 > > Female 2 > > N/A 0 > > > > X Age > > 0-10 2 > > 11-20 2 > >> 20 1 > > N/A 0 > > > > X Rate > > Good 2 > > Bad 2 > > N/A 1 > > > > So basically I want to calculate, in each column, how many people choose > > each answer, including N/A. I know I can do it in Excel in a very > > visualized way, but is there anyway to do it in R in a robust way if I > have > > a fairly large dataset. > > You appear confused about the relative robustness of R and Excel. > > -- > > David Winsemius > Alameda, CA, USA > > [[alternative HTML version deleted]] ______________________________________________ R-help@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.