I am using R and reading a CSV file to summarise group of columns in the file where values are zeros and ones to see whether they have got allergic reaction or not. This file contains 538 variables initially these variables are integers so I am converting all integers into factor variables which solves my purpose. But I am only able to use table function to summarise the values on all factor columns but I need to group the columns and apply them to table function for group by group summary. Could anyone please help me in this regard?
My code is as follows....
egg1 <-read.csv("egg.csv",header = TRUE)
str(egg1)
egg1[sapply(egg1, is.integer)] <- lapply(egg1[sapply(egg1, is.integer)], as.factor)
lapply(egg1, function(egg1) {
if (is.factor(egg1)) return(table(egg1))
})
Here in table I am looking to pass range of variable of CSV file group by group. Please have a look at my sample CSV which contains 3 groups I have coloured for better understanding. Q1: I want to calculate distribution of yes/no (1/0) for dose1,dose2 and dose3 respectively where 3 symptoms are listed for each. Q2: Then compare symptoms of all 3 doses.
table does well by showing summary of all columns but I need group wise summary.