README.md

viewData

The viewData package is an alternative to the View(...) function. It's a thin wrapper around the DT library.

Contents

Motivation

The motivation to build this package was

  1. to learn how to build r packages and
  2. to view and interact with my data outside of a shiny app.

In my data cleaning and transformation workflow, I like to do spot checks of the data to make sure I understand what the code/functions are doing and to see if there are any potential issues with the underlying data or methods.

The base function View() is nice, but I wanted to incorporate the features in DT (e.g., search, filter, view rows, clickable links, etc.). I also wanted to be able to view the data in a browser window (as opposed to Rstudio) which could then be moved to a second monitor. This would allow me to interact with the data and make adjustments to the code without having to resize the Rstudio panes in order to see the data and code on one line.

Since I built the package, I've found the renderULS argument to be very useful if I'm unfamiliar with dataset and I wanted to know more about a category. This works beautifully in a tidywork flow (see examples below).

Installation

The viewData package can be installed using the devtools package.

install.packages("devtools")
devtools::install_github("davidruvolo51/viewData")

The only function viewData(...) is a simple wrapper around the DT package and takes the following options (shown below are the default options).

viewData(data, showFilter = FALSE, row.names = FALSE, renderURLS = FALSE, launch.browser = FALSE)

Arguments

Access keys are also enabled for interacting with table outputs. The current shortcut is for moving the cursor into the search field. This shortcut is:

'accesskey' + t

The combination of keys to enable this functionality varies by browser and OS. See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey for more information.

Examples

Standard use

library(viewData)
viewData(data= iris)

Alternatively, you can use viewData::viewData(...)

Adding Filters

viewData(data = iris, showFilter = TRUE)

Print row.names

viewData(data = mtcars, showFilter = TRUE, row.names = TRUE)

View data in browser

viewData(data= iris, launch.browser = TRUE)

Make clickable URLS

# assign to tmp object
df <- iris

# paste urls
df$urls <- paste0('<a href="https://www.google.com.au/search?q=',df$Species,'">',df$Species,'</a>')

# view
viewData(data= df, renderURLS = TRUE)


Make clickable URLS the tidy way

iris %>%
  mutate(Species = paste0('<a href="https://www.google.com/search?q=',Species,'" target="_blank" rel="noopener">',Species,'</a>')) %>%
  select(Species, everything()) %>%
  viewData::viewData(data = ., showFilter = TRUE, renderURLS =  TRUE, launch.browser = TRUE)

Troubleshooting

The viewData package relies on the following packages shiny, miniUI and DT. If you run into any errors during the installation or usage, it might be due to missing packages or they are outdated. Run the following lines to install/update these packages, and then reinstall the viewData package

install.packages(c("shiny","miniUI","DT"))
devtools::install_github("davidruvolo51/viewData")


davidruvolo51/viewData documentation built on May 6, 2019, 9:08 a.m.