Re: [R] setMethods/setGeneric problem when R CMD CHECK'ing a package

2011-08-24 Thread Jonathan Greenberg
Hmm, so I moved the function call to the same file as the methods
call, and placed it above the method in the file -- but I'm getting
the same error.  Is there something "odd" about as.yearmon in the zoo
package that it might not be getting defined as a generic function?
If so, how would I go about creating a generic?
setGeneric("as.yearmon") doesn't seem to cut it.

Here's the new file contents:

as.yearmon.SpatialPointsDataFrameListZoo=function(x,...)
{

newlist=mapply(zoo:::as.yearmon,x@list,MoreArgs=list(...),simplify=FALSE)
x@list=newlist
return(x)
}

setMethod("as.yearmon",
signature(x = "SpatialPointsDataFrameListZoo"),
as.yearmon.SpatialPointsDataFrameListZoo
)

--j

2011/8/24 Uwe Ligges :
>
>
> On 24.08.2011 10:30, Jonathan Greenberg wrote:
>>
>> R-helpers:
>>
>> I'm trying to build a package, but I'm a bit new to the whole S3/S4
>> methods concept.  I'm trying to add a new definition of the zoo
>> function "as.yearmon", but I'm getting the following error when it
>> gets to this point during a package install:
>
> Thhis seesm more appropiate for the R-devel rather than the R-help list.
> Anyway, see below.
>
>
>> ***
>>
>> R CMD INSTALL STARStools
>> * installing to library
>> ‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library’
>> WARNING: omitting pointless dependence on 'R' without a version
>> requirement
>> * installing *source* package ‘STARStools’ ...
>> ** R
>> ** inst
>> ** preparing package for lazy loading
>> Loading required package: sp
>> raster version 1.9-5 (28-July-2011)
>> Geospatial Data Abstraction Library extensions to R successfully loaded
>> Loaded GDAL runtime: GDAL 1.8.0, released 2011/01/12
>> Path to GDAL shared files:
>> /Library/Frameworks/GDAL.framework/Versions/1.8/Resources/gdal
>> Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
>> Path to PROJ.4 shared files: (autodetected)
>>
>> Attaching package: 'zoo'
>>
>> The following object(s) are masked from 'package:base':
>>
>>     as.Date
>>
>> Creating a new generic function for "as.Date" in "STARStools"
>> Creating a new generic function for "as.list" in "STARStools"
>> Error in setGeneric(f, where = where) :
>>   must supply a function skeleton, explicitly or via an existing function
>> Error : unable to load R code in package 'STARStools'
>> ERROR: lazy loading failed for package ‘STARStools’
>> * removing
>> ‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’
>> * restoring previous
>>
>> ‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’
>>
>> ***
>>
>> # Note that these "require" statements do not appear in the code, but
>> appear in the DESCRIPTION file:
>> require("sp")
>> require("zoo")
>
> ??? Not valid in the DESCRIPTION file. Either use this in  your code or
> import from the corresponding Namespaces which you will have to do anyway
> for the next R release.
>
>
>
>> # Here are the class definitions (filename AAAclassdefinitions.R):
>>
>> setClass("SpatialPointsDataFrameList",representation(list="list"),contains=c("SpatialPointsDataFrame"))
>>
>> setClass("SpatialPointsDataFrameListZoo",contains=c("SpatialPointsDataFrameList"))
>>
>> # And here is where it is getting hung up. filename
>> "as.yearmon.SpatialPointsDataFrameListZoo_SpatialPointsDataFrameListZoo.R"
>>
>> setMethod("as.yearmon",
>>     signature(x = "SpatialPointsDataFrameListZoo"),
>>        as.yearmon.SpatialPointsDataFrameListZoo
>> )
>
> You try to register the method pointing to a function definition that does
> not exist at this point (since you define it below). Just move the
> definition up.
>
> Uwe Ligges
>
>
>>
>> # Filename "as.yearmon.SpatialPointsDataFrameListZoo.R"
>> as.yearmon.SpatialPointsDataFrameListZoo=function(x,...)
>> {
>>
>>  newlist=mapply(zoo:::as.yearmon,x@list,MoreArgs=list(...),simplify=FALSE)
>>        x@list=newlist
>>        return(x)
>> }
>>
>> Thoughts?
>>
>> --j
>>
>



-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
R-help@r-project.org 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] setMethods/setGeneric problem when R CMD CHECK'ing a package

2011-08-24 Thread Uwe Ligges



On 24.08.2011 11:09, Jonathan Greenberg wrote:

Hmm, so I moved the function call to the same file as the methods
call, and placed it above the method in the file -- but I'm getting
the same error.  Is there something "odd" about as.yearmon in the zoo
package that it might not be getting defined as a generic function?
If so, how would I go about creating a generic?
setGeneric("as.yearmon") doesn't seem to cut it.


I haven't looked at the details but just commented on the obvious 
glitches in your code. Now that I tested with R-2.13.1 patched, zoo 
1.7-4, sp 0.9-84, it just works for me:



setClass("SpatialPointsDataFrameList",representation(list="list"),contains=c("SpatialPointsDataFrame"))
setClass("SpatialPointsDataFrameListZoo",contains=c("SpatialPointsDataFrameList"))
#setGeneric("as.yearmon")
as.yearmon.SpatialPointsDataFrameListZoo=function(x,...)
{
newlist=mapply(zoo:::as.yearmon,x@list,MoreArgs=list(...),simplify=FALSE)
x@list=newlist
return(x)
}
setMethod("as.yearmon",
signature(x = "SpatialPointsDataFrameListZoo"),
as.yearmon.SpatialPointsDataFrameListZoo
)
works for me (at least, it is installable and passes checks, if I add

Depends: methods, sp, zoo

into the DESCRIPTION file (hence without using a NAMESPACE yet).


Uwe Ligges









Here's the new file contents:

as.yearmon.SpatialPointsDataFrameListZoo=function(x,...)
{

newlist=mapply(zoo:::as.yearmon,x@list,MoreArgs=list(...),simplify=FALSE)
x@list=newlist
return(x)
}

setMethod("as.yearmon",
 signature(x = "SpatialPointsDataFrameListZoo"),
as.yearmon.SpatialPointsDataFrameListZoo
)

--j

2011/8/24 Uwe Ligges:



On 24.08.2011 10:30, Jonathan Greenberg wrote:


R-helpers:

I'm trying to build a package, but I'm a bit new to the whole S3/S4
methods concept.  I'm trying to add a new definition of the zoo
function "as.yearmon", but I'm getting the following error when it
gets to this point during a package install:


Thhis seesm more appropiate for the R-devel rather than the R-help list.
Anyway, see below.



***

R CMD INSTALL STARStools
* installing to library
‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library’
WARNING: omitting pointless dependence on 'R' without a version
requirement
* installing *source* package ‘STARStools’ ...
** R
** inst
** preparing package for lazy loading
Loading required package: sp
raster version 1.9-5 (28-July-2011)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.8.0, released 2011/01/12
Path to GDAL shared files:
/Library/Frameworks/GDAL.framework/Versions/1.8/Resources/gdal
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
Path to PROJ.4 shared files: (autodetected)

Attaching package: 'zoo'

The following object(s) are masked from 'package:base':

 as.Date

Creating a new generic function for "as.Date" in "STARStools"
Creating a new generic function for "as.list" in "STARStools"
Error in setGeneric(f, where = where) :
   must supply a function skeleton, explicitly or via an existing function
Error : unable to load R code in package 'STARStools'
ERROR: lazy loading failed for package ‘STARStools’
* removing
‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’
* restoring previous

‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’

***

# Note that these "require" statements do not appear in the code, but
appear in the DESCRIPTION file:
require("sp")
require("zoo")


??? Not valid in the DESCRIPTION file. Either use this in  your code or
import from the corresponding Namespaces which you will have to do anyway
for the next R release.




# Here are the class definitions (filename AAAclassdefinitions.R):

setClass("SpatialPointsDataFrameList",representation(list="list"),contains=c("SpatialPointsDataFrame"))

setClass("SpatialPointsDataFrameListZoo",contains=c("SpatialPointsDataFrameList"))

# And here is where it is getting hung up. filename
"as.yearmon.SpatialPointsDataFrameListZoo_SpatialPointsDataFrameListZoo.R"

setMethod("as.yearmon",
 signature(x = "SpatialPointsDataFrameListZoo"),
as.yearmon.SpatialPointsDataFrameListZoo
)


You try to register the method pointing to a function definition that does
not exist at this point (since you define it below). Just move the
definition up.

Uwe Ligges




# Filename "as.yearmon.SpatialPointsDataFrameListZoo.R"
as.yearmon.SpatialPointsDataFrameListZoo=function(x,...)
{

  newlist=mapply(zoo:::as.yearmon,x@list,MoreArgs=list(...),simplify=FALSE)
x@list=newlist
return(x)
}

Thoughts?

--j









__
R-help@r-project.org 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] setMethods/setGeneric problem when R CMD CHECK'ing a package

2011-08-24 Thread Uwe Ligges



On 24.08.2011 10:30, Jonathan Greenberg wrote:

R-helpers:

I'm trying to build a package, but I'm a bit new to the whole S3/S4
methods concept.  I'm trying to add a new definition of the zoo
function "as.yearmon", but I'm getting the following error when it
gets to this point during a package install:


Thhis seesm more appropiate for the R-devel rather than the R-help list. 
Anyway, see below.




***

R CMD INSTALL STARStools
* installing to library
‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library’
WARNING: omitting pointless dependence on 'R' without a version requirement
* installing *source* package ‘STARStools’ ...
** R
** inst
** preparing package for lazy loading
Loading required package: sp
raster version 1.9-5 (28-July-2011)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.8.0, released 2011/01/12
Path to GDAL shared files:
/Library/Frameworks/GDAL.framework/Versions/1.8/Resources/gdal
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
Path to PROJ.4 shared files: (autodetected)

Attaching package: 'zoo'

The following object(s) are masked from 'package:base':

 as.Date

Creating a new generic function for "as.Date" in "STARStools"
Creating a new generic function for "as.list" in "STARStools"
Error in setGeneric(f, where = where) :
   must supply a function skeleton, explicitly or via an existing function
Error : unable to load R code in package 'STARStools'
ERROR: lazy loading failed for package ‘STARStools’
* removing 
‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’
* restoring previous
‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’

***

# Note that these "require" statements do not appear in the code, but
appear in the DESCRIPTION file:
require("sp")
require("zoo")


??? Not valid in the DESCRIPTION file. Either use this in  your code or 
import from the corresponding Namespaces which you will have to do 
anyway for the next R release.





# Here are the class definitions (filename AAAclassdefinitions.R):
setClass("SpatialPointsDataFrameList",representation(list="list"),contains=c("SpatialPointsDataFrame"))
setClass("SpatialPointsDataFrameListZoo",contains=c("SpatialPointsDataFrameList"))

# And here is where it is getting hung up. filename
"as.yearmon.SpatialPointsDataFrameListZoo_SpatialPointsDataFrameListZoo.R"

setMethod("as.yearmon",
 signature(x = "SpatialPointsDataFrameListZoo"),
as.yearmon.SpatialPointsDataFrameListZoo
)


You try to register the method pointing to a function definition that 
does not exist at this point (since you define it below). Just move the 
definition up.


Uwe Ligges




# Filename "as.yearmon.SpatialPointsDataFrameListZoo.R"
as.yearmon.SpatialPointsDataFrameListZoo=function(x,...)
{

newlist=mapply(zoo:::as.yearmon,x@list,MoreArgs=list(...),simplify=FALSE)
x@list=newlist
return(x)
}

Thoughts?

--j



__
R-help@r-project.org 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] setMethods/setGeneric problem when R CMD CHECK'ing a package

2011-08-24 Thread Jonathan Greenberg
R-helpers:

I'm trying to build a package, but I'm a bit new to the whole S3/S4
methods concept.  I'm trying to add a new definition of the zoo
function "as.yearmon", but I'm getting the following error when it
gets to this point during a package install:

***

R CMD INSTALL STARStools
* installing to library
‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library’
WARNING: omitting pointless dependence on 'R' without a version requirement
* installing *source* package ‘STARStools’ ...
** R
** inst
** preparing package for lazy loading
Loading required package: sp
raster version 1.9-5 (28-July-2011)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.8.0, released 2011/01/12
Path to GDAL shared files:
/Library/Frameworks/GDAL.framework/Versions/1.8/Resources/gdal
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
Path to PROJ.4 shared files: (autodetected)

Attaching package: 'zoo'

The following object(s) are masked from 'package:base':

as.Date

Creating a new generic function for "as.Date" in "STARStools"
Creating a new generic function for "as.list" in "STARStools"
Error in setGeneric(f, where = where) :
  must supply a function skeleton, explicitly or via an existing function
Error : unable to load R code in package 'STARStools'
ERROR: lazy loading failed for package ‘STARStools’
* removing 
‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’
* restoring previous
‘/Library/Frameworks/R.framework/Versions/2.13/Resources/library/STARStools’

***

# Note that these "require" statements do not appear in the code, but
appear in the DESCRIPTION file:
require("sp")
require("zoo")

# Here are the class definitions (filename AAAclassdefinitions.R):
setClass("SpatialPointsDataFrameList",representation(list="list"),contains=c("SpatialPointsDataFrame"))
setClass("SpatialPointsDataFrameListZoo",contains=c("SpatialPointsDataFrameList"))

# And here is where it is getting hung up. filename
"as.yearmon.SpatialPointsDataFrameListZoo_SpatialPointsDataFrameListZoo.R"

setMethod("as.yearmon",
signature(x = "SpatialPointsDataFrameListZoo"),
as.yearmon.SpatialPointsDataFrameListZoo
)

# Filename "as.yearmon.SpatialPointsDataFrameListZoo.R"
as.yearmon.SpatialPointsDataFrameListZoo=function(x,...)
{

newlist=mapply(zoo:::as.yearmon,x@list,MoreArgs=list(...),simplify=FALSE)
x@list=newlist
return(x)
}

Thoughts?

--j

-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn...@hotmail.com, Gchat: jgrn307

__
R-help@r-project.org 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.