Commit df3404ab authored by levintow's avatar levintow
Browse files

saving R dataset and raw data

parent 88b60441
# Reading in WIHS data
w<-read.table("/Users/salevintow/Documents/R Software Development/WIHS2009/raw_data/wihs2009.14mar17.dat.txt")
colnames(w)<-c("id","idu","white","age","cd4","drop","delta","art","time")
wihs<-read.table("/Users/salevintow/Documents/R Software Development/WIHS2009/raw_data/wihs2009.14mar17.dat.txt")
colnames(wihs)<-c("id","idu","white","age","cd4","drop","delta","art","time")
# Review variables and make sure data read in correctly
str(w)
str(wihs)
# ART variable is currently a factor w/ 489 levels
# Need to convert to numeric and replace '.' with NA
w$art<-as.character(w$art)
w$art<-ifelse(w$art=="."," ",w$art)
w$art<-as.numeric(w$art)
# Save R data set in repository
save(w,file="wihs.Rda")
wihs$art<-as.character(wihs$art)
wihs$art<-ifelse(wihs$art=="."," ",wihs$art)
wihs$art<-as.numeric(wihs$art)
# Save R data set in the WIHS package
devtools::use_data(wihs)
# Creating raw data folder
use_data_raw()
# Learning how to create WIHS package
install.packages(c("devtools", "roxygen2", "testthat", "knitr"))
library(devtools)
library(roxygen2)
library(testthat)
library(knitr)
# List packages that this package will need - example code:
# devtools::use_package("dplyr") # Defaults to imports
# Then delete all library() code
# Load R data set
load(file="wihs.Rda")
# Initial analyses looking at data
library(ggplot2)
library(dplyr)
......
# Reading in raw WIHS data
wihs<-read.table("/Users/salevintow/Documents/R Software Development/WIHS2009/data-raw/wihs_raw.txt")
# 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")
This diff is collapsed.
File added
File deleted
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