Package {drhur}


Type: Package
Title: Learning R with Dr. Hu
Version: 2.0.0
Description: Provides interactive workshops for learning R easily and happily. Each workshop is a self-contained 'Quarto' Live document whose code cells run in the browser via 'WebAssembly', so learners can read the instructions and run the exercises side by side without a local R setup. The materials accompany the "Learning R with Dr. Hu" workshop series.
License: MIT + file LICENSE
VignetteBuilder: knitr
Encoding: UTF-8
URL: https://www.drhuyue.site/drhur/, https://github.com/sammo3182/drhur
BugReports: https://github.com/sammo3182/drhur/issues
LazyData: true
SystemRequirements: Quarto command-line tool (https://quarto.org)
Depends: R(≥ 3.6.0)
Imports: quarto
Suggests: servr, rmarkdown, scales, modelsummary, knitr, tidyverse
Config/roxygen2/version: 8.0.0
NeedsCompilation: no
Packaged: 2026-05-30 05:35:10 UTC; yuehu
Author: Yue Hu [aut, cre], Qian Qiu [ctb, trl], Xinyi Ye [ctb, trl], Yufei Sun [ctb]
Maintainer: Yue Hu <yuehu@tsinghua.edu.cn>
Repository: CRAN
Date/Publication: 2026-05-30 05:50:02 UTC

Calling for a Workshop in Dr Hu's R Workshop

Description

The function renders a self-contained Quarto Live document from the workshop materials shipped with the package and opens it in the browser. Each workshop is an interactive document whose code cells run in the browser via WebAssembly (webR); no local R session is required to run the exercises. The workshop list is continually updated along with the R workshop with Dr. Hu.

Usage

drhur(
  workshop,
  lang = "cn",
  style = "document",
  output_dir = tempdir(),
  quiet = FALSE
)

Arguments

workshop

A character string naming the workshop to open. See details for the available workshops.

lang

A character string giving the display language: simplified Chinese ("cn", the default) or English ("en").

style

A character string choosing the output style: "document" (the default) renders a scrollable Quarto Live HTML document (live-html); "slide" renders a reveal.js slide deck (live-revealjs).

output_dir

Directory in which the workshop is rendered. Defaults to a per-session temporary directory. The installed package files are never modified.

quiet

Logical; suppress Quarto's rendering output. Defaults to FALSE.

Details

The workshops available in the current version (Basics series):

Every workshop ships in two language editions, selected with lang: simplified Chinese ("cn", the default) and English ("en").

Rendering requires the Quarto command-line tool to be installed. Running the interactive code cells in the rendered document additionally requires an internet connection, because the webR runtime and the workshop's R packages are downloaded in the browser at view time.

Because Quarto Live cells run on OJS and webR, which browsers disable for documents opened directly from disk (file://), the workshop is served over a local web server rather than opened as a file. This serving step uses the servr package, a suggested dependency; install it with install.packages("servr") if prompted. In an interactive session the server is started in the background (so your R console stays free) and remains available for the rest of the session; stop it with servr::daemon_stop().

Value

(Invisibly) the path to the rendered HTML file.

Examples

## Not run: 
# Open the algebra workshop as an HTML live document (Chinese, the default)
drhur("algebra")

# Open the same workshop in English
drhur("algebra", lang = "en")

# Open the data-munging workshop as a slide deck
drhur("munging", style = "slide")

## End(Not run)


A Random Sample of World Value Survey (Wave 7).

Description

A dataset randomly sampled from the 7th wave of World Value Survey released in 2022.

Usage

wvs7

Format

A data frame with 1330 rows and 24 variables:

country

The country the interview was made.

female

Respondent’s sex is female.

age

Respondent's age.

education

The highest education that the respondent had attained.

religious

Independently of whether the respondent attend religious services or not, did the respondent identify him/herself as a religious person, not a religious person, or an atheist?

marital

Marital status of the respondent.

incomeLevel

The income group the respondent believes his/her household belonged.

equalIncentive

Respondent's view between "Incomes should be made more equal" and "There should be greater incentives for individual effort".

equalFreedom

Most people consider both freedom and equality to be important, but if one had to choose between them, which one would the respondent consider more important?

corruption_state

How many state authorities did the respondent believe were involved in corruption.

corruption_local

How many local authorities did the respondent believe were involved in corruption.

corruption_civil

How many civil service providers did the respondent believe were involved in corruption.

trust_family

Respondent's trust of his/her family.

trust_neighbor

Respondent's trust of his/her neighborhood.

trust_stranger

Respondent's trust of people s/he meet for the first time.

trust_foreigner

Respondent's trust of people of another nationality.

confidence_armedForce

Respondent's confidence in the armed forces.

confidence_policy

Respondent's confidence in the armed forces.

confidence_court

Respondent's confidence in the courts.

confidence_gov

Respondent's confidence in the government.

confidence_parliament

Respondent's confidence in the paliament.

confidence_civil

Respondent's confidence in the civil service.

confidence_parties

Respondent's confidence in the political parties.

confidence_tv

Respondent's confidence in the television.

Source

https://www.worldvaluessurvey.org/WVSDocumentationWV7.jsp

References

Haerpfer, C., Inglehart, R., Moreno, A., Welzel, C., Kizilova, K., Diez-Medrano J., M. Lagos, P. Norris, E. Ponarin & B. Puranen et al. (eds.). 2020. World Values Survey: Round Seven – Country-Pooled Datafile. Madrid, Spain & Vienna, Austria: JD Systems Institute & WVSA Secretariat. doi.org/10.14281/18241.1