We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 22eb723 commit 9969d04Copy full SHA for 9969d04
.devcontainer/install_packages.R
@@ -24,10 +24,7 @@ install.packages(c("cli", "rlang",
24
"DT",
25
"testthat",
26
"tidyr",
27
-"readxl",
28
"XML",
29
-"ascii",
30
"rvest",
31
"readr",
32
-"proto",
33
"bizdays"))
DESCRIPTION
@@ -24,15 +24,12 @@ Imports:
httr,
jsonlite,
purrr,
- ascii,
rlang,
methods,
yaml,
digest,
base64enc,
- XML,
34
- readxl,
35
- tidyr
+ XML
36
Suggests:
37
testthat,
38
knitr,
@@ -47,6 +44,7 @@ Suggests:
47
44
magrittr,
48
45
tibble,
49
46
withr,
+ tidyr,
50
vcr (>= 0.6.0)
51
Collate:
52
'rb3-package.R'
NAMESPACE
@@ -50,7 +50,6 @@ export(yc_usd_superset)
importFrom(XML,getNodeSet)
importFrom(XML,xmlInternalTreeParse)
importFrom(XML,xmlValue)
53
-importFrom(ascii,ascii)
54
importFrom(base64enc,base64encode)
55
importFrom(bizdays,add.bizdays)
56
importFrom(bizdays,bizdayse)
@@ -104,7 +103,6 @@ importFrom(readr,read_csv)
104
103
importFrom(readr,read_file)
105
importFrom(readr,read_rds)
106
importFrom(readr,write_rds)
107
-importFrom(readxl,read_excel)
108
importFrom(rlang,.data)
109
importFrom(rvest,html_element)
110
importFrom(rvest,html_nodes)
@@ -125,7 +123,6 @@ importFrom(stringr,str_starts)
125
123
importFrom(stringr,str_sub)
126
124
importFrom(stringr,str_to_lower)
127
importFrom(stringr,str_trim)
128
-importFrom(tidyr,pivot_longer)
129
importFrom(utils,getFromNamespace)
130
importFrom(utils,hasName)
131
importFrom(utils,read.table)
R/fields.R
@@ -16,10 +16,8 @@ as.data.frame.fields <- function(x, ...) {
16
}
17
18
print.fields <- function(x, ...) {
19
- df <- as.data.frame(x)
20
- suppressWarnings(
21
- print(ascii(df, include.rownames = TRUE), type = "org")
22
- )
+ cat(paste(fields_names(x), collapse = ", "), "\n")
+ invisible(x)
23
fields_names <- function(fields) {
R/rb3-package.R
@@ -40,7 +40,6 @@
40
#'
41
#' @name rb3-package
42
43
-#' @importFrom ascii ascii
#' @importFrom base64enc base64encode
#' @importFrom bizdays following preceding load_builtin_calendars
#' @importFrom bizdays add.bizdays bizdayse bizseq getdate
@@ -51,12 +50,10 @@
#' @importFrom digest digest
#' @importFrom dplyr tibble inner_join mutate select filter left_join as_tibble
#' @importFrom dplyr bind_rows arrange rename group_by summarise
-#' @importFrom tidyr pivot_longer
#' @importFrom httr GET POST parse_url status_code headers content config
#' @importFrom jsonlite toJSON fromJSON
57
#' @importFrom purrr map_dfr map_lgl map_chr map_int map
58
#' @importFrom readr write_rds read_rds read_csv read_file
59
-#' @importFrom readxl read_excel
60
#' @importFrom rlang .data
61
#' @importFrom stringr str_replace_all str_starts str_match str_sub str_split
62
#' @importFrom stringr str_to_lower str_detect str_pad str_replace str_trim
R/scraper-indexes.R
@@ -221,24 +221,6 @@ get_single_indexreport <- function(idx_date,
221
222
223
224
-index_get_from_file <- function(year) {
225
- index_data <- read_excel("./examples/IBOVDIA.XLS",
226
- sheet = as.character(year), skip = 1, range = "A3:M33",
227
- col_names = c("day", 1:12),
228
229
-
230
- pivot_longer(index_data, "1":"12", names_to = "month") |>
231
- mutate(
232
- month = as.integer(.data$month),
233
- year = year,
234
- refdate = ISOdate(.data$year, .data$month, .data$day) |> as.Date(),
235
- index_name = "IBOV"
236
- ) |>
237
- filter(!is.na(.data$value)) |>
238
- arrange("refdate") |>
239
- select("refdate", "index_name", "value")
240
-}
241
242
ibovespa_index_get <- function(first_date, last_date = as.Date("1997-12-31")) {
243
f <- system.file("extdata/IBOV.rds", package = "rb3")
244
read_rds(f) |> filter(.data$refdate >= first_date, .data$refdate <= last_date)
R/template.R
@@ -64,22 +64,22 @@ load_template_files <- function() {
64
65
66
67
-print.template <- function(.) {
68
- cat("Template ID:", .$id, "\n")
69
- cat("Expected filename:", .$filename, "\n")
70
- cat("File type:", .$filetype, "\n")
71
- if (is(.$fields, "fields")) {
72
- cat("\n")
73
- print.fields(.$fields)
+print.template <- function(x, ...) {
+ cat("Template ID:", x$id, "\n")
+ cat("Expected filename:", x$filename, "\n")
+ cat("File type:", x$filetype, "\n")
+ if (is(x$fields, "fields")) {
+ cat("Fields: ")
+ print.fields(x$fields)
74
} else {
75
- parts_names <- names(.$parts)
+ parts_names <- names(x$parts)
76
ix <- 0
77
for (nx in parts_names) {
78
ix <- ix + 1
79
cat("\n")
80
cat(sprintf("Part %d: %s\n", ix, nx))
81
82
- print.fields(.$parts[[nx]]$fields)
+ print.fields(x$parts[[nx]]$fields)
83
84
85
invisible(NULL)
examples/index-historical-data.R
@@ -30,6 +30,24 @@ View(index_data)
# ----
+index_get_from_file <- function(year) {
+ index_data <- read_excel("./examples/IBOVDIA.XLS",
+ sheet = as.character(year), skip = 1, range = "A3:M33",
+ col_names = c("day", 1:12),
+ )
+
39
+ pivot_longer(index_data, "1":"12", names_to = "month") |>
+ mutate(
+ month = as.integer(.data$month),
+ year = year,
+ refdate = ISOdate(.data$year, .data$month, .data$day) |> as.Date(),
+ index_name = "IBOV"
+ ) |>
+ filter(!is.na(.data$value)) |>
+ arrange("refdate") |>
+ select("refdate", "index_name", "value")
+}
# str_pad(1:12, 2, pad = "0")
index_get_from_file <- function(year) {
index_data <- read_excel("./examples/IBOVDIA.XLS",
0 commit comments