[R] save objects of own function to workspace

David Winsemius dwinsemius at comcast.net
Tue Feb 14 18:18:55 CET 2012


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 that, as well?
>
> Thank you very much!
>
> Marion
>
>
> 2012/2/14 David Winsemius <dwinsemius at comcast.net>
>
> 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",sep="")

The above line seemed to be the first change to make <Var>_m

>  mz_int<-merge(mz,Dg_a,by=c("asbhh","bpkzm"),all.x=T)
>  colnames(Dg_a)[colnames(Dg_a)=="bpkzm"]<-"bpkzv"
>
> colnames(Dg_a)[colnames(Dg_a)==paste(Var,"_m",sep="")]<- 
> paste(Var,"_v",sep="")

Then this line changed <Var>_m to become <Var>_v. Why not change it to  
<Var>_v in the first place?

>
> Why take two steps to change that column name?
>

>
>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list