-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_data_functions.R
More file actions
31 lines (27 loc) · 947 Bytes
/
get_data_functions.R
File metadata and controls
31 lines (27 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
get_cran_data <- function() {
url <- "https://raw.githubusercontent.com/spsanderson/package-downloads/master/"
f_name <- "old_downloads.RDS"
f_url <- paste0(url, f_name)
data <- readRDS(url(f_url, method = "libcurl"))
data <- as_tibble(data)
write_csv(data, "01_data/cran_logs.csv")
}
get_package_release_data <- function(){
url <- "https://raw.githubusercontent.com/spsanderson/package-downloads/master/"
f_name <- "pkg_release_tbl.rds"
f_url <- paste0(url, f_name)
data <- readRDS(url(f_url, method = "libcurl"))
data <- as_tibble(data)
write_csv(data, "01_data/pkg_release_tbl.csv")
}
csv_to_rds <- function(){
data <- read.csv("01_data/cran_logs.csv")
pkg_data <- read.csv("01_data/pkg_release_tbl.csv")
saveRDS(data, "01_data/cran_logs.rds")
saveRDS(pkg_data, "01_data/pkg_release_tbl.rds")
}
load_cran_data <- function() {
data <- readRDS("01_data/cran_logs.rds") %>%
as_tibble()
return(data)
}