I have a function that I wrote which is supposed to filter some values and then produce a crosstabulation. It filters the values using the dplyr filter,select commands.
My problem is that when I pass the name of the column ot the function I get an error, and when I pass the name as string with "" around it, it does not filter the observations. Here is the code:
fnDoCrosstab <- function(a) {
x <- surv_data1 %>% filter(a != "blank") %>% select(a) %>% as.matrix() %>% as.vector()
y <- surv_data1 %>% filter(a != "blank") %>% select(segment_name) %>% as.matrix() %>% as.vector()
CrossTable(x,y, format = "SPSS",prop.chisq = F)
}
fnDoCrosstab(b_thisyear)