Re: [R] save objects of own function to workspace

2012-02-16 Thread Marion Wenty
Hello Rolf, thank you for your advice! Though, I find there is no need to get personal about my stage of devolopment in R. Cheers, Marion 2012/2/15 Rolf Turner > On 16/02/12 03:59, Marion Wenty wrote: > > > > Thank you for your answers! >> >> Jeff, thanks very much for the tip with the<<-

Re: [R] save objects of own function to workspace

2012-02-15 Thread Rolf Turner
On 16/02/12 03:59, Marion Wenty wrote: Thank you for your answers! Jeff, thanks very much for the tip with the<<- instead of using<- to save the objects outside of the function, as well! I find this very usefull and convenient, also if I decide to choose more objects. This practice is to be

Re: [R] save objects of own function to workspace

2012-02-15 Thread Marion Wenty
s_elternmz <- function(Var="balt") { Dg_a<-mz[,c("asbhh","apkz",Var)] colnames(Dg_a)[colnames(Dg_a)=="apkz"]<-"bpkzm" colnames(Dg_a)[colnames(Dg_a)==Var]<-paste(Var,"_m",sep="") mz_int<-merge(mz,Dg_a,by=c("asbhh","bpkzm"),all.x=T) colnames(Dg_a)[colnames(Dg_a)=="bpkzm"]<-"bpkzv" colnames

Re: [R] save objects of own function to workspace

2012-02-14 Thread David Winsemius
On Feb 14, 2012, at 10:59 AM, Marion Wenty wrote: Thank you very much for your help, David! Now I have got an object which I can work with. You mentioned that I took two steps to create the new column names. I had tried doing it in one step but couldn't find out how. Could you help me with

Re: [R] save objects of own function to workspace

2012-02-14 Thread Jeff Newmiller
It is possible to do what you ask using <<- instead of <-, but from the perspective of using the function it will be much clearer if you add mz as an argument to the function along with Var, and return mz_int at the end. (The easiest way to return a variable is to type it alone on the last line

Re: [R] save objects of own function to workspace

2012-02-14 Thread Marion Wenty
Thank you very much for your help, David! Now I have got an object which I can work with. You mentioned that I took two steps to create the new column names. I had tried doing it in one step but couldn't find out how. Could you help me with that, as well? Thank you very much! Marion 2012/2/14

Re: [R] save objects of own function to workspace

2012-02-14 Thread David Winsemius
On Feb 14, 2012, at 9:20 AM, Marion Wenty wrote: Dear R-helpers, I created an own function which looks like this s_elternmz <- function(Var="balt") { Dg_a<-mz[,c("asbhh","apkz",Var)] colnames(Dg_a)[colnames(Dg_a)=="apkz"]<-"bpkzm" colnames(Dg_a)[colnames(Dg_a)==Var]<-paste(Var,"_m",