Re: [R] Using ddply within a function by argument transfer

2012-03-06 Thread Fredrik Karlsson
Dear list, A follow up on this thread - the solution I ended up with does indeed involve parse(). However, it does the job, and it is more efficient than what I came up with in my other attempts. suspicious.vowels - function(data,factors,vowelcolumn,f1,f2) { for(currfac in

Re: [R] Using ddply within a function by argument transfer

2012-03-04 Thread David Winsemius
On Mar 4, 2012, at 12:20 AM, Fredrik Karlsson wrote: Hi Michael, No, sorry - that is neither the problem or the solution. suspicious.vowels(pb,c(Type,Sex,Vowel),F1,F2) Error in mean(y, na.rm = na.rm) : object 'f1' not found Obviously you have still failed to offer reproducible code to

Re: [R] Using ddply within a function by argument transfer

2012-03-04 Thread Fredrik Karlsson
Hi, Sorry all - I will provide a reproducable version of this. I am still seeing the same problem - maybe it is due to me having to use summarize? Anyway, here is an example (using the data set attached): Two test functions: insidefun - function(x){ return(x+1) } testfun -

Re: [R] Using ddply within a function by argument transfer

2012-03-04 Thread Joshua Wiley
Hi, Still no data (either not attached or a format the mail server scrubs), but I made some up. ddply seems to be a bit tricky in that it holds off evaluating its arguments. I honestly am not sure how to get around that---no amount of fancy footwork with eval() or quote() is going to change the

Re: [R] Using ddply within a function by argument transfer

2012-03-04 Thread Fredrik Karlsson
Hi Joshua, Yes, sorry - I attached an .rda file - maybe it was squashed. Anyway, yes, I agree with you that the function in the present state would not be of very much help to an end user (and your right in thinking that this is not the end implementation of the function, just an example). I too

Re: [R] Using ddply within a function by argument transfer

2012-03-04 Thread Joshua Wiley
Well, the only part that did not work nicely was the inside function. So you could still probably lean on ddply() for much of the work and just append the output of your function to the ddply results or something like that. You might also try to think about your problem in a different way.

Re: [R] Using ddply within a function by argument transfer

2012-03-04 Thread Ista Zahn
Hi, On Sunday, March 04, 2012 03:28:44 PM Fredrik Karlsson wrote: Hi Joshua, Yes, sorry - I attached an .rda file - maybe it was squashed. Anyway, yes, I agree with you that the function in the present state would not be of very much help to an end user (and your right in thinking that this

[R] Using ddply within a function by argument transfer

2012-03-03 Thread Fredrik Karlsson
Dear list, Sorry, but I cannot get my head around how and I could pass arguments along to high-level functions. What I have is a function that would benefit from me using ddply from the plyr package. However, I cannot get the arguments passing part right. So, this is my function:

Re: [R] Using ddply within a function by argument transfer

2012-03-03 Thread R. Michael Weylandt
Untested, but it might be simpler than that: suspicious.vowels(pb,c(Type,Sex,Vowel),F1,F2) Note that F1 is in quotes but F2 isn't. Michael On Sat, Mar 3, 2012 at 5:46 PM, Fredrik Karlsson dargo...@gmail.com wrote: Dear list, Sorry, but I cannot get my head around how and I could pass

Re: [R] Using ddply within a function by argument transfer

2012-03-03 Thread Fredrik Karlsson
Hi Michael, No, sorry - that is neither the problem or the solution. suspicious.vowels(pb,c(Type,Sex,Vowel),F1,F2) Error in mean(y, na.rm = na.rm) : object 'f1' not found /Fredrik On Sat, Mar 3, 2012 at 7:04 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: Untested, but it might

Re: [R] Using ddply within a function by argument transfer

2012-03-03 Thread Joshua Wiley
Hi Fredrik, A reproducible example would help. We have neither your data nor your functions. It is not clear to me what your problem is; I have no difficulty passing arguments from a higher function to ddply(). mtcars[1,1] - NA f - function(data, factors, f1) { ddply(.data = data,