Learning some tough lessons!

March 20, 2018

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

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 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


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)