Git Product home page Git Product logo

adventr's Introduction

adventr: R tutorials for An Adventure in Statistics (Field, 2016)

The adventr package contains a series of interactive tutorials that teach alongside chapters of my 2016 textbook An Adventure in Statistics: the reality enigma. The tutorials are written using a package called learnr. Once a tutorial is running it's a bit like reading a book but with places where you can practice the R code that you have just been taught. The adventr package is free (as are all things -related) and offered to support tutors and students using my textbook who want to learn R.

Installation

You can install the latest release of adventr from CRAN in the usual way. Note that you should include dependencies = TRUE to also install the packages used in the tutorials on your system. If you omit this argument, you will need to manually install these packages (which you won't want to do, trust me).

install.packages("adventr", dependencies = TRUE)

If you want the very latest development version, you can install it from GitHub by executing (in RStudio):

if(!require(devtools)){
  install.packages("devtools")
}

devtools::install_github("profandyfield/adventr", dependencies = TRUE)

Contents of adventr

The package was written initially to support my own teaching on a module where I base the content around An Adventure in Statistics. One quirk of this is that there are some advanced tutorials on topics not covered in the book (but continue the themes of the book ...). Another quirk is that - at present - there are some chapters that don't have associated tutorials (for example, the Chapter on probability).

The tutorials are named to correspond (roughly) to the relevant chapter of the book. For example, adventr_03 would be a good tutorial to run alongside teaching related to chapter 3, and so on.

  • adventr_02: R workflow. Project files, relative paths, objects and functions, creating variables, the pipe operator, dataframes and tibbles, reading and writing files.
  • adventr_03: Summarizing data, introducing ggplot2, histograms, editing plots, frequency polygons.
  • adventr_04: Fitting models. The mean, median, outliers, sums of squares and variance.
  • adventr_05: Visualizing data. Summarizing data by group, plotting grouped data, boxplots, plotting means, plotting raw data, scatterplots.
  • adventr_08: Inferential and robust statistics. Confidence intervals, plotting confidence intervals, robust means, robust confidence intervals, bootstrapping. (covers Chapter 9 too.)
  • adventr_11: Hypothesis testing, effect sizes and Bayes factors.
  • adventr_14: The general linear model (GLM). Fittinga nd interpreting models with one and two predictors, model diagnostics, robust models, Bayes factors.
  • adventr_15: Categorical predictors in the GLM (comparing two means). The t-test, linear models with a two-category predictor, robust estimates, Bayes factors, other robust approaches (trimmed means).
  • adventr_15_rm: Comparing two related/dependent means. The t-test, multilevel linear models with a two-category predictor, robust estimates, Bayes factors, other robust approaches (trimmed means).
  • adventr_16: Categorical predictors in the GLM (comparing several means). Linear models with a multi-category predictor, contrast coding, robust estimates, Bayes factors, other robust approaches (trimmed means).
  • adventr_16_rm: Comparing several related/dependent means. Multilevel linear models with a multi-category predictor, contrast coding, robust estimates, Bayes factors.
  • adventr_17: Factorial designs. Linear models with several categorical predictors, contrast coding, interactions, robust estimates, Bayes factors, other robust approaches (trimmed means).
  • adventr_mlm: Fitting multilevel models. Fixed vs random slopes, preparing categorical predictors, fitting and interpreting the models. (not covered in the book)
  • adventr_growth: Modelling change over time. Growth models using multilevel modelling. (not covered in the book)
  • adventr_log: Categorical outcomes. Crosstabulating frequency data, odds ratios, logistic regression, robust logistic regression. (not covered in the book)

Running tutorials

In Version 1.3 onwards there is a tutorial pane. Having executed

library(adventr)

A list of tutorials appears in this pane. Scroll through them and click on the button to run the tutorial:

Alternatively, to run a particular tutorial from the console execute:

library(adventr)
learnr::run_tutorial("name_of_tutorial", package = "adventr")

and replace "name of tutorial" with the name of the tutorial you want to run. For example, to run tutorial 3 (for Chapter 3) execute:

learnr::run_tutorial("adventr_03", package = "adventr")

The name of each tutorial is in bold in the list above. Once the command to run the tutorial is executed it will spring to life in a web browser.

Suggested workflow

The tutorials are self-contained (you practice code in code boxes) so you don't need to use at the same time. However, to get the most from them I would recommend that you create an project and within that open (and save) a new RMarkdown file each time to work through a tutorial. Within that Markdown file, replicate parts of the code from the tutorial (in code chunks) and use Markdown to write notes about what you have done, and to reflect on things that you have struggled with, or note useful tips to help you remember things. Basically, write a learning journal. This workflow has the advantage of not just teaching you the code that you need to do certain things, but also provides practice in using itself.

See this video explaining my suggested workflow:

<iframe width="560" height="315" src="https://www.youtube.com/embed/FhoYCsZttGc" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

adventr's People

Contributors

profandyfield avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

adventr's Issues

Failing to load in the browser

Hey, this package sounds amazing, but I'm hitting a wall right off the bat. Everything goes well, until a blank web page loads and this output comes up:

> library(adventr)
> learnr::run_tutorial("adventr_03", package = "adventr")
Loading required package: shiny
Warning: package ‘learnr’ was built under R version 3.4.2
Warning: package ‘tidyverse’ was built under R version 3.4.2
── Attaching packages ─────── tidyverse 1.2.1 ──
✔ ggplot2 2.2.1     ✔ readr   1.1.1
✔ tibble  1.3.4     ✔ purrr   0.2.4
✔ tidyr   0.7.2     ✔ dplyr   0.7.4
✔ ggplot2 2.2.1     ✔ stringr 1.2.0
Warning: package ‘tidyr’ was built under R version 3.4.2
Warning: package ‘purrr’ was built under R version 3.4.2
Warning: package ‘dplyr’ was built under R version 3.4.2
── Conflicts ────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()

Listening on http://127.0.0.1:6051
Warning: Error in normalizePath: path[1]="": No such file or directory
Stack trace (innermost first):
    8: <Anonymous>
    7: do.call
    6: rmarkdown::run
    5: force
    4: withr::with_envvar
    3: force
    2: withr::with_dir
    1: learnr::run_tutorial
Error : path[1]="": No such file or directory

On MacOS and Chrome, R is version 3.4.1.

Completion of previous tutorials required?

I wasn't sure where else to ask this, but I'm attempting to jump around and look at the tutorials without completing them to get an idea of what they actually practice and cover. However, I'm not allowed to click anything in the web browser. Is this because I haven't completed previous tutorials?

Couldn't normalize path in `addResourcePath`

Hi,

Using the lastest R downloaded at 1/15/2019 and R-studio (1/15/2019), I'm having the following error in Windows and MacOSX.
Couldn't normalize path in addResourcePath
The complete error is
ERROR: Couldn't normalize path in addResourcePath, with arguments: prefix = 'bootstrap-3.3.5'; directoryPath = ''

Info about my system
Windows 10 (and MacOSX Mojave 10.14.2)
RSTUDIO: Version 1.1.463 – © 2009-2018 RStudio, Inc.

R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 5.2
year 2018
month 12
day 20
svn rev 75870
language R
version.string R version 3.5.2 (2018-12-20)
nickname Eggshell Igloo

json error

@RodrigoDalBen reposted from learnr thread

Hello all,
@profandyfield
I had the same problem described above, so I re-installed "adventr". However, I encountered another problem when trying to run tutorial 11:

library(adventr)
learnr::run_tutorial("adventr_11", package = "adventr")
Error: lexical error: invalid char in json text.
<<<<<<< HEAD {"type":"list","at
(right here) ------^
Tutorials 1, 2, 3 works fine, but from 04 on the same error occur. How can I fix this?

Bad credentials

Just upgraded to R 3.6 (and it feels like a downgrade, what with all the problems with packages). When I tried to install adventr I got this message:

Error: HTTP error 401.
Bad credentials

Rate limit remaining: 56/60
Rate limit reset at: 2019-05-16 19:04:18 UTC

adventr: data basics - complete exercises to continue

I am new to the tutorials and as I work through them I cannot continue with the "try it yourself" parts
I have tried entering the Hint passage and running it however when I go to continue the message "You must complete the exercises in this section before continuing." comes up, is there a reason I cannot continue?

Installation fails if R version is not up to date

First of all, thanks for all the great resources.

Installation from GitHub fails for me, because my R version is 3.6.2, see below. While I can work around this using Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS = "true"), newbies might have more trouble.

Would it be possible to move tidyverse (and learnr) from Depends to Imports? Maybe one could call library("tidyverse") inside .onLoad(), if this is desired. Or, maybe, globally @import tidyverse will suffice?

remotes::install_github("profandyfield/adventr")
#> Installing package into 'C:/Users/hp/Documents/R/win-library/3.6'
#> (as 'lib' is unspecified)
#> * installing *source* package 'adventr' ...
#> ** using staged installation
#> ** R
#> ** data
#> *** moving datasets to lazyload DB
#> ** inst
#> ** byte-compile and prepare package for lazy loading
#> Error: package or namespace load failed for 'tidyverse':
#>     .onAttach failed in attachNamespace() for 'tidyverse', details:
#>     call: NULL
#> error: (converted from warning) package 'ggplot2' was built under R version 3.6.3
#> Error: package 'tidyverse' could not be loaded
#> Execution halted
#> ERROR: lazy loading failed for package 'adventr'
#> * removing 'C:/Users/hp/Documents/R/win-library/3.6/adventr'
#> Error: Failed to install 'adventr' from GitHub:
#>     (converted from warning) installation of package ‘C:/Users/hp/AppData/Local/Temp/Rtmpchl0S4/file1a802f4370d9/adventr_0.1.6.tar.gz’ had non-zero exit status

Failed to install adventr

Hi Andy,

I'm trying to practice R using your package but when I try to install it I got an error:

"Installing 49 packages: tidyverse, learnr, car, effects, lm.beta, robust, sjstats, WRS2, ellipsis, vctrs, lifecycle, isoband, farver, askpass, sys, httpuv, xtable, sourcetools, later, promises, fastmap, openxlsx, zip, minqa, nloptr, numDeriv, mitools, DEoptimR, robustbase, pcaPP, insight, bayestestR, parameters, estimability, sjlabelled, rappdirs, shiny, renv, carData, rio, lme4, survey, fit.models, rrcov, effectsize, emmeans, performance, sjmisc, mc2d
Error: Failed to install 'adventr' from GitHub:
(converted from warning) dependency ‘pbkrtest’ is not available"

In addition, when I try to install the "discovr" ones I got another error:
_"> install_github("profandyfield/discovr")
Error: Failed to install 'unknown package' from GitHub:
HTTP error 404.
Not Found
Did you spell the repo owner (profandyfield) and repo name (discovr) correctly?

  • If spelling is correct, check that you have the required permissions to access the repo.

"_

Progress! But missing an html file

Hi there,

I finally managed to get everything working on R 3.6, got past the Personal Access Token change requirement, and downloaded your package. When I tried to start a lesson, this is what happened:

learnr::run_tutorial("adventr_02", package = "adventr")
Error in shiny_prerendered_html(input_rmd, encoding, render_args) :
Prerendered HTML file not found at ./ais_02_old.html

This seems to be related to a prior issue, but I wasn't able to follow the thread. Is there something I can do to fix this? Thanks!

'setInternet2' is defunct

Hello.

I tried to install adventr under R 3.5.1 and RStudio 1.1.456.
> library(remotes)
> install_github("profandyfield/adventr")
Error: 'setInternet2' is defunct.
See help("Defunct")

Do I read this error correctly and adventr tries to use the now deprecated 'setInternet2' function?
What could I do?

Thanks for any help! :-)

Tutorials Loading Indefinetely

Hi Andy,

I feel really stupid for making this an issue but when I try to start an adventr tutorial, it just won't start and the "Loading Tutorial" text in the tutorial pane remains present indefinetely. There is something happening in the jobs pane but the tutorial does not start. Is this a common problem with interactive R tutorials or did I just miss something during installation?

I'm quite new to R and programming in general so I'm very sorry if this is a weird question.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.