Hi all

I have multiple csv files stored in a list (list.data) having same column names but different data frame names.
I would like to subset a column (CHR) by a specific value (1) and apply it to all the data frames in the list and to all the columns.

I wrote this code :

    CHR1<-lapply(list.data, function(x) { x["CHR"] = 1; x }

However this seem to subset correctly that specific column (CHR) but the other columns did not change, subset was not applied to the rest of the columns.

I wrote also this code but it returns an empty list

    CHR1<-lapply(list.data, subset, "CHR"=1)

Any help highly appreciated.
Thanks
Try:

    CHR1 <- lapply(list.data, function(x) { x[ x$CHR == 1, ] })

- `=` is an assignment operator, e.g.: `myVar = 1; print(myVar)` same as `<-`.

- `==` is a logical operator, used for comparing, e.g.: `1 == 2` this will give us `FALSE`.
