lapply Questions
4
Solved
I have dataset with multiple outcome variables that I would like to test against one predictor. on exploratory analysis I noted some of the relationships are polynomial to the degree 2 rather than ...
Funnyman asked 21/5 at 5:42
4
Solved
this may seem like a overly complicated question, but it has me driving me a little nuts for some time. It is also for curiosity, because I already have a way of doing what I need, so is not that i...
2
Solved
I'm doing the following in order to import some txt tables and keep them as list:
# set working directory - the folder where all selection tables are stored
hypo_selections<-list.files() # chang...
Petigny asked 13/1, 2014 at 12:21
3
Solved
I need to make tutorial for beginner using the R *apply function (without using reshape or plyr package in a first time)
I try to lapply (because i read apply is not good for dataframe) a simple f...
3
Solved
I've got a function, e.g. fun(a, b = 1, c = 3, ...), that takes a number of arguments, some of which have default values. I would like to call this function using lapply(X, FUN, ...), but specify e...
3
Solved
I have a list of data frames and have given each element in the list (e.g. each data frame) a name:
e.g.
df1 <- data.frame(x = c(1:5), y = c(11:15))
df2 <- data.frame(x = c(1:5), y = c(11:...
1
Solved
I'm using the emmeans package and cannot understand why this works
library(emmeans)
mod <- lm(mpg ~ disp + hp, data = mtcars)
l1 <- emmeans(mod, list("disp","hp"))
for (x...
3
Solved
I created a list and I stored one data frame in each component. Now I would like to filter those data frames keeping only the rows that have NA in a specific column. I would like the result of this...
1
Solved
I'm trying to gain a deeper understanding of loops vs. *apply functions in R. Here, I did an experiment where I compute the first 10,000 triangular numbers in 3 different ways.
unwrapped: a ...
5
Solved
Is there any reason why I should use
map(<list-like-object>, function(x) <do stuff>)
instead of
lapply(<list-like-object>, function(x) <do stuff>)
the output should be...
4
I am an R novice, especially when it comes to spatial data. I am trying to find a way to efficiently import multiple (~600) single-band raster (.tif) files into R, all stored in the same folder. No...
11
Solved
Suppose we have files file1.csv, file2.csv, ... , and file100.csv in directory C:\R\Data and we want to read them all into separate data frames (e.g. file1, file2, ... , and file100).
The reason ...
1
Solved
I have a data.table, DT containing one string variable, s, from which I want to create additional variables based on the positions of each character in s. The varname, start and end positions and v...
Breakthrough asked 4/8, 2022 at 20:43
5
Solved
I have a list of dataframes which I eventually want to merge while maintaining a record of their original dataframe name or list index. This will allow me to subset etc across all the rows. To acco...
7
Solved
I have 2 lists inside a list in R. Each sublist contains a different number of dataframes. The data looks like this:
df1 <- data.frame(x = 1:5, y = letters[1:5])
df2 <- data.frame(x = 1:15, y...
1
Solved
I want to apply given function to each row of dataframe and use another values of row, as input parameters/arguments:
Model <- c("H5", "H5", "H5","H4")
Le...
4
Solved
I have a data frame of values across successive years (columns) for unique individuals (rows). A dummy data example is provided here:
dt = structure(list(ID = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), `201...
Mckenna asked 25/3, 2022 at 8:7
4
Solved
I have used lapply to apply a function to a number of data frames:
data.cleaned <- lapply(data.list, shooter_cleaning)
And then labeled each of the resulting data frames in the list according...
Ocean asked 3/11, 2014 at 4:19
3
Solved
It is often said that one should prefer lapply over for loops.
There are some exception as for example Hadley Wickham points out in his Advance R book.
(http://adv-r.had.co.nz/Functionals.html) (M...
Trachoma asked 22/2, 2017 at 14:2
7
I am working with a large dataset where much of the data was entered twice. This means that many of the variables are represented by pairs of columns: column.1 with the data entered by one person, ...
1
Solved
I have an S3 generic function that I would like to be an internal part of a package. I would prefer not to export it if possible. An interesting downside of this is that it seems that lapply is una...
3
Solved
I would like to iterate over columns in a dataframe and split them into the based on a separator. I am using tidyr::separate, which works when I do one column at a time.
For example:
df<- dat...
2
Solved
I am trying to merge various .csv files into one dataframe using the following:
df<- list.files(path = "C:/Users...", pattern = "*.csv", full.names = TRUE) %>% lapply(read...
6
Solved
I have a list of vectors as follows.
data <- list(v1=c("a", "b", "c"), v2=c("g", "h", "k"),
v3=c("c", "d"), v4=c...
Besprinkle asked 17/12, 2014 at 7:29
4
Solved
I'm working through an R tutorial and suspect that I have to use one of these functions but I'm not sure which (Yes I researched them but until I become more fluent in R terminology they are quite ...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.