Thank you, Sarah, I modified your suggestion a little and it works.
Ding
-----Original Message-----
From: Sarah Goslee [mailto:sarah.goslee at gmail.com]
Sent: Sunday, June 28, 2020 2:01 PM
To: Yuan Chun Ding
Cc: r-help at r-project.org
Subject: Re: [R] help with sqldf
[Attention: This email came from an external source. Do not open attachments or
click on links from unknown senders or unexpected emails.]
----------------------------------------------------------------------
WIthout knowing anything about your research domain, take a look at what your
sql looks like:
"select * from r where V1 like markerinfo$flank1[1] "
You are asking to match literally "markerinfo$flank1[1]" and not the R
object referred to.
Try something more like,
paste("select * from r where V1 like", markerinfo$flank1[1])
Sarah
On Sun, Jun 28, 2020 at 4:35 PM Yuan Chun Ding <ycding at coh.org>
wrote:>
> Hi R Users,
>
> I tried to use sql in R; test1 works well,
> library(sqldf)
> test1 <- sqldf("select * from r where V1 like
> '%GCCATGTCAGCACACTACC%TGAAACCTTTAACTATTT%'")
> test2 <- sqldf("select * from r where V1 like markerinfo$flank1[1]
")
>
> but I want to store the search content in a markerinfo file as shown
> below
> > markerinfo$flank1[1]
> [1] "%GCCATGTCAGCACACTACC%TGAAACCTTTAACTATTT%"
>
> However, test2 does not work well.
> How to make test2 work?
> Thank you,
>
> Ding
>
>
> ----------------------------------------------------------------------
--
Sarah Goslee (she/her)
https://urldefense.com/v3/__http://www.numberwright.com__;!!Fou38LsQmgU!9SCiZIQ_zHuDAXWGYxM7lRBCYFNjyeIBBixmHgks3DT_1F48jN5kSuPQ5c2T$
----------------------------------------------------------------------
------------------------------------------------------------
-SECURITY/CONFIDENTIALITY WARNING-
This message and any attachments are intended solely for the individual or
entity to which they are addressed. This communication may contain information
that is privileged, confidential, or exempt from disclosure under applicable law
(e.g., personal health information, research data, financial information).
Because this e-mail has been sent without encryption, individuals other than the
intended recipient may be able to view the information, forward it to others or
tamper with the information without the knowledge or consent of the sender. If
you are not the intended recipient, or the employee or person responsible for
delivering the message to the intended recipient, any dissemination,
distribution or copying of the communication is strictly prohibited. If you
received the communication in error, please notify the sender immediately by
replying to this message and deleting the message and any accompanying files
from your system. If, due to the security risks, you do not wish to receive
further communications via e-mail, please reply to this message and inform the
sender that you do not wish to receive further e-mail from the sender. (LCP301)
------------------------------------------------------------