Re: [R] R CMD CHECK and require() / library() methods

2007-04-25 Thread Crispin Miller
Many thanks! 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Prof 
> Brian Ripley
> Sent: 25 April 2007 16:03
> To: Crispin Miller
> Cc: R-help@stat.math.ethz.ch
> Subject: Re: [R] R CMD CHECK and require() / library() methods
> 
> On Wed, 25 Apr 2007, Crispin Miller wrote:
> 
> > Hi,
> >
> > I have a piece of code that decides at runtime whether to 
> load a data 
> > package (and which package to load).
> > This is then done with a call to:
> >
> > library(x)
> >
> > (where x is a character variable containing the package name).
> >
> > This causes R CMD check to throw out a warning:
> > 'library' or 'required' calls not declared from:
> > x
> 
> Which version of R is this?  All I can find say 'require'.
> 

My mistake - it was a typo it says: 'require'

> >
> > Does anyone have any suggestions as to a fix or workaround for this?
> 
> That call should be
> 
> library(x, character.only=TRUE)
> 
> and that will in R 2.5.0 stop the warning AFAIK.
> 

It works - much appreciated...

Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
R-help@stat.math.ethz.ch 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.


[R] R CMD CHECK and require() / library() methods

2007-04-25 Thread Crispin Miller
Hi,
 
I have a piece of code that decides at runtime whether to load a data
package (and which package to load).
This is then done with a call to:
 
library(x)
 
(where x is a character variable containing the package name).
 
This causes R CMD check to throw out a warning:
'library' or 'required' calls not declared from:
x
 
Does anyone have any suggestions as to a fix or workaround for this?
 
Crispin
 



This email is confidential and intended solely for the use o...{{dropped}}

__
R-help@stat.math.ethz.ch 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.


Re: [R] Matrices with a single column

2005-09-01 Thread Crispin Miller
Thanks everyone!

Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Matrices with a single column

2005-09-01 Thread Crispin Miller
Hi,
I've got a quick question about what happens when indexing into matrices
with a single column. I was wondering if anyone can help ...
 
For example:
> x <- matrix(1:10)

> y <- cbind(x,x)

> x[4:6,]

[1] 4 5 6

> y[4:6,]

   [,1] [,2]

[1,] 4 4

[2,] 5 5

[3,] 6 6

> class(x[4:6,])

[1] "integer"

> class(y[4:6,])

[1] "matrix"

It seems that R is returning the results of indexing into a matrix with
one column as a vector rather than a matrix?

Does anyone have a good way of preventing this from happening?

cheers,

crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Selecting font sizes graphics device

2005-04-28 Thread Crispin Miller
Dear all,
Im' using matrix() and layout() to set up a fairly complex plot...
 
I was wondering if anyone can point me to something that describes the
appropriate incantations to determine, given a text string, the maximum
font size that will allow it to fit into the current plotting area
without being trunucated?
 
best wishes,
Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] File permissions and packages, openVignette

2004-01-22 Thread Crispin Miller
Hi,
I've got a quick question about file permissions and packages...

I'm creating my own package, and am having problems with its vignette
not being seen when I install it into R...

As I understand it, the permissions of the source tree should be as
follows:
  o Directories - drwxrwxr-- 
  o Files - -rw-r--r--
 
Everything builds and runs through 'R CMD check' fine with no warnings
or errors...

I now install the package as root, and again it goes in fine - and I can
see the library, its functions, and their man pages, when I fire up R.

However, when I call openVignette(), my package vignette is not visible.

Going into the file system, finding the installed library, and doing
'chmod -R 777 *' on the package, seems to fix the problem, without
breaking anything else.

However, I suspect I'm not supposed to do this! :-) Can anyone tell me
what permissions I should have on my 'inst/' and 'doc/' directories for
the vignette to be visible to openVignette, or anything else I need to
do to make my package install so that the vignette is visible?

Cheers,
Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Alpha values

2003-11-12 Thread Crispin Miller
Hi,
Does anyone know whether it is possible to construct a colour for
plotting with an alpha value as well as simply specifying rgb values?

Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Creating packages in 1.8

2003-10-31 Thread Crispin Miller
Hi,
Firstly, sorry to reply to my own posting... Also for not having done
more trawling before I sent the original message...

The problems we are having were down to R being installed in a different
directory to the default one (for various sysadmin reasons)...

We've successfully got R runnning on a single machine in the default
directories where it likes to be - it is happy, and 'R CMD check' works
fine... :-)

Alas, this is not a good long-term solution for us can anyone help us
work out the easiest way to get R installed in another directory
structure instead of  the default ones? 

I appreciate that very similar questions have been asked before, but I
suspect that 1.8 is slightly different (since R CMD check ... worked
fine for us in 1.7.1).


Crispin

> -Original Message-----
> From: Crispin Miller 
> Sent: 31 October 2003 14:51
> To: [EMAIL PROTECTED]
> Subject: [R] Creating packages in 1.8
> 
> 
> Hi,
> I decided to upgrade to 1.8 today... :-)
> Anyway, we are writing our own package that is dependent on a 
> bioconductor library - 'affy'. I've checked and when I fire 
> up R, library(affy) behaves as expected... so it all seems to 
> be installed and OK...
> 
> In the DESCRIPTION file in my package source I have the line:
> 
> Depends: affy
> 
> When I run R CMD check simpleaffy
> 
> I get to:
> 
> ...
> * checking package dependencies ... ERROR
> Packages required but not available:
>   WARNING: ignoring environment value of R_HOME
> Prompt >
> 
> Any ideas what is going on - as far as I can see the only 
> dependency is to affy which is there and OK... I get no list 
> of packages that are missing :-(
> 
> I'm assuming the warning comes because I have R_ENVIRON 
> pointing to a .Renviron file in my home directory...
> 
> Any help would be much appreciated!
> Cheers,
> Crispin
>  
> 
> 
>  
> This email is confidential and intended solely for the use 
> o...{{dropped}}
> 
> __
> [EMAIL PROTECTED] mailing list 
> https://www.stat.math.ethz.ch/mailman/listinfo> /r-help
>
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Creating packages in 1.8

2003-10-31 Thread Crispin Miller
Hi,
I decided to upgrade to 1.8 today... :-)
Anyway, we are writing our own package that is dependent on a
bioconductor library - 'affy'.
I've checked and when I fire up R, library(affy) behaves as expected...
so it all seems to be installed and OK...

In the DESCRIPTION file in my package source I have the line:

Depends: affy

When I run R CMD check simpleaffy

I get to:

...
* checking package dependencies ... ERROR
Packages required but not available:
  WARNING: ignoring environment value of R_HOME
Prompt >

Any ideas what is going on - as far as I can see the only dependency is
to affy which is there and OK... I get no list of packages that are
missing :-(

I'm assuming the warning comes because I have R_ENVIRON pointing to a
.Renviron file in my home directory...

Any help would be much appreciated!
Cheers,
Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] environments

2003-10-17 Thread Crispin Miller
Hi,
I have a string representing an environment:

"bob"

And an environment
> bob

How do write a function that takes the string and returns the
environment?

Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Setting PNG sizes

2003-10-13 Thread Crispin Miller
Hi,
Firstly, thanks for your collective help the other day with packages and
the like - I now have a function that takes a few seconds to run instead
of half a day... much obliged!

I'm trying to print out a 300dpi PNG for inclusion in a publication (I
don't want postscript because some of the figures have so many dots in
photoshop starts weeping when I try to rasterize them). 
I see how to set the width and height of the image in pixels in the
dev.print function (e.g.
dev.print(png,file="f.png",width=1500,height=1500), and I can specify
the size of the image itself (using par(pin=c(5,5)) - for a 5 by 5
image, for example) but doing both of these together gives me a small
figure in the middle of a large image, rather than a 300dpi figure. 
Can anyone help?
Cheers
Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] .First.lib doesn't appear to be running after calling lib rary()

2003-10-07 Thread Crispin Miller
Thanks - it is indeed the first '.' that's the problem...
Crispin


> -Original Message-
> From: Liaw, Andy [mailto:[EMAIL PROTECTED]
> Sent: 07 October 2003 15:21
> To: Crispin Miller
> Subject: RE: [R] .First.lib doesn't appear to be running after calling
> lib rary()
> 
> 
> I put .First.lib in the file "zzz.R", and it works for me.  
> My guess is that
> the problem is using a filename that starts with ".".  I see 
> many packages
> put the .First.lib in zzz.R, so I just follow that.
> 
> HTH,
> Andy
> 
> > -Original Message-
> > From: Crispin Miller [mailto:[EMAIL PROTECTED] 
> > Sent: Tuesday, October 07, 2003 10:00 AM
> > To: R-help (E-mail)
> > Subject: [R] .First.lib doesn't appear to be running after 
> > calling library()
> > 
> > 
> > Hi - so I've dusted off the C bits of my brain and gotten a 
> > library written for my package...
> >  
> > It passes R CMD check ok, and I've put a file called 
> > '.First.lib.R' in the pacakge's 'R'  subdirectory. Its 
> > permissions are 644.
> > 
> > It says:
> > 
> > .First.lib <- function(lib,pkg) {
> >library.dynam("foo",pkg,lib);
> >require(affy,quietly=TRUE);
> > }
> > 
> > 
> > I build and INSTALL the package, start R and then call 
> > library(foo). I deduce that my '.First.lib' isn't running 
> > because the affy library doesn't get loaded - and neither 
> > does my dynamic library (which complies ok and results in 
> > 'foo.so' being put in the 'src/' directory of the package)...
> > 
> > Any ideas what I'm doing wrong?
> > 
> > Crispin
> >  
> > 
> > 
> >  
> > This email is confidential and intended solely for the use 
> > o...{{dropped}}
> > 
> > __
> > [EMAIL PROTECTED] mailing list 
> > https://www.stat.math.ethz.ch/mailman/listinfo> /r-help
> > 
> 
>
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] .First.lib doesn't appear to be running after calling library()

2003-10-07 Thread Crispin Miller
Hi - so I've dusted off the C bits of my brain and gotten a library written for my 
package...
 
It passes R CMD check ok, and I've put a file called '.First.lib.R' in the pacakge's 
'R'  subdirectory. Its permissions are 644.

It says:

.First.lib <- function(lib,pkg) {
   library.dynam("foo",pkg,lib);
   require(affy,quietly=TRUE);
}


I build and INSTALL the package, start R and then call library(foo).
I deduce that my '.First.lib' isn't running because the affy library doesn't get 
loaded - and neither does my dynamic library (which complies ok and results in 
'foo.so' being put in the 'src/' directory of the package)...

Any ideas what I'm doing wrong?

Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: FW: [R] Optimising code

2003-10-07 Thread Crispin Miller
Yup, my mistake for not being very clear! Alas the computer is already very fast - 
looks like it's C for me...

> -Original Message-
> From: Patrick Burns [mailto:[EMAIL PROTECTED]
> Sent: 07 October 2003 12:00
> Cc: Crispin Miller
> Subject: Re: FW: [R] Optimising code
> 
> 
> I had misunderstood also.  I agree with Uwe either move
> to C or buy a faster computer -- or at least another one.
> 
> Pat
> 
> Uwe Ligges wrote:
> 
> > Crispin Miller wrote:
> >
> >>>> I have a function that applies a wilcoxon test to 12 
> sets of about 
> >>>> a quarter of a million pairs
> >>>
> >>
> >>
> >>> ... and let me guess: everything is significiant to an almost 
> >>> arbitrary value of \alpha?
> >>
> >>
> >>
> >> :-) For each of quarter of a million sets, I do a wilcoxon between 
> >> two pairs each containing twenty numbers...
> >> I do this 12 times...
> >
> >
> > Ah. Sorry for misunderstanding.
> >
> >
> >>>> (and takes about 3 hours). I've replaced the inner loop I 
> >>>
> >>>
> >>> had originally with a function call via mapply, and also 
> considered 
> >>> different approximations  of the wilcoxon, rather than 
> that which is 
> >>> implemented in wilcox.test, but that makes little 
> difference 9and if 
> >>> anything slows things down :-).
> >>>
> >>> Are you using wilcox.test(), or a self written function?
> >>>
> >>
> >>
> >> I started off with wilcox.test, and tried to speed it up 
> by hacking 
> >> out as much from the original function as possible, since a fair 
> >> proportion of the code being executed was logic deciding 
> between the 
> >> different flavours of the test (I didn't expect that to make much 
> >> difference, but tried it anyway), there was also a call to pnorm() 
> >> which I replaced with a numeric approximation. This is not inlined 
> >> into the original function.
> >
> >
> >
> > In that case you cannot do very much except for writing it in a 
> > language like C / Fortran, if you really need the speed.
> >
> > Uwe Ligges
> >
> >> Crispin
> >>  
> >> 
> >>
> >>  
> >> This email is confidential and intended solely for the use 
> >> o...{{dropped}}
> >>
> >> __
> >> [EMAIL PROTECTED] mailing list
> >> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >
> >
> > __
> > [EMAIL PROTECTED] mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >
> >
> 
> 
> 
>
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


FW: [R] Optimising code

2003-10-07 Thread Crispin Miller

>> I have a function that applies a wilcoxon test to 12 sets of about a quarter of a 
>> million pairs

> ... and let me guess: everything is significiant to an almost arbitrary 
> value of \alpha?

:-) For each of quarter of a million sets, I do a wilcoxon between two pairs each 
containing twenty numbers...
I do this 12 times...


> > (and takes about 3 hours). I've replaced the inner loop I 
> had originally with a function call via mapply, and also 
> considered different approximations  of the wilcoxon, rather 
> than that which is implemented in wilcox.test, but that makes 
> little difference 9and if anything slows things down :-).
> 
> Are you using wilcox.test(), or a self written function?
> 

I started off with wilcox.test, and tried to speed it up by hacking out as much from 
the original function as possible, since a fair proportion of the code being executed 
was logic deciding between the different flavours of the test (I didn't expect that to 
make much difference, but tried it anyway), there was also a call to pnorm() which I 
replaced with a numeric approximation. This is not inlined into the original function.

Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Optimising code

2003-10-07 Thread Crispin Miller
Hi,
Does anyone have any advice on speeding up R functions (short of re-implementing them 
in C :-) )?

I have a function that applies a wilcoxon test to 12 sets of about a quarter of a 
million pairs (and takes about 3 hours). I've replaced the inner loop I had originally 
with a function call via mapply, and also considered different approximations  of the 
wilcoxon, rather than that which is implemented in wilcox.test, but that makes little 
difference 9and if anything slows things down :-).

Cheers,
Crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Apply and its friends

2003-10-06 Thread Crispin Miller
Smart! 

Thanks
Crispin


> -Original Message-
> From: Berwin Turlach [mailto:[EMAIL PROTECTED]
> Sent: 06 October 2003 13:11
> To: Crispin Miller
> Subject: Re: [R] Apply and its friends
> 
> 
> >>>>> "CM" == Crispin Miller <[EMAIL PROTECTED]> writes:
> 
> CM> Hi,
> CM> Forgive a very basic question...
> CM> I need to take two lists-of-lists, and apply a function to
> CM> each pair of elements in the lists  to return a single
> CM> list... 
> CM> For example
> 
> CM> l1 <- list(1:5,6:10,2:15)
> CM> l2 <- list(1:8,4:12,1:19,4:20)
> 
> CM> I could easily do an lapply across each of them, but is there
> CM> a function that does a sort-of pairwise-apply across both
> CM> together?
> Not sure how you can do this in your case since one list has 3
> components and the other 4. :)
> 
> But something like this should work:
> 
>   n <- min( length(l1), length(l2) ) 
>   res <- sapply(1:n, function(x) sum(l1[[x]]) - sum(l2[[x]]) )
> 
> The first line calculates the minimum length of the two list.  The
> second one calls sapply with a function.  The first argument is
> essentially a vector with the components that we would like to use.
> In this case I take the difference of the sum as an example.
> 
> If you don't like to make use of global variables, you can pass on the
> list on which you want to operate explicitly to the function that you
> call in sapply:
> 
>   res <- sapply(1:n, function(x, d1, d2) sum(d1[[x]]) - 
> sum(d2[[x]]), d1=l1, d2=l2)
> 
> Hope this helps.
> 
> Cheers,
> 
> Berwin Turlach
> 
> == Full address 
> Berwin A Turlach  Tel.: +61 (8) 9380 3338 
> (secr)   
> School of Mathematics and Statistics+61 (8) 9380 3383 
> (self)  
> The University of Western Australia   FAX : +61 (8) 9380 1028
> 35 Stirling Highway   
> Crawley WA 6009e-mail: [EMAIL PROTECTED]
> Australiahttp://www.maths.uwa.edu.au/~berwin
> 
>
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Apply and its friends

2003-10-06 Thread Crispin Miller
Hi,
Forgive a very basic question...
I need to take two lists-of-lists, and apply a function to each pair of elements in 
the lists  to return a single list...
For example

l1 <- list(1:5,6:10,2:15)
l2 <- list(1:8,4:12,1:19,4:20)

I could easily do an lapply across each of them, but is there a function that does a 
sort-of pairwise-apply across both together?

Does anybody know of a good document that discusses this kind of basic 
matrix/list/vector manipulation in R?
Regards,
crispin
 


 
This email is confidential and intended solely for the use o...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help