Being new to R, can someone please explain the difference between paste()
and paste0()
, what I had understood from some post is that
p
In simple words,
paste()
is like concatenation using separation factor,
whereas,
paste0()
is like append function using separation factor.
Adding some more references to above discussion, below try outs can be useful to avoid confusion:
> paste("a","b") #Here default separation factor is " " i.e. a space
[1] "a b"
> paste0("a","b") #Here default separation factor is "" i.e a null
[1] "ab"
> paste("a","b",sep="-")
[1] "a-b"
> paste0("a","b",sep="-")
[1] "ab-"
> paste(1:4,"a")
[1] "1 a" "2 a" "3 a" "4 a"
> paste0(1:4,"a")
[1] "1a" "2a" "3a" "4a"
> paste(1:4,"a",sep="-")
[1] "1-a" "2-a" "3-a" "4-a"
> paste0(1:4,"a",sep="-")
[1] "1a-" "2a-" "3a-" "4a-"