Re: [R] Function argument and scope

2016-11-14 Thread Bernardo Doré
Thank you all for replying so quickly. @Jim You are right, I ran into that. You can see as.character() being called to remedy the situation you described. I dropped the factors from the data frame in a line outside the function. Creating the dataframe with stringsAsFactors = F is the easiest way

Re: [R] Function argument and scope

2016-11-14 Thread jeremiah rounds
Hi, Didn't bother to run the code because someone else said it might do what you intended, and also your problem description was complete unto itself. The issue is that R copies on change. You are thinking like you have a reference, which you do not. That is not very R like in style, but it

Re: [R] Function argument and scope

2016-11-13 Thread Jim Lemon
Hi Bernardo, I don't think that your function is doing anything like you expect it to do: test <- data.frame(var1=c("a","b","c"),var2=c("d","e","f")) test var1 var2 1ad 2be 3cf You have a data frame with two columns, the first thing you do is extract the first value in

[R] Function argument and scope

2016-11-13 Thread Bernardo Doré
Hello list, my first post but I've been using this list as a help source for a while. Couldn't live without it. I am writing a function that takes a dataframe as an argument and in the end I intend to assign the result of some computation back to the dataframe. This is what I have so far: