John Huang
John Huang

Reputation: 845

Using lapply with other values

I have a list of data frames named x, and I would like to subtract each data frame in the list by 1. If

values(x) <- 1 - values(x)

If I wanted to use the function lapply for this would it look like this?

values(x) <- 1 - lapply(x, function(l) values(x))

Thank you

Upvotes: 0

Views: 31

Answers (1)

ThomasIsCoding
ThomasIsCoding

Reputation: 101663

I guess what you need might be

1-sapply(x,value)

or

sapply(x,function(v) 1-value(v))

Upvotes: 2

Related Questions