Re: [R] Problem with a if statement inside a function

2011-06-09 Thread Abraham Mathew
I passed it as an argument to the function because every week I'll need to add keywords to the lst, and that function will make the process more automated. On Thu, Jun 9, 2011 at 10:21 AM, Sarah Goslee wrote: > On Thu, Jun 9, 2011 at 11:53 AM, Abraham Mathew > wrote: > > > > lst is a list wit

Re: [R] Problem with a if statement inside a function

2011-06-09 Thread Sarah Goslee
On Thu, Jun 9, 2011 at 12:27 PM, Abraham Mathew wrote: > > I passed it as an argument to the function because every week I'llĀ  need to > add keywords to the lst, and that function will make the process more > automated. But it doesn't. lst is hard-coded within your function, so passing somethin

Re: [R] Problem with a if statement inside a function

2011-06-09 Thread Sarah Goslee
On Thu, Jun 9, 2011 at 11:53 AM, Abraham Mathew wrote: > > lst is a list within the function. Then why is it passed as an argument to the function? You can have a function with no arguments, but in this case why, since it would do exactly the same thing every time? Arguments are for passing info

Re: [R] Problem with a if statement inside a function

2011-06-09 Thread Carl Witthoft
I would start out by checking out ?switch and getting rid of most of those "if"s . Next: I apologize for the harshness of this, but your code really does qualify for http://thedailywtf.com . Creating a zillion variables dXY, for example, is really poor programming practice. Create a list o

Re: [R] Problem with a if statement inside a function

2011-06-09 Thread Abraham Mathew
lst is a list within the function. Good point about the working directory. Thanks Abraham On Thu, Jun 9, 2011 at 9:35 AM, Sarah Goslee wrote: > Can you boil that down into a short reproducible example? > > For instance, when you run your function at the end > > newdf <- myfunc(lst) > > I can

Re: [R] Problem with a if statement inside a function

2011-06-09 Thread Sarah Goslee
Can you boil that down into a short reproducible example? For instance, when you run your function at the end > newdf <- myfunc(lst) I can't run it myself because I don't know what lst is. Although it seems not to matter - what are you passing as an argument to the function, since it seems to be