st4co4
st4co4

Reputation: 477

How to mutate the values in a R list object?

I have a list named "binom" that looks as follows:

binom

"estimate_" values are probabilities that I want to reverse (to do a calculation "1-value"). How to mutate these values in this list?

I googled but did not find a code for doing this. I need the list afterwards as a list for plotting.

Upvotes: 0

Views: 56

Answers (1)

Peter D
Peter D

Reputation: 181

Try looking at ?base::transform or ?dplyr::mutate

You will first need to subset your list to the element you want to manipulate:

library(dplyr)

binom[[1]] %>% 
  mutate(newcol = 1 - estimate_)

You can learn more about data transformation here

In the future, it's helpful to provide a mock dataset with your question instead of a screenshot, so that people have something to work with when attempting to answer your questions.

Upvotes: 2

Related Questions