I have a column in table as below
Col1
========================
"No","No","No","No","No"
"No","No","No"
Yes
No
"Yes","Yes","Yes","Yes"
"Yes","No","Yes", "Yes
I am trying to remove duplicate No and Yes and create column like this
Col1
========================
No
No
Yes
No
Yes
Yes, No
I started with
kickDuplicates <- c("No","Yes")
# create a list of vectors of place names
broken <- strsplit(Table1$Col1, ",")
# paste each broken vector of place names back together
# .......kicking out duplicated instances of the chosen names
Table1$Col1 <- sapply(broken, FUN = function(x) paste(x[!duplicated(x)
| !x %in% kickDuplicates ], collapse = ", "))
But this is not working, i get the same original column with duplicates as before, can anybody tell me where I am going wrong ?
c("\"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\"",
"\"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"Yes\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\"",
"\"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\"",
"\"No\", \"No\"", "\"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\", \"No\"",
"No")