Skip to content

Commit

Permalink
Update read-csv-nlsy-79.R
Browse files Browse the repository at this point in the history
  • Loading branch information
smasongarrison committed Oct 7, 2024
1 parent ff1c3e9 commit 15a5124
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions R/read-csv-nlsy-79.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,15 @@
#' filePathGen2 <- "~/Nlsy/Datasets/gen2-birth.csv"
#' ds <- ReadCsvNlsy79Gen2(filePath = filePathGen2)
#' }
ReadCsvNlsy79Gen1 <- function(filePath,
dsExtract = utils::read.csv(filePath)) {
ReadCsvNlsy79Gen1 <- function(filePath = NULL,
dsExtract = NULL) {
if (is.null(dsExtract)) {
if (is.null(filePath)) {
stop("Either 'filePath' or 'dsExtract' must be provided.")
}
dsExtract <- utils::read.csv(filePath)
}

d <- NlsyLinks::SubjectDetails79
if (!("R0000100" %in%
colnames(dsExtract))) {
Expand Down Expand Up @@ -61,9 +68,14 @@ ReadCsvNlsy79Gen1 <- function(filePath,

return(ds)
}
ReadCsvNlsy79Gen2 <-
function(filePath,
dsExtract = utils::read.csv(filePath)) {
ReadCsvNlsy79Gen2 <- function(filePath = NULL,
dsExtract = NULL) {
if (is.null(dsExtract)) {
if (is.null(filePath)) {
stop("Either 'filePath' or 'dsExtract' must be provided.")
}
dsExtract <- utils::read.csv(filePath)
}
d <- NlsyLinks::SubjectDetails79
# dsExtract <- read.csv(filePath)
if (!("C0000100" %in% colnames(dsExtract))) {
Expand Down

0 comments on commit 15a5124

Please sign in to comment.