[Rd] Invalid date-times and as.POSIXct problems (remotely related to DST issues)

2012-03-12 Thread Karl Ove Hufthammer
I think this should be handled as a bug, but I’m not sure which
platforms and versions it applies to, so I’m writing to this list. The
problem is that as.POSIXct on character strings behaves in a strange way
if one of the date-times are invalid; it converts all the date-times to
dates (i.e., it discards the time part).

Example, which I suspect only works on my locale, with the UTC+1/UTC+2
timezone:

  $ dates=c("2003-10-13 00:15:00", "2008-06-03 14:45:00", "2003-03-30 02:00:00")

Note that the last date-time doesn’t actually exist 
(due to daylight saving time):
http://www.timeanddate.com/worldclock/meetingtime.html?day=30&month=3&year=2003&p1=187&iv=0

  $ d12=as.POSIXct(dates)
  $ d123=as.POSIXct(dates[1:2])
  $ d12
  [1] "2003-10-13 CEST" "2008-06-03 CEST" "2003-03-30 CET"
  $ d123
  [1] "2003-10-13 00:15:00 CEST" "2008-06-03 14:45:00 CEST"

When I include all values, they are all converted to (POSIXct) *dates*,
but if I exclude the invalid one, the rest are properly converted to
(POSIXct) date-times. Note that this is not just a display issue:

 $ unclass(d12)
 [1] 1065996000 1212444000 1048978800
 attr(,"tzone")
 [1] ""
 $ unclass(d123)
 [1] 1065996900 1212497100
 attr(,"tzone")
 [1] ""

I can only reproduce this on Windows; on Linux all the strings are
converted to date-times (the last one to 2003-03-30 01:00:00 CET).
However, if ones specifies a completely invalid time, e.g., 25:00, the
same thing does happen on Linux (2.14.2 Patched). I think the right/best
behaviour would be to convert the invalid date-time string to NA and
convert the other ones proper POSIXct date-times, and perhaps issue a
warning about NAs being generated.

(I originally discovered this problem on data from an Oracle database,
using sqlQuery() from the RODBC package, which automatically converts
date-times to date-times in current timezone (except if you specify
as.is=TRUE), and was surprised that for some queries the date-times were
truncated to dates. A warning that parts of the data were invalid would
be very welcome.)


Version details (for Windows):

$ version
_
platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  14.2
year   2012
month  02
day29
svn rev58522
language   R
version.string R version 2.14.2 (2012-02-29)

$ sessionInfo()
R version 2.14.2 (2012-02-29)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Norwegian-Nynorsk_Norway.1252 
LC_CTYPE=Norwegian-Nynorsk_Norway.1252   
LC_MONETARY=Norwegian-Nynorsk_Norway.1252
[4] LC_NUMERIC=C 
LC_TIME=Norwegian-Nynorsk_Norway.1252

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

-- 
Karl Ove Hufthammer

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


[Rd] --as-cran and need to ignore.svn directories

2012-03-12 Thread Paul Johnson
Good morning:

I submitted a package update to CRAN and got a bounce because I had
not run R CMD check with "--as-cran".  I'd not heard of that before,
but I'm glad to know about it now.

I see it warns when my functions do use partial argument matching, and
I like that advice very much.

Also I see this warning

* checking package subdirectories ... WARNING
Found the following directory(s) with names of version control directories:
  ./.svn
  ./R/.svn
  ./data/.svn
  ./inst/.svn
  ./inst/doc/.svn
  ./inst/examples/.svn
  ./vignettes/.svn
These should not be in a package tarball.

Is there a way to cause R to ignore the .svn folders while running R
CMD check --as-cran or R CMD build?

It seems a little tedious to have to copy the whole directory tree to
some other place and remove the .svn folders before building. I can do
it, but it just seems, well, tedious. I have the feeling that you
"frequent flyers"  would have worked around this already.

-- 
Paul E. Johnson
Professor, Political Science    Assoc. Director
1541 Lilac Lane, Room 504     Center for Research Methods
University of Kansas               University of Kansas
http://pj.freefaculty.org            http://quant.ku.edu

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


Re: [Rd] --as-cran and need to ignore.svn directories

2012-03-12 Thread Jari Oksanen

On 12/03/2012, at 18:03 PM, Paul Johnson wrote:

> Good morning:
> 
> I submitted a package update to CRAN and got a bounce because I had
> not run R CMD check with "--as-cran".  I'd not heard of that before,
> but I'm glad to know about it now.
> 
> I see it warns when my functions do use partial argument matching, and
> I like that advice very much.
> 
> Also I see this warning
> 
> * checking package subdirectories ... WARNING
> Found the following directory(s) with names of version control directories:
>  ./.svn
>  ./R/.svn
>  ./data/.svn
>  ./inst/.svn
>  ./inst/doc/.svn
>  ./inst/examples/.svn
>  ./vignettes/.svn
> These should not be in a package tarball.
> 
> Is there a way to cause R to ignore the .svn folders while running R
> CMD check --as-cran or R CMD build?
> 
> It seems a little tedious to have to copy the whole directory tree to
> some other place and remove the .svn folders before building. I can do
> it, but it just seems, well, tedious. I have the feeling that you
> "frequent flyers"  would have worked around this already.


Paul,

I think the best solution is to 'svn export' svn directory to a temporary 
directory/folder:

svn export my-svn-directory tmp-pkg-directory
R CMD build tmp-pkg-directory
R CMD check --as-cran ...

The two advantages of 'svn export' that it (1) strips the .svn specific files, 
and (2) it really exports only those files that really are under version 
control. More often than once I have had some non-svn files in my svn directory 
so that *my* version of the package works, but the one actually in subversion 
fails.

Cheers, Jari Oksanen 

-- 
Jari Oksanen, Dept Biology, Univ Oulu, 90014 Finland
jari.oksa...@oulu.fi, Ph. +358 400 408593, http://cc.oulu.fi/~jarioksa

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


Re: [Rd] Unexpected behaviour for RowSideColors in function heatmap

2012-03-12 Thread Martin Maechler

> Thanks Kevin, I experienced the same problems with heatmap.2, and therefore 
> resorted to heatmap. For heatmap, the code change I suggested below fixes the 
> problem with side color ordering as far as I can tell, and lets one create a 
> symmetric heatmap with the origin at the top left (which I agree makes it 
> easier to read). Unless this code change breaks something else, it would be 
> nice if it could be incorporated into R.

It now has been incorporated:
For 2.15.0 (due in less than three weeks, see "Release Plans" on
http://developer.r-project.org/)

Thanks you very much, Pär (and Kevin) !

Martin

> P�r

> On 8 Mar 2012, at 17:27, Kevin R. Coombes wrote:

> > First, I can confirm this problem exists today, and can now vaguely recall 
> > seeing it in previous version of R.
> > > sessionInfo()
> > R version 2.14.1 (2011-12-22)
> > Platform: x86_64-pc-mingw32/x64 (64-bit)
> >
> > There is a bigger problem with heatmap.2 in the gplots package.  Using 
> > "symm=TRUE" with no other arguments causes it to fail to print one of the 
> > dendrograms:
> > > library(gplots)
> > > cU <- cor(USJudgeRatings)
> > > heatmap.2(cU, symm = TRUE)
> > Warning message:
> > In heatmap.2(cU, symm = TRUE) :
> >   Discrepancy: Colv is FALSE, while dendrogram is `row'. Omitting column 
> > dendogram.
> >
> > In order to get the column dendrogram displayed using heatmap.2, you must 
> > use "symm=TRUE, Colv=TRUE".  So this succeeds:
> > >  heatmap.2(cU, symm = TRUE, Colv=TRUE)
> >
> > To make things worse, heatmap.2 sometimes gets the direction of the column 
> > colors wrong.  If you omit "Colv=TRUE", it leaves out the column dendrogram 
> > and gets one set of colors wrong.  That, is, the following command fails in 
> > two ways:
> > > sideCols <- rainbow(ncol(cU))
> > > heatmap.2(cU, symm = TRUE, distfun = function(c) as.dist(1 - c),
> >ColSideColors=sideCols, RowSideColors=sideCols)
> >
> > If you include "Colv=TRUE", then it prints the dendrogram and gets both 
> > sets of colorbars correct.  So the following command succeeds:
> > > heatmap.2(cU, symm = TRUE, Colv=TRUE, distfun = function(c) as.dist(1 - 
> > > c),
> > +ColSideColors=sideCols, RowSideColors=sideCols)
> >
> > It is a separate esthetic question as to which diagonal axis should be used 
> > for symmetry. When it works in heatmap.2, the "origin" is at the bottom 
> > left.  Since the dendrograms are printed on the top and left, however, the 
> > symmetry would be easier to see/confirm if the origin were put at the top 
> > left. One might be tempted to fit this by using "revC=TRUE".  However, this 
> > command fails because it gets the colorbar wrong:
> > > heatmap.2(cU, symm = TRUE, Colv=TRUE, revC=TRUE,
> >   distfun = function(c) as.dist(1 - c),
> >   ColSideColors=sideCols, RowSideColors=sideCols)
> >
> > I am occasionally of the opinion that both "heatmap" and "heatmap.2" are 
> > too complex to be used reliably by mortals
> > Kevin
> >
> > On 2/28/2012 4:04 AM, P�r Engstr�m wrote:
> >>
> >> Hello,
> >>
> >> I have come across some unexpected behaviour of the function heatmap in 
> >> the stats package. This looks like a bug to me, but I might have 
> >> misunderstood something.
> >>
> >> When calling the function in symmetric mode, the ColSideColors are plotted 
> >> correctly, but RowSideColors appear in reverse order. This code (modified 
> >> from the example on the help page) demonstrates the problem:
> >>
> >> cU <- cor(USJudgeRatings)
> >> sideCols <- rainbow(ncol(cU))
> >> heatmap(cU, symm = TRUE, distfun = function(c) as.dist(1 - c),
> >>ColSideColors=sideCols, RowSideColors=sideCols)
> >>
> >> Reversing the RowSideColors argument does not solve the problem:
> >>
> >> heatmap(cU, symm = TRUE, distfun = function(c) as.dist(1 - c),
> >>ColSideColors=sideCols, RowSideColors=rev(sideCols))
> >>
> >> I had a look at the the function code and found that this change fixes the 
> >> problem:
> >>
> >> Replace
> >>
> >>image(rbind(1L:nr), col = RowSideColors[rowInd], axes = FALSE)
> >>
> >> with
> >>
> >>image(rbind(if(revC) nr:1L else 1L:nr), col = 
> >> RowSideColors[rowInd], axes = FALSE)
> >>
> >> I am using the current version of R for Mac OS X:
> >>
> >>> sessionInfo()
> >> R version 2.14.1 (2011-12-22)
> >> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
> >>
> >> locale:
> >> [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
> >>
> >> attached base packages:
> >> [1] stats graphics  grDevices utils datasets  methods   base
> >>
> >>
> >> Regards,
> >>
> >> P�r Engstr�m
> >>
> >> Postdoctoral Fellow
> >> EMBL European Bioinformatics Institute
> >> Wellcome Trust Genome Campus
> >> Hinxton, Cambridge, UK

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


Re: [Rd] --as-cran and need to ignore.svn directories

2012-03-12 Thread Prof Brian Ripley

On 12/03/2012 16:00, Paul Johnson wrote:

Good morning:

I submitted a package update to CRAN and got a bounce because I had
not run R CMD check with "--as-cran".  I'd not heard of that before,
but I'm glad to know about it now.


Well, it has only existed for about a month, but the customizations its 
selects are often much older and were documented as being used by CRAN.



I see it warns when my functions do use partial argument matching, and
I like that advice very much.


It switches on a customization that has been documented for years 


Also I see this warning

* checking package subdirectories ... WARNING
Found the following directory(s) with names of version control directories:
   ./.svn
   ./R/.svn
   ./data/.svn
   ./inst/.svn
   ./inst/doc/.svn
   ./inst/examples/.svn
   ./vignettes/.svn
These should not be in a package tarball.

Is there a way to cause R to ignore the .svn folders while running R
CMD check --as-cran or R CMD build?

It seems a little tedious to have to copy the whole directory tree to
some other place and remove the .svn folders before building. I can do
it, but it just seems, well, tedious. I have the feeling that you
"frequent flyers"  would have worked around this already.



You are strongly recommended to run this *on the tarball to be 
submitted*.  If you have .svn directories in that tarball, then you do 
(or CRAN will) have a problem.  R CMD build does omit such directories, 
and you can of course use .Rbuildignore to ignore other things.


Or if you update to subversion 1.7.x the problem will evaporate, as that 
only stores .svn directories at the top level, in my case ~/R/svn/Rpkgs, 
above all the individual packages.



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [Rd] --as-cran and need to ignore.svn directories

2012-03-12 Thread Martin Maechler
> Jari Oksanen 
> on Mon, 12 Mar 2012 16:59:45 + writes:

> On 12/03/2012, at 18:03 PM, Paul Johnson wrote:

>> Good morning:
>> 
>> I submitted a package update to CRAN and got a bounce because I had
>> not run R CMD check with "--as-cran".  I'd not heard of that before,
>> but I'm glad to know about it now.
>> 
>> I see it warns when my functions do use partial argument matching, and
>> I like that advice very much.
>> 
>> Also I see this warning
>> 
>> * checking package subdirectories ... WARNING Found the following
>> directory(s) with names of version control directories: ./.svn
>> ./R/.svn ./data/.svn ./inst/.svn ./inst/doc/.svn ./inst/examples/.svn
>> ./vignettes/.svn These should not be in a package tarball.
>> 
>> Is there a way to cause R to ignore the .svn folders while running R
>> CMD check --as-cran or R CMD build?
>> 
>> It seems a little tedious to have to copy the whole directory tree to
>> some other place and remove the .svn folders before building. I can do
>> it, but it just seems, well, tedious. I have the feeling that you
>> "frequent flyers" would have worked around this already.


> Paul,

> I think the best solution is to 'svn export' svn directory to a
> temporary directory/folder:

No, I don't think that should not be needed.

When building the tarball,  'R CMD build' *does* ignore the .svn
folders, at least for me.

Paul's problem was using  --as-cran on his SVN *directory*
but that's a slight contradiction in itself, as the CRAN maintainers
always run the checks on a tarball...

Martin

> svn export my-svn-directory tmp-pkg-directory
> R CMD build tmp-pkg-directory
> R CMD check --as-cran ...

> The two advantages of 'svn export' that it (1) strips the .svn specific
> files, and (2) it really exports only those files that really are under
> version control. More often than once I have had some non-svn files in
> my svn directory so that *my* version of the package works, but the one
> actually in subversion fails.

> Cheers, Jari Oksanen 

> -- 
> Jari Oksanen, Dept Biology, Univ Oulu, 90014 Finland
> jari.oksa...@oulu.fi, Ph. +358 400 408593, http://cc.oulu.fi/~jarioksa

> __
> 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] --as-cran and need to ignore.svn directories

2012-03-12 Thread Paul Johnson
On Mon, Mar 12, 2012 at 12:47 PM, Martin Maechler
 wrote:
>> Jari Oksanen 
[snip]
>
>    > Paul,
>
>    > I think the best solution is to 'svn export' svn directory to a
>    > temporary directory/folder:
>
> No, I don't think that should not be needed.
>
> When building the tarball,  'R CMD build' *does* ignore the .svn
> folders, at least for me.
>

My tarball was created by R CMD build, I don't know why the .svn
folders were included.  There are no .svn folders in the packages I
made with 2.14.1, so I suppose that is the first problem I have to
figure out.  This was my first build with R-2.14.2.  If I get an
answer, I will write back.

> Paul's problem was using  --as-cran on his SVN *directory*
> but that's a slight contradiction in itself, as the CRAN maintainers
> always run the checks on a tarball...

I don't have an argument against what you say, and I'm glad to do it
however you recommend. But I don't understand this. How do you get the
tarball without first doing R CMD check and R CMD build on the working
directory where the package lives?  I just do what seems to be
recommended in the tutorial by Friedrich Leisch "Creating R Packages:
A Tutorial" and the R extensions document. Until now, I have done this
in the shell to create the package.

R CMD check rockchalk
R CMD build rockchalk

You mean everybody doesn't do it that way?

>From now on, I'm adding --as-cran with check, but what else?

After that finishes, I should be running check on the tarball that was
created by build?

While I'm asking basic packaging questions, I have a vignette
packaging question. My vignette is in

vignettes/outreg.Rnw

The R build process runs latex to make sure the vignette can be built.
But, as far as I can tell, it does not copy the pdf file into

inst/doc/outreg.pdf.

So when building the package, I should still manually compile the pdf
and move it over there?


>
> Martin
>
>    > svn export my-svn-directory tmp-pkg-directory
>    > R CMD build tmp-pkg-directory
>    > R CMD check --as-cran ...
>
>    > The two advantages of 'svn export' that it (1) strips the .svn specific
>    > files, and (2) it really exports only those files that really are under
>    > version control. More often than once I have had some non-svn files in
>    > my svn directory so that *my* version of the package works, but the one
>    > actually in subversion fails.
>
>    > Cheers, Jari Oksanen
>
>    > --
>    > Jari Oksanen, Dept Biology, Univ Oulu, 90014 Finland
>    > jari.oksa...@oulu.fi, Ph. +358 400 408593, http://cc.oulu.fi/~jarioksa


-- 
Paul E. Johnson
Professor, Political Science    Assoc. Director
1541 Lilac Lane, Room 504     Center for Research Methods
University of Kansas               University of Kansas
http://pj.freefaculty.org            http://quant.ku.edu

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


Re: [Rd] --as-cran and need to ignore.svn directories

2012-03-12 Thread Brian G. Peterson
On Mon, 2012-03-12 at 13:43 -0500, Paul Johnson wrote:
> R CMD check rockchalk
> R CMD build rockchalk 

do *build* first, then *check* on the tarball file.
 
-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock

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