If you combine a function (aka c
) with only one parameter, this is the same as the identifier (otherwise it does not call the c
function). Therefore, c(1:10)
same as 1:10
. However, you can combine as many arguments as you want with another type (character, number ...). It will convert the type to you.
all.equal(1:10,c(1:5,6:10)) [1] TRUE all.equal("meow",c("meow")) [1] TRUE c(1:5,6:10,"meow") [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "meow" class(c(1:5,6:10,"meow")) [1] "character"
Another difference is that you can call c with the recursive parameter. As the document says:
?c Usage c(..., recursive = FALSE) Arguments ... objects to be concatenated. recursive logical. If recursive = TRUE, the function recursively descends through lists (and pairlists) combining all their elements into a vector.
source share