Re: [Rd] Post CGI forms with built-in R function?

2006-07-20 Thread Duncan Temple Lang
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


There is a hard coded limit of 4096 characters in
RxmlNanoHTTPScanURL and other ScanURL routines in nanohttp.c
and nanoftp.c.   And your URI is 5138 and so walks past the bounds
of the array of length 4096.

I am not yet convinced that it is worthwhile to increase this limit to
a larger number.  Using POST in this context really is a better
solution.  But we do need to add checks to the code to ensure that
the URI string is smaller than 4096.

I'll try to get an opportunity to do that tomorrow before I take off.

  D.

Duncan Temple Lang wrote:
> 
> Hi Mike
> 
>  If you don't want to have to download any packages but stick entirely
> within R, then you can mimic the code in httpRequest. But,
> as far as I know, there is no function in the standard R distribution to
> POST an HTTP request.
> 
>   As for using
>scan("http://";)
> 
>   what is the string you are using? Are you escaping all the characters
> correctly? What's the error message?
> 
>  If what you are doing involves only relatively basic HTTP requests,
> perhaps the simplest thing to do is use the httpRequest package on CRAN.
> It does the basics.  You may have to handle chunked responses yourself
> and escaping certain characters. But that is a pure R solution that can
> be easily installed via install.packages().
> 
> 
> 
> Mike Schaffer wrote:
> 
>>>I wrote a package that requires downloading data from an external  
>>>server based on parameters specified by the user.
>>>
>>>I have used RMySQL or Rcurl to accomplish this, but in the interest  
>>>of simplicity for users of this package, I'd like this communication  
>>>to not require installing other packages and their dependencies (e.g.  
>>>RMySQL, Rcurl, etc.).  These dependencies are sometimes a deterrent  
>>>to using my package.
>>>
>>>I set up a CGI script on the server to handle data requests.  Now, is  
>>>there a *built-in* R function that could be adapted to post forms or  
>>>otherwise allows long URLs to be passed to this script to retrieve  
>>>the data requested.  I tried using just "scan", but it fails with  
>>>long URLs (sometimes a long list of parameters is required).  I think  
>>>my only option is to use POST, but it doesn't appear it is possible  
>>>without Rcurl.
>>>
>>>Can anyone help or suggest a "native" solution to the problem?
>>>
>>>Thanks.
>>>
>>>__
>>>R-devel@r-project.org mailing list
>>>https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 
> --
> Duncan Temple Lang[EMAIL PROTECTED]
> Department of Statistics  work:  (530) 752-4782
> 4210 Mathematical Sciences Building   fax:   (530) 752-7099
> One Shields Ave.
> University of California at Davis
> Davis,
> CA 95616,
> USA

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

- --
Duncan Temple Lang[EMAIL PROTECTED]
Department of Statistics  work:  (530) 752-4782
4210 Mathematical Sciences Building   fax:   (530) 752-7099
One Shields Ave.
University of California at Davis
Davis,
CA 95616,
USA
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFEv4nO9p/Jzwa2QP4RAnPnAJ974RMxo/KXfxQjaRHoHB1ZsdIy+QCeNhXg
EDk/WHaFUeH5C2v/607kovo=
=FAGn
-END PGP SIGNATURE-

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Post CGI forms with built-in R function?

2006-07-20 Thread Mike Schaffer
Thanks Duncan.  I figured there was some limit.

Your suggestion to check out the httpRequest code has me headed in  
the right direction, but I am having problems with the data returned  
from the socketConnection.  Some of the returned data appears to  
improperly decoded.  I don't know if I've stumbled on a low-level  
socket bug, or I need to error check the results myself.  Can anyone  
figure out the problem in the code below?

This was run using R version 2.3.1 (2006-06-01) on both Linux and OS  
X with the same results.



# First, the correctly formatted data for comparison is returned by  
the code below.  As we've established, this works fine, but I can't  
use it with long URIs:

full.url<-"http://genomics11.bu.edu/cgi-bin/Tractor_dev/external/ 
get_msa.cgi? 
user_id=0&table=seqs_ucsc_hg18&len=350&gene_set_ids=NM_29,NM_64, 
NM_66&orgs=Hs,mm8,canFam2"
read<-readLines(full.url)


# This returns three tab-delimited lines with a header row.

 > read
[1] "NA\tHs\tmm8\tcanFam2"

[2] "NM_29\tTAAGCA--AGACTC-TTGCCCTCTGCCCTCTGCACCTCCGG--- 
CCTGCATGTC--CCTGTGGCCTCTTGTACATCTCCC--- 
CTGGGTCAGAAG-GCCTGGGTGGTTGGCCTCAGG 
CTGTCACACACCTAGGGAGATGCTC-- 
CCGTTTCTGGGAACCTTGGGACTCCTGCA 
AACTTCGGTAAATGTGTAACTCGACCCTGCACCGGCTC 
ACTCTGTTCAGCAGTGAAACTCTGCATCGATCACTAAGACTTCCTGG- 
AAGAGGTCCCAGCGTGAGTGTCGCT--- 
TCTGGCATCTGTCCTTCTGG-CCAGCCTGTGGTC-- 
TGG-CCAAGTGATGTAACCCTCCTCT---CCAGCCT\tTGCAAGTGAG- 
CTTCCTG-GCATGCC--CAGAGAGGCTTACG-- 
AGTGCATCACGAG-CTTTCATCCCAAG- 
GTCTGCATGGCTGGCTTCAGGTTGTCACAACCC- 
ACTCAATC--CTGTGACTG---TGGTCCTGGCTCCAGGG 
AACTTAAATGTGTAACCCAAGGCCAGCC-- 
TATGCATGAGGCT---CATCTGCCAGTAGGGCTTCCTGG-AA- 
CCCAGAG-GAACATCACCCTGGCCCTGATCCATCTTGGT--- 
CAAGCCTGGATTCTCA---TGG-TTCCCTGATCTGGGTCCTCCCCCAGCCT 
\tCCGGGGCTCC-TTCCCTG--CGCCCTCCTCAGCACATT-- 
CTTACTCTCAGAAGCACACCTCGAGAGG--GCTCTGTCAGAAG-GCTTG- 
GTGGCTGGCCTCGGC 
TTGTCACAGCTCAGGGCAGAGACGCGACACACACACCTACACACAGGTACCGCTCCGGACCCGGCCCG 
GGCAAGCTGCGGTCAATGTGTAACTCGGCGGCCCAGCGGCTC 
GTTCTGCTCAGCACAGAAAGTGTGCATCGATCTCCCTGACTTCCTGG- 
AAGGCGTCCCAGCCTGAGAGTAGCTCTGGCGCCTGTACCACC-- 
CCCGTCACATGGTC--GGG- 
CCAAGTGATGTCACCTCCCGCCTAGCCT"

[3] "NM_64\tC- 
CGTGAACT-ATGAG-GTCCAAGACATCTGCGGTGGTT- 
CTCCAGACCTTAGTGTTCTTC--CACTACAAAGTGGGTCCAACAGAGAAAGG 
TCTGTGTTCACCAGGTGG---CCCTGACCC--- 
TGGGAGAGTCCAGGGCAGGGTGCAGCTGCATTCATGCTGCTGGGGAACATGC- 
CCTCAGGTTACTCAATGGACATGTTGGCC-CCAGGGACTG-GCTTAG 
GAAATGGTATTGAGAAATCTCAGC-CCCGGG-GAGAGG--CCATAGAA-- 
GGGCTGAGTGAAAGGCAGGAGCCAG--ATAGCCAGCTCCAGCAGGCGCTGCTCA 
\tATTTAGCAAGACCTTGTAGGGAGAACCAGCCATCCAGAAGTG--CTGGGTTACTGG- 
GACCCAGCTAAGTGTGGGAGGAGGTCACTCTAGACTTCAATGGTCTCTGGTGTAACCAAGTA 
CAACAGGGACCAGCCCAGGTTCAGCATCTGG--- 
CCTTGACCC---CAAGGCCTGAGCCAAG-- 
CAGGTACTTTCAAGCTCCAGGGTAATGGAAATGTGCCTAGGGTTACTCAA-AGG 
CTTGTTGCCC-CAGGTTTGTGAGCTTAGGAAACTATGTTGCGAAAGGGCAGT- 
CCCTGGTG--CAGGAACAGGGAG--GGACCAGA--GAGGA--- 
GAGCCAT--ATAAAGAGCCAGCGGCTACAGAGCTCG 
\t-- 
- 
CCACAAAGGT--TCACCAGCTGG--- 
CCTTGACCC---TGAGGGAGGCCATGGCAAAAGGTGTGTTCATGTTGCAGGAGGACATGC- 
CCTTGGGTTAGTTAC--GACACACTGGCC-CCATTG-ACTTAG 
GAAATGGTATTGAGTAATCTCAGC-TGCAGGGAGG-GGGAGG-- 
CTACAGGAGCTGTGGGCTGGGCTGAA---GGTGGAGGCTCCAG--AT 
GGCAATAACAGCCTCTGCTCA"

[4] "NM_66 
\tAGCTGTTAGGTTGGTGCGTAATTGTGGTGCCATTGCAATGACAA-- 
--AAACTG- 
CAATTACGCACCAACCTAGTCAGTGGCAGAGAATGTACTTGAACCCAGGCTGTCTAGACCTAGATCCC 
ACAGTCCTTGCCACCTCA--CTAATAGCCTGTCCAC---TTGGCAGCTTACCCTAAAGTTA- 
CAGAGGAATAAACACCATGCTGCTACA- 
GATCATTAT--- 
TCTGGTTGGTTTCCAGAGTGACAGG---TAAGTTT-TTGGTC-TGTGCAAAGTCTG- 
TTTCCAGTCACTAGTGGCTTTCTGTTTACTTTGCAGAGCTATTTGCTCT-TACAGAAGCTGACAGT 
\t-- 
 
-- 
GGCTGCTT-CCATGGAATCA- 
CAGTTCTCACTGT---CCTAG--- 
GTGTGCGGTATCACAAG---TGAGTACATTCGTGCTGTGCAAAGCTGA 
GGTTCCAGGTACAAGCGCCTGTTTGCTTTGCTGACCTGTTTGCTCTATGTCAACAGAA- 
CTGAGAGC 
\t-- 
-

Re: [Rd] [R] Continuation and parse

2006-07-20 Thread Prof Brian Ripley
The issue here is that the current expression is still there and 
protected if there is a parse problem.  So you need one more unprotect.

This does not give a problem in source() (the only internal use) as it 
throws an error in those cases.  (It also uses a different branch of the 
code with n < 0.)

Since this seems to be worrying no one else, I am going to add the 
unprotect in the source code for R-devel.

On Thu, 13 Jul 2006, Martin Morgan wrote:

> [this is from R-help, at the end of June]
> 
> Jim Lemon asked about parsing syntactically incorrect versus
> incomplete lines, generating a couple of responses.
> 
> Philippe's suggestion isn't robust (e.g., "\nls)". Prof. Ripley's
> comment lead me to R_ParseVector (the only exposed parse
> routine). Unfortunately, this returns from parsing incomplete or
> syntactically incorrect text with a PROTECT stack imbalance, so there
> is no natural way to return from a .Call.
> 
> What I'd like is to have access to multiline console input after
> parsing but before evaluation, or to return from a .Call like that
> below with either the parsed expression or information about the
> reason for failure. Any suggestions?
> 
> Thanks in advance,
> 
> Martin
> 
> SEXP parses(SEXP cmd) {
>   ParseStatus status;
>   SEXP res;
>   res = R_ParseVector(cmd, 1, &status);
>   return res;
> }
> 
> /* > .Call("parses", "ls(") */
> /* 25SEXP res = R_ParseVector(cmd, 1, &status); */
> /* (gdb) p R_PPStackTop */
> /* $1 = 3 */
> /* (gdb) next */
> /* 26return res; */
> /* (gdb) p R_PPStackTop */
> /* $2 = 5 */
> 
> R version 2.4.0 Under development (unstable) (2006-07-11 r38560)
> x86_64-unknown-linux-gnu
> 
> Philippe Grosjean <[EMAIL PROTECTED]> writes:
> 
> > Well, you haven't used the search engines with the right key: the magic 
> > words are:
> >
> >  > RSiteSearch("incomplete line")
> >
> > With the first document being my query (almost two years ago), and the 
> > second one being Peter Dalgaard answer. You must adapt it to cope with 
> > internationalization, but basically, you could use something like:
> >
> >  > grep("\n2:",try(parse(textConnection("ls)")), silent = TRUE))
> > numeric(0)
> >  > grep("\n2:",try(parse(textConnection("ls(")), silent = TRUE))
> > [1] 1
> 
> From: Prof Brian Ripley 
> Date: Wed, 28 Jun 2006 13:44:49 +0100 (BST)
> 
> On Wed, 28 Jun 2006, Jim Lemon wrote:
> 
> > Hi gurus,
> >
> > After an unsuccessful scrabble through the documentation and Jon's
> > excellent search facility, I am no wiser as to how R recognizes an
> > incomplete command line and politely raises its hand for more. The help
> > page for parse gives no indication that it does anything more than spit
> > the dummy when fed an incomplete command line, but something in there
> > must recognize such ellipsis. Any hints?
> 
> It's internal. Look in src/main/main.c, in particular the R_Repl*
> functions. In short, R_Parse1Buffer can return PARSE_INCOMPLETE.
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] DESCRIPTION and PACKAGES files.

2006-07-20 Thread Allen S. Rout

Greetings; I'm working on translating the heirarchy of R packages into
the Gentoo Ebuild environment, currently working from a 2.3.1 install.

There are several data which it would be nice to see provided
alongside the existing output of available.packages; at the moment I
think I'm going to have to get License and SystemRequirements out of
individual package DESCRIPTIONs.

More generally, it'd be nice to see all the documented fields from
DESCRIPTION files in the output from available.packages(), or at least
collated in PACKAGES.

I have a suggestion to accomplish this which I've hacked up locally
and am happy to build a patch if the suggestion is well-recieved.

available.packages uses read.dcf on the PACKAGES file, accepting only 

flds <- c("Package", "Version", "Priority", "Bundle", "Depends",
  "Imports", "Suggests", "Contains")


If we could optionally accept all of the fields which are mentioned in
'Creating R Extensions', someone who was interested in the broader
data could get at it.

PACKAGES would grow, substantially, but wouldn't be harder to
maintain; in fact PACKAGES could be just a naive concatenation of
everyone's DESCRIPTION files.


For that matter, if you would be willing to add the extra data to
PACKAGES, the current implementation would work, and I could just run
my hacked version and get at what I wanted.  But I know of at least
one other package-heirarchy maintainer who might like this, and
subsuming it in the base function would be nice.



- Allen S. Rout

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] DESCRIPTION and PACKAGES files.

2006-07-20 Thread Prof Brian Ripley
On Thu, 20 Jul 2006, Allen S. Rout wrote:

> 
> Greetings; I'm working on translating the heirarchy of R packages into
> the Gentoo Ebuild environment, currently working from a 2.3.1 install.
> 
> There are several data which it would be nice to see provided
> alongside the existing output of available.packages; at the moment I
> think I'm going to have to get License and SystemRequirements out of
> individual package DESCRIPTIONs.
> 
> More generally, it'd be nice to see all the documented fields from
> DESCRIPTION files in the output from available.packages(), or at least
> collated in PACKAGES.
> 
> I have a suggestion to accomplish this which I've hacked up locally
> and am happy to build a patch if the suggestion is well-recieved.
> 
> available.packages uses read.dcf on the PACKAGES file, accepting only 
> 
> flds <- c("Package", "Version", "Priority", "Bundle", "Depends",
>   "Imports", "Suggests", "Contains")
> 
> 
> If we could optionally accept all of the fields which are mentioned in
> 'Creating R Extensions', someone who was interested in the broader
> data could get at it.
> 
> PACKAGES would grow, substantially, but wouldn't be harder to
> maintain; in fact PACKAGES could be just a naive concatenation of
> everyone's DESCRIPTION files.

And that is the reason: everyone who downloads pays the price for unneeded 
fields in that file.  It was a deliberate decision to minimize download 
times, which are already substantial for people on a dialup connection.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] DESCRIPTION and PACKAGES files.

2006-07-20 Thread Allen S. Rout
Prof Brian Ripley <[EMAIL PROTECTED]> writes:

> And that is the reason: everyone who downloads pays the price for unneeded 
> fields in that file.  It was a deliberate decision to minimize download 
> times, which are already substantial for people on a dialup connection.

OK, that meets the definition of "not well recieved" ;) 

Thanks for your time. 



- Allen S. Rout

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] How do I modify an exported function in a locked environment?

2006-07-20 Thread Prof Brian Ripley
Please do not post to multiple lists: I have removed R-help.

On Thu, 20 Jul 2006, Steven McKinney wrote:

> Running R.app on Mac OS X 10.4
> 
> I am trying to learn how to modify functions
> in a locked environment.

This is deliberately hard.

> For an example, suppose I'm using the package "zoo".
> 
> zoo contains function "rollmean.default"
> 
> > rollmean.default
> function (x, k, na.pad = FALSE, align = c("center", "left", "right"), 
> ...) 
> {
> x <- unclass(x)
> n <- length(x)
> y <- x[k:n] - x[c(1, 1:(n - k))]
> y[1] <- sum(x[1:k])
> rval <- cumsum(y)/k
> if (na.pad) {
> rval <- switch(match.arg(align), left = {
> c(rval, rep(NA, k - 1))
> }, center = {
> c(rep(NA, floor((k - 1)/2)), rval, rep(NA, ceiling((k - 
> 1)/2)))
> }, right = {
> c(rep(NA, k - 1), rval)
> })
> }
> return(rval)
> }
> 
> 
> Suppose for whatever reason I want output to be
> in percent, so I'd like to modify the result to be
> rval <- 100 * cumsum(y)/k
> 
> I cannot just copy the function and change it, as the namespace
> mechanism ensures the rollmean.default in 'zoo' continues to be used.
> 
> If I use
> fixInNamespace("rollmean.default", ns = "zoo")
> I can edit the rval <- cumsum(y)/k line to read
> rval <- 100 * cumsum(y)/k
> save the file and exit the R.app GUI editor.
> 
> But this does not update the exported copy of the
> function (the documentation for fixInNamespace says
> this is the case) - how do I accomplish this last step?

You need to unlock the binding, then assign in package:zoo.
Something like

unlockBinding("rollmean.default", as.environment("package:zoo"))
assign("rollmean.default", zoo:::rollmean.default, pos="package:zoo")

However, it is not usual to export methods, and that is why this case is 
particularly hard.

> If I list the function after editing, I see the original
> copy.  But if I reinvoke the editor via fixInNamespace(),
> I do see my modification.
> Where is my copy residing?  How do I push it out
> to replace the exported copy?
> 
> Is this the proper way to modify a package function?

Many would say it was not proper to `modify a package function'.

> Are there other ways?  I've searched webpages, R news,
> help files and have been unable to find out how to
> get this process fully completed.

> Any guidance appreciated.

You may not like the guidance 

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] How do I modify an exported function in a locked environment?

2006-07-20 Thread Steven McKinney


Running R.app on Mac OS X 10.4

> version
   _ 
platform   powerpc-apple-darwin8.6.0 
arch   powerpc   
os darwin8.6.0   
system powerpc, darwin8.6.0  
status   
major  2 
minor  3.1   
year   2006  
month  06
day01
svn rev38247 
language   R 
version.string Version 2.3.1 (2006-06-01)
> 


I am trying to learn how to modify functions
in a locked environment.

For an example, suppose I'm using the package "zoo".

zoo contains function "rollmean.default"

> rollmean.default
function (x, k, na.pad = FALSE, align = c("center", "left", "right"), 
...) 
{
x <- unclass(x)
n <- length(x)
y <- x[k:n] - x[c(1, 1:(n - k))]
y[1] <- sum(x[1:k])
rval <- cumsum(y)/k
if (na.pad) {
rval <- switch(match.arg(align), left = {
c(rval, rep(NA, k - 1))
}, center = {
c(rep(NA, floor((k - 1)/2)), rval, rep(NA, ceiling((k - 
1)/2)))
}, right = {
c(rep(NA, k - 1), rval)
})
}
return(rval)
}


Suppose for whatever reason I want output to be
in percent, so I'd like to modify the result to be
rval <- 100 * cumsum(y)/k

I cannot just copy the function and change it, as the namespace
mechanism ensures the rollmean.default in 'zoo' continues to be used.

If I use
fixInNamespace("rollmean.default", ns = "zoo")
I can edit the rval <- cumsum(y)/k line to read
rval <- 100 * cumsum(y)/k
save the file and exit the R.app GUI editor.

But this does not update the exported copy of the
function (the documentation for fixInNamespace says
this is the case) - how do I accomplish this last step?

If I list the function after editing, I see the original
copy.  But if I reinvoke the editor via fixInNamespace(),
I do see my modification.
Where is my copy residing?  How do I push it out
to replace the exported copy?

Is this the proper way to modify a package function?
Are there other ways?  I've searched webpages, R news,
help files and have been unable to find out how to
get this process fully completed.

Any guidance appreciated.


Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: [EMAIL PROTECTED]

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
Canada

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] How do I modify an exported function in a locked environment?

2006-07-20 Thread Gabor Grothendieck
As others have mentioned its not really a good idea
to modify the namespace of a package and writing
a wrapper as Duncan suggested is much preferable.

An intermediate approach that
is not as good as the wrapper but better than modifying
the namespace is to copy the objects of interest
to your workspace, change their environments
appropriately and then modify their functionality:

library(zoo)

# copy objects of interest and set their environment

rollmean <- zoo:::rollmean
environment(rollmean) <- .GlobalEnv

rollmean.zoo <- zoo:::rollmean.zoo
environment(rollmean.zoo) <- .GlobalEnv

rollmean.default <- zoo:::rollmean.default
environment(rollmean.default) <- .GlobalEnv

# modify functionality

rollmean.default0 <- rollmean.default
rollmean.default <- function(x, ...) 100 * rollmean.default0(x, ...)

# test

rollmean(1:5, 3) # 100* used
rollmean(zoo(1:5), 3)  # 100* used


On 7/20/06, Steven McKinney <[EMAIL PROTECTED]> wrote:
>
>
> Running R.app on Mac OS X 10.4
>
> > version
>   _
> platform   powerpc-apple-darwin8.6.0
> arch   powerpc
> os darwin8.6.0
> system powerpc, darwin8.6.0
> status
> major  2
> minor  3.1
> year   2006
> month  06
> day01
> svn rev38247
> language   R
> version.string Version 2.3.1 (2006-06-01)
> >
>
>
> I am trying to learn how to modify functions
> in a locked environment.
>
> For an example, suppose I'm using the package "zoo".
>
> zoo contains function "rollmean.default"
>
> > rollmean.default
> function (x, k, na.pad = FALSE, align = c("center", "left", "right"),
>...)
> {
>x <- unclass(x)
>n <- length(x)
>y <- x[k:n] - x[c(1, 1:(n - k))]
>y[1] <- sum(x[1:k])
>rval <- cumsum(y)/k
>if (na.pad) {
>rval <- switch(match.arg(align), left = {
>c(rval, rep(NA, k - 1))
>}, center = {
>c(rep(NA, floor((k - 1)/2)), rval, rep(NA, ceiling((k -
>1)/2)))
>}, right = {
>c(rep(NA, k - 1), rval)
>})
>}
>return(rval)
> }
> 
>
> Suppose for whatever reason I want output to be
> in percent, so I'd like to modify the result to be
> rval <- 100 * cumsum(y)/k
>
> I cannot just copy the function and change it, as the namespace
> mechanism ensures the rollmean.default in 'zoo' continues to be used.
>
> If I use
> fixInNamespace("rollmean.default", ns = "zoo")
> I can edit the rval <- cumsum(y)/k line to read
> rval <- 100 * cumsum(y)/k
> save the file and exit the R.app GUI editor.
>
> But this does not update the exported copy of the
> function (the documentation for fixInNamespace says
> this is the case) - how do I accomplish this last step?
>
> If I list the function after editing, I see the original
> copy.  But if I reinvoke the editor via fixInNamespace(),
> I do see my modification.
> Where is my copy residing?  How do I push it out
> to replace the exported copy?
>
> Is this the proper way to modify a package function?
> Are there other ways?  I've searched webpages, R news,
> help files and have been unable to find out how to
> get this process fully completed.
>
> Any guidance appreciated.
>
>
> Steven McKinney
>
> Statistician
> Molecular Oncology and Breast Cancer Program
> British Columbia Cancer Research Centre
>
> email: [EMAIL PROTECTED]
>
> tel: 604-675-8000 x7561
>
> BCCRC
> Molecular Oncology
> 675 West 10th Ave, Floor 4
> Vancouver B.C.
> V5Z 1L3
> Canada
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] DESCRIPTION and PACKAGES files.

2006-07-20 Thread Seth Falcon
[EMAIL PROTECTED] (Allen S. Rout) writes:

> Prof Brian Ripley <[EMAIL PROTECTED]> writes:
>
>> And that is the reason: everyone who downloads pays the price for unneeded 
>> fields in that file.  It was a deliberate decision to minimize download 
>> times, which are already substantial for people on a dialup connection.
>
> OK, that meets the definition of "not well recieved" ;) 

For the Bioconductor project, we also wanted more information to be
programatically available regarding the packages in a repository.
Instead of bloating the PACKAGES file, we put a separate file, VIEWS
in our repository.  Here is an example:

http://bioconductor.org/packages/1.8/bioc/VIEWS

This file is used to generate the HTML pages that describe our
packages (happy to share the code for generating the VIEWS file if you
like).

So, if you were able to host a CRAN mirror, you could annotate it
similarly.

+ seth

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] png() and image()

2006-07-20 Thread Henrik Bengtsson

Hi,

I try to create PNG images of a certain size where each pixel
intensity corresponds to exactly one probe signal in an Affymetrix
array.  I try to use png() and image() with zero margins to do this.
Example:

z <- matrix(1:15, nrow=45, ncol=30)
png("large.png", height=nrow(z), width=ncol(z), bg="red")
par(mar=c(0,0,0,0))
image(z, col=gray.colors(16), axes=FALSE)
dev.off()

z <- matrix(1:15, nrow=5, ncol=3)
png("tiny.png", height=nrow(z), width=ncol(z), bg="red")
par(mar=c(0,0,0,0))
image(z, col=gray.colors(16), axes=FALSE)
dev.off()

The problem is that on WinXP the very bottom row and the very right
column of pixels in red.  Trying on Linux, it is only the very right
column that is red.  See attached images (you might have to zoom in to
see it).  I try to do this in R v2.3.1.  The same effect is seen if
the jpeg() device is used.

When rescaling, the same effect is seen (the red border effect is one
pixel wide), e.g.

z <- matrix(1:15, nrow=45, ncol=30)
png("large5.png", height=5*nrow(z), width=5*ncol(z), bg="red")
par(mar=c(0,0,0,0))
image(z, col=gray.colors(16), axes=FALSE)
dev.off()

I might be asking for something that is not supported, but is there a
way around this?  It is a problem, because I wish to tile the images
in an HTML page.

Thanks

Henrik


WinXP-large.png
Description: PNG image


WinXP-tiny.png
Description: PNG image


Linux-large.png
Description: PNG image


Linux-tiny.png
Description: PNG image


WinXP-large5.png
Description: PNG image


WinXP-tiny5.png
Description: PNG image
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel