R you asleep?

Being both an R nerd and a dad, I find there are disappointingly few opportunities to combine these (hobbies, responsibilities, not sure what the right word is here…). However, a new concept occurred to me the other day… R coded nursery rhymes!

clap <- function(){
    print("clap!")
}

amIHappy <- "TRUE"
doI <- data.frame(knowIt = "TRUE", wantToShowIt = "TRUE")

ifelse(amIHappy == T & doI$knowIt == T, rep(clap()), print("do nothing, look confused"))
## [1] "clap!"
## [1] "clap!"
ifelse(amIHappy == T & doI$knowIt == T & doI$wantToShowIt == T, rep(clap()), print("do nothing, look confused"))
## [1] "clap!"
## [1] "clap!"

Your child/children will love it, and if they don’t, they’re probably python/C# people…!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s