Title: | Useful Tools for Jurimetrical Analysis Used by the Brazilian Jurimetrics Association |
---|---|
Description: | The Brazilian Jurimetrics Association (ABJ in Portuguese, see <https://abj.org.br/> for more information) is a non-profit organization which aims to investigate and promote the use of statistics and probability in the study of Law and its institutions. This package implements general purpose tools used by ABJ, such as functions for sampling and basic manipulation of Brazilian lawsuits identification number. It also implements functions for text cleaning, such as accentuation removal. |
Authors: | Caio Lente [aut, cre] , Julio Trecenti [aut] , Katerine Witkoski [ctb] , Associação Brasileira de Jurimetria [cph, fnd] |
Maintainer: | Caio Lente <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.2.9000 |
Built: | 2024-11-11 05:30:10 UTC |
Source: | https://github.com/abjur/abjutils |
Add separators to lawsuit IDs
build_id(id)
build_id(id)
id |
One or more lawsuit IDs |
Returns the check digit of a lawsuit numbers in the format unified by the Brazilian National Council of Justice.
calc_dig(num, build = FALSE)
calc_dig(num, build = FALSE)
num |
Ordered digits of the lawsuit number (including 0's) excluding the check digit |
build |
Whether or not the function return the complete lawsuit number (or only the check digits)? |
The check digits or the complete identification number
{ calc_dig("001040620018260004", build = TRUE) calc_dig("001040620018260004", build = FALSE) }
{ calc_dig("001040620018260004", build = TRUE) calc_dig("001040620018260004", build = FALSE) }
Add separators to CARF lawsuits
carf_build_id(id)
carf_build_id(id)
id |
One or more lawsuit ids |
Returns the check digit of a CARF number or full number with the check digit.
carf_calc_dig(id, build = FALSE, verify = TRUE)
carf_calc_dig(id, build = FALSE, verify = TRUE)
id |
Lawsuit number (including trailing zeros), excluding the check digit. |
build |
Whether or not the function return the complete number (or only the check digits)? |
verify |
Verify if number is well formed (gives error if it's not) |
The check digits or the complete identification number
{ carf_calc_dig("10120.008427/2003", build = TRUE) carf_calc_dig("15374.002430/99", build = FALSE) carf_calc_dig(c("101200084272003", "1537400243099")) }
{ carf_calc_dig("10120.008427/2003", build = TRUE) carf_calc_dig("15374.002430/99", build = FALSE) carf_calc_dig(c("101200084272003", "1537400243099")) }
Verifies if a check digit is correct
carf_check_dig(id)
carf_check_dig(id)
id |
String containing the complete lawsuit number |
Whether or not the check digit is well calculated
{ carf_check_dig("10120.008427/2003-02") carf_check_dig(c("10120008427200302", "10766.000511/96-12")) }
{ carf_check_dig("10120.008427/2003-02") carf_check_dig(c("10120008427200302", "10766.000511/96-12")) }
Verifies if a check digit is correct
check_dig(num)
check_dig(num)
num |
String containing the complete lawsuit number |
Whether or not the check digit is well calculated
{ check_dig("0005268-75.2013.8.26.0100") }
{ check_dig("0005268-75.2013.8.26.0100") }
Verifies if a check digit is correct
check_dig_vet(num)
check_dig_vet(num)
num |
A vector containing strings with the complete lawsuit number |
Whether or not the check digit is well calculated
{ check_dig_vet(c("0005268-75.2013.8.26.0100", "0004122-85.2010.6.16.0100")) }
{ check_dig_vet(c("0005268-75.2013.8.26.0100", "0004122-85.2010.6.16.0100")) }
To use this function, simply copy the Query String
Parameters returned by Chrome when analyzing the network flow of
a web page. Paste these QSPs into an R string with double quotes
(as you would to create any string) and pass it to
chrome_to_body()
; the function will print to the console a
formatted command that creates a list with the QSPs. This list
works perfectly with httr::GET()
and httr::POST()
so that
you can easily reproduce a website's behavior.
chrome_to_body(x)
chrome_to_body(x)
x |
A string with Chrome's Query String Parameters |
httr::GET()
, httr::POST()
Remove all non-numeric character from a string
clean_cnj(x)
clean_cnj(x)
x |
A string (cnj) |
Remove separators from lawsuit IDs
clean_id(id)
clean_id(id)
id |
One or more lawsuit IDs |
This function is used by the "Escape Unicode" add-in and removes all accented characters from the current file, replacing them by their equivalent Unicode-escaped values.
escape_unicode()
escape_unicode()
Given one or more lawsuit IDs, this function extracts one or more parts of the IDs given the following correspondence:
"N": number
"D": verification digits
"A": year
"J": segment
"T": court
"O": origin
"": all of the above
extract_parts(id, parts = "")
extract_parts(id, parts = "")
id |
One or more lawsuit IDs |
parts |
String or string vector with desired parts (see description) |
## Not run: extract_parts("001040620018260004", "N") extract_parts("001040620018260004", c("N", "A", "O")) ## End(Not run)
## Not run: extract_parts("001040620018260004", "N") extract_parts("001040620018260004", c("N", "A", "O")) ## End(Not run)
Extract file name without extension
file_sans_ext(x)
file_sans_ext(x)
x |
Character vector of file paths |
Once you run esaj::cjsg_table("subjects")
, you can
use this function to gather the subjects automatically. Download
esaj
by running devtools::install_github("courtsbr/esaj")
.
gather_subjects(subjects)
gather_subjects(subjects)
subjects |
Table returned by |
Elegantly list objects in a R session.
lsos( pos = 1, pattern, order.by = "Size", decreasing = TRUE, head = TRUE, n = 10 )
lsos( pos = 1, pattern, order.by = "Size", decreasing = TRUE, head = TRUE, n = 10 )
pos |
Where to look for the object (see "Details" in |
pattern |
An optional regular expression to match names ( |
order.by |
Sort by |
decreasing |
Should the sorting be decreasing? |
head |
Should |
n |
How many lines |
http://stackoverflow.com/questions/1358003/tricks-to-manage-the-available-memory-in-an-r-session
Regex pattern for finding lawsuit numbers
pattern_cnj()
pattern_cnj()
Mirror of scales:::precision()
precision(x)
precision(x)
x |
See scales:::precision() |
Convert Brazilian currency values (text) to numeric
reais(x)
reais(x)
x |
A currency vector. Ex: c("R$ 10.000,00", "R$ 123,00") |
Remove accented characters from strings converting them to ASCII.
rm_accent(x)
rm_accent(x)
x |
A string vector |
A version of x
without non-ASCII characters
Returns a data frame containing a random sample of lawsuit numbers distributed according to some regional and jurisdictional parameters. The implementation supports both vector and scalar parameters, depending whether or not the function should uniformly sample from a scope of lawsuit numbers or one should define the parameters for each sample unit.
sample_cnj( n, foros, anos, orgao, tr, first_dig = "0", sample_pars = TRUE, return_df = TRUE )
sample_cnj( n, foros, anos, orgao, tr, first_dig = "0", sample_pars = TRUE, return_df = TRUE )
n |
A non negative integer giving the number of codes to generate |
foros |
One or more strings with 4 characters indicating the juridical forum for the sampled codes |
anos |
One or more strings with 4 characters indicating the distribution years of the generated codes |
orgao |
One or more strings with 1 character indicating the jurisdiction of the sampled codes. |
tr |
One or more strings with 1 character indicating the court of the generated codes |
first_dig |
The first digit of the lawsuit code ( |
sample_pars |
Whether or not the parameters define the characteristics of the codes |
return_df |
Whether or not the function should return a data frame |
A data frame or a vector containing a random sample of lawsuits IDs
{ # sampling the parameters sample_cnj(3, foros = "0000", anos = "2015", orgao = 8, tr = 26, first_dig = "0", sample_pars = TRUE, return_df = FALSE ) sample_cnj(10, foros = c("0000", "0001"), anos = c("2014", "2015"), orgao = 8, tr = 26, first_dig = "0", sample_pars = TRUE, return_df = FALSE ) # not sampling the parameters sample_cnj(3, foros = c("0000", "0001", "0002"), anos = c("2014", "2015", "2016"), orgao = rep(8, 3), tr = rep(26, 3), first_dig = "0", sample_pars = FALSE, return_df = FALSE ) }
{ # sampling the parameters sample_cnj(3, foros = "0000", anos = "2015", orgao = 8, tr = 26, first_dig = "0", sample_pars = TRUE, return_df = FALSE ) sample_cnj(10, foros = c("0000", "0001"), anos = c("2014", "2015"), orgao = 8, tr = 26, first_dig = "0", sample_pars = TRUE, return_df = FALSE ) # not sampling the parameters sample_cnj(3, foros = c("0000", "0001", "0002"), anos = c("2014", "2015", "2016"), orgao = rep(8, 3), tr = rep(26, 3), first_dig = "0", sample_pars = FALSE, return_df = FALSE ) }
Wrapper around tidyr::separate()
that splits a column
with lawsuit IDs into 6 columns with its parts (see extract_parts()
).
Note that the IDs must be built (see build_id()
).
separate_cnj(data, col, ...)
separate_cnj(data, col, ...)
data |
A data frame |
col |
Column name or position (see |
... |
Other arguments passed on to |
Produces a contingency table of the elements of a vector calculating relative frequencies as well.
tabela(x, label = "variavel")
tabela(x, label = "variavel")
x |
A vector |
label |
Quoted name of the column to create in output |
A data frame containing frequency and relative frequencies for the levels of x
This function verifies whether all of the arguments of another function already have assigned values. If an argument has a default value but there isn't a corresponding variable, it creates that variable.
test_fun(f, force_default = FALSE)
test_fun(f, force_default = FALSE)
f |
A function |
force_default |
Whether or not to assign the default value to arguments that already have assigned values |
## Not run: f <- function(a, b = 3) { a * b } test_fun(f) a b b <- 5 test_fun(f) a b test_fun(f, TRUE) a b a <- 2 test_fun(f) a b ## End(Not run)
## Not run: f <- function(a, b = 3) { a * b } test_fun(f) a b b <- 5 test_fun(f) a b test_fun(f, TRUE) a b a <- 2 test_fun(f) a b ## End(Not run)
Verifies if a Brazilian lawsuit identification is a cnj number.
verify_cnj(cnj)
verify_cnj(cnj)
cnj |
A vector containing strings with the complete lawsuit number |
Whether or not the check digit is well calculated
Shortcut to write file to "data/" directory from a pipe
write_data(x, name, dir = "data/")
write_data(x, name, dir = "data/")
x |
Object to write |
name |
Name of the object (important when loading) |
dir |
Directory where to save file |