[Rd] "Panel Data Unit Root tests"

2009-01-30 Thread Jose Iparraguirre D'Elia
I could not find a package to run panel data unit root tests in R (there's a 
STATA module, though - PANELUNIT- and routines for Sarno and Taylor's MADF 
test, Levin-Lin-Chu's test, Im-Pesaran-Shin's Test, etc, to do this). 

Hence, I am toying with the idea of having a go at writing up one for R, but 
would like to know whether anyone is already working on this.

 

José

 

 

 

Mr José Luis Iparraguirre

Senior Research Economist

Economic Research Institute of Northern Ireland

2 -14 East Bridge Street

Belfast BT1 3NQ

Northern Ireland

United Kingdom

 

Tel: +44 (0)28 9072 7365

 


[[alternative HTML version deleted]]

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


Re: [Rd] length of POSIXlt object (PR#13482)

2009-01-30 Thread Patrick Burns

'The R Inferno' page 93 and page 99.


Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of "The R Inferno" and "A Guide for the Unwilling S User")

twoutop...@gmail.com wrote:

The length() of a POSIXlt object is given as 9 regardless of the actual
length. For example:

  

make.date.time


function (year=c(2006,2006),month=c(8,8),day=2:5,hour=13,minute=45)
{# convert year, etc., into POSIXlt object
#
d=as.character(make.date(year,month,day))
t=paste(hour,minute,sep=":")
as.POSIXlt(paste(d,t))
}
  

t=make.date.time()
t


[1] "2006-08-02 13:45:00" "2006-08-03 13:45:00" "2006-08-04 13:45:00"
[4] "2006-08-05 13:45:00"
  

length(t)


[1] 9
  

t[1]


[1] "2006-08-02 13:45:00"
  

length(t[1])


[1] 9






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


[Rd] Methods not loaded in R-Devel vs 2.8.1

2009-01-30 Thread Pfaff, Bernhard Dr.
Dear list-member,

I am currently developing a package with S4 classes. The NAMESPACE and 
DESCRIPTION is printed below. Within this package I have set a method 
"residuals" for two classes. In version 2.8.1 these two are reported whereas in 
R-Devel (2009-01-28 r47766). What have I missed? What has changed and how can I 
rectify the issue? Your help and pointers are welcome.


For 2.8.1:
**

> library(gogarch)
Loading required package: fGarch
Loading required package: timeDate
Loading required package: timeSeries
Loading required package: fBasics
Loading required package: MASS
Warning message:
package 'gogarch' was built under R version 2.9.0 
> showMethods("residuals")
Function: residuals (package stats)
object="ANY"
object="fGARCH"
object="Goestml"
object="GoGARCH"

> getMethod("residuals", "GoGARCH")
Method Definition:

function (object, ...) 
{
.local <- function (object, standardize = FALSE) 
{
m <- ncol(obj...@x)
n <- nrow(obj...@x)
resl <- lapply(obj...@models, residuals, standardize = standardize)
resm <- matrix(c(unlist(resl)), ncol = m, nrow = n)
ynames <- paste("y", 1:2, sep = "")
colnames(resm) <- ynames
rownames(resm) <- rownames(obj...@x)
return(resm)
}
.local(object, ...)
}


Signatures:
object   
target  "GoGARCH"
defined "GoGARCH"
> sessionInfo() 
R version 2.8.1 (2008-12-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  datasets  utils grDevices methods   base 

other attached packages:
[1] gogarch_0.2-8 fGarch_280.75 fBasics_280.74MASS_7.2-44  
[5] timeSeries_290.79 timeDate_290.81   fortunes_1.3-6   
> 


For R-Devel:

> library(gogarch)
Loading required package: fGarch
Loading required package: timeDate
Loading required package: timeSeries
Loading required package: fBasics
Loading required package: MASS
> showMethods("residuals")
Function: residuals (package stats)
object="ANY"
object="fGARCH"

> getMethod("residuals", "GoGARCH")
Error in getMethod("residuals", "GoGARCH") : 
  No method found for function "residuals" and signature GoGARCH
> sessionInfo()
R version 2.9.0 Under development (unstable) (2009-01-28 r47766) 
i386-pc-mingw32 

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  grDevices datasets  utils methods   base 

other attached packages:
[1] gogarch_0.2-8 fGarch_280.75 fBasics_280.74MASS_7.2-44  
[5] timeSeries_290.79 timeDate_290.81   fortunes_1.3-6   

loaded via a namespace (and not attached):
[1] grid_2.9.0  lattice_0.17-17 nlme_3.1-89 urca_1.2-2 
[5] vars_1.4-4 
> 


DESCRIPTION:

Package: gogarch
Version: 0.2-8
Type: Package
Title: Generalized Orthogonal GARCH (GO-GARCH) models
Date: 2009-01-30
Author: Bernhard Pfaff
Maintainer: Bernhard Pfaff 
Depends: R (>= 2.7.0), stats, methods, fGarch
Suggests: vars
Description: Implementation of the GO-GARCH model class. 
License: GPL (>= 2)
LazyLoad: yes
LazyLoad: yes

NAMESPACE:
**
## Import packages
import(methods)

## Import functions
importFrom(stats, coef, logLik, residuals)

## Classes   
exportClasses(Goestml, GoGARCH, Goinit, Orthom)

## Methods
exportMethods(angles, cvar, ccor, ccov, coef, converged, goest, logLik, M, 
print, show, t, residuals)

## Functions
export(gogarch, goinit, gollh, gotheta, Rd2, UprodR, unvech, validOrthomObject, 
validGoinitObject)



Dr. Bernhard Pfaff
Director
Invesco Quantitative Strategies International

Invesco Asset Management Deutschland GmbH
Bleichstrasse 60-62
D-60313 Frankfurt am Main

Tel: +49 (0)69 29807 230
Fax: +49 (0)69 29807 178
www.institutional.invesco.com
Email: bernhard_pf...@fra.invesco.com

Geschäftsführer: Karl Georg Bayer, Bernhard Langer, Dr. Jens Langewand, 
Alexander Lehmann, Christian Puschmann
Handelsregister: Frankfurt am Main, HRB 28469
Sitz der Gesellschaft: Frankfurt am Main
 
*
Confidentiality Note: The information contained in this ...{{dropped:10}}

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


Re: [Rd] Methods not loaded in R-Devel vs 2.8.1

2009-01-30 Thread Pfaff, Bernhard Dr.
Sorry for bothering the list one more time. When I run the code with RGui.exe 
the methods are shown in both versions of R and everything is fine. However, 
there is a difference whence the showMethods("residuals") is invoked via 
Rterm.exe. Here, neither under 2.8.1 nor R-Devel are the methods reported for 
"GoGARCH" and "Goestml". I have the following in my .emacs:

(setq inferior-R-program-name "Q:/Shared/Applications/R/R-2.8.1/bin/Rterm.exe")
(setq inferior-R-args "--internet2")
(setq ess-ask-for-ess-directory nil)

and the result is the same:

> library(gogarch)
Loading required package: fGarch
Loading required package: timeDate
Loading required package: timeSeries
Loading required package: fBasics
Loading required package: MASS
Warning message:
package 'gogarch' was built under R version 2.9.0 
> showMethods("residuals")
Function: residuals (package stats)
object="ANY"
object="fGARCH"

> sessionInfo()
R version 2.8.1 (2008-12-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  datasets  utils grDevices methods   base 

other attached packages:
[1] gogarch_0.2-9 fGarch_280.75 fBasics_280.74MASS_7.2-44  
[5] timeSeries_290.79 timeDate_290.81   fortunes_1.3-6   

loaded via a namespace (and not attached):
[1] grid_2.8.1  lattice_0.17-17 nlme_3.1-89 urca_1.2-2 
[5] vars_1.4-4 
> getMethod("residuals", "GoGARCH")
Error in getMethod("residuals", "GoGARCH") : 
  No method found for function "residuals" and signature GoGARCH
> 

So now my question is rather about the difference between RGui.exe and 
Rterm.exe with respect to the method map.

Best,
Bernhard



Dr. Bernhard Pfaff
Director
Invesco Quantitative Strategies International

Invesco Asset Management Deutschland GmbH
Bleichstrasse 60-62
D-60313 Frankfurt am Main

Tel: +49 (0)69 29807 230
Fax: +49 (0)69 29807 178
www.institutional.invesco.com
Email: bernhard_pf...@fra.invesco.com

Geschäftsführer: Karl Georg Bayer, Bernhard Langer, Dr. Jens Langewand, 
Alexander Lehmann, Christian Puschmann
Handelsregister: Frankfurt am Main, HRB 28469
Sitz der Gesellschaft: Frankfurt am Main
  

>-Ursprüngliche Nachricht-
>Von: r-devel-boun...@r-project.org 
>[mailto:r-devel-boun...@r-project.org] Im Auftrag von Pfaff, 
>Bernhard Dr.
>Gesendet: Freitag, 30. Januar 2009 12:13
>An: r-devel@r-project.org
>Betreff: [Rd] Methods not loaded in R-Devel vs 2.8.1
>
>Dear list-member,
>
>I am currently developing a package with S4 classes. The 
>NAMESPACE and DESCRIPTION is printed below. Within this 
>package I have set a method "residuals" for two classes. In 
>version 2.8.1 these two are reported whereas in R-Devel 
>(2009-01-28 r47766). What have I missed? What has changed and 
>how can I rectify the issue? Your help and pointers are welcome.
>
>
>For 2.8.1:
>**
>
>> library(gogarch)
>Loading required package: fGarch
>Loading required package: timeDate
>Loading required package: timeSeries
>Loading required package: fBasics
>Loading required package: MASS
>Warning message:
>package 'gogarch' was built under R version 2.9.0 
>> showMethods("residuals")
>Function: residuals (package stats)
>object="ANY"
>object="fGARCH"
>object="Goestml"
>object="GoGARCH"
>
>> getMethod("residuals", "GoGARCH")
>Method Definition:
>
>function (object, ...) 
>{
>.local <- function (object, standardize = FALSE) 
>{
>m <- ncol(obj...@x)
>n <- nrow(obj...@x)
>resl <- lapply(obj...@models, residuals, standardize = 
>standardize)
>resm <- matrix(c(unlist(resl)), ncol = m, nrow = n)
>ynames <- paste("y", 1:2, sep = "")
>colnames(resm) <- ynames
>rownames(resm) <- rownames(obj...@x)
>return(resm)
>}
>.local(object, ...)
>}
>
>
>Signatures:
>object   
>target  "GoGARCH"
>defined "GoGARCH"
>> sessionInfo() 
>R version 2.8.1 (2008-12-22) 
>i386-pc-mingw32 
>
>locale:
>LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_
>MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252
>
>attached base packages:
>[1] stats graphics  datasets  utils grDevices methods  
> base 
>
>other attached packages:
>[1] gogarch_0.2-8 fGarch_280.75 fBasics_280.74
>MASS_7.2-44  
>[5] timeSeries_290.79 timeDate_290.81   fortunes_1.3-6   
>> 
>
>
>For R-Devel:
>
>> library(gogarch)
>Loading required package: fGarch
>Loading required package: timeDate
>Loading required package: timeSeries
>Loading required package: fBasics
>Loading required package: MASS
>> showMethods("residuals")
>Function: residuals (package stats)
>object="ANY"
>object="fGARCH"
>
>> getMethod("residuals", "GoGARCH")
>Error in getMethod("residuals", "GoGARCH") : 
>  No method found for function "residuals" and signature GoGARCH
>> sessionInfo()
>R version 2.9.0 Under development (unstable) (2009-01

Re: [Rd] Methods not loaded in R-Devel vs 2.8.1

2009-01-30 Thread Prof Brian Ripley
I don't believe this is Rgui vs Rterm either.  More likely it is in 
the startup files for the two sessions, e.g. the library search paths.


Try using --vanilla.

On Fri, 30 Jan 2009, Pfaff, Bernhard Dr. wrote:


Sorry for bothering the list one more time. When I run the code with RGui.exe the methods are shown in both 
versions of R and everything is fine. However, there is a difference whence the 
showMethods("residuals") is invoked via Rterm.exe. Here, neither under 2.8.1 nor R-Devel are the 
methods reported for "GoGARCH" and "Goestml". I have the following in my .emacs:

(setq inferior-R-program-name "Q:/Shared/Applications/R/R-2.8.1/bin/Rterm.exe")
(setq inferior-R-args "--internet2")
(setq ess-ask-for-ess-directory nil)

and the result is the same:


library(gogarch)

Loading required package: fGarch
Loading required package: timeDate
Loading required package: timeSeries
Loading required package: fBasics
Loading required package: MASS
Warning message:
package 'gogarch' was built under R version 2.9.0

showMethods("residuals")

Function: residuals (package stats)
object="ANY"
object="fGARCH"


sessionInfo()

R version 2.8.1 (2008-12-22)
i386-pc-mingw32

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  datasets  utils grDevices methods   base

other attached packages:
[1] gogarch_0.2-9 fGarch_280.75 fBasics_280.74MASS_7.2-44
[5] timeSeries_290.79 timeDate_290.81   fortunes_1.3-6

loaded via a namespace (and not attached):
[1] grid_2.8.1  lattice_0.17-17 nlme_3.1-89 urca_1.2-2
[5] vars_1.4-4

getMethod("residuals", "GoGARCH")

Error in getMethod("residuals", "GoGARCH") :
 No method found for function "residuals" and signature GoGARCH




So now my question is rather about the difference between RGui.exe 
and Rterm.exe with respect to the method map.


Best,
Bernhard



Dr. Bernhard Pfaff
Director
Invesco Quantitative Strategies International

Invesco Asset Management Deutschland GmbH
Bleichstrasse 60-62
D-60313 Frankfurt am Main

Tel: +49 (0)69 29807 230
Fax: +49 (0)69 29807 178
www.institutional.invesco.com
Email: bernhard_pf...@fra.invesco.com

Geschäftsführer: Karl Georg Bayer, Bernhard Langer, Dr. Jens Langewand, 
Alexander Lehmann, Christian Puschmann
Handelsregister: Frankfurt am Main, HRB 28469
Sitz der Gesellschaft: Frankfurt am Main



-Ursprüngliche Nachricht-
Von: r-devel-boun...@r-project.org
[mailto:r-devel-boun...@r-project.org] Im Auftrag von Pfaff,
Bernhard Dr.
Gesendet: Freitag, 30. Januar 2009 12:13
An: r-devel@r-project.org
Betreff: [Rd] Methods not loaded in R-Devel vs 2.8.1

Dear list-member,

I am currently developing a package with S4 classes. The
NAMESPACE and DESCRIPTION is printed below. Within this
package I have set a method "residuals" for two classes. In
version 2.8.1 these two are reported whereas in R-Devel
(2009-01-28 r47766). What have I missed? What has changed and
how can I rectify the issue? Your help and pointers are welcome.


For 2.8.1:
**


library(gogarch)

Loading required package: fGarch
Loading required package: timeDate
Loading required package: timeSeries
Loading required package: fBasics
Loading required package: MASS
Warning message:
package 'gogarch' was built under R version 2.9.0

showMethods("residuals")

Function: residuals (package stats)
object="ANY"
object="fGARCH"
object="Goestml"
object="GoGARCH"


getMethod("residuals", "GoGARCH")

Method Definition:

function (object, ...)
{
   .local <- function (object, standardize = FALSE)
   {
   m <- ncol(obj...@x)
   n <- nrow(obj...@x)
   resl <- lapply(obj...@models, residuals, standardize =
standardize)
   resm <- matrix(c(unlist(resl)), ncol = m, nrow = n)
   ynames <- paste("y", 1:2, sep = "")
   colnames(resm) <- ynames
   rownames(resm) <- rownames(obj...@x)
   return(resm)
   }
   .local(object, ...)
}


Signatures:
   object
target  "GoGARCH"
defined "GoGARCH"

sessionInfo()

R version 2.8.1 (2008-12-22)
i386-pc-mingw32

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_
MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  datasets  utils grDevices methods
base

other attached packages:
[1] gogarch_0.2-8 fGarch_280.75 fBasics_280.74
MASS_7.2-44
[5] timeSeries_290.79 timeDate_290.81   fortunes_1.3-6





For R-Devel:


library(gogarch)

Loading required package: fGarch
Loading required package: timeDate
Loading required package: timeSeries
Loading required package: fBasics
Loading required package: MASS

showMethods("residuals")

Function: residuals (package stats)
object="ANY"
object="fGARCH"


getMethod("residuals", "GoGARCH")

Error in getMethod("residuals", "GoGARCH") :
 No method found for function "residuals" and signature GoGARCH

sessionInfo()

R version 2.9.0 Unde

Re: [Rd] "Panel Data Unit Root tests"

2009-01-30 Thread Achim Zeileis

Jose,

this is not the list for asking questions like this. You should ask on 
R-help or (alternatively!) R-SIG-Finance would be a good place to ask.


I could not find a package to run panel data unit root tests in R 
(there's a STATA module, though - PANELUNIT- and routines for Sarno and 
Taylor's MADF test, Levin-Lin-Chu's test, Im-Pesaran-Shin's Test, etc, 
to do this).


Hence, I am toying with the idea of having a go at writing up one for R, 
but would like to know whether anyone is already working on this.


I think that there's currently no package for this on CRAN but I might be 
wrong. But there's a chance that someone on the SIG has code for this...


Best,
Z

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


Re: [Rd] (PR#13487) Segfault when mistakenly calling [.data.frame

2009-01-30 Thread Christian Brechbühler
On Thu, Jan 29, 2009 at 4:44 PM, Prof Brian Ripley wrote:

> What did your actual application do?  This seems a very strange thing to
> do, and the segfault is in trying to construct the traceback.
>
> Only by using do.call on the object (and not even by name) do I get this
> error.  E.g.
>
>  `[.data.frame`(1:10, 3)
>>
> Error in NextMethod("[") : object not specified
>
>> do.call("[.data.frame", list(1:10, 3))
>>
> Error in NextMethod("[") : object not specified
>
> are fine.
>
> Obviously it would be nice to fix this, but I'd like to understand the
> actual circumstances: there is more to it than the subject line.


Yes, there is more.  For reporting the problem, we tried to pare it down to
a concise, self-contained test case.

My boss was debugging an issue in our R code.  We have our own "["
functions, because stock R drops names when subscripting.  To bypass our
now-suspect functions and get the "real" subscripting method, he used "get"
from package:base.  He was examining a large object, and believing it was a
data frame, chose "[.data.frame".  As it turns out, that object was not a
data frame, and he got an unexpected segfault.  I think it was a matrix.
But it doesn't matter -- a vector as in the test case will give the same.

We have since fixed the bug in our replacement subscripting function, so the
issue might not affect us any more.

Thanks,
/Christian


> On Thu, 29 Jan 2009, brechbueh...@gmail.com wrote:
>
>  Full_Name: Christian Brechbuehler
>> Version: 2.7.2, 2.8.1
>> OS: linux-gnu
>>
>> If we mistakenly believe the object is a data frame (as we did in a much
>> more
>> complicated real situation), this happens:
>>
>>  > do.call(get("[.data.frame",pos="package:base"),list(1:10,3))
>>  Error in NextMethod("[") :
>>no calling generic was found: was a method called directly?
>>
>>   *** caught segfault ***
>>  address (nil), cause 'unknown'
>>
>>  Process R:2 segmentation fault (core dumped) at Thu Jan 29 09:26:29 2009
>>
>> The Error message is appropriate.  But the segmentation fault is
>> unexpected.
>>
>

[[alternative HTML version deleted]]

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


Re: [Rd] (PR#13487) Segfault when mistakenly calling [.data.frame

2009-01-30 Thread Simon Urbanek


On Jan 30, 2009, at 10:30 , Christian Brechbühler wrote:

On Thu, Jan 29, 2009 at 4:44 PM, Prof Brian Ripley >wrote:


What did your actual application do?  This seems a very strange  
thing to

do, and the segfault is in trying to construct the traceback.

Only by using do.call on the object (and not even by name) do I get  
this

error.  E.g.

`[.data.frame`(1:10, 3)



Error in NextMethod("[") : object not specified


do.call("[.data.frame", list(1:10, 3))


Error in NextMethod("[") : object not specified

are fine.

Obviously it would be nice to fix this, but I'd like to understand  
the

actual circumstances: there is more to it than the subject line.



Yes, there is more.  For reporting the problem, we tried to pare it  
down to

a concise, self-contained test case.

My boss was debugging an issue in our R code.  We have our own "["
functions, because stock R drops names when subscripting.


... if you tell it to do so, yes. If you tell it to not do that, it  
won't ... ever tried drop=FALSE ?


Cheers,
S



To bypass our
now-suspect functions and get the "real" subscripting method, he  
used "get"
from package:base.  He was examining a large object, and believing  
it was a
data frame, chose "[.data.frame".  As it turns out, that object was  
not a
data frame, and he got an unexpected segfault.  I think it was a  
matrix.
But it doesn't matter -- a vector as in the test case will give the  
same.


We have since fixed the bug in our replacement subscripting  
function, so the

issue might not affect us any more.

Thanks,
/Christian



On Thu, 29 Jan 2009, brechbueh...@gmail.com wrote:

Full_Name: Christian Brechbuehler

Version: 2.7.2, 2.8.1
OS: linux-gnu

If we mistakenly believe the object is a data frame (as we did in  
a much

more
complicated real situation), this happens:


do.call(get("[.data.frame",pos="package:base"),list(1:10,3))

Error in NextMethod("[") :
  no calling generic was found: was a method called directly?

 *** caught segfault ***
address (nil), cause 'unknown'

Process R:2 segmentation fault (core dumped) at Thu Jan 29  
09:26:29 2009


The Error message is appropriate.  But the segmentation fault is
unexpected.





[[alternative HTML version deleted]]

__
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] (PR#13487) Segfault when mistakenly calling [.data.frame

2009-01-30 Thread Tony Plate

Simon Urbanek wrote:


On Jan 30, 2009, at 10:30 , Christian Brechbühler wrote:

On Thu, Jan 29, 2009 at 4:44 PM, Prof Brian Ripley 
wrote:


What did your actual application do?  This seems a very strange 
thing to

do, and the segfault is in trying to construct the traceback.

Only by using do.call on the object (and not even by name) do I get 
this

error.  E.g.

`[.data.frame`(1:10, 3)



Error in NextMethod("[") : object not specified


do.call("[.data.frame", list(1:10, 3))


Error in NextMethod("[") : object not specified

are fine.

Obviously it would be nice to fix this, but I'd like to understand the
actual circumstances: there is more to it than the subject line.



Yes, there is more.  For reporting the problem, we tried to pare it 
down to

a concise, self-contained test case.

My boss was debugging an issue in our R code.  We have our own "["
functions, because stock R drops names when subscripting.


... if you tell it to do so, yes. If you tell it to not do that, it 
won't ... ever tried drop=FALSE ?
The common situation I have (which might be the same as the OP's) is 
wanting to get a vector from a data frame, and having the rownames of 
the dataframe become the names on the vector.


With matrix, the behavior I want is the default behavior, e.g.,
> x <- cbind(a=c(x=1,y=2,z=3),b=4:6)
> x
 a b
x 1 4
y 2 5
z 3 6
> x[,1]
x y z
1 2 3

But with a data frame, subscripting returns a vector with no names:
> xd <- as.data.frame(x)
> xd[,1]
[1] 1 2 3

One can use drop=FALSE, but then you've still got a data frame, not a 
vector:

> (xd1 <- xd[,1,drop=FALSE])
 a
x 1
y 2
z 3

The simplest way I know to get a named vector is to use as.matrix on the 
one-column dataframe:

> as.matrix(xd1)[,1]
x y z
1 2 3
>
(Which works fine except in the case where xd1 has only one row...)

And BTW, am I missing something, or does the behavior of drop() not 
conform to the description in ?drop:

> Value:
> If 'x' is an object with a 'dim' attribute (e.g., a matrix or
> 'array'), then 'drop' returns an object like 'x', but with any
> extents of length one removed.  Any accompanying 'dimnames'
> attribute is adjusted and returned with 'x': if the result is a
> vector the 'names' are taken from the 'dimnames' (if any).  If the
> result is a length-one vector, the names are taken from the first
> dimension with a dimname.

How is this last sentence consistent with the following behavior?
> dimnames(x[1,1,drop=F])
[[1]]
[1] "x"

[[2]]
[1] "a"

> drop(x[1,1,drop=F])
[1] 1
>
From the description in "Value:" in ?drop, I would have expected above 
result to have the name "x" (the name from the first dimension with a 
dimname).


> sessionInfo()
R version 2.8.1 (2008-12-22)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252


attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base
>


-- Tony Plate


Cheers,
S



To bypass our
now-suspect functions and get the "real" subscripting method, he used 
"get"
from package:base.  He was examining a large object, and believing it 
was a
data frame, chose "[.data.frame".  As it turns out, that object was 
not a

data frame, and he got an unexpected segfault.  I think it was a matrix.
But it doesn't matter -- a vector as in the test case will give the 
same.


We have since fixed the bug in our replacement subscripting function, 
so the

issue might not affect us any more.

Thanks,
/Christian



On Thu, 29 Jan 2009, brechbueh...@gmail.com wrote:

Full_Name: Christian Brechbuehler

Version: 2.7.2, 2.8.1
OS: linux-gnu

If we mistakenly believe the object is a data frame (as we did in a 
much

more
complicated real situation), this happens:


do.call(get("[.data.frame",pos="package:base"),list(1:10,3))

Error in NextMethod("[") :
  no calling generic was found: was a method called directly?

 *** caught segfault ***
address (nil), cause 'unknown'

Process R:2 segmentation fault (core dumped) at Thu Jan 29 09:26:29 
2009


The Error message is appropriate.  But the segmentation fault is
unexpected.





[[alternative HTML version deleted]]

__
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



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


Re: [Rd] In Rd: \describe \itemize and \item

2009-01-30 Thread Nicholas L Crookston
Duncan Murdoch  wrote on 01/29/2009 07:14:11 PM:

> On 29/01/2009 5:22 PM, Nicholas L Crookston wrote:
> > I rebuilt a test version of my yaImpute package using Uwe Ligges' 
windows
> > build service.
> > I got this reply: Check result: OK
> > R version 2.9.0 Under development (unstable) (2009-01-27 r47756)
> >
> > Here is the issue: I have the following construct in help files (this
> > example relates to "data"):
> >
> > \format{
> >   A data frame with 847 rows and 29 columns: \cr\cr
> >   Ground based measurements of trees (Y-variables):
> >   \itemize{
> >  \item{TopHt}{Height of tallest trees (ft)}
> >  \item{LnVolL}{Log of the volume \eqn{(ft^3/acre)} of western 
larch}
> >  .. many lines deleted ..
> >  \item{LnVolPP}{Log of the volume \eqn{(ft^3/acre)} of ponderosa 
pine}
> >  \item{CCover}{Canopy cover (percent)}
> >   }
> >   Geographic Location, Slope, and Aspect (X-variables):
> >   \itemize{
> > \item{utmx}{UTM easting at plot center}
> > \item{utmy}{UTM northing at plot center}
> > .. many lines deleted ..
> > \item{elevm}{Mean elevation (ft) above sea level over plot}
> > \item{slpsinaspm}{Mean of slope (proportion) times the sine of 
aspect}
> >   }
> > .. many lines deleted ..
> > }
> >
> > What I get in the help file is:
> > =
> > Format  
> > A data frame with 847 rows and 29 columns:
> >
> > Ground based measurements of trees (Y-variables):
> >
> >TopHt
> >   Height of tallest trees (ft)
> >LnVolL
> >   Log of the volume (ft^3/acre) of western larch
> > = ..and so on
> > [I've inserted 3 spaces to mimic tabs in this illustration]
> >
> > I would expect (and I used to get) something like this:
> > =
> > Ground based measurements of trees (Y-variables):
> >
> >TopHt   Height of tallest trees (ft)
> >LnVolL  Log of the volume (ft^3/acre) of western larch
> > =
> >

> I think we need more info to comment on.  Is this file one of the ones
> in the yaImpute package on CRAN, or is it unreleased?  Is the Rd file
> available for us to look at?  Does the man page look different in 2.8.1
> from what you expect (there haven't been serious changes there), or only
> in R-devel (2.9.0)?  2.6.2 is pretty old, but I don't think any of the
> requested changes should be incompatible with it.

> Duncan Murdoch

The problem is in an unreleased version built in the development 
environment.
The entire unreleased package can be found at this temporary location: 
http://forest.moscowfsl.wsu.edu/gems/yaImpute_1.0-8.tar.gz

The original is on CRAN (version 1.0-7). It worked under the old parser, 
but
not using parser 2 (the warnings on CRAN point to the problem). 
You can see the difference by looking at TallyLake.Rd 
in the two versions. I would be happy to send you just these files if 
you'd 
like me to.

Note that text version of the help file builds as I expect it to. 
The problem is in the htlm version.

PS: I tried two versions of \items 
\item{utmx}{UTM easting at plot center}
and 
\item{utmx   }{UTM easting at plot center}
(note added spaces, added for readability of the Rd file 
this difference does not seem to matter.)

Thanks, Nick

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


Re: [Rd] In Rd: \describe \itemize and \item

2009-01-30 Thread Duncan Murdoch

On 1/30/2009 2:22 PM, Nicholas L Crookston wrote:

Duncan Murdoch  wrote on 01/29/2009 07:14:11 PM:


On 29/01/2009 5:22 PM, Nicholas L Crookston wrote:
> I rebuilt a test version of my yaImpute package using Uwe Ligges' 

windows

> build service.
> I got this reply: Check result: OK
> R version 2.9.0 Under development (unstable) (2009-01-27 r47756)
>
> Here is the issue: I have the following construct in help files (this
> example relates to "data"):
>
> \format{
>   A data frame with 847 rows and 29 columns: \cr\cr
>   Ground based measurements of trees (Y-variables):
>   \itemize{
>  \item{TopHt}{Height of tallest trees (ft)}
>  \item{LnVolL}{Log of the volume \eqn{(ft^3/acre)} of western 

larch}

>  .. many lines deleted ..
>  \item{LnVolPP}{Log of the volume \eqn{(ft^3/acre)} of ponderosa 

pine}

>  \item{CCover}{Canopy cover (percent)}
>   }
>   Geographic Location, Slope, and Aspect (X-variables):
>   \itemize{
> \item{utmx}{UTM easting at plot center}
> \item{utmy}{UTM northing at plot center}
> .. many lines deleted ..
> \item{elevm}{Mean elevation (ft) above sea level over plot}
> \item{slpsinaspm}{Mean of slope (proportion) times the sine of 

aspect}

>   }
> .. many lines deleted ..
> }
>
> What I get in the help file is:
> =
> Format  
> A data frame with 847 rows and 29 columns:
>
> Ground based measurements of trees (Y-variables):
>
>TopHt
>   Height of tallest trees (ft)
>LnVolL
>   Log of the volume (ft^3/acre) of western larch
> = ..and so on
> [I've inserted 3 spaces to mimic tabs in this illustration]
>
> I would expect (and I used to get) something like this:
> =
> Ground based measurements of trees (Y-variables):
>
>TopHt   Height of tallest trees (ft)
>LnVolL  Log of the volume (ft^3/acre) of western larch
> =
>



I think we need more info to comment on.  Is this file one of the ones
in the yaImpute package on CRAN, or is it unreleased?  Is the Rd file
available for us to look at?  Does the man page look different in 2.8.1
from what you expect (there haven't been serious changes there), or only
in R-devel (2.9.0)?  2.6.2 is pretty old, but I don't think any of the
requested changes should be incompatible with it.



Duncan Murdoch


The problem is in an unreleased version built in the development 
environment.
The entire unreleased package can be found at this temporary location: 
http://forest.moscowfsl.wsu.edu/gems/yaImpute_1.0-8.tar.gz


The original is on CRAN (version 1.0-7). It worked under the old parser, 
but
not using parser 2 (the warnings on CRAN point to the problem). 
You can see the difference by looking at TallyLake.Rd 
in the two versions. I would be happy to send you just these files if 
you'd 
like me to.


Note that text version of the help file builds as I expect it to. 
The problem is in the htlm version.


PS: I tried two versions of \items 
\item{utmx}{UTM easting at plot center}
and 
\item{utmx   }{UTM easting at plot center}
(note added spaces, added for readability of the Rd file 
this difference does not seem to matter.)



Okay, I think I see now.  I installed your package version 1.0-8 in 
R-devel (to be 2.9.0), and the ?TallyLake man page looks fine to me in 
text mode, looks slightly funny in HTML (with the labels one line above 
the thing they're describing).  But to me it looks better in the new 
HTML than version 1.0-7 looked in 2.8.1:  in that version, there was no 
attempt to line up the descriptions to a common left margin, so they 
tended to be confused with the thing they were describing.


So I'm not sure what you'd really like to see in the output.  Can you 
describe it again?


Duncan Murdoch

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


Re: [Rd] In Rd: \describe \itemize and \item

2009-01-30 Thread Nicholas L Crookston
Duncan Murdoch  wrote on 01/30/2009 12:04:56 PM:


> 
> Okay, I think I see now.  I installed your package version 1.0-8 in
> R-devel (to be 2.9.0), and the ?TallyLake man page looks fine to me in
> text mode, looks slightly funny in HTML (with the labels one line above
> the thing they're describing).  But to me it looks better in the new
> HTML than version 1.0-7 looked in 2.8.1:  in that version, there was no
> attempt to line up the descriptions to a common left margin, so they
> tended to be confused with the thing they were describing.

> So I'm not sure what you'd really like to see in the output.  Can you
> describe it again?

Reading from the R-exts.pdf, section 2.4:

"The \itemize and \enumerate commands take a single argument, within which 
there may be
one or more \item commands. The text following each \item is formatted as 
one or more paragraphs,
suitably indented and with the first paragraph marked with a bullet point 
(\itemize)
or a number (\enumerate)."

I'm using \itemize so I expect to see a bullet point making the first 
paragraph of each item.

What I'm getting is what you would expect with the \describe command, as 
described here:

"The \describe command is similar to \itemize but allows initial labels to 
be specified.
The \items take two arguments, the label and the body of the item, in 
exactly the same way
as argument and value \items. \describe commands are mapped to  lists 
in HTML and
\description lists in LATEX."

> Duncan Murdoch

Nick Crookston

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


Re: [Rd] Side-effects of require() vs library() on x86_64 aka amd64

2009-01-30 Thread Dirk Eddelbuettel

On 28 January 2009 at 22:26, Dirk Eddelbuettel wrote:
| 
| RDieHarder fails its regression tests on x86_64 (aka "amd64") at CRAN (using
| Debian), and I see the same on Ubuntu 8.10 in 64 bit.  No issues on 32bit.
| 
| One odd thing is that the program behaves well if run via
| 
| R --no-save < tests/RDieHarder.R
| 
| but NOT when started using 
| 
| R --slave < tests/RDieHarder.R
| 
| as R CMD check does.

Turns out, as so often, that there was a regular bug lurking which is now
fixed in RDieHarder 0.1.1.  But I still would like to understand exactly what
is different so that --slave was able to trigger it when --vanilla,
--no-save, ... did not.  

[ The library() vs require() issue may have been a red herring. ]

Dirk

-- 
Three out of two people have difficulties with fractions.

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