Updating files

This commit is contained in:
Jose 2022-10-27 09:13:32 -03:00
parent 1bcc12a8e5
commit b5b74398d7
4 changed files with 41 additions and 5 deletions

9
.gitignore vendored Normal file → Executable file
View file

@ -95,4 +95,13 @@ flycheck_*.el
# network security
/network-security.data
# html files
*.html
# images
*.png
*.jpg
*.jpeg
# pdf
*.pdf

0
LICENSE Normal file → Executable file
View file

15
README.org Normal file → Executable file
View file

@ -1,3 +1,14 @@
# intro_r
* A brief introduction to R
Scripts describing simple tasks to learn the first steps to work with data using R programming environment
Scripts describing simple tasks to learn the first steps to work with
data using the R programming environment
** First steps in R
* [[./script/help_r.R][Asking for help to use R]]
* [[./script/integerq_modulo.R][Integer quocient and modulo]]
* [[./script/non_stand_eval.R][Non-standard evaluation in R]]
** Subsetting and indexing
* [[./script/replace_values.R][Build column in table indexing values]]

22
script/replace_values.R Normal file → Executable file
View file

@ -71,9 +71,9 @@ maior_valor <- function (df, a, b, c, ...) {
linhas <- nrow(df)
coluna <- rep(0, times = linhas)
coluna[a_maior] <- "a"
coluna[b_maior] <- "b"
coluna[c_maior] <- "c"
coluna[a_maior] <- names(df)[[1]]
coluna[b_maior] <- names(df)[[2]]
coluna[c_maior] <- names(df)[[3]]
df$V1 <- coluna
@ -103,3 +103,19 @@ dfd %>%
m == 3 ~ names(.)[3],
TRUE ~ as.character(m)
))
#' ## Usando o pacote "datatable"
library(data.table)
class(df)
dt <- setDT(df)
#' Using "apply" to know the greatest value by each row ("1") across
#' columns
dt[, great := apply(df, 1, which.max)
][, great := as.character(great)
][, great := c("1" = "a",
"2" = "b",
"3" = "c")[great]]