[R] RSiteSearch for words ``as one entity''.

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Sep 11 08:33:20 CEST 2008


If firefox is involved on a Mac, that is one difference.  My Mac is using 
'open' (the default, I believe) and that is calling Safari (the default, I 
believe).

Yes, it would be the job of browseURL to encode URLs where required.  But 
at least on Windows and using the -remoteURL mechanism (as on Linux) it is 
not.  R itself does have URLencode.

On Thu, 11 Sep 2008, Rolf Turner wrote:

>
> On 11/09/2008, at 10:09 AM, Marc Schwartz wrote:
>
> 	<snip>
>
>> As Prof. Ripley noted, try using debug(RSiteSearch) and then step
>> through the code to see where $HOME is being added to the URL variable.
>> That can help pin it down further. If the URL is not corrupted by the
>> time browseURL() is called, then use debug(browseURL) to trace within
>> that function to see if something is happening there.
>
> 	I have done some digging.  When I do:
>
> 	RSiteSearch("logistic regression")
>
> 	the RSiteSearch() function calls browseURL(qstring) where qstring is 
> qs1 equal to
>
> 	"http://search.r-project.org/cgi-bin/namazu.cgi?query=logistic+regression&max=20&result=normal&sort=score&idxname=Rhelp02a&idxname=functions&idxname=docs"
>
>
> 	Similarly when I do RSiteSearch("{logistic regression}") qstring is 
> qs2 equal to
>
> 	"http://search.r-project.org/cgi-bin/namazu.cgi?query={logistic+regression}&max=20&result=normal&sort=score&idxname=Rhelp02a&idxname=functions&idxname=docs"
>
> 	i.e. the same except for the braces.
>
> 	If I do browseURL(qs1) outside of RSiteSearch() it works as expected.
> 	If I do browseURL(qs2) I get the error.
>
> 	Inside browseURL I find that it calls
>
> 	system(paste(browser, remoteCmd, "> /dev/null 2>&1 ||", browser, 
> quotedUrl, "&"))
>
> 	and browser is "/usr/bin/open", remoteCmd is the qstring with the 
> opening and closing
> 	quote marks attached (escaped with a ``\'') amd quotedUrl is the 
> same.  This is true
> 	irrespective of which qstring (qs1 or qs2 is used).
>
> 	Note that the double backslash shows up in remoteCmd == quotedUrl at 
> this stage.
>
> 	Finally I put the system command into a file ``junk'' and from the 
> command window
> 	(outside R) executed ``sh junk''.
>
> 	With the braces around ``logistic regression'' I can the same error 
> message that
> 	I got in R.  When I simply edited out the braces, the Firefox window 
> opened at
> 	the appropriate URL.  So the problem is in those braces and the 
> single/double
> 	backslash at the start was a red herring.
>
> 	Finally, while I was doing all this I got Henrik Bengtsson's message, 
> and tried
> 	his suggestion:
>
> 	library(R.utils)
> 	browseURL(toUrl(qs2))
>
> 	and BINGO!!! that worked.  (Thanks very much, Henrik.)
>
> 	It's still mysterious why the braces have their deleterious impact on 
> my Mac
> 	but do not have that impact on Professor Ripley's machine.  (But 
> that's the
> 	story of my life:  THEY always pick on ***me***! :-) )
>
> 	So my problem is solved --- via a workaround --- but there's still 
> some vestigial
> 	strangeness.
>
> 	Thanks to all who helped me, especially (again) to Henrik Bengtsson
>
> 		cheers,
>
> 			Rolf
>
> ######################################################################
> Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
>
> ______________________________________________
> 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.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list