Questions tagged as 'lapply'

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
1
answer

Computational efficiency in R - lists or vectors

I'm studying computational efficiency in R, generating matrices through different methods. First, I generate an array of vector form and calculate the variances for its columns: matriz <- matrix(rep(NA, 1000*200), nrow = 1000, ncol=200)...
asked by 10.03.2018 / 04:04
1
answer

Select df data according to data from a list

Expensive as shown below: nr <- c(100:199) dt <- rep("data",100) x <- data.frame(nr,dt) y <- c(110:115) I need to get, with the common numbers between the first column of the data.frame x and the list and match <- x[x[1] =...
asked by 24.05.2017 / 20:38
2
answers

Check for different elements in a list in R

I have a list that each element is a data frame containing various information about a particular pension provider. In the CLASSE column there can only be one type and I need to know who has more than one type. How to create a colu...
asked by 26.09.2017 / 14:33
1
answer

Lapply does not return the desired result for some functions

My list: structure(list(col1 = structure(list(a = 1:5, b = 1:5, c = 1:5), .Names = c("a", "b", "c"), row.names = c(NA, -5L), class = "data.frame"), col2 = structure(list( a = 6:10, c = 6:10), .Names = c("a", "c"), row.names = c(NA, -5L),...
asked by 09.09.2018 / 06:06
1
answer

Use lapply (instead of for) to just leave the common columns of multiple dataframes in a new list

dput of list: structure(list(col1 = structure(list(a = 1:5, b = 1:5, c = 1:5), .Names = c("a", "b", "c"), row.names = c(NA, -5L), class = "data.frame"), col2 = structure(list( a = 6:10, c = 6:10), .Names = c("a", "c"), row.names =...
asked by 07.09.2018 / 23:12
1
answer

Changing the name of rows from a list in R using lapply from a list variable

I have a list called dataList and would like the name of the lines to be the same as a variable called CNPJ that is within that list. For this, I first applied: dadosLista<-lapply(dadosLista, "rownames<-", dadosLista$CNPJ) However, da...
asked by 30.06.2017 / 15:55
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
0
answers

How do I find the maximum and minimum number of a data frame using lapply and sapply?

I can figure out the maximum and minimum value of a data frame like this: question2 <- data.frame (Month = c("January", "February", "March", "April", "May", "June"), Day1 = c(0.73, 0.97, 0.63, 0.35, 0.81, 1.24),...
asked by 26.04.2018 / 02:29