Posts by Athos • 476 points
5 posts
-
5
votes4
answers1920
viewsA: Create column with sum and percentage of the maximum of other columns
An alternative: library(dplyr) dados3 <- dados %>% mutate_at(c("A", "B", "C", "D", "E", "F"), as.numeric) %>% mutate(Soma_total_2 = data_frame(A, B, C, D, E, F) %>% rowSums(na.rm =…
-
15
votes7
answers9711
viewsA: Remove accents
A while ago I set up this function to remove accents. Never let me down. rm_accent <- function(str,pattern="all") { # Rotinas e funções úteis V 1.0 # rm.accent - REMOVE ACENTOS DE PALAVRAS #…
-
3
votes4
answers8289
viewsA: How to put different graphics of ggplot2, separately but on the same screen?
For this, I have already used the multiplot function provided on that website. The function may not be exactly what you need, but it’s easier to change it than to start from scratch. Copying the…
-
1
votes2
answers472
viewsA: Create columns in R from another where some values are null
An alternative only with base functions that could be used for values other than NA: x <- c(1, NA, NA, 2, NA, 3, 4) nao_eh_na <- !is.na(x) x_indices <- cumsum(nao_eh_na) x_vals <-…
-
12
votes2
answers1533
viewsA: What does <<- mean in R?
I will explain with an example. > objeto_fora_da_funcao <- 1 > f <- function() { objeto_fora_da_funcao <- 10 return(objeto_fora_da_funcao) } Exits > f() # [1] 10 >…