Change table to character vector without spaces

  • A+

Let's have a following datafrane:

df <- data.frame(c("a", "c ","e "), c("b ", "d", "f ")) colnames(df) <- c("X1", "X2") df   X1 X2 1  a b  2 c   d 3 e  f 

How to transform the given data.frame to one character vector without spaces?

#Expected result: #vector #[1]"abcdef" 


Another solution from base R.

paste(trimws(as.vector(t(df))), collapse = "") # [1] "abcdef" 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: