Re: [R] vectorized sub, gsub, grep, etc.

2015-08-02 Thread John Thaden
Adam,
The original posting gave a function sub2 whose aim differs both from your 
functions' aim and from the intent of mgsub() in the qdap package:
> Here is code to apply a different 
> pattern and replacement for every target.#Example
X <- c("ab", "cd", "ef")
patt <- c("b", "cd", "a")
repl <- c("B", "CD", "A")
The first pattern ('b') and the first replacement ('B') therefore apply only to 
the first target ('ab'), the second to the second, etc. The function achieves 
its aim, giving the correct answer 'aB', 'CD', 'ef'.

mgsub() satisfies a different need, testing all targets for matches with any 
pattern in the vector of patterns and, if a match is found, replacing the 
matched target with the replacement value corresponding to the matched pattern. 
It, too, achieves its aim, giving a different (but also correct) answer 'AB', 
'CD', 'ef'.
Regards,-John
#Example
X <- c("ab", "cd", "ef")
patt <- c("b", "cd", "a")
repl <- c("B", "CD", "A")

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Splitting lines in R script

2015-08-02 Thread Peter Langfelder
R does not need a semicolon or other character to terminate a command;
if a line can be interpreted as a complete command, it will (first
line in your second example).

Also note that the first example may not produce what you want (if
your second example is any indication) - the result of
pbivnorm(aa,dd,tau) is added to the sum of the first two terms,
because the two minuses give a plus:

> 1- -1
[1] 2

Peter

On Sun, Aug 2, 2015 at 9:05 PM, Steven Yen  wrote:
> I have a line containing summation of four components.
>
> # This works OK:
>   p<-pbivnorm(bb,dd,tau)+pbivnorm(aa,cc,tau)-
> -pbivnorm(aa,dd,tau)-pbivnorm(bb,cc,tau)
>
> # This produces unpredicted results without warning:
>   p<-pbivnorm(bb,dd,tau)+pbivnorm(aa,cc,tau)
> -pbivnorm(aa,dd,tau)-pbivnorm(bb,cc,tau)
>
> Is there a general rule of thumb for line breaks? Thanks you.
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] Splitting lines in R script

2015-08-02 Thread Steven Yen
I have a line containing summation of four components.

# This works OK:
  p<-pbivnorm(bb,dd,tau)+pbivnorm(aa,cc,tau)-
-pbivnorm(aa,dd,tau)-pbivnorm(bb,cc,tau)

# This produces unpredicted results without warning:
  p<-pbivnorm(bb,dd,tau)+pbivnorm(aa,cc,tau)
-pbivnorm(aa,dd,tau)-pbivnorm(bb,cc,tau)

Is there a general rule of thumb for line breaks? Thanks you.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] NATURAL Smoothing B-splines

2015-08-02 Thread Spencer Graves

> library(sos)
> ns. <- findFn('natural spline')
found 191 matches;  retrieving 10 pages
2 3 4 5 6 7 8 9 10
Downloaded 113 links in 70 packages.
> ns2 <- findFn('natural splines')
found 145 matches;  retrieving 8 pages
2 3 4 5 6 7 8
Downloaded 70 links in 42 packages.
> ns2. <- ns.|ns2
> ns2.

# This displayed a table of 137 different help pages sorted to place the 
package with the most matches first.


> findFn2xls(ns2.) # writes a file with a name like "nls2..xls" to the 
working directory [getwd()]

# with a sheet giving a summary by package.


  Hope this helps.
  Spencer


On 8/2/2015 10:10 AM, Marc Lamblin wrote:

Hi all,

I'm an engineering student from Politecnico di Milano.
I want to perform Smoothing using Smoothing B-splines on syntethic
data. The splines must be NATURAL (at the edges the second and third
order derivates are zero).
How can I impose this constraint?
I have searched in R documentation. For Smoothing I use the fda
package. From the description of the function smooth.basis() it seems
that it is not possible to use natural B-splines. I have found only
the function ns() from splines package but in this way you can obtain
only the basis and I have seen that this function is used in models
expressed in symbolic notation.

Thanks in advance!!

mggl

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] PythonInR. Python script in R with parameters required. Download satellite images from NASA

2015-08-02 Thread Florian Schwendinger

I believe the Problem is that you trying to give command line arguments
pyExecfile("myPythonScript.py") and pyExecfile only expects to get a 
filename.



In Pyhton27 pyExecfile only runs the Python command execfile on the 
given filename. So the Problem is that in


pyExecfile("C:/Landsat/download_espa_order.py" -e "magifranqu...@gmail.com"
-o "magifranqu...@gmail.com-07222015-120911" -d "C:/Landsat/ESPA")

your not only providing a file name but also command line arguments.


It is maybe easier for you to use the command line. Something like the 
following should work


python <- "C:/Python27/python.exe"
pyScript <- "C:/Landsat/download_espa_order.py"
email <- "yourem...@gmail.com"
order <- "yourem...@gmail.com-order-number"
targetDirectory <- "C:/Landsat/ESPA"
pyArgs <- sprintf("--email %s --order %s --target_directory %s",
  email, order, targetDirectory)
pyArgs
cmd <- sprintf("%s %s %s", python, pyScript, pyArgs)
cmd
system(cmd ,wait=FALSE)

or

system("C:/Python27/python.exe C:/Landsat/download_espa_order.py --email 
magifranqu...@gmail.com --order magifranqu...@gmail.com-07222015-120911 
--target_directory C:/Landsat/ESPA", wait=FALSE)



If you want to use PythonInR you could something like the following.
pyConnect(pythonExePath=python)
setwd("C:/Landsat/")
pyExec("import download_espa_order")
pySet("email", email)
pySet("order", order)
pyGet("[scene for scene in SceneFeed(email).get_items(order)]")


Florian


On 07/29/2015 06:29 PM, Magi Franquesa wrote:

Hello,

I'm trying to execute a python script within R (3.2.1 x 64) with the
PythonInR package. I would like to download an order of satellite images
from Nasa using a python script (
http://landsat.usgs.gov/documents/espa_bulk_downloader_v1.0.0.zip) but I
have no success. I first run the pyExecfile command with the *feedparser.py*
script and then the *download_espa_order.py* giving the required parameters
(my mail acount and the order number), here is the code:

setwd("C:/Python27")
install.packages("PythonInR")
library(PythonInR)
pyConnect(pythonExePath="C:/Python27/python.exe")
pyIsConnected()
# autodetectPython("C:/Python27/python.exe")

pyExecfile("C:/Landsat/feedparser.py")
pyExecfile("C:/Landsat/download_espa_order.py" -e "magifranqu...@gmail.com"
-o "magifranqu...@gmail.com-07222015-120911" -d "C:/Landsat/ESPA")

and I get this error:

Error: unexpected string constant in
"pyExecfile("C:/Landsat/download_espa_order.py" -e
"magifranqu...@gmail.com""

The code "C:/Landsat/download_espa_order.py" -e
"magifranqu...@gmail.com" -o "magifranqu...@gmail.com-07222015-120911"
-d "C:/Landsat/ESPA" runs ok when I use it within
system console.

I appreciate if someone could help me to solve this problem.

Thank you

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


[R] NATURAL Smoothing B-splines

2015-08-02 Thread Marc Lamblin
Hi all,

I'm an engineering student from Politecnico di Milano.
I want to perform Smoothing using Smoothing B-splines on syntethic
data. The splines must be NATURAL (at the edges the second and third
order derivates are zero).
How can I impose this constraint?
I have searched in R documentation. For Smoothing I use the fda
package. From the description of the function smooth.basis() it seems
that it is not possible to use natural B-splines. I have found only
the function ns() from splines package but in this way you can obtain
only the basis and I have seen that this function is used in models
expressed in symbolic notation.

Thanks in advance!!

mggl

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] Error when compiling R-2.5.1 / *** [d-p-q-r-tests.Rout] Fehler 1

2015-08-02 Thread Joerg Kirschner
Dear Martin,
thanks for the advice, I'll check out Bioconductor.

Meanwhile I reinstalled Ubuntu, this time as 64-bit and the error is gone :
)

Rgds, Joerg

On Sat, Aug 1, 2015 at 8:16 PM, Martin Morgan 
wrote:

> On 07/31/2015 10:48 PM, Joerg Kirschner wrote:
>
>> Hi everyone,
>> I am new to Linux and R - but I managed to build R-2.5.1 from source to
>> use
>> it in Genepattern. Genepattern does only support R-2.5.1 which I could not
>> find anywhere for installation via apt-get or in the Ubuntu
>> Software-Centre
>> (I am using Ubuntu 14.04 (Trusty Tahr) 32-bit)
>>
>
> Are you sure you want to do this? R 2.5.1 is from 2007, which is a very
> long time ago. It seems like GenePattern is not restricted to R-2.5.1,
>
>
>
> http://www.broadinstitute.org/cancer/software/genepattern/administrators-guide#using-different-versions-of-r
>
> and if their default distribution uses it, then I'm not sure I'd recommend
> using GenePattern for new analysis! (Maybe you're trying to re-do a
> previous analysis?)
>
> Since GenePattern modules that use R typically wrap individual CRAN or
> Bioconductor (http://bioconductor.org) packages, maybe you can take out
> the middleman ?
>
> Martin Morgan
>
>
>> But after doing
>>
>> make check
>>
>>
>> I get
>>
>> comparing 'method-dispatch.Rout' to './method-dispatch.Rout.save' ... OK
>> running code in 'd-p-q-r-tests.R' ...make[3]: *** [d-p-q-r-tests.Rout]
>> Fehler 1
>> make[3]: Verzeichnis »/home/karin/Downloads/R-2.5.1/tests« wird verlassen
>> make[2]: *** [test-Specific] Fehler 2
>> make[2]: Verzeichnis »/home/karin/Downloads/R-2.5.1/tests« wird verlassen
>> make[1]: *** [test-all-basics] Fehler 1
>> make[1]: Verzeichnis »/home/karin/Downloads/R-2.5.1/tests« wird verlassen
>> make: *** [check] Fehler 2
>>
>>
>> but I can make install and use R for simple plots etc. afterwards - still
>> I
>> am worried something is wrong, can you give some advice.
>>
>> A closer look at the error gives
>>
>> ## PR#7099 : pf() with large df1 or df2:
>>> nu <- 2^seq(25,34, 0.5)
>>> y <- 1e9*(pf(1,1,nu) - 0.68268949)
>>> stopifnot(All.eq(pf(1,1,Inf), 0.68268949213708596),
>>>
>> +   diff(y) > 0, # i.e. pf(1,1, *) is monotone increasing
>> +   All.eq(y [1], -5.07420372386491),
>> +   All.eq(y[19],  2.12300110824515))
>> Error: All.eq(y[1], -5.07420372386491) is not TRUE
>> Execution halted
>>
>>
>> As I understand so far some errors are critical some are not - can you
>> please give some advice on the error above? Can I still use R installed
>> with that error? What do I need to solve the error?
>>
>> Thanks, Joerg
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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.
>>
>>
>
> --
> Computational Biology / Fred Hutchinson Cancer Research Center
> 1100 Fairview Ave. N.
> PO Box 19024 Seattle, WA 98109
>
> Location: Arnold Building M1 B861
> Phone: (206) 667-2793
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.