Reputation: 19
Hi Im having issues with the following code:
RepLetter(n) <- function(){
return(rep(letters[7]))
}
I want to create a function that returns the nth letter of the alphabet n times.
For example I would want "c"
repeated like "c", "c", "c"
So I could type RepLetter(5)
and R would return "e", "e", "e", "e", "e"
Upvotes: 0
Views: 78
Reputation: 704
You have your function argument in the wrong place, and your arguments to rep
are off.
Try this:
RepLetter <- function(n){
return(rep(letters[n],n))
}
Upvotes: 2