[This article was first published on R – TomazTsql, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)


Want to share your content on R-bloggers? click here if you have a blog, or here if you don’t.

You know the feeling after long vacation and finally sitting in front of your favourite UI and even forgot how to write simplest “hello world” or “foo bar” function? Well, we got you covered! The reverse Hello world function is for all the people returning to the office after rather long vacation.

Create the function:

# reverse Hello World
hello_world <- function(print){
  if (print == "print"){
    print("Hello World")
  } else {
    cat("rWell ...")
  }
}

And be confused for a split second, when you want to use this function correctly 🙂

Welcome back!

As always, the complete code is available on GitHub in  Useless_R_function repository. The sample file in this repository is here (filename: reverse_hello_world.R). Check the repository for future updates.

Happy R-coding and stay healthy!

To leave a comment for the author, please follow the link and comment on their blog: R – TomazTsql.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you’re looking to post or find an R/data-science job.


Want to share your content on R-bloggers? click here if you have a blog, or here if you don’t.

Continue reading: Little useless-useful R functions – Reverse Hello World

Getting back into Coding with Reverse Hello World Function

If you have been away from coding for a while, getting back into the nitty-gritty of programming can often seem daunting. A useful tool for those returning to the office after a long vacation is a simple script known as the “Reverse Hello World” function.

Importance of Ease-in Tools

The Reverse Hello World function exemplifies the importance of tools and functions that ease programmers back into coding. Prolonged breaks can often result in even the most seasoned coders forgetting the basics, like writing a “Hello World” or “foo bar” function. However, with easily accessible and straightforward functions like the reverse Hello World function, the process of acclimating back to complex coding environments becomes smoother.

Implications of the Reverse Hello World Function

In the long term, these script snippets might have significant implications. They are not solely convenience tools but can also be seen as educational resources. In addition to serving individual programmers, they could potentially be incorporated into learning materials for coding boot camps or online courses.

Let’s Check the Function

# reverse Hello World
hello_world <- function(print){ if (print == "print"){ print("Hello World") } else { cat("rWell ...") } }

Note how it prints “Hello World” when the given value matches “print”. As a neat little trick, it’s a simple but effective way to make you think about fundamental coding structures and logic again.

Plausible Future Developments

With the proliferation of online coding platforms and the continuous growth of remote working practices, we can expect to see more practices and functions like the Reverse Hello World. Future versions could include more complex series of commands and algorithms to help seasoned programmers get back into the swing of things after substantial breaks.

Actionable Advice

  • Keep Practicing: Even during periods of breaks from work, try to keep your coding skills sharp by practicing some simple functions occasionally.
  • Share Your Functions: If you create any easy-to-follow yet effective function like this, consider sharing it with the broader programming community. It helps not only you but also others in the same boat.
  • Explore Resources: Make use of coding repositories like GitHub for interesting and creative functions. Be sure to check the Useless R function repository for more such functions.

In conclusion, a mind-boggling tool to jog your memory after a vacation isn’t some high-tech app or game – something as simple as a Reverse Hello World function is enough.

Read the original article