Commit 6e8feacc authored by mabrook's avatar mabrook
Browse files

updating how data are read-in, using tidyverse tools

parent 11bf82e6
# read_data.R
# Purpose: read-in WIHS 2009 for inclusion in package
# This file is run to rebuild the WIHS data for the package
# Authors: Sara Levintow and Alan Brookhart
library(tidyverse)
# Reading in raw WIHS data
wihs<-read.table("/Users/salevintow/Documents/R Software Development/WIHS2009/data-raw/wihs_raw.txt")
wihs<-as_tibble(read.table("./data-raw/wihs_raw.txt",na.strings = "."))
# Assigning column name for each variable
colnames(wihs)<-c("id","idu","white","age","cd4","drop","delta","art","time")
# Reviewing variables to make sure data read in correctly
str(wihs)
# ART variable is currently a factor w/ 489 levels
# Need to convert to numeric and replace '.' with NA
wihs$art<-as.character(wihs$art)
wihs$art<-ifelse(wihs$art=="."," ",wihs$art)
wihs$art<-as.numeric(wihs$art)
save(wihs,file="data/wihs.Rda")
# Save R data set in the sharkr package
devtools::use_data(wihs,overwrite=TRUE)
No preview for this file type
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment