Site icon R-bloggers

Learning some tough lessons!

[This article was first published on R on R-house, 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.

It’s been a while since I’ve posted – mainly because I got myself into a mess with Git and I’ve been putting off trying to sort it out. I’ve been wanting to post about htmlwidgets for a while now, and in my naivity I thought I’d retrospectively try to use the DT package on one of my older posts to jazz up the tables to be more interactive…big mistake!

Lesson 1 – Don’t enhance old posts! Leave them as they are!

I thought it would be a relatively simple case of simply wrapping datatable() around my dataframes, and hey presto, javascript magic! I found out that the javascript from htmlwidgets can interfere with the javascript in the rest of my webpage, messing things up. I did however discover that a package called widgetframe can create a frame for your htmlwidgets so it doesn’t interfere (see the blogdown documentation). Unfortunately this still didn’t work for me, leading to my next lesson:

Lesson 2 – Anything with javascript is never as easy as it seems!

Before long, I was looking for a way to undo those changes and revert to an earlier commit in my Git log. Unfortunately I tend to use the Git functionality that comes with RStudio, and being able to revert isn’t really possible, so I was left fumbling with worryingly powerful commands in Git Bash! I did what’s known as a ‘hard’ reset, but then had to undo that when Git told me I had to Pull before I can push, effectively undoing my reversion. The lesson?

Lesson 3 – Start using Git on the command line! Practice by creating a new repo with some meaningless text files in it.

Getting into a Git mess is not fun and sometimes a program like RStudio trying to be helpful is not giving you the tough love you need!

I’ll try htmlwidgets again in my next post and see how I fare…

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

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.