[R] Problem with a if statement inside a function
Sarah Goslee
sarah.goslee at gmail.com
Thu Jun 9 18:21:24 CEST 2011
On Thu, Jun 9, 2011 at 11:53 AM, Abraham Mathew <abraham at thisorthat.com> 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 information to a function that varies each
time the function is run.
Sarah
> Good point about the working directory.
>
> Thanks
> Abraham
>
>
>
> On Thu, Jun 9, 2011 at 9:35 AM, Sarah Goslee <sarah.goslee at gmail.com> 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'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 completely overwritten.
>>
>> Also, calling setwd() within a function seems like a bad idea, because
>> it guarantees that nobody but you can ever use it. And why would you,
>> rather than passing the working directory as an argument if it's
>> crucial?
>>
>> Sarah
>>
>>
More information about the R-help
mailing list