I am trying to write a function that creates a vector that counts up and back based on the number given `c(1:n, (n-1):1)`. When `3` is entered, however, I want the vector to display as `1,1,1,2,2,2,3,3,3` instead of `1,2,3,2,1`. I have tried using `if(n==3)`, but I get an error when I try to run it that says *"n cannot be found"*, but I can't quite understand why. Any help is very much appreciated! Here is what I have tried:

```
vector<-function(n)
  c(1:n, (n-1):1)
  if(n==3)
    c(rep(1,3),rep(2,3),rep(3,3))

```