Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

[FR] cat, .vcat and message #271

Open
chainsawriot opened this issue Dec 21, 2021 · 0 comments
Open

[FR] cat, .vcat and message #271

chainsawriot opened this issue Dec 21, 2021 · 0 comments

Comments

@chainsawriot
Copy link
Collaborator

Describe the solution you'd like

There are still a few instances of cat in the codebase, e.g.

cat(paste0("Processing ",x[i],"\n"))
requrl <- paste0(url,x[i],endpoint)
next_token <- ""
while(!is.null(next_token)) {
if(next_token!=""){
params[["pagination_token"]] <- next_token
}
dat <- make_query(url = requrl, params = params, bearer_token = bearer_token, verbose = verbose)
next_token <- dat$meta$next_token #this is NULL if there are no pages left
new_rows <- dat$data
new_rows$from_id <- x[i]
new_df <- dplyr::bind_rows(new_df, new_rows) # add new rows
cat("Total data points: ",nrow(new_df), "\n")
Sys.sleep(1)
if (is.null(next_token)) {
if(verbose) {
cat("This is the last page for ",
x[i],
": finishing collection. \n")

cat(paste0("Processing ",x[i],"\n"))
next_token <- ""
while (!is.null(next_token)) {
requrl <- paste0(url,x[i],endpoint)
if(next_token!=""){
params[["pagination_token"]] <- next_token
}
dat <- make_query(url = requrl, params = params, bearer_token = bearer_token, verbose = verbose)
next_token <- dat$meta$next_token #this is NULL if there are no pages left
new_rows <- dat$data
new_rows$from_id <- x[i]
new_df <- dplyr::bind_rows(new_df, new_rows) # add new rows
cat("Total data points: ",nrow(new_df), "\n")

cat(paste0("Processing from ",i," to ", end,"\n"))

Therefore, they can't control the verbosity. The helper function .vcat should be used.

NB: This instance is different because it is asking for radius

cat("Radius must be less than 25 miles")
z <- readline("Input new radius: ")
zn<- as.numeric(z)

Also, according to the rOpenSci packaging guidelines, maybe it is a good idea to switch to message() instead. If all cat instances are replaced, we can simply modify .vcat to change all cat calls to message calls.

Anything else?

No response

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant