Just started learning to use R for the first time this week. For an exercise, I want a function to return "Number" if an argument is a number, and "Text" if if it's a text. I thought maybe I could do this with if/else but having trouble figuring it out and thinking I'm approaching it totally wrong. Thanks for the help in advance!
Its straightforward but rather than give you an answer immediately, It would be best if you shared your attempt, so we could see where you are at and good practice for you also in sharing code.
In your forum post use triple backticks to format it correctly.
This is barely what I have... don't know what I'm supposed to put for x= where it says (x=number) and (x=text). Or maybe I'm going about it completely wrong?
x<-"zzzz"
funcOne <-function(x) {
if(x=text){
result <-"text"
} else {
result <-"number" }
print(result)
}
funcOne(x)