MaC-Perez / Hydra-self-testing

0 stars 0 forks source link

Select one variable from all the 100 sims to create plots #4

Open MaC-Perez opened 1 year ago

MaC-Perez commented 1 year ago

Hi @gavinfay, my simulations are contained in a new matrix (data list) called sim_data. I used to call my data using one line of code for each sim (like here https://github.com/MaC-Perez/Hydra-self-testing/blob/948a34c22575c0d115edead11d9e8160b600f777/hydra_sim.R#L215)

but now I have one data list object with 100 data sets inside and X variables inside of each data set. So I dont know how to read the 100 sims and select one variable to make the plots.

gavinfay commented 1 year ago

Can you add the sim_data object to the repo? I don't see it anywhere.

MaC-Perez commented 1 year ago

@gavinfay I already added the sim_data.rds object

gavinfay commented 1 year ago

sim_data is a list of list objects. The map() functions are a good way to access elements (also pluck, etc.) Say you want to get a dataframe of the observedCatch objects.

purrr::map_dfr(sim_data,"observedCatch",.id = "isim")

This pulls the catch tables and puts them in a new data frame, with an additional column isim that is an index for which of the elements of sim_data the rows correspond to.