Categories

Fun with functions

Hi flog!

Today was a very busy day for phenology but I will not be discussing that today.

I spent this afternoon doing some light coding and durning dinner tonight Amy, Jared, and I held Alex hostage durning a conversation about best coding practices. This conversation transitioned into Jared and Amy helping me write my first function!

Below is the function that I have written, for readers at home feel free to copy and paste and play around

printName <- function(name, punctuation){
print(paste(“My name is”, name, punctuation))
}

this is a function that the 3 of us wrote together (Jared started but Amy finished it, I supervised/tried to help but didn’t know what was going on)

favoritePet = function(answer) {
if(answer == “dog”) {
message(“That is an acceptable choice, but have you considered salamanders?”)}
if(answer == “cat”)
message(“What are you thinking?!?!?!?”)
if(answer == “salamander”)
message(“You are a good person.”)
else{
message(“Please try again…”)}
}

Enjoy!

Mia

twitterpinterestmail

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>