Re: [Rd] fortune() in .Rprofile conflicts with R CMD INSTALL

2007-03-05 Thread Kurt Hornik
> Gregor Gorjanc writes:

> Seth Falcon  fhcrc.org> writes:
>> The quick fix for you is, I believe,
>> 
>> if (interactive()) {
>> library(fortunes)
>> fortune()
>> detach("package:fortunes")
>> }
>> 
>> Whether something could be changed so that R's output doesn't confuse
>> itself and gcc when doing R CMD INSTALL, seems like it should be
>> possible.

> Yes, this solves my! problem. I do not know what is causing this
> behaviour.

Well, r-devel's src/scripts/INSTALL.in now has

if test -z "${lib}"; then
  lib=`echo "cat(.libPaths()[1])" | \
R_DEFAULT_PACKAGES=NULL "${R_EXE}" --no-save --slave`
  message "Installing to library '$lib'"

so we need to find a way to "just get" the result of cat(.libPaths()[1])
into $lib as intended.

One idea might be ensuring that this gets into the last line on its own,
and then taking $lib as the last line of what we got ...

Best
-k

> This did not happen with 2.4.1

> Thank you Seth.

> Gregor

> __
> 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


[Rd] RJDBC

2007-03-05 Thread Jose Sierra
I need help.

I'm trying to connect with an Oracle DBMS and MySQL DBMS, I'm using 
RJDBC package.

My code is the next:

library('rJava')
library('DBI')
library('RJDBC')

//Mysql
drv <- 
JDBC("com.mysql.jdbc.Driver","C:\\Temporal\\mysql-connector-java-3.0.9-stable-bin.jar","'")
 

conn <- dbConnect(drv, "jdbc:mysql://localhost:3306/bd", "user", 
"password")

//Oracle
drv <- 
JDBC("oracle.jdbc.driver.OracleDriver","C:\\Temporal\\classes12.jar","'")
conn <- 
dbConnect(drv,"jdbc:oracle:thin:@192.168.1.70:1521:SDS22","user","password") 


R always returns for oracle
"Error en .local(drv, ...) : Unable to connect JDBC to 
jdbc:oracle:thin:@192.168.1.70:1521:SDS22"
and for mysql
"Error en .local(drv, ...) : Unable to connect JDBC to 
jdbc:mysql://localhost:3306/bd"

And the function summary(drv) returns:
JDBCDriver
name = JDBC
driver.version = 0.1-1
DBI.version = 0.1-1
client.version = NA
max.connections = NA

Can you help me, please?

Another question:
I try to compile ROracle and RMysql for windows but i need Rdll.lib and 
it need R.exp. Can you give me one of this files?


Regards.
Jose Sierra



__ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com

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


Re: [Rd] RJDBC

2007-03-05 Thread Sean Davis
Jose Sierra wrote:
> I need help.
>
> I'm trying to connect with an Oracle DBMS and MySQL DBMS, I'm using 
> RJDBC package.
>
> My code is the next:
>
> library('rJava')
> library('DBI')
> library('RJDBC')
>
> //Mysql
> drv <- 
> JDBC("com.mysql.jdbc.Driver","C:\\Temporal\\mysql-connector-java-3.0.9-stable-bin.jar","'")
>  
>
> conn <- dbConnect(drv, "jdbc:mysql://localhost:3306/bd", "user", 
> "password")
>
> //Oracle
> drv <- 
> JDBC("oracle.jdbc.driver.OracleDriver","C:\\Temporal\\classes12.jar","'")
> conn <- 
> dbConnect(drv,"jdbc:oracle:thin:@192.168.1.70:1521:SDS22","user","password") 
>
>
> R always returns for oracle
> "Error en .local(drv, ...) : Unable to connect JDBC to 
> jdbc:oracle:thin:@192.168.1.70:1521:SDS22"
> and for mysql
> "Error en .local(drv, ...) : Unable to connect JDBC to 
> jdbc:mysql://localhost:3306/bd"
>
> And the function summary(drv) returns:
> JDBCDriver
> name = JDBC
> driver.version = 0.1-1
> DBI.version = 0.1-1
> client.version = NA
> max.connections = NA
>
> Can you help me, please?
>   
Jose,

This message should go to the R-help or the R-SIG-DB list.  When you 
send it, I suggest you include your Java version, the output of a call 
to sessionInfo(), and let folks know whether you can connect from your 
machine using JDBC in Java.  I don't use RJDBC, so I can't help 
directly--sorry.

Sean

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


Re: [Rd] RJDBC

2007-03-05 Thread Jose Sierra
Thank you Sean.

I send the message to R-help.

Sean Davis escribió:
> Jose Sierra wrote:
>> I need help.
>>
>> I'm trying to connect with an Oracle DBMS and MySQL DBMS, I'm using 
>> RJDBC package.
>>
>> My code is the next:
>>
>> library('rJava')
>> library('DBI')
>> library('RJDBC')
>>
>> //Mysql
>> drv <- 
>> JDBC("com.mysql.jdbc.Driver","C:\\Temporal\\mysql-connector-java-3.0.9-stable-bin.jar","'")
>>  
>>
>> conn <- dbConnect(drv, "jdbc:mysql://localhost:3306/bd", "user", 
>> "password")
>>
>> //Oracle
>> drv <- 
>> JDBC("oracle.jdbc.driver.OracleDriver","C:\\Temporal\\classes12.jar","'") 
>>
>> conn <- 
>> dbConnect(drv,"jdbc:oracle:thin:@192.168.1.70:1521:SDS22","user","password") 
>>
>>
>> R always returns for oracle
>> "Error en .local(drv, ...) : Unable to connect JDBC to 
>> jdbc:oracle:thin:@192.168.1.70:1521:SDS22"
>> and for mysql
>> "Error en .local(drv, ...) : Unable to connect JDBC to 
>> jdbc:mysql://localhost:3306/bd"
>>
>> And the function summary(drv) returns:
>> JDBCDriver
>> name = JDBC
>> driver.version = 0.1-1
>> DBI.version = 0.1-1
>> client.version = NA
>> max.connections = NA
>>
>> Can you help me, please?
>>   
> Jose,
>
> This message should go to the R-help or the R-SIG-DB list.  When you 
> send it, I suggest you include your Java version, the output of a call 
> to sessionInfo(), and let folks know whether you can connect from your 
> machine using JDBC in Java.  I don't use RJDBC, so I can't help 
> directly--sorry.
>
> Sean
>


__ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com

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


[Rd] 2 bugs in max.col() (PR#9542)

2007-03-05 Thread oehl_list
Dear R-Developers,

I think I found two bugs in max.col(). Ties between zeros are not broken, which 
might affect simulations. -Inf and Zero can be treated the same, which can give 
completely wrong results, e.g. when the second max is sought by replacing all 
maxs by -Inf. 

To fix max.col I do offer the C-code behind my function rowMax(), which also 
handles NAs and seems to be faster. However, since max.col() is widely used and 
since I only occasionally program C, I'd appreciate if someone would do 
code-review and (again) thorough testing before publishing it. Please note that 
the code was developed under R 1.6.2 and might need porting to R 2.4.1 .

Best regards


Jens Oehlschlägel



# -- output of max.col under 2.4.1. 

> x <- rbind(c(1,1), c(0,0), c(-Inf, 0), c(0, Inf), c(0, NA), c(NA, 0))
> rownames(x) <- paste("c(", apply(x, 1, paste, collapse=","), ")")
> x
[,1] [,2]
c( 1,1 )   11
c( 0,0 )   00
c( -Inf,0 ) -Inf0
c( 0,Inf ) 0  Inf
c( 0,NA )  0   NA
c( NA,0 ) NA0
> 
> cat("ties not broken for c(0,0)\n")
ties not broken for c(0,0)
> cat("erroneously ties broken for c(-Inf, 0)\n")
erroneously ties broken for c(-Inf, 0)
> tmp <- sapply(1:10, function(i)max.col(x, 
> ties.method="random"));rownames(tmp)<-rownames(x);tmp
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
c( 1,1 )   212211121 1
c( 0,0 )   222222222 2
c( -Inf,0 )211221211 1
c( 0,Inf ) 222222222 2
c( 0,NA ) NA   NA   NA   NA   NA   NA   NA   NA   NANA
c( NA,0 ) NA   NA   NA   NA   NA   NA   NA   NA   NANA
> cat("The following look good\n")
The following look good
> tmp <- sapply(1:10, function(i)max.col(x, 
> ties.method="first"));rownames(tmp)<-rownames(x);tmp
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
c( 1,1 )   111111111 1
c( 0,0 )   111111111 1
c( -Inf,0 )222222222 2
c( 0,Inf ) 222222222 2
c( 0,NA ) NA   NA   NA   NA   NA   NA   NA   NA   NANA
c( NA,0 ) NA   NA   NA   NA   NA   NA   NA   NA   NANA
> tmp <- sapply(1:10, function(i)max.col(x, 
> ties.method="last"));rownames(tmp)<-rownames(x);tmp
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
c( 1,1 )   222222222 2
c( 0,0 )   222222222 2
c( -Inf,0 )222222222 2
c( 0,Inf ) 222222222 2
c( 0,NA ) NA   NA   NA   NA   NA   NA   NA   NA   NANA
c( NA,0 ) NA   NA   NA   NA   NA   NA   NA   NA   NANA

> version
   _   
platform   i386-pc-mingw32 
arch   i386
os mingw32 
system i386, mingw32   
status 
major  2   
minor  4.1 
year   2006
month  12  
day18  
svn rev40228   
language   R   
version.string R version 2.4.1 (2006-12-18)


# -- output of rowMax under 1.6.2 

> tmp <- sapply(1:10, function(i)rowMax(x, value=FALSE, na.rm=TRUE, 
> ties.method="random"));rownames(tmp)<-rownames(x);tmp
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
c( 1,1 )   222212211 1
c( 0,0 )   112222111 2
c( -Inf,0 )222222222 2
c( 0,Inf ) 222222222 2
c( 0,NA )  111111111 1
c( NA,0 )  222222222 2
> tmp <- sapply(1:10, function(i)rowMax(x, value=FALSE, na.rm=TRUE, 
> ties.method="first"));rownames(tmp)<-rownames(x);tmp
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
c( 1,1 )   111111111 1
c( 0,0 )   111111111 1
c( -Inf,0 )222222222 2
c( 0,Inf ) 222222222 2
c( 0,NA )  111111111 1
c( NA,0 )  222222222 2
> tmp <- sapply(1:10, function(i)rowMax(x, value=FALSE, na.rm=TRUE, 
> ties.method="last"));rownames(tmp)<-rownames(x);tmp
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
c( 1,1 )   222222222 2
c( 0,0 )   2222222 

[Rd] RJDBC

2007-03-05 Thread Jose Sierra
I need help.

I'm trying to connect with an Oracle DBMS and MySQL DBMS, I'm using 
RJDBC package.

My code is the next:

library('rJava')
library('DBI')
library('RJDBC')

//Mysql
drv <- 
JDBC("com.mysql.jdbc.Driver","C:\\Temporal\\mysql-connector-java-3.0.9-stable-bin.jar","'")
conn <- dbConnect(drv, "jdbc:mysql://localhost:3306/bd", "user", "password")

//Oracle
drv <- 
JDBC("oracle.jdbc.driver.OracleDriver","C:\\Temporal\\classes12.jar","'")
conn <- 
dbConnect(drv,"jdbc:oracle:thin:@192.168.1.70:1521:SDS22","user","password")

R always returns for oracle
 "Error en .local(drv, ...) : Unable to connect JDBC to 
jdbc:oracle:thin:@192.168.1.70:1521:SDS22"
and for mysql
 "Error en .local(drv, ...) : Unable to connect JDBC to 
jdbc:mysql://localhost:3306/bd"

And the function summary(drv) returns:
JDBCDriver
name = JDBC
driver.version = 0.1-1
DBI.version = 0.1-1
client.version = NA
max.connections = NA

Can you help me, please?

Another question: 

I try to compile ROracle and RMysql for windows but i need Rdll.lib and it need 
R.exp. Can you give me one of this files?

 
Regards.
Jose Sierra

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


Re: [Rd] extracting rows from a data frame by looping over the row names: performance issues

2007-03-05 Thread Greg Snow
The difference is in indexing by row number vs. indexing by row name.
It has long been known that names slow matricies down, some routines
make a copy of dimnames of a matrix, remove the dimnames, do the
computations with the matrix, then put the dimnames back on.  This can
speed things up quite a bit in some circumstances.  For your example,
indexing by number means jumping to a specific offset in the matrix,
indexing by name means searching through all the names and doing string
comparisons to find the match.  A 300 fold difference in speed is not
suprising.



-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -Original Message-
> From: Herve Pages [mailto:[EMAIL PROTECTED] 
> Sent: Friday, March 02, 2007 7:04 PM
> To: Greg Snow
> Cc: r-devel@r-project.org
> Subject: Re: [Rd] extracting rows from a data frame by 
> looping over the row names: performance issues
> 
> Hi Greg,
> 
> Greg Snow wrote:
> > Your 2 examples have 2 differences and they are therefore 
> confounded 
> > in their effects.
> > 
> > What are your results for:
> > 
> > system.time(for (i in 1:100) {row <-  dat[i, ] })
> > 
> > 
> > 
> 
> Right. What you suggest is even faster (and more simple):
> 
>   > mat <- matrix(rep(paste(letters, collapse=""), 5*30), ncol=5)
>   > dat <- as.data.frame(mat)
> 
>   > system.time(for (key in row.names(dat)[1:100]) { row <- 
> dat[key, ] })
>  user  system elapsed
>13.241   0.460  13.702
> 
>   > system.time(for (i in 1:100) { row <- sapply(dat, 
> function(col) col[i]) })
>  user  system elapsed
> 0.280   0.372   0.650
> 
>   > system.time(for (i in 1:100) {row <-  dat[i, ] })
>  user  system elapsed
> 0.044   0.088   0.130
> 
> So apparently here extracting with dat[i, ] is 300 times 
> faster than extracting with dat[key, ] !
> 
> > system.time(for (i in 1:100) dat["1", ])
>user  system elapsed
>  12.680   0.396  13.075
> 
> > system.time(for (i in 1:100) dat[1, ])
>user  system elapsed
>   0.060   0.076   0.137
> 
> Good to know!
> 
> Thanks a lot,
> H.
> 
> 
>

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


Re: [Rd] RJDBC

2007-03-05 Thread Simon Urbanek
Jose,

On Mar 5, 2007, at 7:39 AM, Jose Sierra wrote:

> I need help.
>
> I'm trying to connect with an Oracle DBMS and MySQL DBMS, I'm using
> RJDBC package.
>
> My code is the next:
>
> library('rJava')
> library('DBI')
> library('RJDBC')
>
> //Mysql
> drv <-
> JDBC("com.mysql.jdbc.Driver","C:\\Temporal\\mysql-connector- 
> java-3.0.9-stable-bin.jar","'")
>
> conn <- dbConnect(drv, "jdbc:mysql://localhost:3306/bd", "user",
> "password")
>
> //Oracle
> drv <-
> JDBC("oracle.jdbc.driver.OracleDriver","C:\\Temporal\ 
> \classes12.jar","'")
> conn <-
> dbConnect 
> (drv,"jdbc:oracle:thin:@192.168.1.70:1521:SDS22","user","password")
>
>
> R always returns for oracle
> "Error en .local(drv, ...) : Unable to connect JDBC to
> jdbc:oracle:thin:@192.168.1.70:1521:SDS22"
> and for mysql
> "Error en .local(drv, ...) : Unable to connect JDBC to
> jdbc:mysql://localhost:3306/bd"
>

It is very likely a problem with your DB connection or  
authentication. I have tested it with MySQL (I don't have Oracle) and  
it worked without problems. Please test it step-by-step to make sure  
that your DB is configured properly.

Unfortunately RJDBC doesn't pass non-fatal SQL errors back to the  
user, so connection problems are not easy to debug, but you can try  
this to show the connection problem:

dbCheck = function(url, user='', pwd='') {
  j = .jcall("java/sql/DriverManager", "Ljava/sql/Connection;",  
"getConnection", url, user, pwd, check=FALSE)
  x = .jgetEx()
  .jcheck()
  x
}

and use it like this:

 > dbCheck("jdbc:mysql://localhost/foo","user","pwd")
[1] "Java-Object{java.sql.SQLException: Access denied for user  
'user'@'localhost' (using password: YES)}"
 >
 > dbCheck("jdbc:mysql://localhost/foo","root","")
[1] "Java-Object{java.sql.SQLException: Unknown database 'foo'}"
 > dbCheck("jdbc:mysql://bar/foo","root","")

I'll see if I can provide some more helpful response in the dbConnect  
for the next release..


> Another question:
> I try to compile ROracle and RMysql for windows but i need Rdll.lib  
> and  it need R.exp.

No, you don't need those files, because R is linked directly. Simply  
follow the instructions for building R packages on Windows.

Cheers,
Simon

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


[Rd] non-blocking socketConnection

2007-03-05 Thread Chmielowski, Piotr2 [CAI]
In an R session I have

> c <-socketConnection("localhost", port=6011, blocking=F, server=T,
open="w+")

After I connect to the  server from, say, telnet 

% telnet localhost 6011

the socketConnection returns and gives a valid c. 

My problem is as follows : I would expect something like 

> readLines(con=c, n=1)

 to return immediately when reading from c non-blocking c, whether there
are any contents to be read or not. However, readLines only returns when
there is some input to be consumed, ie if in the telnet session I type
foo followed by newline. In short, readLines seems to be blocking even
though the connection is presumably non-blocking.

FYI, A "file" connection does behave as expected, but I do need the
socketConnection here. I am Running R 2.2.0-2.fc4, on Linux
2.6.11-1.1369.

Any help would be greatly appreciated.

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


Re: [Rd] typo in reshape.Rd

2007-03-05 Thread Duncan Murdoch
On 2/28/2007 11:41 PM, Stephen D. Weigand wrote:
> The 3 lines below are from paragraph 4 of \details in reshape.Rd.
> In line [2], a space is needed before "where" and the "to" at the
> end of the line should be removed.
> 
> [1]these names.  The default is variable names like \code{x.1},
> [2]\code{x.2},where \code{split=list(regexp="\\.",include=FALSE)} to
> [3]specifies to split at the dot and drop it from the name. To have 
> alphabetic

Fixed, thanks.

Duncan Murdoch

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


Re: [Rd] typo in R-lang.texi

2007-03-05 Thread Duncan Murdoch
On 2/25/2007 5:49 AM, Stephen Eglen wrote:
> Hi, 
> 
> R-lang.texi line 2020/1 currently says:
> 
>   This allows, e.g., a 
>   local variable in a function to have the same name AS a global object. 
> 
> The word "AS" is missing in that sentence.
> 
> (Line number according to
>  https://svn.r-project.org/R/trunk/doc/manual/R-lang.texi)

Fixed, thanks.

Duncan Murdoch

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


Re: [Rd] typo in nls.Rd

2007-03-05 Thread Duncan Murdoch
On 2/26/2007 6:43 AM, Katharine Mullen wrote:
 > in R version 2.5.0 Under development (unstable) (2007-02-25 r40804),
 > the `formula' entry in the `arguments' section of nls.Rd (L25-26) reads
 >
 > \item{formula}{a nonlinear model \link{formula} including variables and
 > parameters.  Will be coerced to a formula is necessary.}
 >
 > `is' should be `if'.

Fixed, thanks.

Duncan Murdoch

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


Re: [Rd] non-blocking socketConnection

2007-03-05 Thread Simon Urbanek

On Mar 5, 2007, at 12:05 PM, Chmielowski, Piotr2 [CAI] wrote:

> In an R session I have
>
>> c <-socketConnection("localhost", port=6011, blocking=F, server=T,
> open="w+")
>
> After I connect to the  server from, say, telnet
>
> % telnet localhost 6011
>
> the socketConnection returns and gives a valid c.
>
> My problem is as follows : I would expect something like
>
>> readLines(con=c, n=1)
>
>  to return immediately when reading from c non-blocking c, whether  
> there
> are any contents to be read or not. However, readLines only returns  
> when
> there is some input to be consumed, ie if in the telnet session I type
> foo followed by newline. In short, readLines seems to be blocking even
> though the connection is presumably non-blocking.
>
> FYI, A "file" connection does behave as expected, but I do need the
> socketConnection here. I am Running R 2.2.0-2.fc4, on Linux
> 2.6.11-1.1369.
>
> Any help would be greatly appreciated.
>

if (socketSelect(list(c),,0)) readLines(c, 1)

Cheers,
Simon

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


Re: [Rd] Problem using callNextMethod() in S4

2007-03-05 Thread cstrato
Dear Martin

Thank you for this extensive explanation!
I hope that I have understood it, but I will realize it as I proceed with my
package. Now, my example works as I have expected it to work, great!

One problem that I face is lack of extensive explanation of S4 classes,
especially with respect to inheritance.  (Neither the tutorial "S4 Classes
in 15 pages" nor the book "S Programming" are really helpful.) Most
of the time I study the code in BioBase and affy, since there are not
many packages available using S4 and inheritance.
Your explanation below is a good example, how a good S4 tutorial
should cover these issues.

Best regards
Christian

Martin Morgan wrote:
> In this method...
>
> setMethod("initialize", "baseClass",
>function(.Object, ...) {
> print("---initialize:baseClass---")
> #.Object <- callNextMethod();
>   strg <- [EMAIL PROTECTED];
> print(paste("base:strg = ", strg))
>   if (strg == "") {
>  [EMAIL PROTECTED] <- as.character(getwd());
>   }#if
>   if (substr(strg, nchar(strg), nchar(strg)) == "/") {
>  [EMAIL PROTECTED] <- substr(strg, 0, nchar(strg)-1);
>   }#if
> print(paste("base:mydir = ", [EMAIL PROTECTED]))
> .Object <- callNextMethod();
> .Object;
>}
> )#initialize
>
> the argument '...' includes the argument mydir="". Later, when you
> .Object <- callNextMethod(), it invokes the 'next' method with the
> same argument, i.e., with mydir="". This causes the 'mydir' slot to be
> initialized with "", triggering the validity error. You can see this
> more clearly in the following, where the provided argument x=10:1
> overrides the assignment in initialize:
>
>   
>> setClass("A", representation=representation(x="numeric"))
>> 
> [1] "A"
>   
>> setMethod("initialize", "A",
>> 
> +   function(.Object, ...) {
> +   [EMAIL PROTECTED] <- 1:10
> +   callNextMethod()
> +   })
> [1] "initialize"
>
>   
>> new("A", x=10:1)
>> 
> An object of class "A"
> Slot "x":
>  [1] 10  9  8  7  6  5  4  3  2  1
>
> One solution is to name any arguments you're going to manipulate in
> the initialize method, and then make sure the correct arguments are
> passed to callNextMethod. You'll probably want to provide a sensible
> default argument to mydir, so that user doesn't have to do anything
> clever (like remember to pass "") to get the default behavior. Here's
> what I end up with:
>
> setMethod("initialize", "baseClass",
>   function(.Object, mydir=as.character(getwd()), ...) {
>   if (substr(mydir, nchar(mydir), nchar(mydir)) == "/") {
>   mydir <- substr(mydir, 0, nchar(mydir)-1)
>   }
>   callNextMethod(.Object, mydir=mydir, ...);
>   })
>
> setMethod("initialize", "derivedClass",
>   function(.Object, mytitle="MyTitle", ...) {
>   callNextMethod(.Object, mytitle=mytitle, ...)
>   })
>
> Another solution is to follow the convention where callNextMethod()
> comes first (constructing a valid object!), and your initialize method
> then fills in slots with the appropriate values.
>
> One interesting part of your example is that new('derivedClass') does
> NOT cause a validity error, even though the object is invalid
> ('myname' is ""; also, none of your validity method messages are
> printed)! Apparently, the assumption is that you (the programmer, as
> opposed to the user) are not going to create an invalid object by
> default.
>
> Also, take a look at the initialize method that R has constructed for
> derivedClass:
>
>   
>> getMethod("initialize", "derivedClass")
>> 
> Method Definition:
>
> function (.Object, ...) 
> {
> .local <- function (.Object, mytitle = "MyTitle", ...) 
> {
> callNextMethod(.Object, mytitle = mytitle, ...)
> }
> .local(.Object, ...)
> }
>
> Signatures:
> .Object   
> target  "derivedClass"
> defined "derivedClass"
>
> Notice how the function is defined in terms of .Object and  The
> named arguments not present in the generic signature (i.e., 'mytitle')
> are 'hidden' in the .local function definition. By the time
> callNextMethod() has been evaluated, '...' does NOT include
> 'mytitle'. I think this is why you must explicitly include any named
> arguments you want to pass to callNextMethod -- the default is to
> callNextMethod with the generic signature, but with symbols (.Object,
> ...) taking their current value. Here's a simpler illustration:
>
> setClass("A", representation=representation(x="numeric"))
> setMethod("initialize", "A",
>   function(.Object, x, ...) callNextMethod())
>
> This leads to the perhaps unexpected outcome
>
>   
>> new("A", x=10:1)
>> 
> An object of class "A"
> Slot "x":
> numeric(0)
>
> I say unexpected because, if there was no initialize method, or if the
> initialize method were written without 'x' in the signature, then the
> argument 'x' would be used to fill the slot:x.
>
> Here's the soluti

[Rd] Periods in package names?

2007-03-05 Thread Henrik Bengtsson
Hi,

is it ok to have more than one period in a package name, e.g. aroma.light.bioc?

I remember there was once a limitation/a recommendation that one
should use at most one period in a package name.  I just browsed
"Writing R Extensions" (for R v2.4.1) and scanned it for words
"period" and "dot", and I cannot find this limitation anymore, but
only:

"The Package and Version fields give the name and the version of the
package, respectively. The name should consist of letters, numbers,
and the dot character and start with a letter. [...]"

Best

Henrik

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


Re: [Rd] fortune() in .Rprofile conflicts with R CMD INSTALL

2007-03-05 Thread Kurt Hornik
> Kurt Hornik writes:

> Gregor Gorjanc writes:
>> Seth Falcon  fhcrc.org> writes:
>>> The quick fix for you is, I believe,
>>> 
>>> if (interactive()) {
>>> library(fortunes)
>>> fortune()
>>> detach("package:fortunes")
>>> }
>>> 
>>> Whether something could be changed so that R's output doesn't confuse
>>> itself and gcc when doing R CMD INSTALL, seems like it should be
>>> possible.

>> Yes, this solves my! problem. I do not know what is causing this
>> behaviour.

> Well, r-devel's src/scripts/INSTALL.in now has

> if test -z "${lib}"; then
>   lib=`echo "cat(.libPaths()[1])" | \
> R_DEFAULT_PACKAGES=NULL "${R_EXE}" --no-save --slave`
>   message "Installing to library '$lib'"

> so we need to find a way to "just get" the result of cat(.libPaths()[1])
> into $lib as intended.

> One idea might be ensuring that this gets into the last line on its own,
> and then taking $lib as the last line of what we got ...

I think I found (and committed) a solution for this.

Best
-k

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