Strength of a Lennon song exposed with R function glue::glue

March 23, 2019
By

(This article was first published on Guillaume Pressiat, and kindly contributed to R-bloggers)


love_verse <- function(w1, w2, w3){
  glue::glue(
  "Love is {b}, {b} is love
   Love is {y}, {y} love
   Love is {u} to be loved", 
  b = w1, y = w2, u = w3)
}

As a return, parameters sometimes gives echoes of poetry.

love_verse('real', 'feeling', 'wanting')
Love is real, real is love
Love is feeling, feeling love
Love is wanting to be loved
love_verse('touch', 'reaching', 'asking')
Love is touch, touch is love
Love is reaching, reaching love
Love is asking to be loved
## refrain
Love is you
You and me
Love is knowing
We can be
love_verse('free', 'living', 'needing')
Love is free, free is love
Love is living, living love
Love is needing to be loved

https://www.youtube.com/watch?v=7er_xx7Wmg8

list(list(w1 = 'real',  w2 = 'feeling',  w3 = 'wanting'),
     list(w1 = 'touch', w2 = 'reaching', w3 = 'asking' ),
     list(w1 = 'free',  w2 = 'living',   w3 = 'needing')) %>% 
  purrr::map(function(x)do.call(love_verse, x))
[[1]]
Love is real, real is love
Love is feeling, feeling love
Love is wanting to be loved

[[2]]
Love is touch, touch is love
Love is reaching, reaching love
Love is asking to be loved

[[3]]
Love is free, free is love
Love is living, living love
Love is needing to be loved

We could also read title of this article as “strength of an R function exposed with a Lennon song”…

To leave a comment for the author, please follow the link and comment on their blog: Guillaume Pressiat.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)