I see how merge works now, and to answer my own question, I can have any
number of columns of miscellaneous information I want.
--
View this message in context:
http://r.789695.n4.nabble.com/Intersect-2-lists-bring-extra-columns-tp4675136p4675146.html
Sent from the R help mailing list archive
Hi A.K.
That is exactly what I was hoping to do. If you have the time, can you
explain what the fruit[,-1] term means in the merge?
Also, if I wanted to expand the number of columns to report to include a 4th
column, let's call it flavor, how would I go about doing that?
J.S.
--
View this me
HI,
If I understand it correctly:
fruit<- read.csv("example.csv",header=TRUE,stringsAsFactors=FALSE,sep="\t")
res<-merge(fruit["reference"],fruit[,-1],by.x="reference",by.y="list")
res
# reference information
#1 grapefruit pink
#2 lemon yellow
#3 pear green
If th
Thank you, David and Gabor, for the creative solutions, and for introducing
me to pmin()
Jonathan
On Thu, May 20, 2010 at 9:55 PM, Gabor Grothendieck wrote:
> Try this one liner. The first argument of rep is the sorted
> intersection and the second argument is the calculated from the
> paral
Try this one liner. The first argument of rep is the sorted
intersection and the second argument is the calculated from the
parallel minimum of the counts of elements in a that are also in b and
the counts of elements in b that are also in a.
rep(sort(intersect(a, b)), pmin(table(a[a %in% b]), ta
On May 20, 2010, at 7:10 PM, David Winsemius wrote:
On May 20, 2010, at 6:24 PM, Jonathan wrote:
Thanks, but that doesn't quite work, since I'd want the result of
b[b %in% a] to be symmetric with a[a%in%b] (so if there are two 2's
in EACH vector, I'll get two 2's in the result, but if there
On May 20, 2010, at 7:30 PM, Nordlund, Dan (DSHS/RDA) wrote:
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
project.org] On Behalf Of Jonathan
Sent: Thursday, May 20, 2010 3:25 PM
To: David Winsemius
Cc: r-help
Subject: Re: [R] intersect() without
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Jonathan
> Sent: Thursday, May 20, 2010 3:25 PM
> To: David Winsemius
> Cc: r-help
> Subject: Re: [R] intersect() without discarding duplicates?
>
&g
On May 20, 2010, at 6:24 PM, Jonathan wrote:
> Thanks, but that doesn't quite work, since I'd want the result of
> b[b %in% a] to be symmetric with a[a%in%b] (so if there are two 2's
> in EACH vector, I'll get two 2's in the result, but if there are two
> 2's in only one vector, but one two
Thanks, but that doesn't quite work, since I'd want the result of b[b %in%
a] to be symmetric with a[a%in%b] (so if there are two 2's in EACH vector,
I'll get two 2's in the result, but if there are two 2's in only one vector,
but one two in the other, the result will show only one 2.
Consider:
>
On May 20, 2010, at 5:58 PM, Jonathan wrote:
Hi all,
The ?intersect entry kindly points out that it discards duplicate
entries. I'm looking, however, to get the intersection while KEEPING
duplicate entries, and there are no instructions on how to
accomplish this
using intersect().
Does a
On May 11, 2010, at 10:31 PM, Yuan Jian wrote:
Hi there,
how can I test every element in a vector whether appears in another
vector?
such as
a<-c("aa", "bb", "ff", "cc")
b <-c("oo","jj","bb","cc")
somefunction(a,b) gives [False, True, False, True]
The other answers probably gave you what
wrote:
> how can I test every element in a vector whether appears in another vector?
> such as
> a<-c("aa", "bb", "ff", "cc")
> b <-c("oo","jj","bb","cc")
a %in% b
[1] FALSE TRUE FALSE TRUE
__
R-help@r-project.org mailing list
https://stat.ethz.ch/ma
Hi Yuan,
Try
> a<-c("aa", "bb", "ff", "cc")
> b <-c("oo","jj","bb","cc")
> a %in% b
[1] FALSE TRUE FALSE TRUE
HTH,
Jorge
On Tue, May 11, 2010 at 10:31 PM, Yuan Jian <> wrote:
> Hi there,
>
> how can I test every element in a vector whether appears in another vector?
> such as
> a<-c("aa", "
On Mar 17, 2010, at 10:52 PM, Nathan S. Watson-Haigh wrote:
I have 2 sets of data which defines the start and end of date/time
periods. I want to be able to obtain the following:
1) The intersect of those 2 sets of date/time ranges i.e. return
start/end date/time ranges where both sets ove
Kevin
How about, for example,
plot(1, xlab=quote(B~intersect(A)))
Peter Alspach
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Kevin J. Thompson
> Sent: Thursday, 15 November 2007 5:51 a.m.
> To: R-help
> Subject: [R] intersect character
>
>
16 matches
Mail list logo