README.md

Travis build
status AppVeyor Build
Status Coverage
status

talkr Package:

The goal of talkr is to provide use natural language commands to talk through data analysis using dplyr. Currently, natural language processing is not used but a simple grammar.

Installation

You can install talkr from GitHub with:

# install.packages("remotes")
remotes::install_github("muschellij2/talkr")

Example

We will pass in a command to sort the data set.

library(talkr)
library(tibble)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
df = tibble::rownames_to_column(mtcars, var = "car")
is.unsorted(df$mpg)
#> [1] TRUE
res = df %>%
  talk("Sort df by mpg")
#> Warning in talk_get_colnames(data_colnames, cmd, ...): Some words not allowed!
#> Removed
#> [[1]]
#> [1] "df"  "mpg"
is.unsorted(res$mpg)
#> [1] FALSE

If you do not specify the order, it assumes ascending, as dplyr::arrange does:

cmds = c(
  "Sort by mpg ascending and hp decreasing",
  "Sort by mpg and hp decreasing")
res = lapply(cmds, talk_arrange, .data = df)
all.equal(res[[1]], res[[2]])
#> [1] TRUE

Shiny Example

Here is a Shiny app based on https://github.com/yihui/shiny-apps/tree/master/voice, which has an app here: https://yihui.shinyapps.io/voice/. This uses the annyang API: https://github.com/TalAter/annyang. See a live demo at https://jhubiostatistics.shinyapps.io/Speak_dplyr/

talk_shiny_example("sort_better")


muschellij2/talkr documentation built on Jan. 20, 2020, 7:49 p.m.