Re: [Rd] patch for axis.POSIXct (related to timezones)

2009-05-08 Thread Dan Kelley

Some time ago, I posted a note about what I considered to be a bug in
axis.POSIXt() for R 2.8.x, relating to whether timezones in the data are
obeyed on the axes.  A link to that note, and to a quick and helpful
response, is at the following URL

http://www.nabble.com/patch-for-axis.POSIXct-%28related-to-timezones%29-td22338700.html#a22338700

and I note that R 2.9.0 has been adjusted to help with this.  However, there
are still problems.  I do apologize for not having performed a test build
prior to the 2.9.0 release; this was partly because I find test builds
difficult on my OSX box, and partly because I have written replacement code
and mostly use that.  But today I tried R 2.9.0, and the problem persists
... sometimes.  Test code is given below.  The top panel is correct, but the
bottom one is incorrect.  The problem relates to the time interval.

# test code (top panel, OK; bottom panel, incorrect times on x axis)


par(mar=c(2,2,2,1))
par(mfrow=c(2,1))
start <- as.POSIXct("2008-05-01 00:00:00", tz="UTC")
end   <- as.POSIXct("2008-05-01 00:10:00", tz="UTC")
plot(c(start, end), c(0, 1), ylab="")
mtext(paste(start, "to", end), side=3)

start <- as.POSIXct("2008-05-01 00:00:00", tz="UTC")
end   <- as.POSIXct("2008-05-01 01:10:00", tz="UTC")
plot(c(start, end), c(0, 1), ylab="")
mtext(paste(start, "to", end), side=3)




-- 
View this message in context: 
http://www.nabble.com/patch-for-axis.POSIXct-%28related-to-timezones%29-tp22338700p23454737.html
Sent from the R devel mailing list archive at Nabble.com.

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


[Rd] Warning: closing unused connection 3

2009-01-25 Thread Dan Kelley

The subject is a warning that occurs with my 'oce' package in the test on
r-devel-windows-ix86, i.e.

http://cran.r-project.org/web/checks/check_results_oce.html

I see that some other packages have this same error.  I tried searching
postings to this group for this warning, but found nothing.  I'm pretty sure
this warning message was not there a week ago.

Q: is there something I should do, to track down my error, or is this an
error in the testing itself?

Thanks.  Dan.
-- 
View this message in context: 
http://www.nabble.com/Warning%3A-closing-unused-connection-3-tp21656751p21656751.html
Sent from the R devel mailing list archive at Nabble.com.

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


[Rd] patch for axis.POSIXct (related to timezones)

2009-03-04 Thread Dan Kelley

I am finding that axis.POSIXct uses the local timezone for deciding where to
put tic marks, even if the data being plotted are in another time zone.  The
solution is to use attr() to copy from the 'x' (provided as an argument) to
the 'z' (used for the 'at' locations). 

I have pasted my proposed solution in section 1 below (as a diff).  Then, in
section 2, I'll put some test code that I wrote, when I was figuring this
out.

I am not entirely sure whether it's OK, or helpful, to post a diff here.  I
don't understand the R development model well enough to know how to suggest
changes, and ?axis.POSIXct does not list an author, so that's why I'm
posting here.

(All of this matters because I am sharing code with people working in
different timezones; I want the timezone of the data to carry over to the
graph.)

Section 1: patch to axis.POSIXct


(Note that the line numbers may be wrong; I'm not working with the source
for axis.POSIXct, but rather with the output from a listing of the function
in the terminal).

~$ diff -Naur axis.POSIXct.R my.axis.POSIXct.R 
--- axis.POSIXct.R  2009-03-04 16:22:18.0 -0400
+++ my.axis.POSIXct.R   2009-03-04 16:22:56.0 -0400
@@ -1,4 +1,4 @@
-axis.POSIXct <- function (side, x, at, format, labels = TRUE, ...)
+my.axis.POSIXct <- function (side, x, at, format, labels = TRUE, ...)
 {
 mat <- missing(at) || is.null(at)
 if (!mat)
@@ -9,6 +9,7 @@
 else 3:4]
 d <- range[2] - range[1]
 z <- c(range, x[is.finite(x)])
+attr(z, "tzone") <- attr(x, "tzone")
 if (d < 1.1 * 60) {
 sc <- 1
 if (missing(format))
@@ -41,6 +42,7 @@
 zz <- pretty(z/sc)
 z <- zz * sc
 class(z) <- c("POSIXt", "POSIXct")
+attr(z, "tzone") <- attr(x, "tzone")
 if (sc == 60 * 60 * 24)
 z <- as.POSIXct(round(z, "days"))
 if (missing(format))
@@ -48,6 +50,7 @@
 }
 else if (d < 1.1 * 60 * 60 * 24 * 365) {
 class(z) <- c("POSIXt", "POSIXct")
+attr(z, "tzone") <- attr(x, "tzone")
 zz <- as.POSIXlt(z)
 zz$mday <- zz$wday <- zz$yday <- 1
 zz$isdst <- -1
@@ -65,6 +68,7 @@
 }
 else {
 class(z) <- c("POSIXt", "POSIXct")
+attr(z, "tzone") <- attr(x, "tzone")
 zz <- as.POSIXlt(z)
 zz$mday <- zz$wday <- zz$yday <- 1
 zz$isdst <- -1
~$ 


Section 2.  Test code
=

# fake some data, and draw a vertical line at midnight ... note how
# the latter will be in the wrong place (unless the computer is set to UTC).
tc <- c("2008-06-28 15:50:00 UTC","2008-06-28 20:50:00 UTC","2008-06-29
01:50:00 UTC",
   "2008-06-29 06:50:00 UTC","2008-06-29 11:50:00 UTC","2008-06-29
16:50:00 UTC",
   "2008-06-29 21:50:00 UTC","2008-06-30 02:50:00 UTC","2008-06-30
07:50:00 UTC",
   "2008-06-30 12:50:00 UTC")
t <- as.POSIXct(tc, tz="UTC")   # note using UTC

p <- c(2.4998, 0.4687, 2.7120, 2.0676, 0.5614, 2.6121, 0.5161, 2.9572,
2.2567, 0.3820)

t0 <- as.POSIXct("2008-06-29 00:00:00", tz="UTC")
par(mfrow=c(2,1))
plot(t, p, type='l')
abline(v=t0, col='red')

plot(t, p, type='l', axes=FALSE)
box()
axis(2)
source("~/my.axis.POSIXct.R")
my.axis.POSIXct(side=1, x=t)
abline(v=t0, col='red')



-- 
View this message in context: 
http://www.nabble.com/patch-for-axis.POSIXct-%28related-to-timezones%29-tp22338700p22338700.html
Sent from the R devel mailing list archive at Nabble.com.

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


[Rd] better function name: make or as

2009-03-11 Thread Dan Kelley

I've written a function (for the 'oce' package) that takes a list of one type
of object (a "station", observations made by a ship at one location), and
creates another object (a "section", containing a sequence of station
observations).

My question is, should I name my function "make.section()" or
"as.section()"?

I wouldd like to pattern the name on other R functions, but I'm having
difficulty understanding when 'as' and 'make' are used.  (At the moment, I
am using 'make', because it seems to me that 'as' is mainly for mapping
input to output on a sort of one-to-one basis.)

Any suggestions?


-- 
View this message in context: 
http://www.nabble.com/better-function-name%3A-make-or-as-tp22465595p22465595.html
Sent from the R devel mailing list archive at Nabble.com.

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


[Rd] Error in par(split.screens[[n]]) : parameter "i" in "mfg" is out of range

2009-04-03 Thread Dan Kelley

I'm working on my 'oce' package, trying split.screen() instead of par(mfrow). 
My code is too long to post, and I hope it's ok that I ask this question
without doing so.

My code seems to work fine when I source() it, but when I do "R CMD check"
on my package, I get the error that I've put as the subject line, when it
runs examples.

If I comment out the plot() commands from my examples, and build the
package, then I can run those examples (with the plot() uncommented) from
the commandline, with no problems.  And I can run them from the console.  I
don't actually understand the error, although I can see that it is occurring
in a call to screen().

Has anyone else run across this?  Is there a trick I should employ, e.g.
making my package depend on the graphics package or setting up a virtual
device of some type for use in the building process?

PS. This is on OS X with the 2.8.1 version of R.
-- 
View this message in context: 
http://www.nabble.com/Error-in-par%28split.screens--n--%29-%3A-parameter-%22i%22-in-%22mfg%22-is-out-of-range-tp22873439p22873439.html
Sent from the R devel mailing list archive at Nabble.com.

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


Re: [Rd] Error in par(split.screens[[n]]) : parameter "i" in "mfg" is out of range

2009-04-03 Thread Dan Kelley

As a followup, in case this is of use to others, I got my code working by
altering R-2.8.1/src/library/graphics/R/screen.R slightly, removing the sole
reference to "mfg", as follows.


assign("par.list",
   c("xlog","ylog",
 "adj", "bty", "cex", "col", "crt", "err", "font", "lab",
 "las", "lty", "lwd", "mar", "mex",
 ##"mfg",   
 
 "mgp", "pch",
 "pty", "smo", "srt", "tck", "usr", "xaxp", "xaxs", "xaxt", "xpd",
 "yaxp", "yaxs", "yaxt", "fig"), envir=.SSenv)

-- 
View this message in context: 
http://www.nabble.com/Error-in-par%28split.screens--n--%29-%3A-parameter-%22i%22-in-%22mfg%22-is-out-of-range-tp22873439p22878253.html
Sent from the R devel mailing list archive at Nabble.com.

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


[Rd] split.screen bug and patch

2009-04-04 Thread Dan Kelley

I hope it's OK to post a bug report, and a possible patch, on this list.

Introduction
===

The split.screen() docs suggest that users should not return to a screen
after it has been drawn, and that curious errors may result from doing so. 
This is clear from the test file I put below.  However, I have found that
this test file will work properly, with a tiny change to the split.screen
code.  I am posting this here in case it might help others.  (Certainly, I
make no claim that this solves a general problem with split.screen, but baby
steps are steps, nonetheless.)

The test file draws red lines in the wrong place, unless f=0.5.  But it
works OK after the split.screen code is edited as given in the last section
of this email.

Test file
=

close.screen(all.screens=TRUE)
f <- 0.7# works only if f=0.5
split.screen(matrix(c(0,f,0,1, f,1,0,1), nrow=2, byrow=TRUE))
screen(1)
plot(1:10, 1:10)
screen(2)
plot(1:3, 1:3)
screen(1,FALSE)
abline(h=6,col='red')
abline(v=6,col='red')


Code change


Near the start of src/library/graphics/R/screen.R edit the assign() to look
as follows.  The addition solves the problem of the test file, and the
deletion solves a problem in building packages that use split.screen().

assign("par.list",
   c("xlog","ylog",
 "adj", "bty", "cex", "col", "crt", "err", "font", "lab",
 "las", "lty", "lwd", "mar", "mex",
 "fin", ## added
 ## "mfg", ## deleted   
 "mgp", "pch",
 "pty", "smo", "srt", "tck", "usr",
 "xaxp", "xaxs", "xaxt", "xpd",
 "yaxp", "yaxs", "yaxt", "fig"), envir=.oceSSenv)

-- 
View this message in context: 
http://www.nabble.com/split.screen-bug-and-patch-tp22884064p22884064.html
Sent from the R devel mailing list archive at Nabble.com.

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


[Rd] R CMD check dislikes .git directories

2009-04-21 Thread Dan Kelley

This may be new to 2.9.0, but I'm not sure, since I no longer have the older
version.

I notice that  R CMD check  has no problem with .svn directories, but it
dislikes .git directories.  That seems a bit of a problem, for folks like me
who sometimes use git. Perhaps this behaviour could be changed?

Dan.
-- 
View this message in context: 
http://www.nabble.com/R-CMD-check-dislikes-.git-directories-tp23166614p23166614.html
Sent from the R devel mailing list archive at Nabble.com.

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


Re: [Rd] R CMD check dislikes .git directories

2009-04-21 Thread Dan Kelley
I think what I'm pasting below will illustrate.  (The git repo is  
behind a firewall, so I can't invite folks to download the repo to  
test locally.  I could tar up the source and put it on a website if  
that would help.)


* checking if this is a source package ... OK
* checking for executable files ... WARNING
Found the following executable file(s):
  .git/objects/01/9002df908b9c97f98e6ad3dd079bee436a2d66
  .git/objects/08/ac4fdd57a77afe2f8071c2e697cbda02b276b7
  .git/objects/13/49be3ed32dd801eacbdf1cc96a7577dcdfa2d7
  .git/objects/14/45d1188fcd949bd77d5c1117906c7987fe15a7
  .git/objects/18/756ad87b639ad2123a0ac78d04daa613d16966



On 2009-04-21, at 9:24 PM, Duncan Murdoch wrote:


On 21/04/2009 8:10 PM, Duncan Murdoch wrote:

On 21/04/2009 7:59 PM, Dan Kelley wrote:
This may be new to 2.9.0, but I'm not sure, since I no longer have  
the older

version.

I notice that  R CMD check  has no problem with .svn directories,  
but it
dislikes .git directories.  That seems a bit of a problem, for  
folks like me

who sometimes use git. Perhaps this behaviour could be changed?
According to the R Extensions manual, it excludes dirs named  
CVS, .svn, .arch-ids, .bzr, and git.  Is .git the right thing to  
exclude instead of git, or are both possible?


Actually, that looks like a typo in the manual:  the code  
excludes .git, not git.  I'll fix the typo, but it means I don't  
know what error you're talking about.  Could you post instructions  
for reproducing?


Duncan Murdoch

The same section points out the workaround:  use the .Rbuildignore  
file to say what isn't really part of your package.

Duncan Murdoch




Dan Kelley, PhD
Associate Professor and Graduate Coordinator
Dept. Oceanography, Dalhousie University, Halifax NS B3H 4J1
kelley@gmail.com (1-minute path) or dan.kel...@dal.ca (2-hour path)
Phone 902 494 1694;  Fax  902 494 3877

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


[Rd] R_alloc problem on Mac OSX (PR#8683)

2006-03-15 Thread dan . kelley
Full_Name: Dan Kelley
Version: 2.2.1
OS: Mac OSX
Submission from: (NULL) (129.173.23.36)


I'm having difficulties getting R_alloc() to work on a 64-bit Mac running R
2.2.1 installed via a .dmg file obtained from the R site.  Details are given
below, in a level of detail that I hope is appropriate.  My eye was particularly
drawn to line #2 in the gdb 'where' output, but line #1 seems sensible so I may
just be displaying my ignorance by drawing attention to this.

I wonder, is there something I should be doing first, to initialize memory?

 ..

$ R --version
R 2.2.1 (2005-12-20).
Copyright (C) 2005 R Development Core Team

$ gcc -g -o test5 test5.c
-I/library/Frameworks/R.framework/Versions/2.2/Resources/include/
-L/library/Frameworks/R.framework/Versions/2.2/Resources/lib/ -lR -lm
/usr/bin/ld: warning multiple definitions of symbol _signgam
/library/Frameworks/R.framework/Versions/2.2/Resources/lib//libR.dylib(lgamma.lo)
definition of _signgam
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/../../../libm.dylib(gamma9.o)
definition of _signgam

$ gdb test5
GNU gdb 6.1-20040303 (Apple version gdb-413) (Wed May 18 10:17:02 GMT 2005)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "powerpc-apple-darwin"...Reading symbols for shared
libraries  done

(gdb) run
Starting program: /Users/kelley/src/R-from-fortran/test5
Reading symbols for shared libraries .+ done
about to call R_alloc(1,4)

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x000c
GetNewPage (node_class=1) at ../../../../R-2.2.1/src/main/memory.c:622
622 ../../../../R-2.2.1/src/main/memory.c: No such file or directory.
in ../../../../R-2.2.1/src/main/memory.c
(gdb) where
#0  GetNewPage (node_class=1) at ../../../../R-2.2.1/src/main/memory.c:622
#1  0x00293d38 in Rf_allocVector (type=9, length=4) at
../../../../R-2.2.1/src/main/memory.c:1918
#2  0x002932e8 in R_alloc (nelem=25167368, eltsize=1996) at
../../../../R-2.2.1/src/main/memory.c:1604
#3  0x2ad0 in main () at test5.c:8
(gdb) list
617 in ../../../../R-2.2.1/src/main/memory.c
(gdb) file test5
Load new symbol table from "/Users/kelley/src/R-from-fortran/test5"? (y or n) y
Reading symbols from /Users/kelley/src/R-from-fortran/test5...done.
(gdb) list
1   #include 
2   #include 
3   int main()
4   {
5   int *t;
6   long int n = 1;
7   printf("about to call R_alloc(%d,%d)\n",n,sizeof(int));
8   t = (int *) R_alloc(n, sizeof(int));
9   printf("done\n");
10  return(0);
(gdb) src/R-from-fortran/

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


[Rd] Package-check failure (i386) (PR#8822)

2006-04-30 Thread dan . kelley
Full_Name: Dan Kelley
Version: 2.3.0
OS: OSX Macintosh
Submission from: (NULL) (142.68.207.218)


R2.3.0 has a problem checking one of my self-authored Oce package
(http://myweb.dal.ca/kelley/pub/sof/oce/index.php).  The package builds fine on
another machine running a R2.2.1.  Both machines are macintoshes running the
latest version of OSX.

I am reporting this here not to get help - I realize the package is too big to
provide a test case - but rather as an alert.

Running "R CMD check oce" produces an error, and when I checked the relevant
failure file (ctd.Rout.fail), I see the following contents.  This suggests that
maybe the system is trying to run an i386 binary, even though the machine has a
powerpc CPU.  (Now you can see why I'm reporting this -- it seems to be a
problem with the OSX universal binary.)

/Library/Frameworks/R.framework/Resources/bin/R: line 192:
/Library/Frameworks/R.framework/Resources/bin/exec/i386/R: cannot execute binary
file
/Library/Frameworks/R.framework/Resources/bin/R: line 192:
/Library/Frameworks/R.framework/Resources/bin/exec/i386/R: Unknown error: 0

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


[Rd] PR#8822

2006-05-19 Thread Dan . Kelley
Below my signature is an illustration of how I fixed this bug.   
(First, of course, I renamed the "R" file to "R-orig".)

Dan E. Kelley, Assoc. Prof. phone:(902)494-1694
Dept. Oceanography  fax:(902)494-2885
Dalhousie Universitymailto:[EMAIL PROTECTED]
Halifax, NS, Canada B3H 4J1 http://www.phys.ocean.dal.ca/~kelley/ 
Kelley_Dan.html



$ diff -Naur /Library/Frameworks/R.framework/Resources/bin/R /Library/ 
Frameworks/R.framework/Resources/bin/R-orig


--- /Library/Frameworks/R.framework/Resources/bin/R 2006-05-19  
19:08:56.0 -0300
+++ /Library/Frameworks/R.framework/Resources/bin/R-orig 
2006-05-19 19:08:58.0 -0300
@@ -20,8 +20,7 @@
# This script is shared by parallel installs, so nothing in it should
# depend on the sub-architecture except the default here.
#=== BEGIN CRAN CHANGES ===
-R_ARCH=/`arch`
-export R_ARCH
+: ${R_ARCH=/`arch`}
PATH=/usr/local/gcc4.0/bin:$PATH
export PATH
# END CRAN CHANGES 

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