How call this package:

library(devtools)
install_github('AmberlyDziesinski/ds')
#install_github(wdyoyle42/vandy_ds1000/ds_packages/ds)
library(ds)

#Data files
data("vote_gov_states")
data("vote_pres_national")
data("vote_pres_primaries")
data("vote_pres_states")
data("vote_sen_states")
data("hsls_clean")
data("book")
data("sisfcf")
data("covid_cases")
data("covid_death")
data("covid_mask")

#Data help files
?vote_gov_states
?vote_pres_national
?vote_pres_primaries
?vote_pres_states
?vote_sen_states
?hsls_clean
?book
?sisfcf
?covid_cases
?covid_death
?covid_mask


#Tutorials
learnr::run_tutorial("conditional_means", "ds")
learnr::run_tutorial("plot_means", "ds")
learnr::run_tutorial("data_manipulation", "ds")

Files included in this package:

data folder: - contains data, data were cleaned elsewhere - add data to this folder using r/save_dta.R (see step 1 below)

DESCRIPTION: - describes the package (author, license, set ups, etc.) - can be edited directly

LICENSE.md: - license for the package - Created using the standard MIT license in devtools - can be edited directly

man folder: - contains the help files for each dataset - do not edit these directly, use roxygen (see step 2 below)

NAMESPACE: - autogenerated from roxygen - do not edit

R folder: - contains the code for each dataset that makes the help files and calls the data - save_dta.R was used to import data/scratch code; all code must be commented out before building the package

README: - includes information about the package, how to use/edit it - the file you are currently reading

How to edit this package (adding data and editing help files)

  1. Use the R/save_data.r file to import data and save file to the data folder NOTE: comment out code after use so the package will not try to run this code, which results in an error
# hsls <- load(file = "C:\\Users\\amber\\Documents\\data_sci\\hsls_data\\hsls_clean.rda")
# usethis::use_data(hsls, overwrite = TRUE)

2.Make a new .r file in the R folder, titled for the dataset Insert Roxygen code Code the name of the dataset in quotes

#'
#'HSLS Data
#'
#'Loads clean version of High School Longitudinal Study (HSLS) data into the environment
#' @usage data(hsls)
#' @details The data in this file were collected by the National Center for Education Statistics (NCES) for the High School Longitudinal Study of 2009. Full data files and codebooks can be downloaded from \url{https://nces.ed.gov/OnlineCodebook}. Data were cleaned to exclude students with missing data and students who did not attend a four-year college.
#' @format
#' Data are structured as one observation per individual.
#' Variables include:
#' \describe{
#'   \item{student_id}{Student identifier assigned for all base year eligible students (including respondents, nonrespondents, and questionnaire incapable students). Numeric value ranging from 10001 to 35206}
#'   \item{sex}{Sex of the student. Categories: Male; Female}
#'   \item{race}{Race of the student. Categories: Amer. Indian/Alaska Native, non-Hispanic; Asian, non-Hispanic; Black/African-American, non-Hispanic; Hispanic, no race specified; Hispanic, race specified; More than one race, non-Hispanic; Native Hawaiian/Pacific Islander, non-Hispanic; White, non-Hispanic }
#'   \item{hispanic}{Student is Hispanic. Categories: Yes; No}
#'   \item{family_income}{Categorical variable indicating the student's family's income from all sources in 2008. Categories: Family income less than or equal to $15,000; Family income > $15,000 and <= $35,000; Family income > $35,000 and <= $55,000; Family income > $55,000 and <= $75,000; Family income > $75,000 and <= $95,000; Family income > $95,000 and <= $115,000; Family income > $115,000 and <= $135,000; Family income > $135,000 and <= $155,000; Family income > $155,000 and <=$175,000; Family income > $175,000 and <= $195,000; Family income > $195,000 and <= $215,000; Family income > $215,000 and <= $235,000; Family income > $235,000 }
#'   \item{ses}{Composite variable to measure a construct for socioeconomic status. Calculated using a combination of parental education, occupation, and family income. Continuous variable ranging from -1.7526 to 2.5668}
#'   \item{ap_ib_credit}{Total credits the student earned from Advanced Placement (AP) and International Baccalaureate (IB) courses while in high school. Continuous variable ranging from 0 to 13}
#'   \item{gpa}{Student's overall GPA. Continuous variable ranging from 0.0 to 4.0}
#'   \item{hours_extracurricular}{Hours student spent on extracurricular activities on a typical school day. Categories include: Less than 1 hour; 1 to 2 hours; 2 to 3 hours; 3 to 4 hours; 4 to 5 hours; 5 or more hours}
#'   \item{college_tour}{Did the student attend a program at, or take a tour of a college campus? Categories: Yes; No}
#'   \item{music}{Did the student participate in music or dance while in high school? Categories: Yes; No}
#'   \item{art}{Did the student participate in art while in high school? Categories: Yes; No}
#'   \item{drama}{Did the student participate in theater or drama while in high school? Categories: Yes; No}
#'   \item{sports}{Did the student participate in organized sports while in high school? Categories: Yes; No}
#'   \item{other_club}{Did the student participate in other club/group/scouting while in high school? Categories: Yes; No}
#'   \item{worked_job}{Did the student ever work for pay while in high school? Categories: Yes; No}
#' }
#' @examples
#' # Run descriptive statistics on the data:
#' # hist(gpa)
#' # table(family_income)
#' # mean(ap_ib_credit)
#' @source \url{https://nces.ed.gov/OnlineCodebook}

"hsls"
  1. Transform roxygen into the documentation/help file save .r file Build>more> Document This makes a new .Rd file in the man folder. Do not edit the NAMESPACE file or the man/file.Rd files Check the documentation/help file by opening the man/file.Rd file and clicking "preview" Edit documentation in the .r file if necessary

  2. Rebuild the package Build> more> Clean and rebuild

  3. Check the package for errors Build > check fix any errors

  4. Commit changes to github

How to make a tutorial

  1. Make learnr files This code makes the learnr tutorial (written on the scratch folder save_dta.R)
library(learnr)
usethis::use_tutorial("<tutorial-name>", "<Tutorial Title>", open = interactive())

usethis::use_tutorial("test", "test", open = interactive())
This will make a new folder in "/inst/tutorials", which contains a .Rmd with the tutorial-name
  1. Edit .Rmd file to write the tutorial More info: https://rstudio.github.io/learnr/ https://rstudio.github.io/learnr/exercises.html#hints-and-solutions

  2. Rebuild the package Build> more> Clean and rebuild

  3. Check the package for errors Build > check fix any errors

  4. Commit changes to github

Running the tutorial

To run the tutorial, students will either: -Click on the "Tutorial" tab, click on subject "start tutorial" - Run the following code (this opens the tutorial in their browser):

learnr::run_tutorial("<tutorial-name>", "<package-name>")
#learnr::run_tutorial("conditional_means", "ds")
 The tutorial now appears in the "tutorial" tab panel


AmberlyDziesinski/ds documentation built on Dec. 17, 2021, 8:45 a.m.