Nick HK Profile picture
Econ prof @SeattleU. Book The Effect https://t.co/3F41M6EzEb out now! Check my pinned thread for all my projects. Substack https://t.co/YYrIUc8JPC

Mar 24, 2019, 10 tweets

Very excited to say that my 📦#Rstats package📦 vtable is now available on CRAN, installable with install.packages('vtable')
vtable is a *variable browser* for R that helps you look at your data WHILE you're working on it. (thread/)

One thing I sorely miss in R, coming from Stata, is the ability to look through your variables while coding, without having to open it up directly or repeatedly call head(), str(), etc. None of those options work great anyway when you have lots of vars. Show me information!

So vtable(yourdataset) generates an informative table with information about all your variables (ranges, factor levels, classes...), and opens it up in RStudio Viewer (if in RStudio) or a browser window (if not). Heck, or save it to file as a piece of the data documentation.

Comes with plenty of bells n whistles. Add summary statistics with summ=, or have it tell you whether the variable has missing obs with missing=TRUE. Data titling and description (data.title, desc) for if you're building doc files.

Big ol' bonus: VARIABLE/VALUE LABELS. Notice last tweet it auto displayed the variable/value labels from efc? It will do that with labels coming from sjlabelled, haven, or Hmisc. This labeled Stata file was imported via haven. Plus, apply your own labels in one of 3 easy formats.

Not to mention, way easier to SEARCH variables. Want to find a given label, or a given factor level? You could try to remember which sjlabelled sub-function lets you do that & spend time on proper syntax, or just use vtable to open up a browser window and do Ctrl/cmd-F 🤷‍♀️

Very glad it's on CRAN now, and thanks to the reviewers for dealing with first-timer me. More information on options and the methods of using your own variable labels in the documentation or here: nickchk.com/vtable.html

Also, an intro video (done before it was on CRAN, so slightly outdates)
Enjoy!

One last thing: comes with the helper function dftoHTML which is really just intended to do some HTML preprocessing for vtable. But as a bonus, also allows you to have a copy of your data open without having to flip back and forth to the View tab.

Can be real handy if you find yourself needing to look back at the data a lot. And you can always subset/select before calling it (as with vtable too, of course) if you just want to look at a few variables. Ok now that's it, /fin.

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling