Questions tagged as 'apply'

1
answer

Is it possible to convert this for loop to a function of the apply family?

df_loop <- data.frame(data1, data2, data3, 0) for (i in 4:nrow(df_loop[1])) { tmp_1 = df_loop[i,1] tmp_2 = df_loop[i,2] tmp_2_lag3 = df_loop[i-3,2] tmp_3 = df_loop[i,3] if (!is.na(tmp_2_lag3)) { if((tmp_1 >...
asked by 06.06.2017 / 09:23
2
answers

Apply, sapply, mapply, lapply, vapply, rapply, tapply, replicate, aggregate, by and correlates in R. When and how to use?

What is the difference between the functions apply , sapply , mapply , lapply , vapply , rapply , tapply , replicate , aggregate , by and correlates no R? When and how to use each o...
asked by 04.03.2014 / 23:52
2
answers

Replace specific column values by NA

I would like to detect and replace values above 6 in just a few columns of a data.frame by NA. I did the syntax like this but it is giving error ... Could anyone give me a help? Thanks! data <- apply(dados[14:128], 2, function(x) {x[x >...
asked by 05.06.2018 / 22:56
3
answers

Calculate the average temperature in R

I have: Data Sala.1 Sala.2 Sala.3 Horas 1 02/08/2013 20.5 19.7 21.6 15:00 2 02/08/2013 19.7 18.9 20.2 15:30 3 02/08/2013 19.7 19.1 20.0 16:00 4 02/08/2013 19.7 18.8 19.8 16:30 5 02/08/2013 19.8 18.8 19.9...
asked by 27.03.2018 / 19:31
1
answer

How to send data frames data in code questions in optimized R?

Edited - As pointed out in Marcos Moraes' comment, I tried to reinvent the wheel of an available resource in the base layer of R, since dput is capable of producing the same effect. Our failure. :( The central question of my question still rema...
asked by 29.10.2016 / 13:43