Everyday R code (4)

#otherwise, we usually write it into a flag column this way, before we pivot it into excel and using excel pivot table there to make tons filter changes request from the manager.

data$Int<-NA
data$Int[data$Site %in% c(“a”, “b”,  “c”  )]<-“Int”
data$Int[data$Site  %in% c(“C”,”G”, “O”,”E”,”I”)]<-“notInt”

#pivot

tableSummary<-data[,list(ContactCount=length(ID)),by=list(Int,Group,SKILL,RESPONSE,HAS_POLL, TYPE,survey_question_code)]

write.csv(tableSummary,’summaryTable.csv’)

# Make sure you included all the possible filters, then we can play it in excel using pivot table with whatever filters the leaders need. The request of the combination of the filters changed in mins, and I find it efficient this way instead of getting final results from R by changing filters every time.

Be the first to comment

Leave a Reply

Your email address will not be published.


*