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.
You can install talkr
from GitHub with:
# install.packages("remotes")
remotes::install_github("muschellij2/talkr")
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
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.