Skip to content

Commit 9969d04

Browse files
committed
removed dependencies
Removed dependencies for - ascii - tidyr (now in Suggests because of the vignettes) - readxl
1 parent 22eb723 commit 9969d04

8 files changed

+32
-45
lines changed

.devcontainer/install_packages.R

-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ install.packages(c("cli", "rlang",
2424
"DT",
2525
"testthat",
2626
"tidyr",
27-
"readxl",
2827
"XML",
29-
"ascii",
3028
"rvest",
3129
"readr",
32-
"proto",
3330
"bizdays"))

DESCRIPTION

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@ Imports:
2424
httr,
2525
jsonlite,
2626
purrr,
27-
ascii,
2827
rlang,
2928
methods,
3029
yaml,
3130
digest,
3231
base64enc,
33-
XML,
34-
readxl,
35-
tidyr
32+
XML
3633
Suggests:
3734
testthat,
3835
knitr,
@@ -47,6 +44,7 @@ Suggests:
4744
magrittr,
4845
tibble,
4946
withr,
47+
tidyr,
5048
vcr (>= 0.6.0)
5149
Collate:
5250
'rb3-package.R'

NAMESPACE

-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export(yc_usd_superset)
5050
importFrom(XML,getNodeSet)
5151
importFrom(XML,xmlInternalTreeParse)
5252
importFrom(XML,xmlValue)
53-
importFrom(ascii,ascii)
5453
importFrom(base64enc,base64encode)
5554
importFrom(bizdays,add.bizdays)
5655
importFrom(bizdays,bizdayse)
@@ -104,7 +103,6 @@ importFrom(readr,read_csv)
104103
importFrom(readr,read_file)
105104
importFrom(readr,read_rds)
106105
importFrom(readr,write_rds)
107-
importFrom(readxl,read_excel)
108106
importFrom(rlang,.data)
109107
importFrom(rvest,html_element)
110108
importFrom(rvest,html_nodes)
@@ -125,7 +123,6 @@ importFrom(stringr,str_starts)
125123
importFrom(stringr,str_sub)
126124
importFrom(stringr,str_to_lower)
127125
importFrom(stringr,str_trim)
128-
importFrom(tidyr,pivot_longer)
129126
importFrom(utils,getFromNamespace)
130127
importFrom(utils,hasName)
131128
importFrom(utils,read.table)

R/fields.R

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ as.data.frame.fields <- function(x, ...) {
1616
}
1717

1818
print.fields <- function(x, ...) {
19-
df <- as.data.frame(x)
20-
suppressWarnings(
21-
print(ascii(df, include.rownames = TRUE), type = "org")
22-
)
19+
cat(paste(fields_names(x), collapse = ", "), "\n")
20+
invisible(x)
2321
}
2422

2523
fields_names <- function(fields) {

R/rb3-package.R

-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#'
4141
#' @name rb3-package
4242
#'
43-
#' @importFrom ascii ascii
4443
#' @importFrom base64enc base64encode
4544
#' @importFrom bizdays following preceding load_builtin_calendars
4645
#' @importFrom bizdays add.bizdays bizdayse bizseq getdate
@@ -51,12 +50,10 @@
5150
#' @importFrom digest digest
5251
#' @importFrom dplyr tibble inner_join mutate select filter left_join as_tibble
5352
#' @importFrom dplyr bind_rows arrange rename group_by summarise
54-
#' @importFrom tidyr pivot_longer
5553
#' @importFrom httr GET POST parse_url status_code headers content config
5654
#' @importFrom jsonlite toJSON fromJSON
5755
#' @importFrom purrr map_dfr map_lgl map_chr map_int map
5856
#' @importFrom readr write_rds read_rds read_csv read_file
59-
#' @importFrom readxl read_excel
6057
#' @importFrom rlang .data
6158
#' @importFrom stringr str_replace_all str_starts str_match str_sub str_split
6259
#' @importFrom stringr str_to_lower str_detect str_pad str_replace str_trim

R/scraper-indexes.R

-18
Original file line numberDiff line numberDiff line change
@@ -221,24 +221,6 @@ get_single_indexreport <- function(idx_date,
221221
}
222222
}
223223

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-
242224
ibovespa_index_get <- function(first_date, last_date = as.Date("1997-12-31")) {
243225
f <- system.file("extdata/IBOV.rds", package = "rb3")
244226
read_rds(f) |> filter(.data$refdate >= first_date, .data$refdate <= last_date)

R/template.R

+10-10
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,22 @@ load_template_files <- function() {
6464
}
6565
}
6666

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)
67+
print.template <- function(x, ...) {
68+
cat("Template ID:", x$id, "\n")
69+
cat("Expected filename:", x$filename, "\n")
70+
cat("File type:", x$filetype, "\n")
71+
if (is(x$fields, "fields")) {
72+
cat("Fields: ")
73+
print.fields(x$fields)
7474
} else {
75-
parts_names <- names(.$parts)
75+
parts_names <- names(x$parts)
7676
ix <- 0
7777
for (nx in parts_names) {
7878
ix <- ix + 1
7979
cat("\n")
8080
cat(sprintf("Part %d: %s\n", ix, nx))
81-
cat("\n")
82-
print.fields(.$parts[[nx]]$fields)
81+
cat("Fields: ")
82+
print.fields(x$parts[[nx]]$fields)
8383
}
8484
}
8585
invisible(NULL)

examples/index-historical-data.R

+18
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ View(index_data)
3030

3131
# ----
3232

33+
index_get_from_file <- function(year) {
34+
index_data <- read_excel("./examples/IBOVDIA.XLS",
35+
sheet = as.character(year), skip = 1, range = "A3:M33",
36+
col_names = c("day", 1:12),
37+
)
38+
39+
pivot_longer(index_data, "1":"12", names_to = "month") |>
40+
mutate(
41+
month = as.integer(.data$month),
42+
year = year,
43+
refdate = ISOdate(.data$year, .data$month, .data$day) |> as.Date(),
44+
index_name = "IBOV"
45+
) |>
46+
filter(!is.na(.data$value)) |>
47+
arrange("refdate") |>
48+
select("refdate", "index_name", "value")
49+
}
50+
3351
# str_pad(1:12, 2, pad = "0")
3452
index_get_from_file <- function(year) {
3553
index_data <- read_excel("./examples/IBOVDIA.XLS",

0 commit comments

Comments
 (0)