I have a list of data.frames and would like to construct a new data.frame from the list like so:
u=runif(2, 0, 1)
u.obs=list(data.frame(site='dl',
swe.obs=runif(4, 0, 1),
model.type='r'),
data.frame(site='nt',
swe.obs=runif(5, 0, 1),
model.type='lm'),
data.frame(site='nt',
swe.obs=runif(3,0,1),
model.type='lm'),
data.frame(site='nt',
swe.obs=runif(3,0,1),
model.type='r'))
EDIT: @dickoa gave an answer that worked for my example but not for real so I am adding to u.obs to make it more real.
EDIT2: Just kidding. it looked different, but is the same from what I can tell.
summ.df=data.frame(model=u,
obs.min=laply(u.obs$swe.obs, min),
obs.max=laply(u.obs$swe.obs, max),
obs.mean=laply(u.obs$swe.obs, mean),
site=laply(u.obs$site, '[', 1),
model.type=laply(u.obs$model.type, '[', 1),
date=laply(u.obs$date, '[', 1))
but I can't extrct site
and model.type
even though u.obs[[1]]$site[1]
works fine. Can someone assist me?
Thanks