Learning some tough lessons!

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…

comments powered by Disqus