class: inverse, left, bottom background-image: url(https://images.unsplash.com/photo-1502740479091-635887520276?auto=format&fit=crop&q=80&w=1469&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D) background-size: cover # .Large[# A featurette: How do you retrieve R help file as text?] ## .small[Featuring baptnz@vis.social's R help retrieval] #### .tiny[Gina Reynolds | 2023-11-02 |Image credit: Zhen H, Upsplash] ??? Title --- count: false .panel1-feature-auto[ ```r # tidytuesday data *library(magrittr) ``` ] .panel2-feature-auto[ ] --- count: false .panel1-feature-auto[ ```r # tidytuesday data library(magrittr) *tmp <- tempfile() ``` ] .panel2-feature-auto[ ] --- count: false .panel1-feature-auto[ ```r # tidytuesday data library(magrittr) tmp <- tempfile() *help(mtcars, package = datasets) ``` ] .panel2-feature-auto[ ] --- count: false .panel1-feature-auto[ ```r # tidytuesday data library(magrittr) tmp <- tempfile() help(mtcars, package = datasets) %>% * as.character() ``` ] .panel2-feature-auto[ ``` ## [1] "/Library/Frameworks/R.framework/Resources/library/datasets/help/mtcars" ``` ] --- count: false .panel1-feature-auto[ ```r # tidytuesday data library(magrittr) tmp <- tempfile() help(mtcars, package = datasets) %>% as.character() %>% * utils:::.getHelpFile() ``` ] .panel2-feature-auto[ ``` ## \title{Motor Trend Car Road Tests}\name{mtcars}\alias{mtcars}\keyword{datasets}\description{ ## The data was extracted from the 1974 \emph{Motor Trend} US magazine, ## and comprises fuel consumption and 10 aspects of ## automobile design and performance for 32 automobiles (1973--74 ## models). ## }\usage{mtcars}\format{ ## A data frame with 32 observations on 11 (numeric) variables. ## \tabular{rll}{ ## [, 1] \tab mpg \tab Miles/(US) gallon \cr ## [, 2] \tab cyl \tab Number of cylinders \cr ## [, 3] \tab disp \tab Displacement (cu.in.) \cr ## [, 4] \tab hp \tab Gross horsepower \cr ## [, 5] \tab drat \tab Rear axle ratio \cr ## [, 6] \tab wt \tab Weight (1000 lbs) \cr ## [, 7] \tab qsec \tab 1/4 mile time \cr ## [, 8] \tab vs \tab Engine (0 = V-shaped, 1 = straight) \cr ## [, 9] \tab am \tab Transmission (0 = automatic, 1 = manual) \cr ## [,10] \tab gear \tab Number of forward gears \cr ## [,11] \tab carb \tab Number of carburetors ## } ## }\note{ ## Henderson and Velleman (1981) comment in a footnote to Table 1: ## \sQuote{Hocking [original transcriber]'s noncrucial coding of the ## Mazda's rotary engine as a straight six-cylinder engine and the ## Porsche's flat engine as a V engine, as well as the inclusion of the ## diesel Mercedes 240D, have been retained to enable direct comparisons ## to be made with previous analyses.} ## }\source{ ## Henderson and Velleman (1981), ## Building multiple regression models interactively. ## \emph{Biometrics}, \bold{37}, 391--411. ## }\examples{ ## require(graphics) ## pairs(mtcars, main = "mtcars data", gap = 1/4) ## coplot(mpg ~ disp | as.factor(cyl), data = mtcars, ## panel = panel.smooth, rows = 1) ## ## possibly more meaningful, e.g., for summary() or bivariate plots: ## mtcars2 <- within(mtcars, { ## vs <- factor(vs, labels = c("V", "S")) ## am <- factor(am, labels = c("automatic", "manual")) ## cyl <- ordered(cyl) ## gear <- ordered(gear) ## carb <- ordered(carb) ## }) ## summary(mtcars2) ## } ``` ] --- count: false .panel1-feature-auto[ ```r # tidytuesday data library(magrittr) tmp <- tempfile() help(mtcars, package = datasets) %>% as.character() %>% utils:::.getHelpFile() %>% * tools:::Rd2latex(Rd = ., out = tmp) ``` ] .panel2-feature-auto[ ] --- count: false .panel1-feature-auto[ ```r # tidytuesday data library(magrittr) tmp <- tempfile() help(mtcars, package = datasets) %>% as.character() %>% utils:::.getHelpFile() %>% tools:::Rd2latex(Rd = ., out = tmp) *pandoc::pandoc_convert(file = tmp, * from = "latex", * to = 'markdown') ``` ] .panel2-feature-auto[ ``` ## The data was extracted from the 1974 *Motor Trend* US magazine, and ## comprises fuel consumption and 10 aspects of automobile design and ## performance for 32 automobiles (1973--74 models). ## ## mtcars ## ## A data frame with 32 observations on 11 (numeric) variables. ## ## Henderson and Velleman (1981) comment in a footnote to Table 1: 'Hocking ## \[original transcriber\]'s noncrucial coding of the Mazda's rotary ## engine as a straight six-cylinder engine and the Porsche's flat engine ## as a V engine, as well as the inclusion of the diesel Mercedes 240D, ## have been retained to enable direct comparisons to be made with previous ## analyses.' ## ## Henderson and Velleman (1981), Building multiple regression models ## interactively. *Biometrics*, , 391--411. ## ## require(graphics) pairs(mtcars, main = \"mtcars data\", gap = 1/4) ## coplot(mpg disp \| as.factor(cyl), data = mtcars, panel = ## panel.smooth, rows = 1) \#\# possibly more meaningful, e.g., for ## summary() or bivariate plots: mtcars2 \<- within(mtcars, vs \<- ## factor(vs, labels = c(\"V\", \"S\")) am \<- factor(am, labels = ## c(\"automatic\", \"manual\")) cyl \<- ordered(cyl) gear \<- ## ordered(gear) carb \<- ordered(carb) ) summary(mtcars2) ``` ] --- count: false .panel1-feature-auto[ ```r # tidytuesday data library(magrittr) tmp <- tempfile() help(mtcars, package = datasets) %>% as.character() %>% utils:::.getHelpFile() %>% tools:::Rd2latex(Rd = ., out = tmp) pandoc::pandoc_convert(file = tmp, from = "latex", to = 'markdown') -> * md ``` ] .panel2-feature-auto[ ] <style> .panel1-feature-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-feature-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-feature-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- --- Also: possible alternative route https://yihui.org/rd2roxygen/ --- ### Check out flipbookr, used to build this featurette - https://github.com/EvaMaeRey/flipbookr - discussion: https://github.com/EvaMaeRey/flipbookr/blob/master/docs/draft_jasa_submission.pdf --- ### Check out more featurettes - https://EvaMaeRey.github.io/featurette