Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metab() can't be called by ddply()? confused #70

Open
rBatt opened this issue Nov 15, 2014 · 6 comments
Open

metab() can't be called by ddply()? confused #70

rBatt opened this issue Nov 15, 2014 · 6 comments

Comments

@rBatt
Copy link
Contributor

rBatt commented Nov 15, 2014

I can run the following code fine when I pass each year-lake combo to metab() individually, but not when I try to do it all through ddply(). I think the error might be in conquerList:

metabBK <- ddply(hfData, c("lake"), metab, method="bookkeep", irr.name="irr2")

Output:

[1] "Points removed due to incomplete day or duplicated time step: 7933"
[1] "NA's added to fill in time series: 228960"
Error: length(u1) == s1 * s2 is not TRUE
traceback()
6: stop(list(message = "length(u1) == s1 * s2 is not TRUE", call = NULL, 
       cppstack = NULL))
5: .Call("plyr_loop_apply", PACKAGE = "plyr", n, f)
4: loop_apply(n, do.ply)
3: llply(.data = .data, .fun = .fun, ..., .progress = .progress, 
       .inform = .inform, .parallel = .parallel, .paropts = .paropts)
2: ldply(.data = pieces, .fun = .fun, ..., .progress = .progress, 
       .inform = .inform, .parallel = .parallel, .paropts = .paropts)
1: ddply(hfData, c("lake"), metab, method = "bookkeep", irr.name = "irr2")
@lawinslow
Copy link
Member

What does hfData look like?

@rBatt
Copy link
Contributor Author

rBatt commented Nov 16, 2014

@lawinslow

dput(head(hfData))

structure(list(lake = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("paul", 
"peter"), class = "factor"), datetime = structure(c(1210694400, 
1210694700, 1210695000, 1210695300, 1210695600, 1210695900), class = c("POSIXct", 
"POSIXt"), tzone = "GMT"), year = c(2008, 2008, 2008, 2008, 2008, 
2008), doy = c(134.666666666667, 134.670138888889, 134.673611111111, 
134.677083333333, 134.680555555556, 134.684027777778), do.obs = c(10.4347483191214, 
10.4528878395361, 10.4500595198614, 10.4380570411655, 10.4087379516118, 
10.4055922795976), do.sat = c(10.0747468313655, 10.0999625107891, 
10.0999846075527, 10.0807120402841, 10.0495479240296, 10.0239167387756
), wtr = c(12.379333051731, 12.2693323477265, 12.2692362745664, 
12.3532440129325, 12.4899999039994, 12.6033339093371), doSat = c(97.6598307734584, 
97.5865454017649, 97.5599284817454, 97.6332213454424, 97.6600261833021, 
97.880076761626), z.mix = c(1.5, 1.5, 1.5, 1.5, 1.5, 1.5), k.gas = c(0.492825255571682, 
0.511874243056661, 0.491352605979017, 0.492338819545, 0.475021164297611, 
0.495831029616867), irr = c(147.5, 124.701986754946, 109.867549668811, 
100.016501650173, 102.491749174914, 142.665562913905), wnd = c(1.18393660745817, 
1.40853299870392, 1.18393660745817, 1.18234004295608, 0.942855367755401, 
1.18393660745817), chl = c(2.30265083940554, 1.72931341004522, 
1.56931878608269, 2.00878286367763, 2.53598513274742, 2.22931533006012
), pH = c(6.601958991, 6.621968761, 6.621978531, 6.631988334, 
6.631998072, 6.632007842)), .Names = c("lake", "datetime", "year", 
"doy", "do.obs", "do.sat", "wtr", "doSat", "z.mix", "k.gas", 
"irr", "wnd", "chl", "pH"), row.names = c(NA, 6L), class = "data.frame")

@rBatt
Copy link
Contributor Author

rBatt commented Nov 16, 2014

Except I think I added a column "irr2" which was just the 0L 1L integer form of irr

@lawinslow
Copy link
Member

Can you filter the data.frame yourself and just supply it to metab? I doubt that ddply has anything to do with it.

@rBatt
Copy link
Contributor Author

rBatt commented Nov 16, 2014

Yeah, if I subset it on my own (i.e., supply 1 lake-year) and supply it to
metab, it works fine.

I think it's crashing at the conquer list step in metab.

Might have something to do with how ddply() stores the intermediates. Not
sure.

On Sun, Nov 16, 2014 at 3:30 PM, Luke Winslow [email protected]
wrote:

Can you filter the data.frame yourself and just supply it to metab? I
doubt that ddply has anything to do with it.


Reply to this email directly or view it on GitHub
#70 (comment)
.

@lawinslow
Copy link
Member

Wrap the metab function in a function and stick a breakpoint inside of
it. Then you can look at what it is trying to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants