From 1a01b25329aaed5176fea97fd4f35bcddf16a3c7 Mon Sep 17 00:00:00 2001 From: tavo-wasd Date: Mon, 6 Nov 2023 21:45:33 -0600 Subject: [PATCH] more R --- awesome-software/rstudio/README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/awesome-software/rstudio/README.md b/awesome-software/rstudio/README.md index e7e6d75..10648ba 100644 --- a/awesome-software/rstudio/README.md +++ b/awesome-software/rstudio/README.md @@ -17,11 +17,27 @@ View(DATASET_N) ### Crear una lista y combinarla Crea una lista `DATA_LIST` con los `dataframes` importados -previamente. Luego, combinar la lista de en uno solo. +previamente. Luego, combinar la lista en uno solo. ```r DATA_LIST <- list(DATASET_01, DATASET_02, ... DATASET_N) DATA_TOT <- Reduce(function(x, y) merge(x, y, all=TRUE), DATA_LIST) ``` +# Operaciones específicas + +Para un `dataframe` `DATA_TOT`, añadir una variable (columna) +con el valor de una variable `VAR_VALUE`, en caso de ser **mayor** a cero. + +```r +DATA_TOT$VAR_POSITIVE <- ifelse(DATA_TOT$VAR_VALUE > 0, DATA_TOT$VAR_VALUE, 0) +``` + +Para un `dataframe` `DATA_TOT`, añadir una variable (columna) +con el valor de una variable `VAR_VALUE`, en caso de ser **menor** a cero. + +```r +DATA_TOT$VAR_NEGATIVE <- ifelse(DATA_TOT$VAR_VALUE < 0, DATA_TOT$VAR_VALUE, 0) +``` + # Operaciones entre filas y columnas