I am having some troubles with leading and trailing white space in a data.frame.
For example, I like to take a look at a specific row in a data.fra
row
data.fra
Use grep or grepl to find observations with white spaces and sub to get rid of them.
names<-c("Ganga Din\t", "Shyam Lal", "Bulbul ") grep("[[:space:]]+$", names) [1] 1 3 grepl("[[:space:]]+$", names) [1] TRUE FALSE TRUE sub("[[:space:]]+$", "", names) [1] "Ganga Din" "Shyam Lal" "Bulbul"