Hi,
I am trying to use as_factor to quickly convert survey data results into a dataframe to work with. But, when I use as_factor() on the df, nothing happens to the df... however,
if I use as_factor() on each column it seems to be working. I assume that the problem is one of the columns cant be converted to a factor and so none are being converted, but I have 100 columns so I need a solution to identify which column is the problem
sample <- data.frame(structure(list(Q8 = c("Core city of a smaller/medium region",
"Core city of a smaller/medium region", "Core city of a rural region",
"Inner ring or developed suburb", "Developing or outer suburb"
), Q35 = c("Below 50,000", "Below 50,000", "Below 50,000", "Below 50,000",
"Below 50,000"), Q9_1 = c("Worsened Slightly", "Worsened Slightly",
"Worsened Greatly", "Worsened Slightly", "Improved Slightly"),
Q9_2 = c("Worsened Slightly", "Worsened Slightly", "Worsened Slightly",
"Worsened Slightly", "Improved Slightly"), Q9_3 = c("Worsened Slightly",
"Worsened Slightly", "Worsened Slightly", NA, "Improved Slightly"
), Q48 = c("Manufacturing", "Healthcare", "Education", "Other",
"Manufacturing"), Q48_12_TEXT = c(NA, NA, NA, "Telemarketing",
NA), Q26_1 = c("Decreased", "No Change", "No Change", "No Change",
"Increased"), Q26_2 = c("Increased", "Don't Know/NA", "No Change",
"No Change", "Increased"), Q26_3 = c("No Change", "No Change",
"Increased", "Increased", "No Change"), Q26_4 = c("No Change",
"No Change", "Increased", "Don't Know/NA", "Increased")), row.names = c(NA,
-5L), class = c("tbl_df", "tbl", "data.frame")))
sample <- as_factor(sample)
summary(sample) #so frustrating!