knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)

Xplorer

Xplorer provides a set of functions for convenient exploration of datasets in R, see() and browse().

see() {#see}

see() prints the following details of an object to the console:

There are several other packages which attempt to do someting similar, but none of them offers the ease of use and thourough inspection of ojects. For example, base R offers the functions summary(), str() and structure(). However, each of those is limited in what they display and leave other aspects untouched. see() combines a number of functions that would have to be invoked seperately and mirrors Stata's 'codebook'.

see()is an S3 generic and currently comes with the following data types:

Example

library("Xplorer")

# Create example data
numeric.labelled <- c(1, 2, 2, 3, 3, 3, 4, 4, 4, 4)
attributes(numeric.labelled)$label <- "mylabel"

# see the object
see(numeric.labelled)

browse() {#browse}

The aim of browse() is to create a data.frame that allows you to use the search field in the Rstudio View() function to search for variables based on their names or values, which is currently not possible. In particular if a dataset is very large and no comprehensive codebook is available, quickly searching for variable names makes finding variables of interest much easier.

If you are not working in Rstudio, View() may not work in the same way and may not offer a search option. Hence browse() does not call View() directly. Instead, store the data in a new object first, which then can be opened with View() in Rstudio. browse() can also be called on a data.frame directly to print the output to the console.

Example

library("Xplorer")

# Create an example data.frame and add some variable labels
data(mtcars)
attributes(mtcars$mpg)$label <- "Miles/(US) gallon"
attributes(mtcars$cyl)$label <- "Number of cylinders"
attributes(mtcars$disp)$label <- "Displacement (cu.in.)"
attributes(mtcars$hp)$label <- "Gross horsepower"
attributes(mtcars$drat)$label <- "Rear axle ratio"
attributes(mtcars$wt)$label <- "Weight (1000 lbs)"
attributes(mtcars$qsec)$label <- "1/4 mile time"
attributes(mtcars$vs)$label <- "V/S"

# Call browse() directly...
browse(mtcars)

# ...or assign to df and open with View()
df <- browse(mtcars)

Then use View(df) and use the search field to search variable names and labels. Or, even simpler, just use View(browse(mtcars)).

Installation

You can install Xplorer from GitHub with:

remotes::install_github("fschaffner/Xplorer")

Please report issues or requests for additional functionality to https://github.com/fschaffner/Xplorer/issues.



fschaffner/Xplorer documentation built on Oct. 4, 2019, 1:27 a.m.