Can functions return vectors in the c() format?

#1

Hello everyone,
I am new to making functions and couldn't find the answer to the question of whether there even is the possibility to get a vector output for a function?
For instance when I combine two vectors into one like so:

    V1 <- c("I", "a", "cat")
    V2 <- c("am","crazy","lady")

    my_fun <- function(x,y) {
     c(rbind(x,y))
    }
    my_fun(V1,V2) 

Is there a way to get the output

    c("I","am","a","crazy","cat","lady") 

instead of

    [1] "I"     "am"    "a"     "crazy" "cat"   "lady" 
0 Likes

#2

c() is not a format, it's a function to define (construct) vectors and what you are seen as output is the printed representation of your character vector.

4 Likes

#3

Thank you very much for the clarification.

0 Likes

#4

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

0 Likes

closed #5

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

0 Likes