What are the paste() and paste0() functions in R used for?

r

#1

Hello,

When and why do we use the paste() and paste0() functions in R?


#2

@adityashrm21- paste is the function is used combine the thing in specific manner
paste(LETTERS)
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
paste has 3 arguments.
paste (…, sep = " ", collapse = NULL)
The … is the stuff you want to paste together and sep and collapse are the guys to get it done. There are three basic things I paste together:

paste0 is short for:
paste(x, sep="")
paste0(“a”, “b”) == paste(“a”, “b”, sep="")
[1] TRUE
we can see both are same .

Hope this help!
Regards,
hinduja1234


#3

if you want variable students as stud1,stud2…stud100
so just write

paste0(“stud”,1:100)
or
paste(“stud”,1:100,sep="")…:smile:

Hope this help!
Regards,
nilesh.borade