clessn / clessnverse Goto Github PK
View Code? Open in Web Editor NEWCollection of packages and functions for the CLESSN's projects
License: Other
Collection of packages and functions for the CLESSN's projects
License: Other
❯ checking Rd \usage sections ... WARNING
Undocumented arguments in documentation object 'dbxDeleteFile'
‘filename’ ‘token’
Undocumented arguments in documentation object 'dbxDownloadFile'
‘filename’ ‘local_path’ ‘token’
Undocumented arguments in documentation object 'dbxListDir'
‘dir’ ‘token’
Undocumented arguments in documentation object 'dbxMoveFile'
‘source’ ‘destination’ ‘token’ ‘overwrite’
Undocumented arguments in documentation object 'dbxUploadFile'
‘filename’ ‘remote_path’ ‘token’ ‘overwrite’
Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.
Solution to try
ggplot2::rel()
Relative sizing for theme elementsThere are unspecified global variables.
❯ checking R code for possible problems ... NOTE
dbxDeleteFile: no visible binding for global variable ‘logger’
dbxDownloadFile: no visible binding for global variable ‘logger’
dbxListDir: no visible binding for global variable ‘logger’
dbxMoveFile: no visible binding for global variable ‘logger’
dbxUploadFile: no visible binding for global variable ‘logger’
detect_language: no visible binding for global variable ‘txt’
detect_language: no visible binding for '<<-' assignment to ‘file_ftz’
detect_language: no visible binding for global variable ‘file_ftz’
translate_text: no visible binding for global variable ‘txt’
Undefined global functions or variables:
file_ftz logger txt
usethis::use_import_from()
RCurl
RCurl::curlEscape
RCurl::getURL
XML
Other
Code and explanation from William Poirier:
Probablement plus facile de créer une fonction pour faire l’opération que tu veux faire. La fonction scale() est faite pour soustraire la moyenne de la colonne à toute les observations, et a en diviser l’écart-type
scaling_01 <- function(vector){
min <- min(vector)
max <- max(vector)
output <- (vector-min)/(max-min)
return(output)
}
sapply(data,scaling_01)
See documentation and tests in https://github.com/clessn/editwars/tree/11-standardise-edit-war-reverts-and-fatalities-variables
Always a error message when downloading
── R CMD check results ──────────────────────────────────────────────────────── clessnverse 0.4.0 ────
Duration: 46.4s
❯ checking R files for non-ASCII characters ... WARNING
Found the following file with non-ASCII characters:
dev_t.R
Portable packages must use only ASCII characters in their R code,
except perhaps in comments.
Use \uxxxx escapes for other characters.
According to R Packages:
Checking R files for non-ASCII characters.
For maximum portability (i.e. so people can use your package on Windows) you should avoid using non-ASCII
characters in R files. It’s ok to use them in comments, but object names shouldn’t use them,
and in strings you should use unicode escapes. See the CRAN-specific notes in ?sec-code for more details.
eval(parse(text="string"))
evalparse("string")
Namespace should not be edited by hand, only using tags from roxygen2.
Based on purrr::has_element()
misses_element <- function(.x, .y) {
purrr::none(.x, identical, .y)
}
# Hubert's example
x <- c(3, 5, 7, 2, 4)
x |> misses_element(5)
# [1] FALSE
x |> misses_element(6)
# [1] TRUE
# Purrr::has_element examples
x <- list(1:10, 5, 9.9)
x |> misses_element(1:10)
# [1] FALSE
x |> misses_element(3)
# [1] TRUE
See code in elxn-qc2022
Add these lines of code (and remove former arguments) to the theme()
function of the clessnverse themes.
theme(strip.background = element_blank(),
axis.line = element_blank(),
axis.ticks = element_blank())
❯ checking Rd \usage sections ... WARNING
Undocumented arguments in documentation object 'commit_mart_row'
‘refresh_data’
Documented arguments not in \usage in documentation object 'commit_mart_row':
‘mode’
Undocumented arguments in documentation object 'dbxDeleteFile'
‘filename’ ‘token’
Undocumented arguments in documentation object 'dbxDownloadFile'
‘filename’ ‘local_path’ ‘token’
Undocumented arguments in documentation object 'dbxListDir'
‘dir’ ‘token’
Undocumented arguments in documentation object 'dbxMoveFile'
‘source’ ‘destination’ ‘token’ ‘overwrite’
Undocumented arguments in documentation object 'dbxUploadFile'
‘filename’ ‘remote_path’ ‘token’ ‘overwrite’
Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.
To resolve https://github.com/clessn/elxn-qc2022/issues/16, I'm running the clessnverse::get_dictionary
example:
Lines 640 to 647 in 41beaf8
I get the following error message:
> clessnverse::get_dictionary("covid", c("en", "fr"), credentials)
[1] "https://hublot.clessn.cloud/admin/api/v1/files/config_dict/"
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
'file' must be a character string or connection
Ran the source code for clessnverse::get_dictionary
line by line, the error message pops up here:
Line 655 in 41beaf8
Credentials
Packages and code
In a regression, when a independant variable has a missing value, that observation is removed.
It would be nice to be able to count the number of missing values per variable.
Create function count_missing_values()
which wraps around count_na()
and count_null()
.
Function could be applied using mutate(accross(all_of(variables), count_missing_values)
.
It is difficult to understand the content of the package because of empty files and because scale_discrete_quorum.R
should be in the thematic file visualization.R
.
Delete empty .R
files
Other
scale.R
to visualization.R
Difficult to maintain all of the functions because of the variety.
Create smaller packages that clessnverse would import à la tidyverse. Could divide by goal/user group.
Smaller package ideas:
clessndev
: would contain all dev_*.R
When I run devtools::check()
, I get the following error:
❯ checking examples ... ERROR
Running examples in ‘clessnverse-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: commit_mart_row
> ### Title: clessnverse::commit_mart_row
> ### Aliases: commit_mart_row
>
> ### ** Examples
>
>
> # connect to hublot
> credentials <- hublot::get_credentials(
+ Sys.getenv("HUB3_URL"),
+ Sys.getenv("HUB3_USERNAME"),
+ Sys.getenv("HUB3_PASSWORD")
+ )
>
>
> clessnverse::commit_mart_row(
+ table_name = "political_parties_press_releases_freq",
+ key = "QS212022",
+ row = list(week_num=21, count=6, political_party="QS"),
+ mode = "refresh",
+ credentials = credentials)
No encoding supplied: defaulting to UTF-8.
Error in hublot::handle_response(response, path, 200) :
error 403 (wrong credentials or action not allowed) at api/v1/clhub_tables_mart_political_parties_press_releases_freq/filter/ : <!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="robots" content="NONE,NOARCHIVE">
<title>403 Forbidden</title>
<style type="text/css">
html * { padding:0; margin:0; }
body * { padding:10px 20px; }
body * * { padding:0; }
body { font:small sans-serif; background:#eee; color:#000; }
body>div { border-bottom:1px solid #ddd; }
h1 { font-weight:normal; margin-bottom:.4em; }
h1 span { font-size:60%; color:#666; font-weight:normal; }
#info { background:#f6f6f6; }
#info ul { margin: 0.5em 4em; }
#info p, #summary p { padding-top:10px; }
#summary { background: #ffc; }
#explanation { background:#eee; border-bottom: 0px none; }
</style>
</head>
<body>
<div id="summary">
<h1>Forbidden <span>(403)</span>
</h1>
<p>CSRF verification failed. R
Calls: <Anonymous> -> <Anonymous> -> <Anonymous> -> <Anonymous>
Execution halted
.Renviron
is set up with my credentials.In source code R/dev_t.R
, put examples in between don't run:
#'@examples
#'\dontrun{
#'geocode("3817 Spruce St, Philadelphia, PA 19104")
#'geocode("Philadelphia, PA")
#'dat <- data.frame(value=runif(3),address=c("3817 Spruce St, Philadelphia, PA 19104","Philadelphia, PA","Neverneverland"))
#'geocode(dat)
#'}
Package version number hasn't been updated regularly. Therefore, users can't currently update their package without having to put force = TRUE.
Update package number so that when you run the code to download it, it automatically updates it.
Use format for version number MAJOR.MINOR.PATCH
https://semver.org
Default branches used to be called master
, but now they're called main
. Previous default branches haven't been renamed, but having some repos named one or the other is inconvenient, hence why I'm standardizing it.
According to the documentation, By default, GitHub names the default branch *main* in any new repository.
These warnings pop up when running devtools::document()
> document()
ℹ Updating clessnverse documentation
ℹ Loading clessnverse
There were 32 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: [dev_dropbox.R:3] @description requires a value
2: [dev_dropbox.R:4] @param requires a value
3: [dev_dropbox.R:5] @param requires a value
4: [dev_dropbox.R:6] @param requires a value
5: [dev_dropbox.R:7] @return requires a value
6: [dev_dropbox.R:8] @examples requires a value
7: [dev_dropbox.R:59] @description requires a value
8: [dev_dropbox.R:60] @param requires a value
9: [dev_dropbox.R:61] @param requires a value
10: [dev_dropbox.R:62] @param requires a value
11: [dev_dropbox.R:63] @return requires a value
12: [dev_dropbox.R:64] @examples requires a value
13: [dev_dropbox.R:117] @description requires a value
14: [dev_dropbox.R:118] @param requires a value
15: [dev_dropbox.R:119] @param requires a value
16: [dev_dropbox.R:120] @param requires a value
17: [dev_dropbox.R:121] @return requires a value
18: [dev_dropbox.R:122] @examples requires a value
19: [dev_dropbox.R:153] @description requires a value
20: [dev_dropbox.R:154] @param requires a value
21: [dev_dropbox.R:155] @param requires a value
22: [dev_dropbox.R:156] @param requires a value
23: [dev_dropbox.R:157] @return requires a value
24: [dev_dropbox.R:158] @examples requires a value
25: [dev_dropbox.R:190] @description requires a value
26: [dev_dropbox.R:191] @param requires a value
27: [dev_dropbox.R:192] @param requires a value
28: [dev_dropbox.R:193] @param requires a value
29: [dev_dropbox.R:194] @return requires a value
30: [dev_dropbox.R:195] @examples requires a value
31: [dev_tools.R:15] @param requires a value
32: [dev_tools.R:16] @return requires a value
Undocumented arguments in documentation object 'normalize_min_max'
‘x’
Documented arguments not in \usage in documentation object 'normalize_min_max':
‘vector’
Lines 23 to 28 in 5e17967
There has been version conflicts in the namespace file reported by @p2xcode.
To facilitate maintenance of the package, please add @export
roxygen2 tags to functions that should be listed as exports in NAMESPACE.
Namespace should only be edited automatically by roxygen2 when running devtools::document()
. Running devtools::document()
will override any manual edits.
When devtools::check()
is run, the following note appears about clessnverse::get_hub2_table()
❯ checking R code for possible problems ... NOTE
Found if() conditions comparing class() to string:
File ‘clessnverse/R/dev_t.R’: if (!is.null(data_filter) && !class(data_filter) == "list" || length(data_filter) == 0) ...
Use inherits() (or maybe is()) instead.
The line in question is 216 in clessnverse/R/dev_t.R
Make it easier to read the package source code.
Reduce redundant and obsolete information / content.
get_EuDistance()
to #93Users don't have a clear expectation of the state of the functions, but they still want convenient access to experimental functions.
Add badges from the lifecycle package:
#' `r lifecycle::badge("experimental")`
#' `r lifecycle::badge("deprecated")`
#' `r lifecycle::badge("superseded")`
Eventually, could create defunct.R
to store all defunct functions, like in dplyr
sample_biased()
, calculate_proportions()
and run_dictionary()
in analysis.R
)To facilitate continuous integration or development, there should be automated tests.
Set up GitHub Actions to run R CMD check.
For a basic test, use:
usethis::use_github_actions()
Eventually, can set up tests for Linux, MacOs, Windows with
usethis::use_github_action_check_standard()
Package doesn't do one thing. There's a lot of dependencies #34. It's hard to maintain.
1.0.0
Packages
clessnvis
: contains all visualisation scriptsclessndev
: contain all dev_*.R
usethis::use_tidy_description()
The code for get_EuDistance()
is commented out here:
Lines 4 to 29 in 4d5c231
It is not part of the package. It's unclear why it is included like this.
Similar functions seem to exist already, therefore this function might not be needed.
When I run devtools::check()
, I get the following error:
── R CMD check results ───────── clessnverse 0.0.0.9122 ────
Duration: 1m 18.7s
❯ checking examples ... ERROR
Running examples in 'clessnverse-Ex.R' failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: get_hub2_table
> ### Title: clessnverse::get_hub2_table
> ### Aliases: get_hub2_table
>
> ### ** Examples
>
>
> clessnhub::login(
+ Sys.getenv("HUB_USERNAME"),
+ Sys.getenv("HUB_PASSWORD"),
+ Sys.getenv("HUB_URL"))
connexion à en cours...
Error in curl::curl_fetch_memory(url, handle = handle) :
Protocol "" not supported or disabled in libcurl
Calls: <Anonymous> ... request_fetch -> request_fetch.write_memory -> <Anonymous>
Execution halted
❯ checking package dependencies ... NOTE
Imports includes 21 non-default packages.
Importing from so many packages makes the package vulnerable to any of
them becoming unavailable. Move as many as possible to Suggests and
use conditionally.
❯ checking R code for possible problems ... NOTE
Found if() conditions comparing class() to string:
File 'clessnverse/R/dev_t.R': if (!is.null(data_filter) && !class(data_filter) == "list" || length(data_filter) == 0) ...
Use inherits() (or maybe is()) instead.
1 error ✖ | 0 warnings ✔ | 2 notes ✖
sum(is.na(vector))
Can be applied in a sapply for multiple columns
Message d'erreur
Error in get(method, envir = home) :
lazy-load database '/Library/Frameworks/R.framework/Versions/4.2/Resources/library/gtable/R/gtable.rdb' is corrupt
In addition: Warning messages:
1: In heightDetails(ggrobs[[i]]) :
restarting interrupted promise evaluation
2: In get(method, envir = home) :
restarting interrupted promise evaluation
3: In get(method, envir = home) : internal error -3 in R_decompress1
Issue description
When downloading clessnverse
, I got the following error messages and it stopped downloading.
> devtools::install_github("clessn/clessnverse")
Downloading GitHub repo clessn/clessnverse@HEAD
Skipping 2 packages not available: hublot, clessnhub
Installing 21 packages: SnowballC, ISOcodes, iterators, XML, tokenizers, janeaustenr, hunspell, getopt, RcppArmadillo, stopwords, RcppParallel, fastmatch, foreach, rlist, tidytext, tidyjson, optparse, hublot, clessnhub, tictoc, quanteda
# [skipping to the error messages]
ERROR: dependencies ‘clessnhub’, ‘hublot’ are not available for package ‘clessnverse’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/clessnverse’
Warning messages:
1: packages ‘hublot’, ‘clessnhub’ are not available for this version of R
Versions of these packages for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
2: In i.p(...) :
installation of package ‘RcppArmadillo’ had non-zero exit status
3: In i.p(...) :
installation of package ‘/var/folders/f4/dg30smyn5jx_5ffqrtz0zn2m0000gn/T//RtmpoNQnus/filec5b9febff8/clessnverse_0.0.0.9200.tar.gz’ had non-zero exit status
I solved this by downloading clessnhub
and hublot
before retrying to download clessnverse
.
devtools::install_github("clessn/clessn-hub-r")
devtools::install_github("clessn/hublotr")
It worked after that.
Solution proposal
clessnhub
and hublot
Users with no credentials for Hublot cannot try the example in clessnverse::get_dictionary
because covid
is a private dictionary, according to the Hublot website.
Replace the private covid
dictionary example with a public one like stopwords
:
# get credentials from hublot
credentials <- hublot::get_credentials(
Sys.getenv("HUB3_URL"),
Sys.getenv("HUB3_USERNAME"),
Sys.getenv("HUB3_PASSWORD")
)
# retrieve the COVID dictionary in both EN and FR
clessnverse::get_dictionary("stopwords", c("en", "fr"), credentials)
Before implementing, should validate the proposed code and resolve #47
Originally posted by @judith-bourque in #47 (comment)
When devtools::check()
is run, the following note appears
checking package dependencies ... NOTE
Imports includes 22 non-default packages.
Importing from so many packages makes the package vulnerable to any of
them becoming unavailable. Move as many as possible to Suggests and
use conditionally.
❯ checking R files for non-ASCII characters ... WARNING
Found the following file with non-ASCII characters:
dev_t.R
Portable packages must use only ASCII characters in their R code,
except perhaps in comments.
Use \uxxxx escapes for other characters.
❯ checking dependencies in R code ... WARNING
'::' or ':::' imports not declared from:
‘RCurl’ ‘XML’ ‘fastText’ ‘http’
❯ checking Rd \usage sections ... WARNING
Undocumented arguments in documentation object 'commit_mart_row'
‘refresh_data’
Documented arguments not in \usage in documentation object 'commit_mart_row':
‘mode’
Undocumented arguments in documentation object 'dbxDeleteFile'
‘filename’ ‘token’
Undocumented arguments in documentation object 'dbxDownloadFile'
‘filename’ ‘local_path’ ‘token’
Undocumented arguments in documentation object 'dbxListDir'
‘dir’ ‘token’
Undocumented arguments in documentation object 'dbxMoveFile'
‘source’ ‘destination’ ‘token’ ‘overwrite’
Undocumented arguments in documentation object 'dbxUploadFile'
‘filename’ ‘remote_path’ ‘token’ ‘overwrite’
Undocumented arguments in documentation object 'normalize_min_max'
‘x’
Documented arguments not in \usage in documentation object 'normalize_min_max':
‘vector’
Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter ‘Writing R documentation files’ in the ‘Writing R
Extensions’ manual.
❯ checking package dependencies ... NOTE
Imports includes 23 non-default packages.
Importing from so many packages makes the package vulnerable to any of
them becoming unavailable. Move as many as possible to Suggests and
use conditionally.
❯ checking R code for possible problems ... NOTE
dbxDeleteFile: no visible binding for global variable ‘logger’
dbxDownloadFile: no visible binding for global variable ‘logger’
dbxListDir: no visible binding for global variable ‘logger’
dbxMoveFile: no visible binding for global variable ‘logger’
dbxUploadFile: no visible binding for global variable ‘logger’
detect_language: no visible binding for global variable ‘txt’
detect_language: no visible binding for '<<-' assignment to ‘file_ftz’
detect_language: no visible binding for global variable ‘file_ftz’
translate_text: no visible binding for global variable ‘txt’
Undefined global functions or variables:
file_ftz logger txt
Found if() conditions comparing class() to string:
File ‘clessnverse/R/dev_t.R’: if (!is.null(data_filter) && !class(data_filter) == "list" || length(data_filter) == 0) ...
Use inherits() (or maybe is()) instead.
0 errors ✔ | 3 warnings ✖ | 2 notes ✖
When users download the package for the first time, it throws an error message that it can't download hublotr and clessn-hub-r from CRAN.
Follow instructions in this vignette by adding the packages in the description to Remotes:
Remotes: clessn/hublotr,
clessn/clessn-hub-r
Suggested description:
"Package for data domestication, analysis and visualization"
Adrien: je devine que t'as l'autorisation pour le faire?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.