Skip to content

Commit

Permalink
Fixed issue with fredqd()
Browse files Browse the repository at this point in the history
  • Loading branch information
cykbennie committed Jan 27, 2023
1 parent 7dea12c commit 178e800
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 689 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: fbi
Type: Package
Title: Factor-Based Imputation and FRED-MD/QD Data Set
Version: 0.6.0
Date: 2022-01-19
Version: 0.7.0
Date: 2023-01-27
Authors@R: c(person("Yankang (Bennie)", "Chen", email = "[email protected]", role = c("aut", "cre")),
person("Serena", "Ng", email = "[email protected]", role = "aut"),
person("Jushan", "Bai", email = "[email protected]", role = "aut"))
Expand All @@ -22,9 +22,9 @@ Description: Factor-Based imputation of missing values in panel data and
URL: https://github.com/cykbennie/fbi
Depends: R (>= 3.5.0)
Imports: stats, readr, pracma
License: GPL-3 + LICENSE
License: GPL-3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
Suggests: knitr, rmarkdown
VignetteBuilder: knitr
674 changes: 0 additions & 674 deletions LICENSE

This file was deleted.

8 changes: 4 additions & 4 deletions R/fredmd.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ fredmd <- function(file = "", date_start = NULL, date_end = NULL, transform = TR
# Prepare raw data
rawdata <- readr::read_csv(file, col_names = FALSE, col_types = cols(X1 = col_date(format = "%m/%d/%Y")),
skip = 2)

rawdata <- as.data.frame(rawdata)
row_to_remove = c()
for (row in (nrow(rawdata)-20):nrow(rawdata)){
if(!any(is.finite(unlist(rawdata[row, ])))){
row_to_remove = c(row_to_remove,row)# remove NA rows
}
}
}
if(length(row_to_remove)>0){
rawdata = rawdata[-row_to_remove,]
}
attrdata <- read.csv(file, header = FALSE, nrows = 2)

attrdata <- utils::read.csv(file, header = FALSE, nrows = 2)
header <- c("date", unlist(attrdata[1,2:ncol(attrdata)]))
colnames(rawdata) <- header

Expand Down
1 change: 0 additions & 1 deletion R/fredmd_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#' \item{gsi:description}{description of the series in GSI}
#' \item{group}{group of the series}
#' \item{edited}{logical, indicating if the data has been editted}
#' \item{varname}{"X" + id}
#' }
#'
#' @source The \code{fredmd_description} data were obtained from
Expand Down
14 changes: 11 additions & 3 deletions R/fredqd.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,19 @@ fredqd <- function(file = "", date_start = NULL, date_end = NULL, transform = TR
# Prepare raw data
rawdata <- readr::read_csv(file, col_names = FALSE, col_types = cols(X1 = col_date(format = "%m/%d/%Y")),
skip = 3)
ind_notna <- min(which(is.na(rawdata[,1]))) - 1
rawdata <- rawdata[1:ind_notna, ] # remove NA rows

rawdata <- as.data.frame(rawdata)
row_to_remove = c()
for (row in (nrow(rawdata)-20):nrow(rawdata)){
if(!any(is.finite(unlist(rawdata[row, ])))){
row_to_remove = c(row_to_remove,row)# remove NA rows
}
}
if(length(row_to_remove)>0){
rawdata = rawdata[-row_to_remove,]
}

attrdata <- read.csv(file, header = FALSE, nrows = 3)
attrdata <- utils::read.csv(file, header = FALSE, nrows = 3)
header <- c("date", unlist(attrdata[1,2:ncol(attrdata)]))
colnames(rawdata) <- header

Expand Down
1 change: 0 additions & 1 deletion R/fredqd_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#' \item{sw_mnemonic}{mnemonic used in SW (2012)}
#' \item{description}{a brief definition of the series}
#' \item{group}{group of the series}
#' \item{varname}{"X" + id}
#' }
#'
#' @source The \code{fredqd_description} data were obtained from
Expand Down
Binary file modified fbi.pdf
Binary file not shown.
1 change: 0 additions & 1 deletion man/fredmd_description.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/fredqd_description.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 178e800

Please sign in to comment.