Skip to content
Prev 380970 / 398500 Next

how to split a column by tab ?

Hello,

You could try a character class instead of one character (the tab char).
There are two character classes that you can try, [:blank:] and 
[:space:], see ?regex.

strsplit(as.character(daT1), "[[:blank:]]+")

Then form the final result. I have changed rbind to cbind, it seemed 
more appropriate (?).

s <- strsplit(as.character(daT1), "[[:blank:]]+")
x <- lapply(s, function(.s) .s[!grepl("[[:alpha:]]+", .s)])
daT3 <- as.data.frame(do.call(cbind, x))
daT3


Hope this helps,

Rui Barradas

?s 12:54 de 09/09/19, Marna Wagley escreveu: