0
I am creating a function, but when calling the function, the parameter is not working when performing FILTER and SUM.
To select the column or to perform an n() type count, it works correctly.
Following example:
df <- data.frame(C1 = c(1,2,NA,3))
df_funcao = function(PERIODO){
soma = df %>%
dplyr::select(PERIODO) %>%
filter(PERIODO != 'NA') %>%
summarise(soma = sum(PERIODO))
return(soma)
}
df_2 <- df_funcao(C1)
df_2
Here gives a Character error, but is as numeric format.
Error: Problem with
summarise()
columnsoma
. isoma = sum(PERIODO)
.
x invalid 'type' (Character) of argument
Runrlang::last_error()
to see Where the error occurred.
Worked out, hadn’t found anywhere else this way.
– Diego Wenceslau