1

I want to exclude/copy rows/columns of multiple dataframes within a list in a list. The code doesn't work yet. Maybe somebody here knows what to do.

Zelllysate_extr <- list()

#defining the list

Zelllysate_extr$X0809P3_extr <- X0809P3_extr

#defining the list within the list

X0809P3_extr = lapply(Zelllysate_colr[["X0809P3"]], function(x) {
  as.data.frame(x) <- Zelllysate_colr[["X0809P3_colr"]][2:1500, 1 & 3:4]
  return(x)
}) 

#defining the list for the dataframes to place in; 2:1500, 1 & 3:4 are the rows and columns to copy

thanks

Phil
  • 7,287
  • 3
  • 36
  • 66

1 Answers1

0

Instead of trying to iterate over the list, iterate over the length of the list.

X0809P3_extr = lapply(1: length(Zelllysate_colr[["X0809P3"]]), function(x) {
  Zelllysate_colr[["X0809P3_colr"]][[x]][2:1500, c(1, 3:4)]
}) 

You don't need a return or to set the value equal to something in lapply.

I'm assuming that Zelllysate_colr[["X0809P3"]] is a list within the list Zelllysate_colr.

If this doesn't work, you'll have to share some of your data. Most of the time the output from dput(head(dataObject)) is enough, but I think you're working with lists of lists, so that might not be enough to see the structure. You can read about how to ask great questions to get great answers quickly.

Kat
  • 15,669
  • 3
  • 18
  • 51