Skip to content

Instantly share code, notes, and snippets.

@seankross
Created March 21, 2015 15:35
Show Gist options
  • Save seankross/912fe3b9f19a91b0a7bd to your computer and use it in GitHub Desktop.
Save seankross/912fe3b9f19a91b0a7bd to your computer and use it in GitHub Desktop.
Swirl R Programming Script Answers
"%p%" <- function(left, right){
paste(left, right)
}
boring_function <- function(x) {
x
}
evaluate <- function(func, dat){
func(dat)
}
mad_libs <- function(...){
# Do your argument unpacking here!
args <- list(...)
place <- args[["place"]]
adjective <- args[["adjective"]]
noun <- args[["noun"]]
# Don't modify any code below this comment.
# Notice the variables you'll need to create in order for the code below to
# be functional!
paste("News from", place, "today where", adjective, "students took to the streets in protest of the new", noun, "being installed on campus.")
}
my_mean <- function(my_vector) {
sum(my_vector)/length(my_vector)
}
remainder <- function(num, divisor = 2) {
num %% divisor
}
telegram <- function(...){
paste("START", ..., "STOP")
}
@Carmendom
Copy link

Now edit and save the R script bin_op.R.

Write your own binary operator below from absolute scratch! Your binary

operator must be called %p% so that the expression:

"Good" %p% "job!"

will evaluate to: "Good job!"

"%p%" <- function(){ # Remember to add arguments! paste(left, right, sep = " ") Sourcing your script...

| Not exactly. Give it another go.

| Remember: 'Hello' %p% 'student!' is how you use the binary operator. Please help me I have tried everything

This worked
"%p%" <- function(left,right){ # Remember to add arguments!
paste(left,right,sep=" ")
}

@drdanbad
Copy link

u save before hitting submit (

I am having the same issue and I have saved my script - any other solutions?

@EleniB98
Copy link

EleniB98 commented Feb 5, 2024

Copy the code you received at the end of the swirl lesson and paste it into the corresponding question below.
What is the answer??
Its for quiz after week 1
I submited the swrl exercises but what code is the LAST code??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment