Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: Paste two strings without space [duplicate]

Tags:

merge

r

paste

I want to merge following two strings in R (and remove the spaces). I was using paste but I was not able to get desired results.

a <- "big earth"
b <- "small moon"

c <- paste(a,b, sep = "")

I want to have a c <- "bigearthsmallmoon" Thank you very much for the help.

like image 919
Behzod A Avatar asked Dec 13 '22 08:12

Behzod A


1 Answers

You can paste the strings together into one with paste(). Then you can use gsub() to remove all spaces:

gsub(" ", "", paste(a, b))
# [1] "bigearthsmallmoon"
like image 126
sindri_baldur Avatar answered Jan 11 '23 14:01

sindri_baldur