[R] Error - function join()

arun smartpink111 at yahoo.com
Mon Oct 8 13:59:54 CEST 2012


Hi,
join() works for me.

 Please check if the function is masked by loading other packages.
dat1 <- read.table(text="
  PT_ID    IDX_DT  OBS_DATE DAYS_DIFF OBS_VALUE CATEGORY
13  4549 2002-08-21 2002-08-20        -1      183        2
14  4549 2002-08-21 2002-11-14        85        91        1
15  4549 2002-08-21 2003-02-18      181        89        1
16  4549 2002-08-21 2003-05-15      267      109        2
17  4549 2002-08-21 2003-12-16      482        96        1
128  4839 2006-11-28 2006-11-28        0      179        2
", header=TRUE)
dat3<-aggregate(DAYS_DIFF~PT_ID,data=dat1,min)
library(plyr)

join(dat1,dat3,type="inner",by=c("PT_ID","DAYS_DIFF"))
#  PT_ID     IDX_DT   OBS_DATE DAYS_DIFF OBS_VALUE CATEGORY
#1  4549 2002-08-21 2002-08-20        -1       183        2
#2  4839 2006-11-28 2006-11-28         0       179        2
  A.K.  



----- Original Message -----
From: R. Michael Weylandt <michael.weylandt at gmail.com>
To: Jhope <jeanwaijang at gmail.com>
Cc: r-help at r-project.org
Sent: Monday, October 8, 2012 3:13 AM
Subject: Re: [R] Error - function join()

On Mon, Oct 8, 2012 at 12:22 AM, Jhope <jeanwaijang at gmail.com> wrote:
> Hi R-listers,
>
> In plyr I am using coding I have used before but an error seems to be
> apparent. Has the function "join" been replaced by another word? I tried
> this before and it didn't work and then worked for me. But now it is not
> working again.
>
> Please advise, Jean
>
>> data.to.analyze <- join(responses, envir, by="QuadratEvent")
> Error: could not find function "join"
>

I'm not sure there ever was a commonly used "join" function. Perhaps
you are looking for one of

?merge
?rbind
?cbind

In particular, merge(,,by = "") seems right. But this doesn't have
anything to do with plyr so I might be misunderstanding you.

Michael

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.





More information about the R-help mailing list