r - Concatenating Two Vectors to a New Vector -
i trying combine 2 vectors create new vector. tried (well, similar this).
y <- c(10,10,11,11) m <- c(1,2,1,2) <- data.frame(m,y) paste(my[1], my[2], sep = "")
i this:
# [1] "c(1, 2, 1, 2)c(10, 10, 11, 11)"`
i same thing when use collapse
instead of sep
.
i trying get:
# ["1 10","2 10","1 11","2 11"]
try of following instead:
paste(my[[1]], my[[2]]) # [1] "1 10" "2 10" "1 11" "2 11" paste(my[, 1], my[, 2]) # [1] "1 10" "2 10" "1 11" "2 11" paste(my$m, my$y) # [1] "1 10" "2 10" "1 11" "2 11" do.call(paste, my) # [1] "1 10" "2 10" "1 11" "2 11"
the problem weren't selecting values in column, rather, single-column data.frame
.
of course, use original vectors:
> paste(m, y) [1] "1 10" "2 10" "1 11" "2 11"
Comments
Post a Comment