13: Sampling in R

Statistical Thinking for the 21st Century · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-NC 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    13: Sampling in R

    First we load the necessary libraries and set up the NHANES adult dataset

    library(tidyverse)
    library(ggplot2)
    library(knitr)
    library(cowplot)
    
    set.seed(123456)
    opts_chunk$set(tidy.opts=list(width.cutoff=80))
    options(tibble.width = 60)
    
    
    # load the NHANES data library
    library(NHANES)
    
    # create a NHANES dataset without duplicated IDs 
    NHANES <-
      NHANES %>%
      distinct(ID, .keep_all = TRUE) 
    
    #create a dataset of only adults
    NHANES_adult <- 
      NHANES %>%
      filter( 
        Age >= 18
      ) %>%
      drop_na(Height)


    This page titled 13: Sampling in R was last modified on Mon, 11 Jan 2021 05:13:16 GMT and is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Russell A. Poldrack via source content that was edited to the style and standards of the LibreTexts platform.