Re: [R] Problem reading binaries created with fortran

2009-12-17 Thread Duncan Murdoch

On 17/12/2009 3:48 PM, kapo coulibaly wrote:

Is it possible to read fortran binaries with R? I tried unsucessfully and my
understanding is that fortran write binaries with leading and trailing
bytes. I get numbers but not the right ones.
Thanks

ps: the binary I'm interested in reading is a MODFLOW output with a mix of
character, double and integers.


R can read most binary files, as long as you tell it the right format to 
read.  You need to consult the documentation of the program that 
produced the file to find out the format.  If it adds leading or 
trailing bytes, just tell R to skip over those --- but you need to know 
how much to skip.


Duncan Murdoch

__
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] Problem reading binaries created with fortran

2009-12-17 Thread Duncan Murdoch

On 17/12/2009 3:48 PM, kapo coulibaly wrote:

Is it possible to read fortran binaries with R? I tried unsucessfully and my
understanding is that fortran write binaries with leading and trailing
bytes. I get numbers but not the right ones.
Thanks

ps: the binary I'm interested in reading is a MODFLOW output with a mix of
character, double and integers.


One other thing:  the hexView package does a very nice job of displaying 
the file, so you can work out what the structure is if the documentation 
is unclear (or nonexistent).


Duncan Murdoch

__
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] Sweave Makefile issue

2009-12-17 Thread Duncan Murdoch

On 17/12/2009 3:19 PM, Luc Villandré wrote:

Dear R-specialists,

I am trying to create a Makefile that will first convert all my .Rnw 
files into .tex files and then, that will run the LaTeX compiler to 
produce a pdf document. This issue has been discussed before. Hence, 
I've basically adapted a Makefile I found at 
http://n4.nabble.com/R-Sweave-R-and-complex-latex-projects-td810020.html#a810023 
to make it compatible with a Windows XP environment. You will find my 
version of it at the end of this message.


It doesn't exactly address your question, but you might also want to 
look at the patchDVI package on R-forge.  It takes a Rnw file as input, 
runs Sweave and some version of latex, then patches the result so that 
reverse search (from the .dvi or a .pdf with synctex) goes back to the 
Rnw file instead of going to the .tex file.


It doesn't address the problem of an output file depending on multiple 
.Rnw files, but it does at least handle the case of one .Rnw being 
included by a master .tex file.  For example, I use something close to 
this in a batch file to process one .Rnw and display the whole thing:


echo library(patchDVI);SweaveMiktex('%2', '%3.tex') | Rterm --slave
yap -1 -s%1%2 %3.dvi

The arguments are
%1=line number,
%2=filename of .Rnw file,
%3=basename of master file (or of the filename)

Duncan Murdoch



However, it's not doing what I expect it to do. Instead of only using 
pdfTeX on total_article.tex (which is the file with the necessary 
headers and \include's), it tries to convert all my tex files into pdf, 
which of course cannot be done since only total_article.tex has the 
necessary structure to be understood by the compiler.


What's wrong then with this Makefile (I am using GNU Make 3.81)?

I will be grateful for any help you can provide.
_

MASTER = total_article.pdf

# the master document depends on all of the tex files
Rfile = prepareScript.R
RNWFILES = $(wildcard *.Rnw)
TEXFILES = $(wildcard *.tex)
DEPENDS = $(patsubst %.Rnw,%.tex,$(RNWFILES)) $(TEXFILES)

RERUN = (There were undefined references|Rerun to get 
(citations|cross-references|the bars) (correct|right)|Table widths have 
changed. Rerun LaTeX.|Linenumber reference failed)

RERUNBIB = No file.*\.bbl|Citation.*undefined

all : $(MASTER)

$(MASTER) : $(DEPENDS)

%.tex : %.Rnw

SWEAVE '$'

%.pdf : %.tex

@pdflatex $
@egrep -c $(RERUNBIB) $*.log  (bibtex $*;pdflatex $); true
@egrep $(RERUN) $*.log  (pdflatex $) ; true
@egrep $(RERUN) $*.log  (pdflatex $) ; true

clean:
@del *.aux *.log *.bbl *.blg *.brf *.cb *.ind *.idx *.ilg  \
  *.inx *.ps *.dvi *.toc *.out *.lot *~ *.lof *.ttt *.fff \
  *.eps *.pdf
@del -f $(patsubst %.Rnw,%.tex,$(RNWFILES))
   
script :

Rcmd BATCH $(Rfile)



__
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] Problem reading binaries created with fortran (More infos)

2009-12-17 Thread Duncan Murdoch

On 17/12/2009 4:30 PM, kapo coulibaly wrote:

The structure of the file is clear (see below) the first line is made of
integers and doubles with the fifth being a text string followed by arrays
of double precision number.:
int1 int2 double1 double2 text int3 int4 int5
(array of double)

here is an example of file:
1 1 1.0 1.0 HEAD 160 224 3
23.4  34.5 ..


That's not the file that readBin is reading, that's the output from 
something that knows how to read it.  If you show us the hex dump from 
hexView, it's likely we can suggest what to do to read it, especially 
knowing the above output.


Duncan Murdoch




I tried to read the first line with readBin (results are copied below):


zz - file(heads.hds, rb)
readBin(zz,what=integer,n=2)

[1] 1 1

readBin(zz,what=double,n=2)

[1]  7.812502e-03 6.013470e-154

readBin(zz,what=character,n=1)

[1] HEAD 

readBin(zz,what=integer,n=3)

[1] 14680064655360


Thanks





On Thu, Dec 17, 2009 at 3:52 PM, Phil Spector spec...@stat.berkeley.eduwrote:


Kapo -
  You'll get a better response if you tell us what you've already tried,
and an even better response if you
can provide a reproducible example.

   - Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu



On Thu, 17 Dec 2009, kapo coulibaly wrote:

 Is it possible to read fortran binaries with R? I tried unsucessfully and

my
understanding is that fortran write binaries with leading and trailing
bytes. I get numbers but not the right ones.
Thanks

ps: the binary I'm interested in reading is a MODFLOW output with a mix of
character, double and integers.

   [[alternative HTML version deleted]]

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




[[alternative HTML version deleted]]

__
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-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] Getting Rd pages right for redefined S3 generic

2009-12-18 Thread Duncan Murdoch

On 17/12/2009 11:08 PM, S Ellison wrote:

I'm writing a package, and would appreciate advice on controlling the
help documentation cross-references for a redefined generic.

I wanted to define a cbind equivalent for an object that mostly behaves
like a data frame. base::cbind dispatches to a data frame method if
_any_ parameter is a data frame, so I defined a new S3 cbind and
cbind.default to handle dispatch on first object only. Though I confess
that redefining cbind leaves me a tad nervous, that all works OK so far.

However, R cmd tells me (rightly) that I haven't documented the generic
and new default. But I don't want to; I want ?cbind to point to the base
package help pages, not to mine.


But then the documentation will be incorrect, since it mentions the 
non-standard handling of dataframes, which you've done away with.



Assuming that's not unwise (?), what do I have to do to tell R cmd that
it should not look for Rd docs for cbind and cbind.default in my package
whilst still having my generic handle dispatch correctly?

It looks like one answer _might_ be not to export my redefined cbind  -
but will a local generic still work properly if it's not exported?


I would say that what you've done is unwise.  I would rename the 
function to avoid future confusion, especially if you decide to export 
it.  Even if it's for internal use only, won't you want a reminder in 2 
years time that cbind(a,b) doesn't mean what the documentation says it 
means?


Duncan Murdoch

__
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] How to define new operators

2009-12-18 Thread Duncan Murdoch

On 18/12/2009 10:22 AM, berga...@gmail.com wrote:

Dear R community

I try to create a new operator to build a special sum of two CashFlows. (my  
S4 Class)


I tried the following but this is actually not what I want.

setGeneric(++,function(e1,e2)standardGeneric(++))

setMethod(+,signature=list(CashFlow,CashFlow),function(e1,e2){
print(+)
})
setMethod(++,signature=list(CashFlow,CashFlow),function(e1,e2){
print(++)
})

The problem here is that this work but it treats ++ as a general  
function.. the call is ++(e1,e2).

I'm looking for somthing like e3 - e1 ++ e2
The R parser limits the operators it recognizes to the predefined ones, 
plus user-defined ones of the form %op% (where op could be ++ if you 
liked).  You can't define ++ as an operator because the parser will see 
it as two plus signs, not as a single infix operator.


Duncan Murdoch

__
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] Inserting .png plots in MS Word.

2009-12-19 Thread Duncan Murdoch

On 19/12/2009 1:28 PM, Wenjie Lee wrote:

Hi R Users,

I'm using following sample code to save png plots.

png(file=sample.png, width=8, height=6)

Then I copy or use insert pictures function to get the image into MS Word.
After copying, if I try to stretch or re-size the image it starts getting
distorted. Is there a way to standardized graph pixels so that the
sharpness of the graph is maintained (at least for minor
stretching/re-sizing). Is it possible to achieve this?

I know I can change width and height, but I have to submit this .doc file to
my adviser and he may need to re-size it.

Any suggestion would be highly appreciated,



If you want to resize the graphic, you shouldn't use a bitmap format. 
Use .pdf, .eps, .wmf, etc.  It's still best to generate the graph at the 
final size (to get fonts and line widths right), but you'll get better 
results than with resizing a bitmap.


I don't know which vector formats your advisor's version of MS Word 
supports, but presumably their docs will tell you.


Duncan Murdoch

__
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] Inserting .png plots in MS Word.

2009-12-19 Thread Duncan Murdoch

On 19/12/2009 3:06 PM, Wenjie Lee wrote:

Thanks David and Duncan,
 
pdf()/eps() are good options. Can you please tell which function 
produces .wmf images.


win.metafile() (on Windows only, I think) produces .wmf images.

I finally want to copy/insert these images into word file (.doc) and 
submit it to my adviser, and keep a possibility to re-size pictures.
 
Is it possible to add these .pdf / .eps images into word (instead of latex).


I don't know, I rarely use it.

Duncan Murdoch



Thanks,
Wenjie

On Sat, Dec 19, 2009 at 1:49 PM, Duncan Murdoch murd...@stats.uwo.ca 
mailto:murd...@stats.uwo.ca wrote:


On 19/12/2009 1:28 PM, Wenjie Lee wrote:

Hi R Users,

I'm using following sample code to save png plots.

png(file=sample.png, width=8, height=6)

Then I copy or use insert pictures function to get the image
into MS Word.
After copying, if I try to stretch or re-size the image it
starts getting
distorted. Is there a way to standardized graph pixels so that the
sharpness of the graph is maintained (at least for minor
stretching/re-sizing). Is it possible to achieve this?

I know I can change width and height, but I have to submit this
.doc file to
my adviser and he may need to re-size it.

Any suggestion would be highly appreciated,


If you want to resize the graphic, you shouldn't use a bitmap
format. Use .pdf, .eps, .wmf, etc.  It's still best to generate the
graph at the final size (to get fonts and line widths right), but
you'll get better results than with resizing a bitmap.

I don't know which vector formats your advisor's version of MS Word
supports, but presumably their docs will tell you.

Duncan Murdoch




__
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] Limit on number of times Realloc can be called?

2009-12-20 Thread Duncan Murdoch

Adam Waldemar Kowalewski wrote:

Hello,

I've been writing a program in C that will be called by R. I seem to have
stumbled upon an odd error that seems to suggest there is a limit on the
number of times Realloc (the R version as defined in the manual
R-extenstions not the C version realloc) when I try to use the
following program:

#include R.h
#include Rinternals.h

SEXP test_mem_alloc(SEXP z) {
double *t = Calloc(sizeof(double), double);
*t = 2;
SEXP end_product;
int i = 0;
for(i=1; i  20; i++) {
t = Realloc(t, sizeof(t) + sizeof(double), double);
  


The second argument to Realloc is supposed to be the number of elements 
to allocate.  sizeof(t) is 4 or 8 (32 bit or 64 bit), sizeof double is 
8, so you always allocate 12 or 16 elements.  Then in the next line you 
write out of bounds.


Duncan Murdoch


t[i] = i;
}
PROTECT(end_product = allocVector(REALSXP,6));
for(i = 0; i  20; i++) {
REAL(end_product)[i] = t[i];
}
UNPROTECT(1);
Free(t);
return end_product;
}

I call it from R using the following script:

z - 1

test_mem_alloc - function(z) {
if(!(is.loaded(test_mem_alloc_v6))) dyn.load(test_mem_alloc_v6.dll)
out - .Call(test_mem_alloc,
as.double(z))
return(out)
dyn.unload(test_mem_alloc_v6.dll)
}

Basically I get the following error messages:

First:

Runtime Error!

Program: C:\Program Files\R\R-2.10.0\bin\Rgui.exe

This application has requested the Runtime to terminate it in an unusual
way. Please contact the application's support team for more information.

The second error message is:

The instruction at 0x002c. The memory could not be read.

Now, if change the number of times the program goes through the for loop
from 20 to say 6, and hence calls Realloc fewer times, then the program
runs without any problems. It does not seem to have anything to do with
the size of the memory being allocated as I changed the size of the total
memory being allocated with a for loop with only 6 iterations to
something that is substantially larger than the memory being allocated in
the for loop when calling Realloc twenty times and the program ran
successfully. Has anyone else come across this problem or knows about some
sort of limitation on using Realloc that is not specified in the R
documentation?

Any help would be greatly appreciated.

Yours sincerely

Adam Kowalewski

__
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-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] Playing with rgl: a Youtube video

2009-12-21 Thread Duncan Murdoch
I've just posted a demo made with the rgl package to Youtube, visible 
here:  http://www.youtube.com/watch?v=prdZWQD7L5c


For future reference, here are the steps I used:

1.  Design a shape to be displayed, and then play with the animation 
functions to make it change over time.  Use play3d to do it live in R, 
movie3d to write the individual frames of the movie to .png files.


2.  Use the ffmpeg package (not an R package, a separate project at 
http://ffmpeg.org) to convert the .png files to an .mp4 file.  The 
individual frames totalled about 1 GB; the compressed movie is about 45 
MB. 

3.  Upload to Youtube.  I'm not a musician, so I had to use one of their 
licensed background tracks, I couldn't write my own.  I spent a lot of 
time picking one and then adjusting the timing of the video to 
compensate.  Each render/upload cycle at full resolution took about an 
hour and a half.  It's a lot faster to render in a smaller window with 
fewer frames per second, but it's still tedious.   It's easier to 
synchronize if you actually have a copy of the music locally, but 
Youtube doesn't let you download their music.  So the timing isn't 
perfect, but it's good enough for me!


Duncan Murdoch

__
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] Problem with expand.grid

2009-12-22 Thread Duncan Murdoch

On 22/12/2009 11:19 AM, Keith Jewell wrote:
Just confirming it isn't the bug fixed in 2.11.0dev, and giving an even 
simpler example:
  


The docs for expand.grid say it works on lists, but they don't mention 
dataframes.  Although a dataframe is in many ways a list with extra 
structure, apparently something in the subsetting done in expand.grid 
assumes it has a regular list, not a dataframe.


So you might get what you want with expand.grid(as.list(dDF)), though 
this doesn't really make sense:  do you really want 10^7 rows, with lots 
of repetition?  I suspect you want to expand the grid of unique values 
in each column, which you could do using


expand.grid(lapply(dDF, unique))

Duncan Murdoch


R version 2.11.0 Under development (unstable) (2009-12-20 r50794)

 expand.grid(data.frame(y=1:10, t=1:10))
Error in `[[-.data.frame`(`*tmp*`, i, value = c(1L, 2L, 3L, 4L, 5L, 6L,  :
  replacement has 100 rows, data has 10

Keith Jewell k.jew...@campden.co.uk wrote in message 
news:hgqqja$rk...@ger.gmane.org...

 Hi All,

 This example code
 
 dDF - structure(list(y = c(4.75587, 4.8451, 5.04139, 4.85733, 5.20412,
 5.92428, 5.69897, 4.78958, 4, 4), t = c(0, 48, 144, 192, 240,
 312, 360, 0, 48, 144), Batch = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1
 ), T = c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2), pH = c(4.6, 4.6, 4.6,
 4.6, 4.6, 4.6, 4.6, 4.6, 4.6, 4.6), S = c(0, 0, 0, 0, 0, 0, 0,
 0, 0, 0), N = c(0, 0, 0, 0, 0, 0, 0, 80, 80, 80)), .Names = c(y,
 t, Batch, T, pH, S, N), row.names = c(NA, 10L), class = 
 data.frame)

 str(dDF)
 expand.grid(dDF)
 
 'hangs' for a while and then gives an error

 Error in `[[-.data.frame`(`*tmp*`, i, value = c(4.75587, 4.8451, 5.04139, 
 :

  replacement has 1000 rows, data has 10

 In NEWS.R-2.11.0dev I read:
o The new (in 2.9.0) 'stringsAsFactors' argument to expand.grid()
 was not working: it now does work but has default TRUE for
 backwards compatibility.

 but I don't think that's relevant, I have no factors.

 I'm probably being silly. Can anyone point out where?

 Best...

 Keith Jewell

 --please do not edit the information below--

 Version:
 platform = i386-pc-mingw32
 arch = i386
 os = mingw32
 system = i386, mingw32
 status = Patched
 major = 2
 minor = 10.1
 year = 2009
 month = 12
 day = 21
 svn rev = 50796
 language = R
 version.string = R version 2.10.1 Patched (2009-12-21 r50796)

 Windows Server 2003 x64 (build 3790) Service Pack 2

 Locale:
 LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United 
 Kingdom.1252;LC_MONETARY=English_United 
 Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252


 Search Path:
 .GlobalEnv, package:stats, package:graphics, package:grDevices, 
 package:utils, package:datasets, package:methods, Autoloads, package:base



__
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-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] Playing with rgl: a Youtube video

2009-12-22 Thread Duncan Murdoch

On 22/12/2009 12:49 PM, Mark Knecht wrote:

On Mon, Dec 21, 2009 at 4:42 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:
 I've just posted a demo made with the rgl package to Youtube, visible here:
  http://www.youtube.com/watch?v=prdZWQD7L5c

 For future reference, here are the steps I used:

 1.  Design a shape to be displayed, and then play with the animation
 functions to make it change over time.  Use play3d to do it live in R,
 movie3d to write the individual frames of the movie to .png files.

 2.  Use the ffmpeg package (not an R package, a separate project at
 http://ffmpeg.org) to convert the .png files to an .mp4 file.  The
 individual frames totalled about 1 GB; the compressed movie is about 45 MB.
 3.  Upload to Youtube.  I'm not a musician, so I had to use one of their
 licensed background tracks, I couldn't write my own.  I spent a lot of time
 picking one and then adjusting the timing of the video to compensate.  Each
 render/upload cycle at full resolution took about an hour and a half.  It's
 a lot faster to render in a smaller window with fewer frames per second, but
 it's still tedious.   It's easier to synchronize if you actually have a copy
 of the music locally, but Youtube doesn't let you download their music.  So
 the timing isn't perfect, but it's good enough for me!

 Duncan Murdoch


Cool enough video. Thanks for sharing.

I'm curious - did you do the equations for the knot in R? If so what
did they look like, assuming there's no reason you cannot share it.
  


The knot has equation

cbind(sin(theta)+2*sin(2*theta), 2*sin(3*theta), cos(theta)-2*cos(2*theta))

The threads in the braid have equation

cbind(sin(theta) + sin(2*theta)/2, sin(theta-pi) + sin(2*theta)/2, theta)

in the local coordinates of the knot.

Overall it's about 100 lines of R code, too ugly to post.

Duncan Murdoch

__
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] Playing with rgl: a Youtube video

2009-12-23 Thread Duncan Murdoch

On 23/12/2009 7:13 AM, Rainer M Krug wrote:



On Tue, Dec 22, 2009 at 8:10 PM, Duncan Murdoch murd...@stats.uwo.ca 
mailto:murd...@stats.uwo.ca wrote:


On 22/12/2009 12:49 PM, Mark Knecht wrote:

On Mon, Dec 21, 2009 at 4:42 AM, Duncan Murdoch
murd...@stats.uwo.ca mailto:murd...@stats.uwo.ca wrote:
  I've just posted a demo made with the rgl package to Youtube,
visible here:
   http://www.youtube.com/watch?v=prdZWQD7L5c
 
  For future reference, here are the steps I used:
 
  1.  Design a shape to be displayed, and then play with the
animation
  functions to make it change over time.  Use play3d to do it
live in R,
  movie3d to write the individual frames of the movie to .png
files.
 
  2.  Use the ffmpeg package (not an R package, a separate
project at
  http://ffmpeg.org) to convert the .png files to an .mp4 file.
 The
  individual frames totalled about 1 GB; the compressed movie
is about 45 MB.


Could you please post the command line options you used for ffmpeg? I 
remember I wanted to do an animation, also from .png, and I struggled a lot.


Sure.  The png files were 1024 by 768, designed to be displayed at 
24fps.  The command line was


ffmpeg  -b 240 -r 24 -i movie%03d.png -s xga movie.mp4

The -b option controls the target bit rate.  The -r option says how many 
frames per second, -i includes all the files (named things like 
movie001.png, etc.), -s sets the output size, with xga being a quick way 
to say 1024x768, and movie.mp4 is the output file.  There are tons of 
options to change codec, etc., but I found the -b option was the only 
one I needed to play with.


Duncan Murdoch



Rainer
 


  3.  Upload to Youtube.  I'm not a musician, so I had to use
one of their
  licensed background tracks, I couldn't write my own.  I spent
a lot of time
  picking one and then adjusting the timing of the video to
compensate.  Each
  render/upload cycle at full resolution took about an hour and
a half.  It's
  a lot faster to render in a smaller window with fewer frames
per second, but
  it's still tedious.   It's easier to synchronize if you
actually have a copy
  of the music locally, but Youtube doesn't let you download
their music.  So
  the timing isn't perfect, but it's good enough for me!
 
  Duncan Murdoch
 

Cool enough video. Thanks for sharing.

I'm curious - did you do the equations for the knot in R? If so what
did they look like, assuming there's no reason you cannot share it.
 



The knot has equation

cbind(sin(theta)+2*sin(2*theta), 2*sin(3*theta),
cos(theta)-2*cos(2*theta))

The threads in the braid have equation

cbind(sin(theta) + sin(2*theta)/2, sin(theta-pi) + sin(2*theta)/2,
theta)

in the local coordinates of the knot.

Overall it's about 100 lines of R code, too ugly to post.

Duncan Murdoch


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




--
NEW GERMAN FAX NUMBER!!!

Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation 
Biology, UCT), Dipl. Phys. (Germany)


Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa

Cell:   +27 - (0)83 9479 042
Fax:+27 - (0)86 516 2782
Fax:+49 - (0)321 2125 2244
email:  rai...@krugs.de mailto:rai...@krugs.de

Skype:  RMkrug
Google: r.m.k...@gmail.com mailto:r.m.k...@gmail.com



__
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] Unwanted association between a function and a namespace

2009-12-23 Thread Duncan Murdoch

On 23/12/2009 3:36 PM, p_conno...@slingshot.co.nz wrote:

I can't understand how the plyr package is turning up here:


sessionInfo()

R version 2.10.1 (2009-12-14)
i686-pc-linux-gnu

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] lattice_0.17-26

loaded via a namespace (and not attached):
[1] grid_2.10.1 plyr_0.1.9

I can understand that lattice would be using grid without having that
package loaded, but I can't understand how plyr got there.


One way for this to happen is if you have a copy of a function from plyr 
in your global environment.  The functions in plyr reference its 
namespace, so you'd get it loaded that way.




It wouldn't matter if that namespace hadn't become associated somehow
with a function I have somewhere else on the search path (thereby
rendering the function unfindable).  


This doesn't make sense.  If the function is on the search path, it 
doesn't matter what namespace is associated with it:  you'll find it. 
If you have a function with the same name in globalenv() then you'll 
have problems.  The simple solution is to remove it (e.g. rm(f)); a 
better long term solution is to *never* store anything in your workspace 
between sessions.  Start with a clean global environment each time.


Duncan Murdoch

My guess is that if I knew how that

happened, I'd then know why plyr is loaded by namespace.  However, I'm
lost for ideas on how that could have happened.

Suggestions as to where I should be looking greatly appreciated.  Or, even
if that's unknowable, how to remove the association between the namespace
and the function.

TIA

--
Patrick Connolly
Plant  Food Research
Mt Albert
Auckland
New Zealand
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~

__
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-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] Unwanted association between a function and a namespace

2009-12-23 Thread Duncan Murdoch

On 23/12/2009 6:08 PM, p_conno...@slingshot.co.nz wrote:

Quoting Duncan Murdoch murd...@stats.uwo.ca:


On 23/12/2009 3:36 PM, p_conno...@slingshot.co.nz wrote:

I can't understand how the plyr package is turning up here:



[...]


I can understand that lattice would be using grid without having that
package loaded, but I can't understand how plyr got there.

One way for this to happen is if you have a copy of a function from plyr
in your global environment.  The functions in plyr reference its
namespace, so you'd get it loaded that way.


I've never loaded the plyr package, except for when I used the reshape
package.  It's possible at that time, I had occasion to use a function
I have of the same name as one in the plyr package, but I would not
have saved a copy of either function in the global environment.


It wouldn't matter if that namespace hadn't become associated somehow
with a function I have somewhere else on the search path (thereby
rendering the function unfindable).

This doesn't make sense.  If the function is on the search path, it
doesn't matter what namespace is associated with it:  you'll find it.


Perhaps I need to be more explicit.  The find() function does indeed
find it, and I can edit it in ESS using the normal C-c C-d sequence.
HOWEVER, when I do args() of it, I get the args of the plyr function
-- even when I've not loaded that package.  Trying to use the function
in code ends up calling the plyr function.


If you have a function with the same name in globalenv() then you'll
have problems.  The simple solution is to remove it (e.g. rm(f)); a
better long term solution is to *never* store anything in your workspace
between sessions.  Start with a clean global environment each time.


I thought I'd found a fix when I specifically loaded plyr and then
detached it with the unload = TRUE argument.  sessionInfo() seems to
show that I had gotten rid of the plyr by namespace, but I still get this:

summarize
function(.data, ...) {
  eval(substitute(data.frame(...)), .data, parent.frame())
}
environment: namespace:plyr

Curiouser and curiouser as Alice would say.



And where is that function?  find(summarize) should tell you.  The 
fact that it has the plyr namespace as its environment doesn't mean it 
is stored there.


Duncan Murdoch

__
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] Remove double quotation marks

2009-12-29 Thread Duncan Murdoch

On 29/12/2009 1:16 PM, Lisa wrote:

Dear All,

I am not sure how to remove double quotation marks in a string, e.g.,
paste(variable, 1). Can anybody please help me solve it? Thank you in
advance.


I think you need to tell us what is wrong with what you get from that. 
When I look at the result:


 cat(paste(variable, 1), \n)
variable 1

I see no quotation marks.  (If you use print() you'll see some, but they 
aren't part of the string, they are just used in the default display by 
print().)


Duncan Murdoch

__
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] pass functions and arguments to function

2009-12-29 Thread Duncan Murdoch

On 29/12/2009 3:08 PM, Hao Cen wrote:

Hi,

I wonder how to pass several functions and their arguments as arguments to
a function. For example, the main function is

f = function(X  ) {
   process1(X)
   ...


   process2(X)
}

I have a few functions that operate on X, e.g. g1(X, par1), g2(X, par2),
g3(X, par3).  par1, par2 and par3 are parameters and of different types. I
would like to pass g1, g2, g3 and their arguments to f and g1, g2, g3 may
appear to be in different orders. So that final effect of the passing is


Just pass them.  If you know there are three functions, set up f as

f - function(X, f1, f2, f3, par1, par2, par3) {
  process1(X)
  f1(X, par1)
  f2(X, par2)
  f3(X, par3)
  process2(X)
}

and call it as

f(X, g1, g2, g3, par1, par2, par3)

If you don't know how many functions there will be, put them in a list:

f - function(X, fs, pars) {
  process1(X)
  for (i in 1:length(fs)) fs[[i]](pars[[i]])
  process2(X)
}

and call it as

f(X, list(g1, g2, g3), list(par1, par2, par3))

Duncan Murdoch



f = function(X  ) {
   process1(X)
   g1(X, par1)
   g2(X, par2)
   g3(X, par3)
   process2(X)
}

If I pass g2(X, par2),g3(X, par3), g1(X, par1) to f, I would expect to get
the effect of
f = function(X  ) {
   process1(X)
   g2(X, par2)
   g3(X, par3)
   g1(X, par1)
   process2(X)
}

Appreciate any suggestions.

thanks

Jeff


ps please ignore my previous blank subject email. It was accidentally sent
before the letter was completed.

__
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-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] pass functions and arguments to function

2009-12-29 Thread Duncan Murdoch

On 29/12/2009 5:24 PM, Hao Cen wrote:

Thanks. I don't know how many functions there will be.

What if g1, g2, g3 have variable number of parameters? say g1 has parg1a,
parg1b, and g3 has parg3a, parg3b, parg3c, parg4d.


pars could be a list of lists of parameters instead of a list of 
parameters, then the calls could be


do.call(fs[[i]], pars[[i]])

But it's very unlikely that you are doing something that's a good idea.

Duncan Murdoch



 f - function(X, fs, pars) {
process1(X)
for (i in 1:length(fs))
  fs[[i]](pars[[i]])   # doesn't work here

process2(X)

 }


On Tue, December 29, 2009 4:57 pm, Duncan Murdoch wrote:

On 29/12/2009 3:08 PM, Hao Cen wrote:


Hi,


I wonder how to pass several functions and their arguments as arguments
to a function. For example, the main function is

f = function(X  ) { process1(X) ...



process2(X) }


I have a few functions that operate on X, e.g. g1(X, par1), g2(X,
par2), g3(X, par3).  par1, par2 and par3 are parameters and of different
types. I would like to pass g1, g2, g3 and their arguments to f and g1,
g2, g3 may appear to be in different orders. So that final effect of the
passing is

Just pass them.  If you know there are three functions, set up f as


f - function(X, f1, f2, f3, par1, par2, par3) { process1(X) f1(X, par1)
f2(X, par2) f3(X, par3) process2(X) }


and call it as

f(X, g1, g2, g3, par1, par2, par3)

If you don't know how many functions there will be, put them in a list:


f - function(X, fs, pars) { process1(X) for (i in 1:length(fs))
fs[[i]](pars[[i]]) process2(X) }


and call it as

f(X, list(g1, g2, g3), list(par1, par2, par3))

Duncan Murdoch



f = function(X  ) { process1(X) g1(X, par1) g2(X, par2) g3(X, par3)
process2(X) }


If I pass g2(X, par2),g3(X, par3), g1(X, par1) to f, I would expect to
get the effect of f = function(X  ) { process1(X) g2(X, par2) g3(X, par3)
g1(X, par1) process2(X) }


Appreciate any suggestions.


thanks

Jeff



ps please ignore my previous blank subject email. It was accidentally
sent before the letter was completed.

__
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-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] seg-fault... but on what

2009-12-30 Thread Duncan Murdoch

On 30/12/2009 9:20 AM, Nick Torenvliet wrote:

I got the following after running succesfully through this loop 28 million
times... the loop opens text files in a directory and inserts line by line
into a database...
  


This looks like a bug in RMySql or possibly R.  What versions are you 
using?  Can you make it happen reproducibly with the same script?  Can 
you simplify the script so it happens quickly, rather than requiring 28 
million iterations?  Without a simple recipe to reproduce it, I doubt if 
anyone would be able to track down the problem.


Duncan Murdoch

 *** caught segfault ***
address 0xc010, cause 'memory not mapped'

Traceback:
 1: .getGeneric(f, where, package)
 2: getGeneric(coerce, where = where)
 3: as(obj, integer)
 4: mysqlConnectionInfo(dbObj, ...)
 5: dbGetInfo(conn, rsId)
 6: dbGetInfo(conn, rsId)
 7: dbListResults(con)
 8: dbListResults(con)
 9: mysqlQuickSQL(conn, statement, ...)
10: dbGetQuery(con, sql)
11: dbGetQuery(con, sql)
12: doTryCatch(return(expr), name, parentenv, handler)
13: tryCatchOne(expr, names, parentenv, handlers[[1L]])
14: tryCatchList(expr, classes, parentenv, handlers)
15: tryCatch(expr, error = function(e) {call - conditionCall(e)if
(!is.null(call)) {if (identical(call[[1L]],
quote(doTryCatch))) call - sys.call(-4L)dcall -
deparse(call)[1L]prefix - paste(Error in, dcall, : )
LONG - 75Lmsg - conditionMessage(e)sm - strsplit(msg,
\n)[[1L]]if (14L + nchar(dcall, type = w) + nchar(sm[1L], type =
w)  LONG) prefix - paste(prefix, \n  , sep =
)}else prefix - Error : msg - paste(prefix,
conditionMessage(e), \n, sep = ).Internal(seterrmessage(msg[1L]))
if (!silent  identical(getOption(show.error.messages), TRUE))
{cat(msg, file = stderr())
.Internal(printDeferredWarnings())}invisible(structure(msg, class =
try-error))})
16: try(dbGetQuery(con, sql))
17: eval.with.vis(expr, envir, enclos)
18: eval.with.vis(ei, envir)
19: source(~/SoothSayer/EODData/DBScripts/loadEODQuotes.r)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:


The code is pretty simple...


library(RMySQL)
drv - dbDriver(MySQL)
con - dbConnect(drv, host=localhost, dbname=markets, user=root,
pass=embryoni3)
fileList - list.files(pattern = [[:upper:]]{2,}, all.files = FALSE,
full.names = FALSE, recursive = FALSE, ignore.case = FALSE)
for (x in 1:length(fileList)){
string - strsplit(fileList[x], _, fixed = TRUE)
string - string[[1]][1]
fileLines - read.csv(fileList[x],header = FALSE,row.names = NULL )

for ( j in 1:length(fileLines[,1])){
sql - paste(insert into endOfDayData
(date,market,symbol,open,high,low,close,volume) values (',
fileLines[j,2],',',string,',',as.character(fileLines[j,1]),',',fileLines[j,3],',',fileLines[j,4],',',fileLines[j
,5],',',fileLines[j,6],',',fileLines[j,7],'),sep=)
#print(sql)
atmpt - try(dbGetQuery(con,sql))
options(show.error.messages = TRUE)
if(inherits(atmpt, try-error)){

}

}

}

dbDisconnect(con)

My understanding was that in general R liked to put a placekeeper like NA or
NULL in for non-existent elements of defined structures... so I was
surprised to see a seg fault... I'm having trouble interpretting the
error... any clues would be appreciated.

Nick

[[alternative HTML version deleted]]

__
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-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] Obtaining partial output from a function that does not run to completion.

2009-12-31 Thread Duncan Murdoch

On 31/12/2009 9:29 AM, John Sorkin wrote:
I have written a function that contains runs 
lm()

vif()  and
glm()

When the glm() blows up with an error message, I don't get the output from 
either the lm() or vf() even thought neither lm() nor vif() have any problems . 
How can I force the function to print sequential results rather than wait for 
the entire function to complete before listing the functhion's output?


Call print, e.g.

print(x - lm(...))
print(y - vif(...))
etc.

Duncan Murdoch


Thanks,
John



minBMI-function(SS,SimData)
{
SampleData-sample(1:SS,size=SS,replace=TRUE)
fitBMIEpiRevlm-lm(AAMTCARE~BMIEpiRevAdjc+BMIEpiRevAdjcSq+SEX+jPHI+jMEDICAID+H_AGE+jMARSTAT+factor(jEDUCATION)+factor(jsmokercat)+factor(jrace)+log(INCOME_C+1),data=SimData[SampleData,],x=TRUE)
print(summary(fitBMIEpiRevlm))
print(vif(fitBMIEpiRevlm))
fitBMIEpiRev- 
glm(AAMTCARE~BMIEpiRevAdjc+BMIEpiRevAdjcSq+SEX+jPHI+jMEDICAID+H_AGE+jMARSTAT+factor(jEDUCATION)+factor(jsmokercat)+factor(jrace)+log(INCOME_C+1),data=SimData[SampleData,],family=Gamma(link=log))

print(summary(fitBMIEpiRev))
}
minBMI(SS,SimData)  



John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

__
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-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] Obtaining partial output from a function that does not run to completion.

2009-12-31 Thread Duncan Murdoch

John Sorkin wrote:

Duncan,
Thank you, however, if you will look at my function (bottom of this Email 
message), you will see that I have used print(). It appears that the print 
function is not run until the entire function completes running.
  


No, statements are run in the order you give them.  The output of the 
prints might not appear immediately, but they will be executed.


You haven't posted any code that I can run, so I can't tell you what is 
going wrong in your case, but here's what I see with my own example:


 f - function(x) {
+ print(1)
+ print(2)
+ stop('error')
+ }
 f(2)
[1] 1
[1] 2
Error in f(2) : error

Duncan Murdoch

John




John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing) Duncan Murdoch 
murd...@stats.uwo.ca 12/31/2009 10:19 AM 
On 31/12/2009 9:29 AM, John Sorkin wrote:
  
I have written a function that contains runs 
lm()

vif()  and
glm()

When the glm() blows up with an error message, I don't get the output from 
either the lm() or vf() even thought neither lm() nor vif() have any problems . 
How can I force the function to print sequential results rather than wait for 
the entire function to complete before listing the functhion's output?



Call print, e.g.

print(x - lm(...))
print(y - vif(...))
etc.

Duncan Murdoch

  

Thanks,
John



minBMI-function(SS,SimData)
{
SampleData-sample(1:SS,size=SS,replace=TRUE)
fitBMIEpiRevlm-lm(AAMTCARE~BMIEpiRevAdjc+BMIEpiRevAdjcSq+SEX+jPHI+jMEDICAID+H_AGE+jMARSTAT+factor(jEDUCATION)+factor(jsmokercat)+factor(jrace)+log(INCOME_C+1),data=SimData[SampleData,],x=TRUE)
print(summary(fitBMIEpiRevlm))
print(vif(fitBMIEpiRevlm))
fitBMIEpiRev- 
glm(AAMTCARE~BMIEpiRevAdjc+BMIEpiRevAdjcSq+SEX+jPHI+jMEDICAID+H_AGE+jMARSTAT+factor(jEDUCATION)+factor(jsmokercat)+factor(jrace)+log(INCOME_C+1),data=SimData[SampleData,],family=Gamma(link=log))

print(summary(fitBMIEpiRev))
}
minBMI(SS,SimData)  



John David Sorkin M.D., Ph.D.
Chief, Biostatistics and Informatics
University of Maryland School of Medicine Division of Gerontology
Baltimore VA Medical Center
10 North Greene Street
GRECC (BT/18/GR)
Baltimore, MD 21201-1524
(Phone) 410-605-7119
(Fax) 410-605-7913 (Please call phone number above prior to faxing)

Confidentiality Statement:
This email message, including any attachments, is for th...{{dropped:6}}

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




Confidentiality Statement:
This email message, including any attachments, is for ...{{dropped:3}}


__
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] using optim

2010-01-02 Thread Duncan Murdoch

On 01/01/2010 11:45 PM, Erin Hodgess wrote:

Dear R People:

I know that you can use optim for a function with several parameters.

Is there an equivalent for 2 functions, please?  Or should I put
together a finite difference type of matrix, etc., please?


What is the goal?  optim optimizes a scalar value.  If you have a length 
2 vector to optimize, what does that mean?


Duncan Murdoch



Thanks,
Happy New Year,
Erin




__
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] package license questions

2010-01-03 Thread Duncan Murdoch

On 02/01/2010 11:19 PM, Markus Weisner wrote:

I am looking for some advice on licenses.  Here is my situation:

Over the last couple years, I have developed a rather large number of fire
department analysis functions.  I am in the process of trying to publish
some packages to make these functions available to the public.  I am trying
to release two packages that essentially define S4 classes for common types
of fire department data.  Then, I would like to publish a package that
essentially reads in these fire department data types and returns analysis
results.  My concern is that I may eventually want to build and sell some
proprietary functions and I am trying not to box myself out of this future
option.  It is my understanding that if I use the GPL license, all work
based on my packages would have to take on the GPL license (effectively
making it impossible to sell software). 


That only applies to other people unless you choose to incorporate other 
people's GPL'd code into your package.  The GPL imposes no conditions on 
the copyright holder, it's a license given by the copyright holder to 
other people to allow them to do things (basically copying, modifying, 
and redistributing) that otherwise would be copyright violations.


The obligation the other people need to follow is that *they* must offer 
the GPL license if they include your code.  So they'll have some trouble 
commercializing it (but it's not impossible to commercialize GPL'd code, 
it's just supposed to be impossible to do it in a closed source way).


The trap with GPL is that other people may make improvements to your 
code that you'd like to use.  If you do, they become copyright holders 
as well, and then the combined work has to be licensed using GPL unless 
all of you can agree otherwise.  But at that point you've accepted a 
free contribution from someone else, it's only fair to share the 
ownership of the product with them.


 It looks like the Lesser General

Public License (LGPL) may suit my needs by allowing me to make public my
current work without eliminating the possibility of future proprietary
work.  I have a couple questions I am hoping somebody can answer.


   - It says that libraries licensed under a LGPL can be used by
   proprietary software.  What is meant by libraries?  Are class definitions
   and functions considered libraries?
   - If I use the LGPL for all my packages, do I maintain the right to build
   and sell software that is based on these LGPL packages?  For instance, could
   I use the class definitions from a LGPL package as inputs for analysis in a
   piece of proprietary software?
   - Other than potentially allowing competitors to also use my LGPL
   packages in their proprietary software, are there any big disadvantages to
   using a LGPL?
   - If somebody improves on my LGPL S4 class definitions, can I still then
   use them in a proprietary package despite their being modified?


The LGPL puts weaker constraints on users of your code.  You still 
maintain all the rights you ever did, but it doesn't stop them from 
commercializing closed-source products using your code as a library, 
whatever that means.


Duncan Murdoch



I am a big supporter of the open source community and have personally
benefitted greately from open source software.  My intentions are to release
my work as open source, but just don't want to be boxed out of future
proprietary developments.  These licenses can be pretty confusing, so I
appreciate any information that can help me figure this out.

Thanks,
Markus

[[alternative HTML version deleted]]

__
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-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] F77_CALL, F77_NAME definition

2010-01-03 Thread Duncan Murdoch

On 03/01/2010 9:11 AM, rkevinbur...@charter.net wrote:

I give up. Maybe it is my search (Windows) but I cannot seem to find the 
definition of the F77_CALL or F77_NAME macros. Either there are too many 
matches or the search just doesn't find it. For example where is the source for:

F77_CALL(dpotri)

?


It's your search.  The definition is in src/include/R_ext/RS.h.

BTW, this sort of question is much more of an R-devel question than an 
R-help one.


Duncan Murdoch

__
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] F77_CALL, F77_NAME definition

2010-01-03 Thread Duncan Murdoch

On 03/01/2010 9:43 AM, Barry Rowlingson wrote:

On Sun, Jan 3, 2010 at 2:11 PM,  rkevinbur...@charter.net wrote:

I give up. Maybe it is my search (Windows) but I cannot seem to find the 
definition of the F77_CALL or F77_NAME macros. Either there are too many 
matches or the search just doesn't find it. For example where is the source for:

F77_CALL(dpotri)

?


 I'm not sure what the Windows equivalent of 'grep -r F77_CALL .' is,
but the developer who wrote lbfgsb.c left a blatant clue which popped
up as the third match:

./appl/lbfgsb.c:#include R_ext/RS.h /* for F77_CALL */

About three screenfulls later the actual definition itself appeared.

 If you are going to do a lot of this on a windows box, get cygwin and
learn to use the unix utilities in a cygwin bash shell!


I think it's better to use a reasonable text editor here; I used 
Textpad.  I don't think there's anything too special about it, but it 
does have Search | Find in files, and I can list the file pattern 
(obviously *.h for a macro definition), and the folder (R-devel/src on 
my system), and then I only get six hits:  two definitions and 4 uses. 
That's a lot better than 3 screenfuls.


You can also use the Windows search facility to find the file, but I 
find it clunky, and rarely use it.  It does also make it easy to limit 
the searches in the same way as the above, but it won't show the results 
as nicely.


I'm sure you can do the same thing with grep, but I can never remember 
the syntax to say to search only in *.h files, whereas with the GUI 
searches it's easy.


Duncan Murdoch

__
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] F77_CALL, F77_NAME definition

2010-01-03 Thread Duncan Murdoch

On 03/01/2010 10:32 AM, Barry Rowlingson wrote:

On Sun, Jan 3, 2010 at 3:20 PM, Duncan Murdoch murd...@stats.uwo.ca wrote:


I think it's better to use a reasonable text editor here; I used Textpad.  I
don't think there's anything too special about it, but it does have Search
| Find in files, and I can list the file pattern (obviously *.h for a macro
definition), and the folder (R-devel/src on my system), and then I only get
six hits:  two definitions and 4 uses. That's a lot better than 3
screenfuls.


 Of course. Emacs + Etags. Then it's about four keystrokes :)


But of course to reduce Search for F77_CALL to 4 keystrokes you need 
to be able to do Lempel-Ziv encoding in your head; that's what I hate 
about Emacs.


Duncan

__
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] locator and print

2010-01-04 Thread Duncan Murdoch

On 04/01/2010 10:18 AM, Thomas Roth wrote:

Hi,

Using the following R-Code the printing via print takes place after locator
although print is placed before locator

###
test = function()
{
plot(1:10)
print(test)
locator(1)
}

test
###

Is there some way to force the printing before locator is being evaluated. I
assume that there is some buffer that needs to be turned off? Where do I
have to look. Locator and print help page don't cover this problem.
  


flush.console() will flush output to the console in systems that support 
it.  In the Windows GUI, there's a menu item Misc | Buffered output 
that can control buffering.


Duncan Murdoch

Thanks in advance,

Thomas

__
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-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] How to dynamically display title for a graph

2010-01-04 Thread Duncan Murdoch

On 04/01/2010 11:30 AM, noclue_ wrote:

I have written  a function (see below) which encloses a boxplot.  My function
xbox takes in a variable name (such as age), and do a boxplot. Now I
would like to add a title for the graph dynamically displaying the variable
name as part of title. 


But, in reality, the title displays VALUES of my variable.

Obviously, sprintf does not work. 


Can somebody shed light on how to solve my problem in properly displaying a
title ?

Thanks.

-

 xbox- function(X)
 {
  boxplot(_expenses ~ X, data=my_tab,main=sprintf(title is %s,X))
 }
 
 xbox(age)
  



Use deparse(substitute(X)) in the sprintf.  This says:  get the 
expression passed as X, and convert it to text.


Duncan Murdoch

__
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] polygamma or Hurwitz zeta function

2010-01-04 Thread Duncan Murdoch

On 04/01/2010 5:27 PM, HAKAN DEMIRTAS wrote:

Hi,

Is there any R library that is capable of handling polygamma function 
(Hurwitz zeta function also works)? I am aware of digamma(0 and trigamma(), 
but could not find more advanced versions.


RSiteSearch(polygamma) points to the psigamma function, on the same 
man page as digamma and trigamma.


Duncan Murdoch


I'd appreciate any help.

Hakan Demirtas

__
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-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] Dynamic arguments in rbind function

2010-01-04 Thread Duncan Murdoch

On 04/01/2010 7:31 PM, Steven Kang wrote:

Hi, all

Basically, I have unknown number of data that need to be imported and
collapsed row-wisely.

The code below works fine, however the rbind function may require 50
arguments if there are 50 data files...

Thus, I would like to explore whether there are any methods in using dynamic
objects (i.e from the resulting objects in the for loop) as an argument in
the *rbind* function.



setwd(.)

import.files - c(a.txt, b.txt,  c.txt,  d.txt,  e.txt)
for (i in 1:length(import.files)) {
  assign(paste(imp, i, sep = .), read.delim(eval(paste(.\\,
import.files[i], sep = )), header = TRUE))


Computing names like this is almost always a bad idea.  It's better to 
just put the items in a list:


imp - list()
for (i in 1:length(import.files)) {
  imp[[i]] - read.delim(eval(paste(.\\,
  import.files[i], sep = )), header = TRUE)
}

Then to bind them all, simply use do.call(rbind, imp).

Duncan Murdoch


}

combined - rbind(*imp.1, imp.2, imp.3, imp.4, imp.5, imp.6*)



Your expertise in resolving this issue would be greatly appreciated.



Steve

[[alternative HTML version deleted]]

__
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-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] mean for subset

2010-01-05 Thread Duncan Murdoch

On 05/01/2010 1:29 PM, Geoffrey Smith wrote:

Hello, does anyone know how to take the mean for a subset of observations?
For example, suppose my data looks like this:

OBS NAME   SCORE
1  Tom   92
2  Tom   88
3  Tom   56
4  James85
5  James75
6  James32
7  Dawn 56
8  Dawn 91
9  Clara 95
10Clara 84

Is there a way to get the mean of the SCORE variable by NAME but only when
the number of observations is equal to 3?  In other words, is there a way to
get the mean of the SCORE variable for Tom and James, but not for Dawn and
Clara?  Thank you.
  


You probably want to do it in two steps:  first, find which names have 3 
observations, and take that subset of the dataset; then do the mean on 
all groups.  This is one way:


 counts - table(dataset$NAME)
 keep - names(counts)[counts == 3]
 subset - dataset[ dataset$NAME %in% keep,]
 tapply(subset$SCORE, subset$NAME, mean)
  Clara DawnJames  Tom
 NA   NA 64.0 78.7

Duncan Murdoch

__
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] adding 3D arrows to 3D plots

2010-01-07 Thread Duncan Murdoch

Eben J. Gering wrote:

Greetings,

I would like to add 3D arrows (i.e. arrow-headed vectors linking X1Y1Z1 to X2,Y2,Z2) to a 3D plot; ideally the sort of plot that can be rotated interactively.  Is this possible using plot3d, or another 3d plotter in R?  
While it is easy to draw segments in plot3d (e.g. below), I haven't figured out how to add arrow heads, or to create 3d arrows from scratch.  


##two headless segments:
library(rgl)
matrix(1:2,2,3)-segment1
matrix(1:3,2,3)-segment2
plot3d(segment2,type=l,col=red,xlim=c(0,3),ylim=c(0,3),zlim=c(0,3))
plot3d(segment1,type=l,add=TRUE,col=blue)

  


There isn't any current code to do that in rgl, but if you have a 
particular shape of arrow in mind, you could probably draw it with some 
combination of functions.  The main problem is that I've never seen any 
very appealing rotatable 3d arrows.  There's a Matlab function to draw 
some here:  
http://www.mathworks.com/matlabcentral/fileexchange/8396-draw-3d-arrows; 
it could probably be translated into rgl if you wanted that.


Duncan Murdoch

__
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] Building static HTML help pages in R 2.10.x on Windows

2010-01-07 Thread Duncan Murdoch

Michal Kulich wrote:

On 7.1.2010 9:49, Dieter Menne wrote:
  

Thanks for that code. I fully agree that the current help system is a step
back. For stable bookmarking, my workaround is to put

options(help.ports=6800)

into the profile,  so I can created links like

http://127.0.0.1:6800/library/gmodels/html/estimable.html

but this still required that I start RGui and the help system once. 


Dieter



Thanks for this, too. Btw, is there a way to start the dynamic Rhelp server in the background without manually launching RGui? That, combined with Dieter's suggestion, would bring the help system sort of back to its original state. 
  


You don't need Rgui, you could run Rterm, which would have a smaller 
footprint. It's not very hard to start it and minimize it, but if you 
want it running invisibly, you'll need to figure out how to hide the icon.


A disadvantage of doing this is that you won't see help relevant to your 
current session, you'll see help relevant to the background task.  In 
2.10.x there aren't many differences, but you'll find it more limiting 
in 2.11.x and later.


Duncan Murdoch

I am sorry to say that the new dynamic help is a HUGE nuisance to me. Had to 
revert back to R 2.9 because of that :-(.

Michal

__
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-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] Strange behaviour of as.integer()

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 7:31 AM, Ulrich Keller wrote:

I have encountered a strange behaviour of as.integer() which does not
seem correct to me. Sorry if this is just an indication of me not
understanding floating point arithmetic.


.57 * 100

[1] 57

.29 * 100

[1] 29

So far, so good. But:


as.integer(.57 * 100)

[1] 56

as.integer(.29 * 100)

[1] 28

Then again:


all.equal(.57 * 100, as.integer(57))

[1] TRUE

all.equal(.29 * 100, as.integer(29))

[1] TRUE

This behaviour is the same in R 2.10.1 (Ubuntu and Windows) and 2.9.2
(Windows),
all 32 bit versions. Is this really intended?


Yes, as the man page states, non-integer values are truncated towards 
zero.  Normal printing rounds them.  So .57*100, which is slightly less 
than 57, is rounded to 57 for printing, but is truncated to 56 by 
as.integer.


 .57*100  57
[1] TRUE

Duncan Murdoch

__
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] How to report or correct translations typos?

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 9:04 AM, Kenneth Roy Cabrera Torres wrote:

Hi R users and developers:

Thanks to Mr Pablo Emilio Verde for his constribution
to the spanish translation for R messages he makes a very
good job.

I find a tiny typo on the translation,
in particular on the es.po file line 7312 it says:
pueto
it should be:
puerto

How can anybody might correct a typo or which is the
best way to correct it on a future patch?
  


You can see the translation teams listed on 
http://developer.r-project.org/TranslationTeams.html.  You send your 
corrections to them (as you have already done; this message is just to 
confirm you've done what you should do).


Duncan Murdoch

Thank you for your help.

Kenneth

__
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-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] Building static HTML help pages in R 2.10.x on Windows

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 9:05 AM, Michael Friendly wrote:

Michal Kulich wrote:
 On 7.1.2010 9:49, Dieter Menne wrote:
 
 I am sorry to say that the new dynamic help is a HUGE nuisance to me. Had to revert back to R 2.9 because of that :-(.
 
 Michal


I too have reverted to 2.9.2 on Win XP because I find html help to be 
far less convenient than the compiled CHM help I had before. CHM help is
so much easier because the Contents, Index and Search panels make it 
easy to *see* all the items defined for a package, and I get a separate 
help window for each package.

I very much appreciate the efforts of the R-core team to move R forward,
but I think the change in help is a step back.
  


You can see the items for the package on the index page for the package, 
which is linked from every page.


You can put together a package that displays the help in your favourite 
format, if you don't like the default format.  There's nothing that we 
used in CHM help that couldn't be duplicated in Javascript, without the 
security holes.


I see it as more important that R core enables others to do what they 
want, rather than to maintain ancient designs.


Duncan Murdoch

__
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] diag, diag- and [ , [-

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 9:31 AM, berga...@gmail.com wrote:

Dear all
I have the following problem.

M - matrix(0,3,3) # dimension of M is dinamic and this can lead to the  
next subscript


diag(M[1,1]) - rep(100,1)
#Error in `diag-`(`*tmp*`, value = 100) :
# only matrix diagonals can be replaced

diag(M[1,1,drop=F]) - rep(100,1)
#Error in diag(M[1, 1, drop = F]) - rep(100, 1) :
# incorrect number of subscripts

diag(M[2:3,1:2]) - rep(100,2)
# works fine

Is there a way to usw diag as replacement function when the input matrix is  
subscript to a one by one matrix. I don't want extra if(dim==1)... etc.
  


The problem isn't with diag, it's with [-.  When you include drop=F, 
it doesn't appear to handle properly the matrix indexing that diag() uses.


So a simpler example is just

M[1,1, drop=FALSE] - 1

which generates the same error you saw.  I'd call this a bug; I'll look 
into it.  ([- is done internally in some fairly ugly code, so this 
might take a while.)


As a workaround, I think this does what you want:

n - 1
submatrix - M[1:n,1:n,drop=FALSE]
diag(submatrix) - rep(100, n)
M[1:n,1:n] - submatrix

Duncan Murdoch


Thanks a lot in advance.
Best regards,
Roger

[[alternative HTML version deleted]]

__
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-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] Building static HTML help pages in R 2.10.x on Windows

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 9:47 AM, Michal Kulich wrote:

On 7.1.2010 12:18, Duncan Murdoch wrote:
 You don't need Rgui, you could run Rterm, which would have a smaller
 footprint. It's not very hard to start it and minimize it, but if you
 want it running invisibly, you'll need to figure out how to hide the icon.

This works. Not entirely invisible but not a big deal about that.
The R code run within Rterm is

options(help_type=html,help.ports=6800)
help.start()
library(audio)
wait(-1)

[couldn't find another way to hang R indefinitely in batch mode]

 
 A disadvantage of doing this is that you won't see help relevant to your

 current session, you'll see help relevant to the background task.  In
 2.10.x there aren't many differences, but you'll find it more limiting
 in 2.11.x and later.

Not a problem if one is not switching between different versions of R. The 
current version is on the path and the path will get updated (manually) after a 
new version is installed. Thus, the relevant help will be always displayed.
  


Not necessarily.  The current help system can display information about 
the current session, e.g. the result of ls(), as a simple example.  But 
if you use a single background session you won't get relevant information.


Duncan Murdoch
Thanks, this is a kind of solution. Now I can use bookmarks to HTML help for the favorite libraries when working in ESS - the impossibility to set those and the need to start Rgui was the big nuisance. 


I am sure the new help system will get gradually improved in the future.

Best,

Michal




__
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] Building static HTML help pages in R 2.10.x on Windows

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 9:51 AM, Gabor Grothendieck wrote:

On Thu, Jan 7, 2010 at 9:20 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:
 On 07/01/2010 9:05 AM, Michael Friendly wrote:

 Michal Kulich wrote:
  On 7.1.2010 9:49, Dieter Menne wrote:
   I am sorry to say that the new dynamic help is a HUGE nuisance to me.
   Had to revert back to R 2.9 because of that :-(.
   Michal

 I too have reverted to 2.9.2 on Win XP because I find html help to be far
 less convenient than the compiled CHM help I had before. CHM help is
 so much easier because the Contents, Index and Search panels make it easy
 to *see* all the items defined for a package, and I get a separate help
 window for each package.
 I very much appreciate the efforts of the R-core team to move R forward,
 but I think the change in help is a step back.


 You can see the items for the package on the index page for the package,
 which is linked from every page.

 You can put together a package that displays the help in your favourite
 format, if you don't like the default format.  There's nothing that we used
 in CHM help that couldn't be duplicated in Javascript, without the security
 holes.

 I see it as more important that R core enables others to do what they want,
 rather than to maintain ancient designs.

Perhaps the link to the Index could be placed at both the top and
bottom rather than just at the bottom since its a nuisance to have to
scroll down and its less noticeable at the bottom as its typically off
the screen.
Yes, I may do that at some point, to make the layout of the help pages 
more consistent.  Most higher level pages have a consistent header 
(more so in R-devel), but the individual topic pages don't.


What I'd really like is for someone who has good taste to redesign the 
look of the whole system.  I think one or two people are working on 
packages to do this, and I'd much rather spend time providing whatever 
low level support they need, rather than doing it myself.


Duncan Murdoch

__
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] Building static HTML help pages in R 2.10.x on Windows

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 10:00 AM, Michal Kulich wrote:

On 7.1.2010 15:52, Duncan Murdoch wrote:
 Not necessarily.  The current help system can display information about
 the current session, e.g. the result of ls(), as a simple example.  But
 if you use a single background session you won't get relevant information.
 
 Duncan Murdoch


Sorry, I must admit I don't get it.

  
A more useful example than ls() would be methods().   I think it would 
be nice to have a list of methods included in the man page for a generic 
function, and links to their pages if they have their own man pages.  
You might want to list all installed methods, with some sort of 
highlighting to indicate which ones are already attached, or perhaps be 
able to toggle between installed and attached, or whatever.  None of 
that is possible with static help, not even a list of installed methods, 
because someone might install a new package that offers some others 
after the static help has already been built.


You just need to use some imagination.

Duncan Murdoch

__
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] Building static HTML help pages in R 2.10.x on Windows

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 11:36 AM, Jonathan Baron wrote:

For what it is worth, I would gladly sacrifice this capability in
order to be able to consult all my R help pages through a Firefox
bookmark to the packages listing (which is what I used to do, and will
do again, when I get time to either rebuild from source or get the
forthcoming Fedora RPM, which will have static pages as the default),
without starting an R session.
  


What's so hard about leaving an R session running, and using bookmarks 
as Dieter described?


Duncan Murdoch

Jon

On 01/07/10 10:32, Duncan Murdoch wrote:
 A more useful example than ls() would be methods().   I think it would 
 be nice to have a list of methods included in the man page for a generic 
 function, and links to their pages if they have their own man pages.  
 You might want to list all installed methods, with some sort of 
 highlighting to indicate which ones are already attached, or perhaps be 
 able to toggle between installed and attached, or whatever.  None of 
 that is possible with static help, not even a list of installed methods, 
 because someone might install a new package that offers some others 
 after the static help has already been built.
 
 You just need to use some imagination.
 
 Duncan Murdoch




__
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] Problem with writeBin and importing into gfortran compiled programs

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 2:05 PM, jgar...@ija.csic.es wrote:

Hi all,
I'm having problems trying to export binary arrays from R and importing
them into fortran (linux openSUSE 10.3 (x86_64), gfortran compiler,
fortran 90/95 program).

Let's say the problem can be expressed as:

R part

whini - runif(1000)
writeBin(whini,fwhini.dat)

f90 part

PROGRAM foo
INTEGER, PARAMETER :: DP = KIND(1.0D0)
INTEGER :: status
REAL(DP), DIMENSION(10,100) :: whini
OPEN(UNIT=5, FILE='fwhini.dat', STATUS='OLD', ACTION='READ', 
 FORM='UNFORMATTED', IOSTAT=status)
READ(5) whini
CLOSE(5)
WRITE(*,*) whini
END PROGRAM

Now, if within the R session I check

typeof(whini)
[1] double

and try

whini.copy - readBin(fwhini.dat,what=double(),n=1000)

the copy of whini is right. However, execution of the fortran program
gives the message:

Fortran runtime error: Unformatted file structure has been corrupted.

I've tried also to declare whini in the fortran part as SINGLE precision,
and to force writeBin using the size argument.
size=4 and size=8 give the same error (whini as double in the fortran
part), while size=16 gives the alternative error
Fortran runtime error: I/O past end of record on unformatted file

Please, could you help me with this problem?
I've never used Fortran 90, so I can't tell if your type declaration is 
really declaring double precision values.
So what I'd do is to create an array (say the values 1 to 1000) within 
your Fortran program, and write it out.
Then do the same in R, and do a binary compare of the files to see what 
the differences are.  The things to look for are:


Size of values (4 or 8 bytes or something else).

Byte order within values (big or little endian).

R is very flexible in what it writes, and probably Fortran is flexible 
in what it can read, but you need to figure out what the differences are 
before you can match them up.


The viewRaw() function in the hexView package is a simple way to look at 
the bytes in the files.


Duncan Murdoch

__
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] Building static HTML help pages in R 2.10.x on Windows

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 2:16 PM, Kevin Wright wrote:

Well, among other things, if my global environment becomes
cluttered/corrupt/etc and I quit R, then restart R, the links in my browser
are now dead.

You weren't following Dieter's instructions, then.


  I have to close all the tabs and call help to open them
again.  Also, the R-supplied java tool for searching help is ancient and
underwhelming.


Then contribute a new one.

  A desktop search tool (X1/Copernic/GoogleDesktop/etc) can be
very handy, but only if it has pre-built help files to index.  Imperfect,
stale, non-dynamic help is better than no help at all!
  


Then fix the search tool so it can search dynamic web pages.  They can 
be spidered too, just like static ones.


Duncan Murdoch

As others have done, I have switched back to 2.9.2 until I can build all
help files (on Windows).  Thanks to those people who are figuring out how to
do this.
  
Kevin


On Thu, Jan 7, 2010 at 11:50 AM, Duncan Murdoch murd...@stats.uwo.cawrote:

 On 07/01/2010 11:36 AM, Jonathan Baron wrote:

 For what it is worth, I would gladly sacrifice this capability in
 order to be able to consult all my R help pages through a Firefox
 bookmark to the packages listing (which is what I used to do, and will
 do again, when I get time to either rebuild from source or get the
 forthcoming Fedora RPM, which will have static pages as the default),
 without starting an R session.



 What's so hard about leaving an R session running, and using bookmarks as
 Dieter described?

 Duncan Murdoch

  Jon

 On 01/07/10 10:32, Duncan Murdoch wrote:
  A more useful example than ls() would be methods().   I think it would 
 be nice to have a list of methods included in the man page for a generic 
 function, and links to their pages if they have their own man pages.   You
 might want to list all installed methods, with some sort of  highlighting
 to indicate which ones are already attached, or perhaps be  able to toggle
 between installed and attached, or whatever.  None of  that is possible
 with static help, not even a list of installed methods,  because someone
 might install a new package that offers some others  after the static help
 has already been built.
   You just need to use some imagination.
   Duncan Murdoch


 __
 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-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] Debugging issues encountered during the R CMD check process

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 2:48 PM, Jason Rupert wrote:
I read through the Writing R Extensions and the Debugging in R website (http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/), looking for some hints about how to solve the issue of debugging problems encountered during the R CMD check process, but nothing seems to be mentioned about addressing issues encountered. 


Specifically, I am working with the R signal package which is hosted at the 
following location:
http://code.google.com/p/r-signal/

I would like to debug the problem that is shown below, and is encountered when I run R CMD check signal. 

Thank you for any insights that are provided as the R signal package is nice and it would be good to have it working again with R 2.9.x and beyond. 

Thank you again for the help. 


From the 00check.log

* using log directory 
'/Users/jasonkrupert/Documents/RStuff/Rsignal/r-signal/signal.Rcheck'
* using R version 2.9.2 (2009-08-24)
* using session charset: UTF-8
* checking for file 'signal/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'signal' version '0.6'
* checking package dependencies ... OK
* checking if this is a source package ... WARNING



 
 ### Name: interp

 ### Title: Interpolate / Increase the sample rate
 ### Aliases: interp
 ### Keywords: math
 
 ### ** Examples
 
 
 # The graph shows interpolated signal following through the

 # sample points of the original signal.
 t = seq(0, 2, by = 0.01)
 x = chirp(t,2,.5,10,'quadratic') + sin(2*pi*t*0.4)
 y = interp(x[seq(1, length(x), by = 4)],4,4,1)   # interpolate a sub-sample
Warning in rbind(x, array(val, dim = c(n - nx, NCOL(x :
  number of columns of result is not a multiple of vector length (arg 1)
Warning in Fft(postpad(x, N)) * B :
  longer object length is not a multiple of shorter object length
Error in ifft(Fft(postpad(x, N)) * B) : 
  dims [product 36] do not match the length of object [256]

Calls: interp - fftfilt - fftfiltx - ifft
Execution halted

  


You'll often get more informative error messages in recent R releases if 
you set the environment variable


R_KEEP_PKG_SOURCE=yes

I don't know if it will help in this case.

Duncan Murdoch

__
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] startup file

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 4:10 PM, mkna005 mkna005 wrote:

Hi!
I was wondering if it is possible to have a startup script similar to
matlab as such when R starts up the script is automatically executed?
Thanks
  

Yes, see ?Startup.

Duncan Murdoch

__
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] %d/%m/%Y can not be displayed in a .rd file

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 2:09 PM, rusers.sh wrote:

Hi all,
  I found the date format (e.g.%d/%m/%Y) in the .rd file cannot be
displayed after building the package. See below,
###.rd file
\examples{
a-10/20/1999
DateConversion(a,DateIn=%m/%d/%Y,DateOut=%d/%m/%Y)
}
The result is 
Examples:
 a-10-20-1999
 DateConversion(a,DateIn=

  ??%m/%d/%Y seems cannot be recognized.
Is there some method to solve this and make it visible?
  Thanks a lot.



The % character is a comment character in Rd files.  You need to escape it:

DateConversion(a,DateIn=\%m/\%d/\%Y,DateOut=\%d/\%m/\%Y)



Duncan Murdoch

__
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] Building static HTML help pages in R 2.10.x on Windows

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 2:58 PM, Kevin Wright wrote:

On Thu, Jan 7, 2010 at 9:32 AM, Duncan Murdoch murd...@stats.uwo.ca wrote:

 On 07/01/2010 10:00 AM, Michal Kulich wrote:

 On 7.1.2010 15:52, Duncan Murdoch wrote:
  Not necessarily.  The current help system can display information about
  the current session, e.g. the result of ls(), as a simple example.  But
  if you use a single background session you won't get relevant
 information.
   Duncan Murdoch

 Sorry, I must admit I don't get it.



 A more useful example than ls() would be methods().   I think it would be
 nice to have a list of methods included in the man page for a generic
 function, and links to their pages if they have their own man pages.  You
 might want to list all installed methods, with some sort of highlighting to
 indicate which ones are already attached, or perhaps be able to toggle
 between installed and attached, or whatever.  None of that is possible with
 static help, not even a list of installed methods, because someone might
 install a new package that offers some others after the static help has
 already been built.


You just need to use some imagination.


OK, I'll try imagining this approach:
- Static help pages are installed with R.
- install.packages() launches a subroutine to fix the \link references that
need updating.  Uninstalling needs to do the same.  (Busywork, but that's
why we have computers.)
- I have an R object foo.  I type ShowMeAllMethodsFor(foo,
installed=TRUE, attached=TRUE) which checks all installed packages and
attached packages for appropriate methods, then serves up a dynamic help
page with links to the relevant static help pages, color-coded by
installed/attached.


I don't like the fragmentation of the R help system.  This just produces 
yet another set of pages which are not reachable from anywhere but one 
place.


The help system should be a network of pages which are all 
interconnected.  I should be able to click on something in the ?plot 
page and get to the ?plot.formula page (which I can do now, based on a 
static link) or the ?plot.foo page (which hasn't been written yet, but 
will be by the time I look at ?plot).


Duncan Murdoch

__
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] [Fwd: snowfall on Win7]

2010-01-07 Thread Duncan Murdoch

On 07/01/2010 4:39 PM, Murph wrote:

Jochen Knaus wrote:
 
 .
 
 Anybody having experiences with Win7 yet?
 
 
 
 
R 2.10.1 installed today on win7 works fine for this new user.  Although the

demos fail with a complaint about unable to setwdI suspect it's a
privaleges problem.   Win7 is awkward about install privaleges. I suspect my
working directory is in Admin land; and I'm trying to execute from
/user/tom  If I could figure out a function to have R list my
environmental variables; I could probably figure it out.
  


Sys.getenv()  will list them (possibly on very long lines; you'll need 
to scroll to the right to see anything).


Duncan Murdoch

I have two processor on my Toshiba...
Murph



__
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] Building static HTML help pages in R 2.10.x on Windows

2010-01-08 Thread Duncan Murdoch

Michal Kulich wrote:

On 7.1.2010 20:22, Duncan Murdoch wrote:

  

A more useful example than ls() would be methods().   I think it
would be nice to have a list of methods included in the man page for
a generic function, and links to their pages if they have their own
man pages.  You might want to list all installed methods, with some
sort of highlighting to indicate which ones are already attached, or
perhaps be able to toggle between installed and attached, or
whatever.  None of that is possible with static help, not even a list
of installed methods, because someone might install a new package
that offers some others after the static help has already been built.


I see. Well, I never lacked any of these capabilities... Please understand that people who use R to do their work may have different objectives than the developers - and they form the majority of R users. 

  
Then they should contribute to the development.  I don't owe you 
anything.  You owe us a lot.


Duncan Murdoch


On 07/01/2010 2:16 PM, Kevin Wright wrote:



  
Well, among other things, if my global environment becomes 
cluttered/corrupt/etc and I quit R, then restart R, the links in my

 browser are now dead.
  


  

You weren't following Dieter's instructions, then.



Indeed, but that option is not documented, as far as I know - at least not in 2.10.0. And even if it was, most users would not be able to find it or use it because they have no clue what a port is. 
 
  

I have to close all the tabs and call help to open them again.
Also, the R-supplied java tool for searching help is ancient and 
underwhelming.
  
 
  

Then contribute a new one.



Duncan, if even the quite advanced and computer-proficient users have trouble 
using the dynamic R help and have to resort to some quite complex and cumbersome 
home-made solutions to get back the basic functionality then something is not 
right. It's true that the help system was never a particular strength of R and 
that it needed an overhaul. What worked well in the late 90's with a few dozen 
packages does not work well with 1000 packages. However, 2.10.x does not seem 
to make things better.

The work of the R developers should be widely appreciated and we really do 
appreciate it. The question is whether their effort is extended in the best 
direction... (Imho, that's an issue with most open-source projects and it's 
been much worse with Mozilla than with R).

Just my 2c.

Michal




__
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] Building static HTML help pages in R 2.10.x on Windows

2010-01-08 Thread Duncan Murdoch

Dieter Menne wrote:


Duncan Murdoch wrote:
  
What's so hard about leaving an R session running, and using bookmarks 
as Dieter described?





It pollutes my space, and I am a Window-closing maniac, so it won't survive
the next attack.

http://www.microsoft.com/downloads/en/confirmation.aspx?familyId=9d467a69-57ff-4ae7-96ee-b18c4790cffddisplayLang=en

It might be worth a try to use instsrv and srvany to install the batch as a
server. The resource kit cries out loud when installed on Window 7 for being
a stupid old dinosaur, but in similar case I could still use it.

  


If that works, writing up instructions would be a useful contribution.

Duncan Murdoch

__
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] Is there any function in R like ezplot in matlab?

2010-01-09 Thread Duncan Murdoch

On 09/01/2010 5:22 AM, 军 吕 wrote:

Hi,

Is there any function in R like ezplot in matlab?

How to draw the relationship  between x y like this

x^y+y^(sinx)=log(x+y)




It's not pre-packaged, but drawing a contour plot of the function

f - function(x,y) x^y+y^sin(x) - log(x+y)

should do it:

xvals - yvals - seq(0, 30, len=1000)
zvals - outer(xvals, yvals, f)
contour(xvals, yvals, zvals, levels=0)


Duncan Murdoch

__
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] Online R documentation

2010-01-09 Thread Duncan Murdoch

On 09/01/2010 12:48 PM, Dieter Menne wrote:


Karl Ove Hufthammer wrote:
In case anybody is looking for ideas in how to improve the above 
site, inclusion of rendered example graphs, similar to the ones at 
http://www.metaresearch.de/exlib/;, would be nice.




If the format you use on your site were  accepted as the standard in R, this
would be a great step forward in improving the dinosaur.

I prefer to have help locally, though, because I would like to have the
first search restricted to the packages I have installed, to avoid being
drowned by 2000 packages I never need.


Including graphical output in the man pages is one of the eventual goals 
of the new help system.  I doubt it will make it into 2.11.x, but it 
will probably be there in 2.12.x.


Duncan Murdoch

__
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] Calling FING.EXE under RGui.EXE for windows.

2010-01-09 Thread Duncan Murdoch

On 07/01/2010 1:25 PM, Uwe Ligges wrote:

Argh. I see it as well. Will dig a lit tomorrow.


I don't know exactly what's going on, but it looks as though it is 
something specific to the find.exe utility, e.g. maybe it is assuming 
that it's being run inside a console and reading CONIN$ or writing to 
CONOUT$ without checking whether they can be opened.  When you run it 
from Rterm, Rterm is in a console, which appears to be good enough.


So it may be anyone who wants to use it will have to contact Microsoft 
to find out how...


Duncan Murdoch



Uwe





On 07.01.2010 12:25, Gabor Grothendieck wrote:

I get a problem with shell too:

Under Rgui:


R.version.string

[1] R version 2.10.1 Patched (2010-01-01 r50884)


system(C:\\windows\\system32\\find /?, intern = TRUE)

character(0)


system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE)

character(0)


shell(C:\\windows\\system32\\find /?)

Warning message:
In shell(C:\\windows\\system32\\find /?) :
  'C:\windows\system32\find /?' execution failed with error code 1

They all work, i.e. they give the required help message, under Rterm
and when I issue this from the Windows console it works:
C:\windows\system32\find /?


2010/1/7 Uwe Liggeslig...@statistik.tu-dortmund.de:


On 07.01.2010 02:04, Gabor Grothendieck wrote:

If you have C:\Rtools\bin on your PATH note that it contains a
UNIX-like find utility that conflicts with the find utility in
Windows.  If that is the problem then remove that from your PATH and
then run the batch file.

The batchfiles distribution at http://batchfiles.googlecode.com  has
utilities (Rgui.bat, R.bat, Rtools.bat, etc.) that will automatically
add C:\Rtools\bin to your path temporarily or only while R is running
so that you can leave it off your PATH.


I guess it's the use of system() rather than shell() that causes the
problem. Under Windows, you have to use shell in order to start a command
interpreter.

Uwe Ligges



On Wed, Jan 6, 2010 at 6:51 PM, John Schexnayderjsc...@us.ibm.com
  wrote:

This is sort of a strange bug.  Not show stopping, but annoying.  I was
wondering if anyone else has noticed this and reported it before I submit
a bug report.

I noticed while running the RGui and attempting to debug one of my
scripts
that I encountered a Windows error informing me that Find String [grep]
Utility has encountered a problem and needs to close.  It is being
generated by a call to a DOS batch file which contains a call to
Find.exe.
  It can be reproduced by simply typing  System(find) in RGui.  What I
found strange is that I have been running this script daily without this
problem for months.  I now realize I never ran that portion of the script
while in RGui.exe.  It has always run in batch mode which is done by
Rterm.exe.

I have tried this on three separate machines now all running Windows XP
SP3, with versions of R 2.8.1 and R 2.10.1  If executing System(find)
under RGui, an error window for the Find String Utility is generated and
the command is not exectuted.  If the same command is issued in Rterm the
expected FIND: Parameter format not correct message is properly
returned.

It doesn't seem an important bug, but it could be the canary in the mine
for a larger problem somewhere down the road.

Re,
John Schexnayder

IBM Tape Manufacturing - Information Technology
San Jose, CA  95138
jsc...@us.ibm.com

[[alternative HTML version deleted]]

__
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-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-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-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] Calling FING.EXE under RGui.EXE for windows.

2010-01-09 Thread Duncan Murdoch

On 09/01/2010 6:31 PM, Gabor Grothendieck wrote:

That doesn't explain why this returns character(o) even though we have
launched a console for it:

system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE)


I don't see any console launched.  R redirects stdin and stdout (and 
stderr, I think), and it appears that Windows doesn't open a console.  I 
do see a console flash by if I do


system('cmd /c c:/WINDOWS/system32/find.exe /?', wait=FALSE, 
invisible=FALSE)


but of course then we don't capture the output, so it's not very useful. 
 Looking at the source, the only case where we ask to create a console 
is the combination wait=FALSE, invisible=FALSE, but there might be 
combinations of other options that make this a default.  The MS 
documentation says that a console will be created automatically for any 
console application, but that doesn't appear to be happening.


So I guess you could get find.exe to work by calling it from a batch 
file with a pause at the end and using the wait=FALSE,invisible=FALSE 
options.


The above observations are in Win XP SP3, not anything newer.

Duncan Murdoch



On Sat, Jan 9, 2010 at 5:24 PM, Duncan Murdoch murd...@stats.uwo.ca wrote:

On 07/01/2010 1:25 PM, Uwe Ligges wrote:

Argh. I see it as well. Will dig a lit tomorrow.

I don't know exactly what's going on, but it looks as though it is something
specific to the find.exe utility, e.g. maybe it is assuming that it's being
run inside a console and reading CONIN$ or writing to CONOUT$ without
checking whether they can be opened.  When you run it from Rterm, Rterm is
in a console, which appears to be good enough.

So it may be anyone who wants to use it will have to contact Microsoft to
find out how...

Duncan Murdoch


Uwe





On 07.01.2010 12:25, Gabor Grothendieck wrote:

I get a problem with shell too:

Under Rgui:


R.version.string

[1] R version 2.10.1 Patched (2010-01-01 r50884)


system(C:\\windows\\system32\\find /?, intern = TRUE)

character(0)


system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE)

character(0)


shell(C:\\windows\\system32\\find /?)

Warning message:
In shell(C:\\windows\\system32\\find /?) :
 'C:\windows\system32\find /?' execution failed with error code 1

They all work, i.e. they give the required help message, under Rterm
and when I issue this from the Windows console it works:
C:\windows\system32\find /?


2010/1/7 Uwe Liggeslig...@statistik.tu-dortmund.de:

On 07.01.2010 02:04, Gabor Grothendieck wrote:

If you have C:\Rtools\bin on your PATH note that it contains a
UNIX-like find utility that conflicts with the find utility in
Windows.  If that is the problem then remove that from your PATH and
then run the batch file.

The batchfiles distribution at http://batchfiles.googlecode.com  has
utilities (Rgui.bat, R.bat, Rtools.bat, etc.) that will automatically
add C:\Rtools\bin to your path temporarily or only while R is running
so that you can leave it off your PATH.

I guess it's the use of system() rather than shell() that causes the
problem. Under Windows, you have to use shell in order to start a
command
interpreter.

Uwe Ligges



On Wed, Jan 6, 2010 at 6:51 PM, John Schexnayderjsc...@us.ibm.com
 wrote:

This is sort of a strange bug.  Not show stopping, but annoying.  I
was
wondering if anyone else has noticed this and reported it before I
submit
a bug report.

I noticed while running the RGui and attempting to debug one of my
scripts
that I encountered a Windows error informing me that Find String
[grep]
Utility has encountered a problem and needs to close.  It is being
generated by a call to a DOS batch file which contains a call to
Find.exe.
 It can be reproduced by simply typing  System(find) in RGui.
 What I
found strange is that I have been running this script daily without
this
problem for months.  I now realize I never ran that portion of the
script
while in RGui.exe.  It has always run in batch mode which is done by
Rterm.exe.

I have tried this on three separate machines now all running Windows
XP
SP3, with versions of R 2.8.1 and R 2.10.1  If executing
System(find)
under RGui, an error window for the Find String Utility is generated
and
the command is not exectuted.  If the same command is issued in Rterm
the
expected FIND: Parameter format not correct message is properly
returned.

It doesn't seem an important bug, but it could be the canary in the
mine
for a larger problem somewhere down the road.

Re,
John Schexnayder

IBM Tape Manufacturing - Information Technology
San Jose, CA  95138
jsc...@us.ibm.com

   [[alternative HTML version deleted]]

__
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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do

Re: [R] Calling FING.EXE under RGui.EXE for windows.

2010-01-10 Thread Duncan Murdoch

Gabor Grothendieck wrote:

I noticed this does work, i.e. it displays the requested help info, in
Rgui on my Vista system:

library(tcltk)
.Tcl(exec find /?)
  


Yes, here too.  It stores the output in a tclObj, so it's doing what we 
want to do.  Anyone familiar with the Tcl source, and can spot the 
difference between their exec and our system()?


Duncan Murdoch

On Sat, Jan 9, 2010 at 7:27 PM, Duncan Murdoch murd...@stats.uwo.ca wrote:
  

On 09/01/2010 6:31 PM, Gabor Grothendieck wrote:


That doesn't explain why this returns character(o) even though we have
launched a console for it:

system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE)
  

I don't see any console launched.  R redirects stdin and stdout (and stderr,
I think), and it appears that Windows doesn't open a console.  I do see a
console flash by if I do

system('cmd /c c:/WINDOWS/system32/find.exe /?', wait=FALSE,
invisible=FALSE)

but of course then we don't capture the output, so it's not very useful.
 Looking at the source, the only case where we ask to create a console is
the combination wait=FALSE, invisible=FALSE, but there might be
combinations of other options that make this a default.  The MS
documentation says that a console will be created automatically for any
console application, but that doesn't appear to be happening.

So I guess you could get find.exe to work by calling it from a batch file
with a pause at the end and using the wait=FALSE,invisible=FALSE options.

The above observations are in Win XP SP3, not anything newer.

Duncan Murdoch



On Sat, Jan 9, 2010 at 5:24 PM, Duncan Murdoch murd...@stats.uwo.ca
wrote:
  

On 07/01/2010 1:25 PM, Uwe Ligges wrote:


Argh. I see it as well. Will dig a lit tomorrow.
  

I don't know exactly what's going on, but it looks as though it is
something
specific to the find.exe utility, e.g. maybe it is assuming that it's
being
run inside a console and reading CONIN$ or writing to CONOUT$ without
checking whether they can be opened.  When you run it from Rterm, Rterm
is
in a console, which appears to be good enough.

So it may be anyone who wants to use it will have to contact Microsoft to
find out how...

Duncan Murdoch



Uwe





On 07.01.2010 12:25, Gabor Grothendieck wrote:
  

I get a problem with shell too:

Under Rgui:



R.version.string
  

[1] R version 2.10.1 Patched (2010-01-01 r50884)



system(C:\\windows\\system32\\find /?, intern = TRUE)
  

character(0)



system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE)
  

character(0)



shell(C:\\windows\\system32\\find /?)
  

Warning message:
In shell(C:\\windows\\system32\\find /?) :
 'C:\windows\system32\find /?' execution failed with error code 1

They all work, i.e. they give the required help message, under Rterm
and when I issue this from the Windows console it works:
C:\windows\system32\find /?


2010/1/7 Uwe Liggeslig...@statistik.tu-dortmund.de:


On 07.01.2010 02:04, Gabor Grothendieck wrote:
  

If you have C:\Rtools\bin on your PATH note that it contains a
UNIX-like find utility that conflicts with the find utility in
Windows.  If that is the problem then remove that from your PATH and
then run the batch file.

The batchfiles distribution at http://batchfiles.googlecode.com  has
utilities (Rgui.bat, R.bat, Rtools.bat, etc.) that will automatically
add C:\Rtools\bin to your path temporarily or only while R is running
so that you can leave it off your PATH.


I guess it's the use of system() rather than shell() that causes the
problem. Under Windows, you have to use shell in order to start a
command
interpreter.

Uwe Ligges


  

On Wed, Jan 6, 2010 at 6:51 PM, John Schexnayderjsc...@us.ibm.com
 wrote:


This is sort of a strange bug.  Not show stopping, but annoying.  I
was
wondering if anyone else has noticed this and reported it before I
submit
a bug report.

I noticed while running the RGui and attempting to debug one of my
scripts
that I encountered a Windows error informing me that Find String
[grep]
Utility has encountered a problem and needs to close.  It is being
generated by a call to a DOS batch file which contains a call to
Find.exe.
 It can be reproduced by simply typing  System(find) in RGui.
 What I
found strange is that I have been running this script daily without
this
problem for months.  I now realize I never ran that portion of the
script
while in RGui.exe.  It has always run in batch mode which is done by
Rterm.exe.

I have tried this on three separate machines now all running Windows
XP
SP3, with versions of R 2.8.1 and R 2.10.1  If executing
System(find)
under RGui, an error window for the Find String Utility is generated
and
the command is not exectuted.  If the same command is issued in
Rterm
the
expected FIND: Parameter format not correct message is properly

Re: [R] Calling FING.EXE under RGui.EXE for windows.

2010-01-10 Thread Duncan Murdoch
I'm quitting on this one.  For the record, I took a look at a fairly old 
version of the Tcl code (from 8.4.13) that I had around from an old 
attempt to get it to work properly with MDI windows.  There are a number 
of differences between their exec code and our system() code, but I 
couldn't find the right combination to get system() to be able to run 
find.  It always crashes with a seg fault in ulib.dll when run with 
input coming from the pipe we send it.


If you use input redirection on the command line, it's fine, for example

system(cmd /c c:/WINDOWS/system32/find /? nul)

or

shell(c:/WINDOWS/system32/find \Hello\ c:/temp/foo.txt nul)

So perhaps we're not setting up the pipe correctly, but it works with 
most other programs, so I'm going to assume find is using it 
incorrectly, unless someone points out what we're doing wrong.


Duncan Murdoch


On 10/01/2010 8:18 AM, Gabor Grothendieck wrote:

I noticed this does work, i.e. it displays the requested help info, in
Rgui on my Vista system:

library(tcltk)
.Tcl(exec find /?)

On Sat, Jan 9, 2010 at 7:27 PM, Duncan Murdoch murd...@stats.uwo.ca wrote:

On 09/01/2010 6:31 PM, Gabor Grothendieck wrote:

That doesn't explain why this returns character(o) even though we have
launched a console for it:

system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE)

I don't see any console launched.  R redirects stdin and stdout (and stderr,
I think), and it appears that Windows doesn't open a console.  I do see a
console flash by if I do

system('cmd /c c:/WINDOWS/system32/find.exe /?', wait=FALSE,
invisible=FALSE)

but of course then we don't capture the output, so it's not very useful.
 Looking at the source, the only case where we ask to create a console is
the combination wait=FALSE, invisible=FALSE, but there might be
combinations of other options that make this a default.  The MS
documentation says that a console will be created automatically for any
console application, but that doesn't appear to be happening.

So I guess you could get find.exe to work by calling it from a batch file
with a pause at the end and using the wait=FALSE,invisible=FALSE options.

The above observations are in Win XP SP3, not anything newer.

Duncan Murdoch


On Sat, Jan 9, 2010 at 5:24 PM, Duncan Murdoch murd...@stats.uwo.ca
wrote:

On 07/01/2010 1:25 PM, Uwe Ligges wrote:

Argh. I see it as well. Will dig a lit tomorrow.

I don't know exactly what's going on, but it looks as though it is
something
specific to the find.exe utility, e.g. maybe it is assuming that it's
being
run inside a console and reading CONIN$ or writing to CONOUT$ without
checking whether they can be opened.  When you run it from Rterm, Rterm
is
in a console, which appears to be good enough.

So it may be anyone who wants to use it will have to contact Microsoft to
find out how...

Duncan Murdoch


Uwe





On 07.01.2010 12:25, Gabor Grothendieck wrote:

I get a problem with shell too:

Under Rgui:


R.version.string

[1] R version 2.10.1 Patched (2010-01-01 r50884)


system(C:\\windows\\system32\\find /?, intern = TRUE)

character(0)


system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE)

character(0)


shell(C:\\windows\\system32\\find /?)

Warning message:
In shell(C:\\windows\\system32\\find /?) :
 'C:\windows\system32\find /?' execution failed with error code 1

They all work, i.e. they give the required help message, under Rterm
and when I issue this from the Windows console it works:
C:\windows\system32\find /?


2010/1/7 Uwe Liggeslig...@statistik.tu-dortmund.de:

On 07.01.2010 02:04, Gabor Grothendieck wrote:

If you have C:\Rtools\bin on your PATH note that it contains a
UNIX-like find utility that conflicts with the find utility in
Windows.  If that is the problem then remove that from your PATH and
then run the batch file.

The batchfiles distribution at http://batchfiles.googlecode.com  has
utilities (Rgui.bat, R.bat, Rtools.bat, etc.) that will automatically
add C:\Rtools\bin to your path temporarily or only while R is running
so that you can leave it off your PATH.

I guess it's the use of system() rather than shell() that causes the
problem. Under Windows, you have to use shell in order to start a
command
interpreter.

Uwe Ligges



On Wed, Jan 6, 2010 at 6:51 PM, John Schexnayderjsc...@us.ibm.com
 wrote:

This is sort of a strange bug.  Not show stopping, but annoying.  I
was
wondering if anyone else has noticed this and reported it before I
submit
a bug report.

I noticed while running the RGui and attempting to debug one of my
scripts
that I encountered a Windows error informing me that Find String
[grep]
Utility has encountered a problem and needs to close.  It is being
generated by a call to a DOS batch file which contains a call to
Find.exe.
 It can be reproduced by simply typing  System(find) in RGui.
 What I
found strange is that I have been running this script daily without
this
problem for months.  I now realize I never ran that portion of the
script
while

Re: [R] Calling FING.EXE under RGui.EXE for windows.

2010-01-10 Thread Duncan Murdoch

On 10/01/2010 1:42 PM, Gabor Grothendieck wrote:

Perhaps you can add it to the bug list before you leave it including
what you tried in case its a symptom of some larger underlying
problem.


This list is archived, so there's a record.  But I think this is a find 
bug, not an R bug, so it doesn't make sense to add it to the R bug list.


Duncan Murdoch



On Sun, Jan 10, 2010 at 1:24 PM, Duncan Murdoch murd...@stats.uwo.ca wrote:

I'm quitting on this one.  For the record, I took a look at a fairly old
version of the Tcl code (from 8.4.13) that I had around from an old attempt
to get it to work properly with MDI windows.  There are a number of
differences between their exec code and our system() code, but I couldn't
find the right combination to get system() to be able to run find.  It
always crashes with a seg fault in ulib.dll when run with input coming from
the pipe we send it.

If you use input redirection on the command line, it's fine, for example

system(cmd /c c:/WINDOWS/system32/find /? nul)

or

shell(c:/WINDOWS/system32/find \Hello\ c:/temp/foo.txt nul)

So perhaps we're not setting up the pipe correctly, but it works with most
other programs, so I'm going to assume find is using it incorrectly, unless
someone points out what we're doing wrong.

Duncan Murdoch


On 10/01/2010 8:18 AM, Gabor Grothendieck wrote:

I noticed this does work, i.e. it displays the requested help info, in
Rgui on my Vista system:

library(tcltk)
.Tcl(exec find /?)

On Sat, Jan 9, 2010 at 7:27 PM, Duncan Murdoch murd...@stats.uwo.ca
wrote:

On 09/01/2010 6:31 PM, Gabor Grothendieck wrote:

That doesn't explain why this returns character(o) even though we have
launched a console for it:

system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE)

I don't see any console launched.  R redirects stdin and stdout (and
stderr,
I think), and it appears that Windows doesn't open a console.  I do see a
console flash by if I do

system('cmd /c c:/WINDOWS/system32/find.exe /?', wait=FALSE,
invisible=FALSE)

but of course then we don't capture the output, so it's not very useful.
 Looking at the source, the only case where we ask to create a console is
the combination wait=FALSE, invisible=FALSE, but there might be
combinations of other options that make this a default.  The MS
documentation says that a console will be created automatically for any
console application, but that doesn't appear to be happening.

So I guess you could get find.exe to work by calling it from a batch file
with a pause at the end and using the wait=FALSE,invisible=FALSE
options.

The above observations are in Win XP SP3, not anything newer.

Duncan Murdoch


On Sat, Jan 9, 2010 at 5:24 PM, Duncan Murdoch murd...@stats.uwo.ca
wrote:

On 07/01/2010 1:25 PM, Uwe Ligges wrote:

Argh. I see it as well. Will dig a lit tomorrow.

I don't know exactly what's going on, but it looks as though it is
something
specific to the find.exe utility, e.g. maybe it is assuming that it's
being
run inside a console and reading CONIN$ or writing to CONOUT$ without
checking whether they can be opened.  When you run it from Rterm, Rterm
is
in a console, which appears to be good enough.

So it may be anyone who wants to use it will have to contact Microsoft
to
find out how...

Duncan Murdoch


Uwe





On 07.01.2010 12:25, Gabor Grothendieck wrote:

I get a problem with shell too:

Under Rgui:


R.version.string

[1] R version 2.10.1 Patched (2010-01-01 r50884)


system(C:\\windows\\system32\\find /?, intern = TRUE)

character(0)


system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE)

character(0)


shell(C:\\windows\\system32\\find /?)

Warning message:
In shell(C:\\windows\\system32\\find /?) :
 'C:\windows\system32\find /?' execution failed with error code 1

They all work, i.e. they give the required help message, under Rterm
and when I issue this from the Windows console it works:
C:\windows\system32\find /?


2010/1/7 Uwe Liggeslig...@statistik.tu-dortmund.de:

On 07.01.2010 02:04, Gabor Grothendieck wrote:

If you have C:\Rtools\bin on your PATH note that it contains a
UNIX-like find utility that conflicts with the find utility in
Windows.  If that is the problem then remove that from your PATH
and
then run the batch file.

The batchfiles distribution at http://batchfiles.googlecode.com
 has
utilities (Rgui.bat, R.bat, Rtools.bat, etc.) that will
automatically
add C:\Rtools\bin to your path temporarily or only while R is
running
so that you can leave it off your PATH.

I guess it's the use of system() rather than shell() that causes the
problem. Under Windows, you have to use shell in order to start a
command
interpreter.

Uwe Ligges



On Wed, Jan 6, 2010 at 6:51 PM, John Schexnayderjsc...@us.ibm.com
 wrote:

This is sort of a strange bug.  Not show stopping, but annoying.
 I
was
wondering if anyone else has noticed this and reported it before I
submit
a bug report.

I noticed while running the RGui and attempting to debug one of my
scripts
that I encountered

Re: [R] Help with Order

2010-01-11 Thread Duncan Murdoch

On 11/01/2010 7:37 AM, Steve Sidney wrote:

Dear List

As a fairly new R programmer I seem to have run into a strange problem - 
probably my inexperience with R


After reading and merging successive files into a single data frame, I find 
that order does not sort the data as expected.


I have multiple references in each file but each file refers to measurement 
data obtained at a different time.


Here's the code

library(reshape)
# Enter file name to Read  Save data
FileName=readline(Enter File name:\n)
# Find first occurance of file
for ( round1 in 1 : 6) {
ReadFile=paste(round1,C_,FileName,_Stats.csv, sep=)
if (file.exists(ReadFile))
break
}

x = data.frame(read.csv(ReadFile, header=TRUE),rnd=round1)
for ( round2 in (round1+1) : 6) {
#
ReadFile=paste(round2,C_,FileName,_Stats.csv, sep=)
if (file.exists(ReadFile)) {
y = data.frame(read.csv(ReadFile, header=TRUE),rnd = round2)
if (round2 == (round1 +1))
z=data.frame(merge(x,y,all=TRUE))
z=data.frame(merge(y,z,all=TRUE))
}
}
ordered = order(z$lab_id)

results = z[ordered,]

res = data.frame( 
lab=results[,lab_id],bw=results[,ZBW],wi=results[,ZWI],pf_zbw=0,pf_zwi=0,r 
= results[,rnd])



#
# Establish no of samples recorded
nsmpls = length(res[,c(lab)])

# Evaluate Z_scores for Between Lab Results
for ( i in 1 : nsmpls) {
if (res[i,bw]  3 | res[i,bw]  -3)
res[i,pf_zbw]=1
}
# Evaluate Z_scores for Within Lab Results
for ( i in 1 : nsmpls) {
if (res[i,wi]  3 | res[i,wi]  -3)
res[i,pf_zwi]=1
}

dd = melt(res, id=c(lab,r), pf_zbw)
b = cast(dd, lab ~ r)
If anyone could see why the ordering only works for about 55 of 70 records 
and could steer me in the right direction I would be obliged


I can't try out your code, but I'd guess it's due to conversion of 
strings to factors.  Sorting factors will sort them by their numerical 
value, not by the strings.


So the solution is to set stringsAsFactors=FALSE, either in each 
read.csv call, or globally with options(stringsAsFactors=FALSE).


Duncan Murdoch

__
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] example() leaves console prompting to press Enter for new graphs

2010-01-11 Thread Duncan Murdoch

On 11/01/2010 9:28 AM, Michael Friendly wrote:

Env: Win XP, R 2.9.2]

It's a minor annoyance, but I find that after I run example(), the 
console state of prompting to press Enter for
each new graph remains as it is under example.  It's more annoying that 
it seems difficult to turn this behavior

off!

In a fresh session:
   getOption(example.ask)
[1] default

Run an example:
  example(plot)
plot require(stats)

plot plot(cars)
Waiting to confirm page change...
...

  getOption(example.ask)
[1] default

# do another plot:
  plot(sin, -pi, 2*pi)
Waiting to confirm page change...
 

# reset option to FALSE
  options(example.ask=FALSE)
  plot(sin, -pi, 2*pi)
Waiting to confirm page change...

# try resetting devAskNewPage
  devAskNewPage(ask = NULL)
[1] TRUE
  plot(sin, -pi, 2*pi)
Waiting to confirm page change...
 

There does seem to be code in example to reset this state on exit, and 
I'm baffled why it doesn't actually

do it

   ...
if (ask == default)
ask - echo  grDevices::dev.interactive(orNone = TRUE)
if (ask) {
if (.Device != null device) {
oldask - grDevices::devAskNewPage(ask = TRUE)
if (!oldask)
on.exit(grDevices::devAskNewPage(oldask), add = TRUE)
}
op - options(device.ask.default = TRUE)
on.exit(options(op), add = TRUE)
}
   ...

So, how can I restore the previous state of plotting w/out prompting?

  



It's not the console state that is left that way, it's the graphics 
window.  If you close it, the next window you open will have the state 
you wanted.  If you had had a window open before you called example, it 
would have been restored. 


Duncan Murdoch

__
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] R for windows 64 bit

2010-01-11 Thread Duncan Murdoch

On 11/01/2010 11:29 AM, alessia matano wrote:

Dear all,

do you know if there is any particular version of R to implement with
windows 64 bit, in such a way to increase the amount of memory it can
use?
  


There are two that I know of.  Revolution Computing sells one, built 
with a commercial compiler.  Brian Ripley made a posting last week on 
the R-devel list about an experimental build using gcc.


Duncan Murdoch

How should I increase the memory, and more importantly to set a higher
max vector size? It still stops me saying Could not allocate vector
of size 145


__
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] Calling FING.EXE under RGui.EXE for windows.

2010-01-11 Thread Duncan Murdoch

On 11/01/2010 2:56 PM, John Schexnayder wrote:
I just wanted to add that it is not only caused by the FIND.EXE, but I 
also noticed the same problem with DOSKEY.EXE.  It too causes the same 
fault, but the redirection (nul) prevents the fault just like Duncan 
pointed out with FIND.  I imagine there are number of other executables 
that would produce the same results.  Oddly enough FINDSTR.EXE does not 
produce the fault.  (You would think it would share code with FIND.EXE.)


I also noticed other strange differences now that I poke around with other 
executables.  For instance


shell(copy /?)

produces the desired help information in RGui.exe however 


shell(xcopy /?)

does not.  I know they are different in that copy is not an executable, 
but a system call where Xcopy is an executable, but they should behave the 
same way.
Especially considering they do behave properly in Rterm.  Again this is an 
RGui only phenomena.
  


I don't find it very surprising.  cmd.exe doesn't have the bug, so copy 
/? works fine.  find.exe and apparently xcopy.exe do, so they fail.


It's not a bug in doskey that it doesn't work; it's supposed to talk to 
the console, so if there is no console, it won't work.  But find and 
xcopy have no business talking to the console.  They should simply work 
with stdin/stdout.


Duncan Murdoch


Re,
John Schexnayder

IBM Tape Manufacturing - Information Technology
San Jose, CA  95138
jsc...@us.ibm.com




From:
Gabor Grothendieck ggrothendi...@gmail.com
To:
Duncan Murdoch murd...@stats.uwo.ca
Cc:
Uwe Ligges lig...@statistik.tu-dortmund.de, John Schexnayder/San 
Jose/i...@ibmus, r-h...@stat.math.ethz.ch

Date:
01/10/2010 10:42 AM
Subject:
Re: [R] Calling FING.EXE under RGui.EXE for windows.



Perhaps you can add it to the bug list before you leave it including
what you tried in case its a symptom of some larger underlying
problem.

On Sun, Jan 10, 2010 at 1:24 PM, Duncan Murdoch murd...@stats.uwo.ca 
wrote:

 I'm quitting on this one.  For the record, I took a look at a fairly old
 version of the Tcl code (from 8.4.13) that I had around from an old 
attempt

 to get it to work properly with MDI windows.  There are a number of
 differences between their exec code and our system() code, but I 
couldn't

 find the right combination to get system() to be able to run find.  It
 always crashes with a seg fault in ulib.dll when run with input coming 
from

 the pipe we send it.

 If you use input redirection on the command line, it's fine, for example

 system(cmd /c c:/WINDOWS/system32/find /? nul)

 or

 shell(c:/WINDOWS/system32/find \Hello\ c:/temp/foo.txt nul)

 So perhaps we're not setting up the pipe correctly, but it works with 
most
 other programs, so I'm going to assume find is using it incorrectly, 
unless

 someone points out what we're doing wrong.

 Duncan Murdoch


 On 10/01/2010 8:18 AM, Gabor Grothendieck wrote:

 I noticed this does work, i.e. it displays the requested help info, in
 Rgui on my Vista system:

 library(tcltk)
 .Tcl(exec find /?)

 On Sat, Jan 9, 2010 at 7:27 PM, Duncan Murdoch murd...@stats.uwo.ca
 wrote:

 On 09/01/2010 6:31 PM, Gabor Grothendieck wrote:

 That doesn't explain why this returns character(o) even though we 
have

 launched a console for it:

 system(cmd /c C:\\windows\\system32\\find /?, intern = TRUE)

 I don't see any console launched.  R redirects stdin and stdout (and
 stderr,
 I think), and it appears that Windows doesn't open a console.  I do 
see a

 console flash by if I do

 system('cmd /c c:/WINDOWS/system32/find.exe /?', wait=FALSE,
 invisible=FALSE)

 but of course then we don't capture the output, so it's not very 
useful.
  Looking at the source, the only case where we ask to create a console 
is

 the combination wait=FALSE, invisible=FALSE, but there might be
 combinations of other options that make this a default.  The MS
 documentation says that a console will be created automatically for 
any

 console application, but that doesn't appear to be happening.

 So I guess you could get find.exe to work by calling it from a batch 
file

 with a pause at the end and using the wait=FALSE,invisible=FALSE
 options.

 The above observations are in Win XP SP3, not anything newer.

 Duncan Murdoch

 On Sat, Jan 9, 2010 at 5:24 PM, Duncan Murdoch murd...@stats.uwo.ca
 wrote:

 On 07/01/2010 1:25 PM, Uwe Ligges wrote:

 Argh. I see it as well. Will dig a lit tomorrow.

 I don't know exactly what's going on, but it looks as though it is
 something
 specific to the find.exe utility, e.g. maybe it is assuming that 
it's

 being
 run inside a console and reading CONIN$ or writing to CONOUT$ 
without
 checking whether they can be opened.  When you run it from Rterm, 
Rterm

 is
 in a console, which appears to be good enough.

 So it may be anyone who wants to use it will have to contact 
Microsoft

 to
 find out how...

 Duncan Murdoch

 Uwe





 On 07.01.2010 12:25, Gabor Grothendieck wrote:

 I get a problem with shell

Re: [R] error variable names are limited to 256 bytes when sourcing code

2010-05-26 Thread Duncan Murdoch

Brian Frizzelle wrote:
I've written a function that takes some input data output from a 
simulation model and creates some graphs. It's not very complicated 
code, and it works perfectly fine if I just run the code as is.


But I have converted it into a function so we call it externally, and 
when I try to source the code to test the function, I get the error 
message variable names are limited to 256 bytes. I've tried searching 
online for a solution to this, but everything I have come across deals 
with this error in relation to input data, not a function.


The code is 389 lines long, so I'd rather not paste it here and clog up 
inboxes. If you have an idea as to why this is happening and would like 
to see the code, please email me and I will send it to you.
  


Current versions of R will tell you which line contained the error.  
Can't you find and post just that one line?  If you aren't seeing an 
error report, you could divide and conquer:  edit blocks out of your 
file until you can figure out which lines matter.


My guess would be something involving backticks (i.e. things like `x`); 
R will see the first one, and collect characters until the next one as a 
single identifier.


Duncan Murdoch

__
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] How to install an archived version of a package in windows

2010-05-27 Thread Duncan Murdoch

Nevil Amos wrote:
How do I install an archived version of a package - in this case 
Geneland 3.1.5 in windows?


The archived versions are available on CRAN and tar.gz.  I can downland 
this, but then the only option to install a local copy is

  utils:::menuInstallLocal()
or install from local zip file in the console packages menu, this does 
not work wither with the downlaoded tar.gz, or if I unzip it and save 
all its contents as Genland_3.1.5.zip in the R/bin direcotry.


What do I need to do?


The archived versions are source packages.  So you need to install the 
tools to build from source (see the R Admin manual, or 
http://www.murdoch-sutherland.com/Rtools/), then simply do


install.packages(foo.tar.gz, type=source, repos=NULL)

from within R, or

Rcmd INSTALL foo.tar.gz

from outside.

Duncan Murdoch

__
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] Rprofile: distinguish between Rgui, Rterm, JGR?

2010-05-27 Thread Duncan Murdoch

Michael Friendly wrote:

[Environment: Win XP, R 2.10.1]

In my Rprofile I have startup code to do various things, intended for 
when I use the Rgui console.
Some of these are causing problems in JGR now that I've installed it.  
How can I test for R

running with Rgui to do some of these things only there?

  
Look at .Platform$GUI.  It shows Rgui or RTerm for those two.  I 
don't have JGR installed, but I'd guess it shows something differently 
there.


Duncan Murdoch

__
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] difference in sort order linux/Windows (R.2.11.0)

2010-05-28 Thread Duncan Murdoch

carslaw wrote:

Dear R users,

I'm a bit perplexed with the effect sort has here, as it is different on
Windows vs. linux. 
It makes my factor levels and subsequent plots different on the two systems.
  


You are using different collation orders.  On Linux, your sessionInfo shows

en_GB.utf8   


while Windows shows

English_United Kingdom.1252


so you should be prepared for differences.  That said, it certainly 
looks as though the string comparison is wrong on Linux.  Using Ted 
Harding's examples, I get these results:


 AB CD  ABCD
[1] FALSE
 AB CD  ABCD 
[1] FALSE

on Windows in the English_Canada.1252 locale and on Linux in the C 
locale.  However,  when I use the locale that's default on our system, 
en_US.UTF-8, I get


 AB CD  ABCD
[1] TRUE
 AB CD  ABCD 
[1] FALSE

as Ted did, and that certainly looks wrong.

Duncan Murdoch

Given:

types - c(PC-D-Euro-0, PC-D-Euro-1, PC-D-Euro-2, PC-D-Euro-3, 
PC-D-Euro-4, PC-D-Euro-5, PC-D-Euro-6, LCV-D-Euro-0, 
LCV-D-Euro-1, LCV-D-Euro-2, LCV-D-Euro-3, LCV-D-Euro-4, 
LCV-D-Euro-5, LCV-D-Euro-6, HGV-D-Euro-0, HGV-D-Euro-I, 
HGV-D-Euro-II, HGV-D-Euro-III, HGV-D-Euro-IV EGR, HGV-D-Euro-IV SCR, 
HGV-D-Euro-IV SCRb, HGV-D-Euro-V EGR, HGV-D-Euro-V SCR, 
HGV-D-Euro-V SCRb, HGV-D-Euro-VI, HGV-D-Euro-VIb)


On linux, sort does:

sort(types)
 [1] HGV-D-Euro-0   HGV-D-Euro-I   HGV-D-Euro-II 
 [4] HGV-D-Euro-III HGV-D-Euro-IV EGR  HGV-D-Euro-IV SCR 
 [7] HGV-D-Euro-IV SCRb HGV-D-Euro-V EGR   HGV-D-Euro-VI 
[10] HGV-D-Euro-VIb HGV-D-Euro-V SCR   HGV-D-Euro-V SCRb 
[13] LCV-D-Euro-0   LCV-D-Euro-1   LCV-D-Euro-2  
[16] LCV-D-Euro-3   LCV-D-Euro-4   LCV-D-Euro-5  
[19] LCV-D-Euro-6   PC-D-Euro-0PC-D-Euro-1   
[22] PC-D-Euro-2PC-D-Euro-3PC-D-Euro-4   
[25] PC-D-Euro-5PC-D-Euro-6



And on Windows:

sort(types)

 [1] HGV-D-Euro-0   HGV-D-Euro-I   HGV-D-Euro-II
 [4] HGV-D-Euro-III HGV-D-Euro-IV EGR  HGV-D-Euro-IV SCR
 [7] HGV-D-Euro-IV SCRb HGV-D-Euro-V EGR   HGV-D-Euro-V SCR 
[10] HGV-D-Euro-V SCRb  HGV-D-Euro-VI  HGV-D-Euro-VIb   
[13] LCV-D-Euro-0   LCV-D-Euro-1   LCV-D-Euro-2 
[16] LCV-D-Euro-3   LCV-D-Euro-4   LCV-D-Euro-5 
[19] LCV-D-Euro-6   PC-D-Euro-0PC-D-Euro-1  
[22] PC-D-Euro-2PC-D-Euro-3PC-D-Euro-4  
[25] PC-D-Euro-5PC-D-Euro-6  


Session info for both systems is below.  The order I actually want is the
Windows one, but looking at it,
 the linux order is perhaps more intuitive.  However, the problem is the
order is inconsistent between
 the two systems.  Any suggestions?

sessionInfo()
R version 2.11.0 (2010-04-22) 
x86_64-pc-linux-gnu 


locale:
 [1] LC_CTYPE=en_GB.utf8  LC_NUMERIC=C
 [3] LC_TIME=en_GB.utf8   LC_COLLATE=en_GB.utf8   
 [5] LC_MONETARY=en_GB.utf8   LC_MESSAGES=en_GB.utf8  
 [7] LC_PAPER=en_GB.utf8  LC_NAME=en_GB.utf8  
 [9] LC_ADDRESS=en_GB.utf8LC_TELEPHONE=en_GB.utf8 
[11] LC_MEASUREMENT=en_GB.utf8LC_IDENTIFICATION=en_GB.utf8


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


other attached packages:
[1] rkward_0.5.3

loaded via a namespace (and not attached):
[1] tools_2.11.0

  

sessionInfo()


R version 2.11.0 (2010-04-22)
x86_64-pc-mingw32

locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252  
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C  
[5] LC_TIME=English_United Kingdom.1252   

 
attached base packages:


[1] stats graphics  grDevices utils datasets  methods   base

Dr David Carslaw
King's College London
Environmental Research Group
Franklin Wilkins Building
150 Stamford Street
London
SE1 9NH 



__
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] difference in sort order linux/Windows (R.2.11.0)

2010-05-28 Thread Duncan Murdoch

On 28/05/2010 9:24 AM, (Ted Harding) wrote:

An experiment:

  sort(c(AACD,A CD))
  #  [1] AACD A CD

  sort(c(ABCD,A CD))
  #  [1] ABCD A CD

  sort(c(ACCD,A CD))
  #  [1] ACCD A CD

  sort(c(ADCD,A CD))
  #  [1] A CD ADCD

  sort(c(AECD,A CD))
  #  [1] A CD AECD
  ## (with results for AFCD, ... AZCD similar to the last two).

  LC_COLLATE=en_GB.UTF-8

(R version 2.11.0 (2010-04-22) on Linux).

So this behaves, in en_GB.UTF-8, as though   (SPACE) is between
C and D.

This is nuts!!!

Curable if I set (e.g.) LC_LOCALE=C on startup. But what else
might break if I do so?
  


You have to realize that to a large extent this is not under our 
control.  Your system will have linked to some library (outside of R) to 
do string collation, and the problem lies in that library.  You should 
determine which system library is handling your collations.


I'd like to tell you how to do that, but I don't know for your build.  
You can find out if you're using the recommended ICU library by running 
example(icuSetCollate); that gives a number of warnings like


In icuSetCollate(locale = da_DK, case_first = default) :
 ICU is not supported on this build

in Windows.  If you don't see those, then you want to talk to the ICU 
people.  If you do, then you'll need to look deeper to find out what 
you're actually using.


Duncan Murdoch

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 28-May-10   Time: 14:24:08
-- XFMail --

__
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-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] Gelman 2006 half-Cauchy distribution

2010-05-28 Thread Duncan Murdoch

On 28/05/2010 9:29 AM, Christopher David Desjardins wrote:

Hi,
I am trying to recreate the right graph on page 524 of Gelman's 2006 
paper Prior distributions for variance parameters in hierarchical 
models in Bayesian Analysis, 3, 515-533. I am only interested, however, 
in recreating the portion of the graph for the overlain prior density 
for the half-Cauchy with scale 25 and not the posterior distribution. 
However, when I try:


curve(dcauchy, from=0, to=200, location=0, scale=25)

the probabilities for the half-Cauchy values seem to approach zero 
almost immediately after 0 whereas in Gelman 2006 the tail appears much 
fatter giving non-zero probabilities out to 100.
  


Don't ignore the warnings!!!  The scale argument is not being passed to 
dcauchy.  (Nothing in the help page suggests it would be, but some other 
similar functions would have passed it, so I can see how you made the 
wrong assumption.  But why did you ignore all those warnings?)  You'll 
get what you want with


curve( dcauchy(x, location=0, scale=25), from=0, to=200)

or with

den - function(x) dcauchy(x, location=0, scale=25)
curve(den, from=0, to=200)

if you don't like using the magic name x in the first one.

Duncan Murdoch
I am interested in replicating this because I want to use half-Cauchy 
priors and want to play around with the scale values but I want to know 
what my prior looks like before using it in models.


Please cc me as I am digest subscriber.

Thanks!
Chris

__
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-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] Gelman 2006 half-Cauchy distribution

2010-05-28 Thread Duncan Murdoch

On 28/05/2010 10:14 AM, Christopher David Desjardins wrote:

Perfect. Thanks.
Also using R 2.11.0 on Fedora I didn't get any warnings with my command.
  


That's a serious problem.  Can you give more details (i.e. just plain R, 
R under ESS, etc.)?


Duncan Murdoch


Chris

On 05/28/2010 09:09 AM, Berwin A Turlach wrote:
 curve(2*dcauchy(x, location=0, scale=25), from=0, to=200)


__
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-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] Does Sweave run in the global environment ?

2010-05-28 Thread Duncan Murdoch

On 28/05/2010 1:58 PM, Paul wrote:

Hello
It seems that sweave always runs in the global environment.  



By default it uses the RweaveEvalWithOpt function to evaluate 
expressions, and they are evaluated in the global environment.  It's 
possible to change that.  You need to make your own driver.  I'd start 
with the default one via


mydriver - RweaveLatex()

then replace the code running part with your own, e.g.

myenvironment - environment()  # This will make the current environment 
is the default, rather than globalenv()


myEvalWithOpt - function (expr, options){
   if(options$eval){
   res - try(withVisible(eval(expr, myenvironment)),
  silent=TRUE)
   if(inherits(res, try-error)) return(res)
   if(options$print | (options$term  res$visible))
   print(res$value)
   }
   return(res)
}

mydriver$runcode - makeRweaveLatexCodeRunner(evalFunc = myEvalWithOpt)

and then run Sweave with your driver:

Sweave(file, driver=mydriver)

I haven't tried any of this, and it's possible some of the functions I 
used above are not exported from the utils package.  But this should get 
you started if you (sensibly) want to avoid setting your variable as a 
global.


Another approach (which I use) is to never run Sweave() from within R; 
always use R CMD Sweave (or some equivalent), and define all the local 
variables in the Sweave file.  But this doesn't work if you want to 
generate lots of Sweave output files.


Duncan Murdoch

I want to 
run sweave from within a function, and pass a variable into sweave, 
however when I do this, sweave doesn't see the variable.


Here's my example test_sweave.Rnw file

|% 
\documentclass[a4paper]{article}

\usepackage[OT1]{fontenc}
\usepackage{Sweave}
\begin{document}

\title{Test Sweave Document}
\author{Paul Hurley}

\maketitle

=

if(exists(foo)){print(foo)}
ls()
Sys.time()
@ 
\end{document}

|

If I run this code;

|testFoo-function(){
  foo-My Test String 
  Sweave(test_sweave.Rnw) 
  require(tools)
  texi2dvi(file = test_sweave.tex, pdf = TRUE) 
}


rm(foo) testFoo()
|

my resulting file does NOT contain the contents of the string foo.

| if (exists(foo)) {
+ print(foo)
+ }
 ls()
[1] testFoo
|

If I run this code (i.e, the same thing, just run directly)

|rm(foo)
foo-My Test String
Sweave(test_sweave.Rnw)
require(tools) 
texi2dvi(file = test_sweave.tex, pdf = TRUE)

|

my resulting file does contain the foo string

| if (exists(foo)) {
+ print(foo)
+ }
[1] My Test String
 ls()
[1] foo testFoo
|

and if I run this code

|testBar-function(){
foo-My Test String
Sweave(test_sweave.Rnw)
require(tools) 
texi2dvi(file = test_sweave.tex, pdf = TRUE)

}

rm(foo)
testBar()
|

My resulting file also contains the foo string

| if (exists(foo)) {
+ print(foo)
+ }
[1] My Test String
 ls()
[1] foo testBar testFoo
|

So, it seems that sweave runs in the global environment, not in the 
environment it was called from. This means the only way to pass 
variables to sweave when sweave is run from a function is to use the - 
operator to put the variable in the global environment. (I think).


Anyone else want to comment who knows more about environments ?


Thanks

Paul.

[[alternative HTML version deleted]]

__
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-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] ICD9 codes

2010-05-29 Thread Duncan Murdoch
I have received the Matched a Filter Rule message a number of times.  
I have some control over what the headers of my messages look like, so 
if I was told what the filter rule is, I could perhaps modify the 
messages to avoid it.  You probably don't want to post that information 
to the list, but it might be worthwhile to send it privately to authors 
of false positive messages.


Duncan Murdoch

On 29/05/2010 6:43 AM, (Ted Harding) wrote:

It is perhaps time to bring to people's general attention that
there is an issue with postings from gmail.com addresses being
held for moderation because The headers matched a filter rule.
It is not only gmail.com, but there is a marked excess of these.
Vishwanath (@gmail.com) is one of many victims.

There is a group of about a dozen people who act as moderators,
approving or discarding messages which have been held. Reasons
for holding are almost always either Posting from Non-Member
or Matched a Filter Rule. We do this somewhat non-systematically,
looking at the list of held messages on a convenience basis.
However, it would be unlikely that any valid message would be
held for more than an hour or so; usually it would be less.

The situation has been discussed recently amongst the moderators,
including the list manager Martin Maechler. We are undecided
about the best action (if any) -- while the excessive false
trapping of gmail.com postings is at least an inconvenience
for the trapped, and sometimes leads to visible distress or
embarrassment, the presence of the filter rules does prevent
spam from reaching the list.

Vishwanath's reaction in repeatedly re-posting is perhaps
understandable on the part of someone who is not familiar with
how the moderation system operates. In fact he posted the same
message 4 times (morning  evening on 27 May, and again on 28 May)
as can be seen from the archives. He is subscribed to the list,
so would normally receive copies of his own postings via the list
(and therefore know that it had got through) unless he has opted
to not receive his own postings. In that case, having received
the held for moderation message, not receiving his posting via
the list, and not thinking of looking in the archives, he could
form the impression that it/they had vanished into a black hole,
and try again.

Since we began to discuss this about a fortnight ago, I have
been keeping a count of those held messages which I have seen
myself. Not counting true spam, only genuine messages, the results
are as follows. NM denote a posting from a non-member, FR
denotes a posting that matched a filter rule, GM denotes a
posting from a gmail.com address, NGM one not from gmail.com.

  FR NM
+-+-
GM  | 45  |   4
+-+-
NGM | 19  |  24

Fisher test: P=7.3e-07, OR=13.7, CI=(4.0, 62.0)

About 30% of R-help subscribers have gmail.com addresses, so they
are clearly over-represented in the FR group (70%)!

It is suspected that the gmail.com filter rule may perhaps be
triggered by HTML, though the reason is not yet clear.

Meanwhile, a reminder to people who receive notification that
their posting has been held for moderation: Please check the
archives to see whether your message has reached the list within
a reasonable time (say 2 hours -- there can be a delay before a
message is placed in the archives) beforetrying to do anything
about it: https://stat.ethz.ch/pipermail/r-help

Hoping this helps to clarify an issue which can lead to unwanted
consequences.

Ted.

On 29-May-10 05:42:27, Vishwanath Sindagi wrote:
  

Dear Prof Frank Harrel:

I am extremely sorry for having reposted the same question numerous
times. Earlier when I had posted I got  replies stating that my post
had matched a filter rule and hence was being held by the moderator.
So I assumed that the question was never posted and I reposted with
different subject lines just to make sure that it gets posted.

I sincerely apologise for the inconvenience caused.

Regards,
Vishwanath

On Sat, May 29, 2010 at 4:10 AM, Frank E Harrell Jr
f.harr...@vanderbilt.edu wrote:


Your notes are bordering on harassment. _Do you expect that everyone
who
reads this list will reply I do not have anything that will help you
if
they don't? _By my count this is your 4th note asking for this help.

That being said I hope that you do find help somewhere or implement it
yourself and share the result, as your question is an important one.

Also, please be sure to state your affiliation on your notes.

Frank

On 05/28/2010 02:19 PM, Vishwanath Sindagi wrote:
  

Hello:

I am working on getting some statistics related to clinical trials
and
stuff. I have to work with ICD9 codes.

Is anyone aware of any R method that deals with ICD9 codes
verification and manipulation.

Thanks
Vishwanath



--
Frank E Harrell Jr _ Professor and Chairman _ _ _ _School of Medicine
_ _ _ _ _ _ _ _ _ _ Department of Biostatistics _ Vanderbilt
University

  

__
R

Re: [R] warning In fun(...) : no DISPLAY variable so Tk is not available

2010-05-29 Thread Duncan Murdoch

Nevil Amos wrote:
I am getting the above warning following loading of Geneland 3.1.5 on 
unix , while a simple plot sends output to the pdf file ( see attached 
code) no output results from Geneland functions, resulting in empty pdf 
files
  


That message is saying it can't find an X11 server for Tcltk to use.  If 
you do have X11 available, then just set the DISPLAY environment 
variable in the normal way; if you don't, then you're not going to be 
able to use that package on Unix.  (The Windows implementation is 
self-contained, so it should work there.)


Duncan Murdoch


  library (Geneland)
Loading required package: RandomFields
Loading required package: fields
Loading required package: spam
Package 'spam' is loaded. Spam version 0.21-0 (2010-03-13).
Type demo( spam) for some demos, help( Spam) for an overview
of this package.
Help for individual functions is optained by adding the
suffix '.spam' to the function name, e.g. 'help(chol.spam)'.

Attaching package: 'spam'

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

 backsolve, forwardsolve, norm

  Try help(fields) for an overview of this library
fields web: http://www.image.ucar.edu/Software/Fields
Loading required package: mapproj
Loading required package: maps
Loading required package: snow
Loading required package: tcltk
Loading Tcl/Tk interface ... done
ooo
oGeneland is loaded   o
o o
o* Please *   o
o o
oRegister on  o
ohttp://folk.uio.no/gillesg/Geneland/register.php o
o o
oSee manual ono
ohttp://folk.uio.no/gillesg/Geneland/Geneland.htmlo
o o
oThis is Geneland-3.1.5   o
o o
ooo
Warning message:
In fun(...) : no DISPLAY variable so Tk is not available
  pdf(test.pdf)
  plot(1:10,1:10)
  dev.off()
null device

__
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-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] Vector docs

2010-05-30 Thread Duncan Murdoch

i...@whywouldwe.com wrote:

Hi

The docs for R are very practical, which is quite refreshing compared to 
other languages, however I can't find any details about all the things I 
can do with a vector. I'm expecting methods like vector.contains('foo') 
and vector.remove('foo'), maybe those methods don't exist but I'd love 
to find a page that details the ones that do.


I'd also like to find some docs about foreach loops (unless there's a 
better way to iterate through a vector), I've only found mailing list posts.


  


There may be such a page somewhere, but it is probably incomplete.  The 
object model in R has methods owned by generics, not by classes.  So 
even if someone wrote a list of all methods that worked on vectors, 
someone else could add a new one without modifying the vector class.


You can ask R what methods are currently visible, e.g.

library(methods)
showMethods(classes=vector)

but it won't show methods in unattached packages.

Duncan Murdoch

__
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] error on Windows OS

2010-05-31 Thread Duncan Murdoch

M.Ribeiro wrote:

I received by email an R package (file.tar.gz) that was created in Linux.
The package was already installed in another computer in linux using
install.packages and it worked

I am not familiar with installing packages but I would like to install it on
Windows

I downloaded the Rtools29.exe and tryed to install using

install.packages(foo.tar.gz, repos=NULL, type=source)
but the message was

Warning in install.packages(GR_1.0.tar.gz, repos = NULL, type = source)
:
  argument 'lib' is missing: using 'C:\Documents and Settings\mr\My
Documents/R/win-library/2.9'
  


That's a funny name to use for the library for R 2.10.x, but it's not a 
serious error.

'sh' is not recognized as an internal or external command,
operable program or batch file.
  


That's the one that stopped the install.  Apparently the Rtools bin 
directory is not being found by Windows in your PATH.  The Rtools 
installer can put it there; maybe you should just reinstall Rtools and 
choose that option.

Warning message:
In install.packages(GR_1.0.tar.gz, repos = NULL, type = source) :
  installation of package 'GR_1.0.tar.gz' had non-zero exit status

my questios are:

Where shall I save the .tar.gz file??
  


That doesn't matter, as long as it's a readable directory.

Do I need to do anything else with the Rtools besides installing
(C:/Rtools)??
  


Set the Windows PATH variable.

Is the problem with the way I did or with the package??

  

So far it looks like the Rtools install.

Duncan Murdoch

Thanks a lot
Cheers 



__
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] Building a what list for scan to use

2010-05-31 Thread Duncan Murdoch

On 31/05/2010 7:07 AM, Alex van der Spek wrote:
Using read.table now on large files. Scan should be faster reading and 
parsing the files if a 'what' list is provided.


How would I generate a what list that repeats the the last 4 elements n 
(n=14 or 10 or 8) times?


whatlist=list(Tstamp=,Condition=0,A1=0,B1=0,C1=0,D1=0)

All are numeric, either decimal or hexadecimal.

  


Do it like this:

n - 14
indices - c(1,2, rep(3:6, n))
biglist - whatlist[indices]


This repeats the names too; if you want new names for the repeated 
columns, you can reassign the names afterwards, e.g.


names(biglist) - paste(name, 1:(2+4*n))

Duncan Murdoch

__
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] Y-axis range in histograms

2010-05-31 Thread Duncan Murdoch

On 31/05/2010 10:49 AM, Aarne Hovi wrote:

Hi,

I'm trying to create a histogram with R. The problem is that the frequency
is high for a couple of x-axis categories (e.g. 1500) and low for most of
the x-axis categories (e.g. 50)  
http://r.789695.n4.nabble.com/file/n2237476/LK3_hist.jpg . When I create the

histogram, it is not very informative, because only the high frequencies can
be seen clearly. Is there any way I could cut the y-axis from the middle so
that the y-axis values ranged for example from 0 to 300, and then again from
900 to 1500?


Using a bar chart like that takes away most of the value of using a bar 
chart:  you lose both area and length as visual clues to the value.  Why 
not do something different?  For example,


x - runif(1700) + rep(1:5, c(1500,50,55,45,50))
hist(x, breaks=5)  # The one you don't like
h - hist(x, breaks=5, plot=FALSE)  # Get the data
plot(h$mids, h$counts, log=y) # Plot on a log scale
abline(v=h$breaks,col=lightgray) # Indicate the bins

Duncan Murdoch

__
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] error on Windows OS

2010-05-31 Thread Duncan Murdoch

On 31/05/2010 9:13 AM, M.Ribeiro wrote:
Ok, 
I re-installed the Rtools (now Rtools211 because I was in another computer

with R version 2.10) , and the message now when I tried to install the
package was

Warning: invalid package 'GWSR_1.0.tar.gz'
Erro: ERROR: no packages specified
Warning message:
In install.packages(GWSR_1.0.tar.gz, repos = NULL, type = source) :
  installation of package 'GWSR_1.0.tar.gz' had non-zero exit status


Any Clue?



I would guess that the package didn't exist in the current directory.

I'd recommend working in the CMD window rather than in R (using Rcmd 
INSTALL GWSR_1.0.tar.gz); it is sometimes tricky to see what the state 
of the system is from R.



Duncan Murdoch

__
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] Question about the license of an R package

2010-06-01 Thread Duncan Murdoch

Mauricio Zambrano wrote:

Dear R-users,

I'm developing a package that heavily depends on another package
released under the GPL-2 license.
  


Are you including code from that package in yours, or just making use of 
it?  The former requires that you follow all the GPL rules about your 
own.  If you just use their package, then license your package any way 
you like.

In addition, some few functions depends on other packages released
under the following licences (as described in the corresponding pages
of http://cran.r-project.org/web/packages/):

GPL
GPL =2.

I want to release my package under a GPL = 2 license, and after
reading the section 1.1.1 of the R-exts manual and looking at the
compatibility matrix found on http://gplv3.fsf.org/dd3-faq,  I'm still
in doubt if I can do that.

I would appreciate if you could tell me if can I release my package
under a GPL = 2 license considering the aforementioned licenses ?


Finally, a general question:

When a package is released under GPL =2, does it mean that the terms
of the GPL-3 license apply or not ?
  


I believe that's an offer to license under whatever version of the GPL 
(from 2 up) that the person using your code chooses.  If GPL-3 offers 
something that GPL-2 doesn't (e.g. compatibility with other GPL-3 code), 
they can use that.  If GPL-3 places restrictions they don't like (e.g. 
incompatibility with GPL-2 code), they can use GPL-2.


Duncan Murdoch

Thanks in advance for any help.

Mauricio

__
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-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] Seeking help on Vectorize()

2010-06-03 Thread Duncan Murdoch

Megh Dal wrote:

Dear falks, here I have written following function :
 
fn - Vectorize(function(x = 1:3, y = 3:6) {

x - matrix(x, nrow=1)
y - matrix(y, ncol=1)
dat - apply(x, 2, function(xx) {
  apply(y, 1, function(yy) {
  return(xx + yy) } ) })
return(dat)}, SIMPLIFY = TRUE)

If I run this function, I got some warning message, even format of the returned 
object is not correct, for example :
 
  

  fn(x = 1:3, y = 3:7)


[1] 4 6 8 7 9
Warning message:
In mapply(FUN = function (x = 1:3, y = 3:6)  :
  longer argument not a multiple of length of shorter
 
However if I run individual line of codes like :
 
  

x - 1:3; y = 3:7
x - matrix(x, nrow=1)
 y - matrix(y, ncol=1)
 dat - apply(x, 2, function(xx) {


+   apply(y, 1, function(yy) {
+   return(xx + yy) } ) })
  

dat


 [,1] [,2] [,3]
[1,]456
[2,]567
[3,]678
[4,]789
[5,]89   10

 
I get exactly what I want. Where I am making fault?


I think you don't understand what Vectorize is trying to do.  It is 
basically a way to run a loop, calling your function with each matching 
pair of x and y values, i.e. x=1, y=3 in the first call, then x=2 y=4 in 
the second, etc.  The warning comes because you have three x values and 
five y values, so it will repeat the 1st two x values -- but it warns 
you that's likely not what you intended.


Duncan Murdoch

__
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] Your message to R-help awaits moderator approval

2010-06-05 Thread Duncan Murdoch

Gabor Grothendieck wrote:

This has happened to me too.  The last time it occurred I was replying
to another post and on my second attempt I deleted the replied-to
portion and reposted just my portion and it worked.

On Fri, Jun 4, 2010 at 4:35 PM, yjmha69 yjmh...@yahoo.com wrote:
  

What filter rule is violated?
So frustrated, why can't I post question!



The problem is that you are posting from gmail.com, and yjmha69 was 
posting from yahoo.com.  The messages will eventually make it through if 
you are patient.


Duncan Murdoch



- Original Message 
From: r-help-boun...@r-project.org r-help-boun...@r-project.org
To: yjmh...@yahoo.com
Sent: Fri, June 4, 2010 12:28:37 PM
Subject: Your message to R-help awaits moderator approval

Your mail to 'R-help' with the subject

subsetting a dataframe

Is being held until the list moderator can review it for approval.

The reason it is being held:

The message headers matched a filter rule

Either the message will get posted to the list, or you will receive
notification of the moderator's decision.  If you would like to cancel
this posting, please visit the following URL:


https://stat.ethz.ch/mailman/confirm/r-help/151139c40b029d260fb9bde07e60a96a68dc572d




__
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-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-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] Write.fwf works from Mac, throws different number of row error in Windows

2010-06-05 Thread Duncan Murdoch
You need to give us something reproducible or we won't likely be able to 
help you.  Put together a small example that illustrates the problem, 
and it will likely be fixed pretty quickly, or your error will be 
pointed out.  (You need to give us a way to construct outframe, we don't 
have it.)


Duncan Murdoch

mazibuko wrote:
Hello, 


I am having a problem with write.fwf in Windows. I wrote a code to ingest a
number of text files with weather data in them, process them, and then
output a text file with two parts: 1) a set of column names, 2) the
processed data table. 


I wrote and tested the program on my Mac, and it worked fine. However, on
the windows machine, where I intend the work to be done, when I run the
following line (last line of the script): 

  

write.fwf(outframe,file=outfile1,sep=,quote=FALSE,rownames=FALSE,colnames=FALSE,


+
width=c(4,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8),append=TRUE,justify='right')

I get the following error: 


Error in data.frame(colname = colnamesMy, nlevels = 0, position = 0, width =
0,  : 
  arguments imply differing number of rows: 0, 1

In addition: Warning message:
In write.fwf(outframe, file = outfile1, sep = , quote = FALSE,  :
  recycling 'width'

I can't see the reason for this. The data in outframe are all numeric, and
it worked on the Mac, and outframe has 7 rows on Windows and on the Mac, so
I am not sure what is going on here.

Here is my traceback() and sessionInfo() in case it helps: 

  

traceback()

3: stop(arguments imply differing number of rows: , paste(unique(nrows), 
   collapse = , ))
2: data.frame(colname = colnamesMy, nlevels = 0, position = 0, width = 0, 
   digits = 0, exp = 0, stringsAsFactors = FALSE)
1: write.fwf(outframe, file = outfile1, sep = , quote = FALSE, 
   rownames = FALSE, colnames = FALSE, width = c(4, 8, 8, 8, 
   8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8), append = TRUE, 
   justify = right)
  

sessionInfo()

R version 2.10.1 (2009-12-14) 
i386-pc-mingw32 


locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C  
[5] LC_TIME=English_United States.1252


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


other attached packages:
[1] doBy_4.0.5  survival_2.35-7 gdata_2.7.1 chron_2.3-34   


loaded via a namespace (and not attached):
[1] cluster_1.12.1 grid_2.10.1gtools_2.6.1   Hmisc_3.7-0   
[5] lattice_0.17-26Matrix_0.999375-33
  

Any advice on this will be much appreciated. 

Thanks. 



  






__
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] R CMD in 2.11.1 error

2010-06-06 Thread Duncan Murdoch

Andy Zhu wrote:
Hi, 


I have a set of user defined package which I have installed in 2.8.1 for quite 
some time.  I installed 2.11.0 and 2.11.1 a couple of days ago while still 
having 2.8.1 version in my system. For the package, package.skeleton works fine 
in R 2.11.  However, it comes problem when I run Rcmd check/intall. The  
intall.out shows below.

I further tested that I reran R-2.8.1/bin/R CMD check in 2.8.1.  it still 
works.  Then I ran and test the doomed function, gzWrite, in R-2.11.1/binRgui, 
it also works fine.  So, is this the problem in R-2.11.1/bin/Rcmd itself? How 
do I fix it?  I have MinGW, Perl, etc. installed in my system.

  


The problem is in the help file, not in the R code.  You need to look 
somewhere near line 92 of quantplus/man/gzWrite.Rd.


Duncan Murdoch

I also attached my function gzWrite below.

Thank you very much.


00check.out:

* install options are ' --no-html'

* installing *source* package 'quantplus' ...
** R
** preparing package for lazy loading
** help
Warning: newline within quoted string at gzWrite.Rd:92
Warning: ./man/gzWrite.Rd:99: unknown macro '\n'
Warning: newline within quoted string at gzWrite.Rd:92
Error in parse_Rd(./man/gzWrite.Rd, encoding = unknown, ...) : 
  Unexpected end of input (in  quoted string opened at gzWrite.Rd:99:46)

ERROR: installing Rd objects failed for package 'quantplus'
* removing 
'd:/developer/projects/quant+/package_builder/quantplus.Rcheck/quantplus'

the problem function:
**
gzWrite = 
# write out a data frame into a gzip file in the format of write.table

function(ds, outdir, outpfx, datepfx, sep='\t', quote=TRUE, row.names=FALSE, 
col.names=TRUE, na='NA', append=FALSE) {
if (F) {
ds = ds.price;
outdir = pathPrice;
outpfx = paste(pfx.price,'_',sep='');
datepfx = fdate;
sep = '\t';
quote = TRUE;
row.names = FALSE;
col.names = TRUE;
na = 'NULL';
append = FALSE;
}
file.out = paste(outdir, '\\', outpfx, datepfx, '.gz', sep='');
file.tmp = paste(outdir, '\\', outpfx, datepfx, '.txt',sep='');
write.table(ds, file=file.tmp, sep=sep, quote=quote, row.names=row.names, 
col.names=col.names, na=na, append=append);
zz = gzfile(file.out, 'w');
raw = file(file.tmp, 'r');
cat(readLines(raw), file=zz, append=F, sep='\n');
close(zz);
close(raw);
unlink(file.tmp);

invisible(NA);
}


  
	[[alternative HTML version deleted]]


__
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-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] Package not on CRAN mirrow - what now?

2010-06-10 Thread Duncan Murdoch

markw...@afrihost.co.za wrote:

Package arulesSequences isn't on CRAN for automatic package install.
I downloaded a *.tar.qz version because no *.zip for Windows offered.
Why is this?
I expanded *.tar.qz in ~R/R-2.11.0/library/arulesSequences
I then assumed that R would list it in the packages list but it doesn't.
What am I doing wrong ?



You need to install it, it's not generally enough to just unpack it.  
But that will not work, because the package is marked as Unix-only.  
You could try to figure out what needs fixing to get it working on 
Windows, but it's probably not easy.


Duncan Murdoch

__
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] Capturing buffered output from Rterm

2010-06-10 Thread Duncan Murdoch

Keith Jewell wrote:

In MS Windows I
  a) invoke Rterm from a batch file (test.bat)
  b) to execute commands from a script (m:\test.rsc)
  c) capturing output in a log file (m:\test.log)
BUT if the script results in an error the error message is NOT written to 
the log file, leaving me problems when the error is from a complicated 
function.


Simplified example:.

test.bat 
REM ensure 'R' is in path
path \\Server02\stats\R\R-Current\bin\;%PATH%
Rterm  --no-init-file --no-restore-data --no-save --silent  m:\test.rsc  
m:\test.log

-

m:\test.rsc -
print(this is a test)
#generate an error
nls()
--

The error message:
  Error in .Internal(inherits(x, what, which)) : 'x' is missing
is is NOT written to the log file, which just ends

m:\test.log --
  snip
  

print(this is a test)


[1] this is a test
  

#generate an error
nls()


-

I surmise this is due to output buffering (?). In an S-Plus version I turned 
off buffering with

  guiSetOption(option.name=BufferOutputWindows, value.string=F)
but I don't think this is available in R (?).

Has anyone any suggestions?


It's not output buffering, it's because error messages go to a different 
file handle than regular ones.  You need to redirect both stdout and stderr.


I'm not sure of the syntax to do that in Windows CMD, but R CMD BATCH 
test.rsc instead of Rterm would do it.  (The output should go to test.Rout.)


Duncan Murdoch

__
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] R in Linux: problem with special characters

2010-06-11 Thread Duncan Murdoch

daniel fernandes wrote:




Hi,
 
I’m working with the 64 bit version of R 2.11.0 for Linux. My session info is:
 
R version 2.11.0 (2010-04-22)

x86_64-redhat-linux-gnu
 
locale:

[1] C
 
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base 
 
 
When I try to print words with special characters the result is that the expression printed has some kind of code substituting the special character. For example, if I run print(“dúvida”) the result is:
 
  print(dúvida)

[1] d\372vida
 
This as problem has something to do with the locale settings? If I run the locale command in the Linux server, I get:
  


Yes, it's your locale settings. The C locale doesn't support the ú 
character in your string, and displays it in octal.


Duncan Murdoch
 
[daniel.fernan...@pt-lnx13 ~]$ locale

LANG=pt_PT.UTF-8
LC_CTYPE=C
LC_NUMERIC=C
LC_TIME=C
LC_COLLATE=C
LC_MONETARY=C
LC_MESSAGES=C
LC_PAPER=C
LC_NAME=C
LC_ADDRESS=C
LC_TELEPHONE=C
LC_MEASUREMENT=C
LC_IDENTIFICATION=C
LC_ALL=C
 
Thanks in advance for your help,
 
Daniel
 



TRANSFORME SUAS FOTOS EM EMOTICONS PARA O MESSENGER. CLIQUE AQUI E VEJA COMO. 		 	   		  
_

VEJA SEUS EMAILS ONDE QUER QUE VOCÊ ESTEJA, ACESSE O HOTMAIL PELO SEU CELULAR 
AGORA.

=Live_Hotmailutm_medium=Taglineutm_content=VEJASEUSEM84utm_campaign=MobileServices
[[alternative HTML version deleted]]

  



__
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-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] Rgui crashed on Windows XP Home

2010-06-11 Thread Duncan Murdoch

Jinsong Zhao wrote:

Hi there,

I just installed R 2.11.1 on my PC, which runs a Windows XP Home.

The installation is successful, however, when I double click on the
R icon, I get the following error message:

R for Windows GUI front-end has encountered a problem and needs to close.  
We are sorry for the inconvenience.
  


The error occurs in msvcrt.dll, a Microsoft dll.  It happened after a 
call from one of the R dlls, setting up the GUI.


I don't really know what to suggest to fix this, other than the usual 
things:  try running R with the --vanilla command line argument, try 
shutting down everything else on your system, etc.


Duncan Murdoch

Error signature is:
AppName: rgui.exeAppVer: 2.111.52157.0   ModName: msvcrt.dll
ModVer: 7.0.2600.2180Offset: d2b5

I get a gdb, and then gdb the Rgui.exe, I get the following message:

(gdb) run
Starting program: D:\Program Files\R\R-2.11.1\bin/Rgui.exe
[New Thread 2460.0xb7c]

Program received signal SIGSEGV, Segmentation fault.
0x77c1d2b5 in msvcrt!mblen () from C:\WINDOWS\system32\msvcrt.dll
(gdb) bt
#0  0x77c1d2b5 in msvcrt!mblen () from C:\WINDOWS\system32\msvcrt.dll
#1  0x77c1d3a9 in msvcrt!mbstowcs () from C:\WINDOWS\system32\msvcrt.dll
#2  0x635597f9 in GA_newwindow ()
   from D:\Program Files\R\R-2.11.1\bin\Rgraphapp.dll
#3  0x63543a25 in GA_newcontrol ()
   from D:\Program Files\R\R-2.11.1\bin\Rgraphapp.dll
#4  0x63543c3f in GA_newimagebutton ()
   from D:\Program Files\R\R-2.11.1\bin\Rgraphapp.dll
#5  0x6c723d7e in setupui () from D:\Program Files\R\R-2.11.1\bin\R.dll
#6  0x004014e2 in ?? ()
#7  0x00401425 in ?? ()
#8  0x00401708 in ?? ()
#9  0x0040124b in ?? ()
#10 0x004012b8 in ?? ()
#11 0x7c816fe7 in RegisterWaitForInputIdle ()
   from C:\WINDOWS\system32\kernel32.dll
#12 0x in ?? ()
(gdb)

The Rterm.exe can run normally. I don't know it's a bug of Rgui or a bug of my 
system.

Thanks for any help.

Regards,
Jinsong

__
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-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] Html help

2010-06-14 Thread Duncan Murdoch

Murray Jorgensen wrote:

I have just installed R 2.11.1 on my XP laptop.

I like html help for browsing but text help for on-the-fly look-ups. I 
was a bit surprised when I was asked to choose between them during the 
installation. I chose text, thinking I could fix the html help later, 
which is what I am trying to do now.


Now when I ask for html help my browser goes to

'http://-ip-number-/doc/html/index.html'

instead of where I want on my computer:

C:\apps\R\R-2.11.1\doc\html\index.html

Now I can go where I want manually but then the package list on


C:\apps\R\R-2.11.1\doc\html\packages.html

does not include all the packages that I have installed and linked. I 
don't want to read my html help from the web because sometimes I am 
off-line or on a slow connection.


How do I go about getting a local set of html help files?

  


Since 2.10.0, HTML help is generated on demand.  It doesn't go off your 
local computer, it works locally.  This saves a bit of space (the HTML 
is generated from the same source as the text is generated from), but 
the main point is that it allows help pages to contain dynamic content.  
For example, Romain Francois posted some demo code a while ago to allow 
the display of graphics generated by R within help pages.  
(Unfortunately it depended on a particular browser feature not supported 
by Internet Explorer, so I'm going to need to put together something 
less elegant, but that's life.)


Duncan Murdoch

__
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] Simple 3D Plot Question

2010-06-15 Thread Duncan Murdoch

Nick Torenvliet wrote:

Hi all,

I've got a simple 3D plot as follows...

  

xx - seq(-20,20,.5)
yy - seq(-20,20,.5)
zFunc - function(x,y){3*x^2*y}
z - outer(xx,yy,zFunc)
persp(xx,yy,z,theta=30,phi=30,ticktype=detailed)



Just beautiful!

My question is how do I constrain the plot to only display x^2 = y = 1?


If you set z values to NA, the surface mesh won't be plotted.  Those 
restrictions you give are a pretty small part of the range of xx and yy 
though, so you'll want to restrict them, e.g.


xx - seq(-1,1,len=20)
yy - seq(0,1,len=20)
zFunc - function(x,y){ifelse(x^2  y  y  1, 3*x^2*y, NA)}
z - outer(xx,yy,zFunc)
persp(xx,yy,z,theta=30,phi=30,ticktype=detailed)

Duncan Murdoch

__
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] Package testing

2010-06-15 Thread Duncan Murdoch

Gábor Csárdi wrote:

Dear all,

I would like to write some tests for my R package, and the usual
'tests' directory seemed like a good solution, but there is something
I cannot understand.

It is possible to supply .Rout.save files with the expected output for
the tests, which is great. But since the tests are not run with R
--slave, the expected output needs to contain all the extra output
from R, e.g. the startup message. The commands are echoed to the
output, too.

This makes it difficult to write proper tests, as they will
necessarily fail on all but one R versions (the version number is
always part of the output), and one would need to write the test
programs twice, once in the normal .R file, and once in the .Rout.save
file.

Is there a way to work around these things? Or am I trying to use the
'tests' directory for something that was not intended?
  


The normal workflow is to write the tests as R files, and run them.  
Then manually check every line of the Rout, and when you're satisfied 
it's fine, save it as an Rout.save file.  After that R will only report 
changes to that file that occur after the header, so version numbering 
changes will be ignored, but changes that affect your output will not.


Duncan Murdoch

__
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] trigonometric regression

2010-06-17 Thread Duncan Murdoch

William Simpson wrote:

Suppose I do a trigonometric regression
fit-lm(y~ cf + sf)
where cf and sf are the cos and sine components.

b-coef(fit)
I have the fitted sine component b[2] and the cos component b[3].
Doing summary(fit) gives me the p-values and SEs for b[2] and b[3].

But I want the amplitude of the fitted waveform
amp-sqrt(b[2]^2+b[3]^2)

Can someone please tell me how to get the p-value for amp?
  


the p-value for amp is ambiguous; p-values refer to tests, not 
functions.  But let's assume you want to test whether amp = 0.  Then 
this is achieved by an F test comparing the model with cf and sf versus 
one without it.  You'll see it in summary(fit) at the bottom of the 
display.  If you want to include other covariates in the model, you can 
use anova, e.g.


anova(lm(y ~ other), lm(y ~ cf + sf + other))

Duncan Murdoch

__
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] R licensing query

2010-06-17 Thread Duncan Murdoch

On 17/06/2010 10:26 AM, Jeff Newmiller wrote:

I think there is something else going on here, since no security organization 
would accept an email from a nonexistent organization as justification for adding 
software that they are suspicious of to their system.
  


The R Foundation is not nonexistent, but our answer to the questions 
about compatibility and harmlessness are in the banner you get when you 
start it:


R is free software and comes with ABSOLUTELY NO WARRANTY.

This is a shorter version of the longer non-warranty in paragraph 11 of 
the GPL v2, which you can see by running


RShowDoc(COPYING)

from within R.

Duncan Murdoch

On the other hand, if you can't figure out what is really going on, and you can 
loosen up some funds, you can probably get Revolutions R to provider you with 
commercial support.

McAllister, Gina gina.mcallis...@luht.scot.nhs.uk wrote:

I have recently started a new job at an NHS hospital in Scotland.  Since
I took up this post 6 months ago I have had an ongoing dispute with the
IT secutiry dept. who refuse to install R on my computer.  I previously
worked in another branch of the NHS where R was widely used and yet
there is nothing I can say which will persuade the IT dept here to even
visit the website!  With some help from our head of department, they
have now agreed to install R but only if they receive an email from 'R'
ensuring that it is licensed for commercial use, is compaitable with
Windows XP and will not affect the networked computer system here.  My
only other option for data anlaysis is Excel, we have no money for
S-plus or any other stats programme.  Can anyone suggest anything or
send me a suitable email?
 
Many thanks,

Georgina

*
The information contained in this message may be confide...{{dropped:12}}

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

---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
---
Sent from my phone. Please excuse my brevity.

__
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-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] tempfile problem

2010-06-17 Thread Duncan Murdoch

On 17/06/2010 12:43 PM, Ben Madin wrote:

G'day all,

The documentation for tempfile states :

The names are very likely to be unique among calls to tempfile in an R session and 
across simultaneous R sessions. The filenames are guaranteed not to be currently in 
use.

My problem I think relates to the second part of the sentence, which is the 
guarantee... and it is being met ... but I need to save the files as .png 
files, in the same directory, so I am adding the suffix and I suppose therefore 
the next offering can be unique (as it doesn't have the prefix)

I am using a command like :

 fname - basename(tempfile(nahis, /Library/WebServer/Documents/nahis/tmp))

 on a mac, or 


 fname - basename(tempfile(nahis, /htdocs/nahis/tmp))

on a FreeBSD system, as I need to be able to find the file from the web browser 
up to 24 hours later.

and then 


 this_filename - paste(fname, .png, sep = )

and saving the file as this_filename, hence the next call doesn't find it's own 
suggestion, and starts again.
  


It sounds as though you are doing something strange with the random 
number seed, because those names are chosen at random, and then checked 
for uniqueness.  If
the seed is being reset you could get the same name twice in a row, but 
otherwise it's very unlikely.  (And it's the C library function rand(), 
not R's RNG that is used.)

Is there any alternative filenameing approach I can use to get around this? Do 
I need to manually scan and reject the name if it matches the names I already 
have? Should I just digest the current time ? (It's working so far!)
  


If you use the current time, watch out for timer accuracy and fast 
computers.  You may be able to get more than one file created before the 
next timer tick.


I'd suggest that you should generate more than enough filenames once at 
the start, confirm they're all unique, and then just take them one by 
one as needed.  Alternatively, create the tempfile() as well as the 
tempfile().png, but this is likely to be really slow if the seed is the 
same each time, because checking for the existence of the first n tries 
is going to be slow.


Duncan Murdoch

__
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] 12th Root of a Square (Transition) Matrix

2010-06-18 Thread Duncan Murdoch

On 18/06/2010 2:01 AM, Corey Gallon wrote:

Dear R-tisans,

I am trying to calculate the 12th root of a transition (square) matrix, but 
can't seem to obtain an accurate result.  I realize that this post is laced 
with intimations of quantitative finance, but the question is both R-related 
and broadly mathematical.  That said, I'm happy to post this to R-SIG-Finance 
if I've erred in posting this to the general list.

I've pulled down an annual transition matrix from the latest Moody's Corporate 
Default Study, and I'm using this (with the default row added manually) as the 
basis for this calculation.  (I've pasted the dput of the resulting matrix 
below.)  According to Hull, Appendix E [1], an arbitrary root of a square 
matrix (A) can be calculated by multiplying the inverse matrix of eigenvectors 
(X-inv) by the nth-root of diagonalized matrix of eigenvalues (Lambda-star) by 
the matrix of eigenvectors (X) -- all of these eigenvectors(values) being 
calculated from the matrix for which one wishes to calculate the nth root.  The 
equation is as follows:

A = X-inv %*% Lambda-star %*% X
  


This is wrong:  you've swapped X and X-inv.  So your final line below 
should be


nth_root - X %*% L_star %*% X_inv


Duncan Murdoch

I've written the code below to implement this, but the result doesn't seem to 
be correct.  (I can't raise the resulting matrix to the 12th power to calculate 
the original matrix.)  I believe that the reason for this is the order in which 
R returns the eigenvalues (i.e. a vector in descending order) and the order in 
which I've created the matrix of eigenvectors, but I may be wrong in this 
suspicion.

I defer to the collective wisdom of the community, and hope that minds greater 
than mine may provide insight.



Cheers,

Corey


  

dput(trans_matrix)



structure(c(0.9426, 0.0047, 0, 4e-04, 0, 5e-04, 0, 0, 0, 0, 0,
0, 9e-04, 0, 0, 0, 0, 0, 0.0308, 0.8205, 0.0254, 4e-04, 9e-04,
0, 0, 0, 0, 4e-04, 0.0016, 0, 0, 0, 0, 0, 0, 0, 0.021, 0.1291,
0.7978, 0.034, 0.0043, 0.0025, 0.0011, 3e-04, 9e-04, 4e-04, 0,
0, 0, 0, 0, 0, 0, 0, 0.0056, 0.0394, 0.1174, 0.8366, 0.0509,
0.0094, 0.0023, 0.0022, 0.0014, 0.0017, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0.0016, 0.0448, 0.0944, 0.8253, 0.0569, 0.011, 0.0051,
6e-04, 0.0021, 0.0016, 0, 0, 0, 0, 0, 0, 0, 0, 0.0016, 0.0067,
0.024, 0.0873, 0.8108, 0.0677, 0.0105, 0.004, 0.0017, 0, 9e-04,
0, 0, 0.0039, 0.0045, 0, 0, 0, 0.0016, 0.0024, 0.0064, 0.0179,
0.0833, 0.7838, 0.0758, 0.012, 0.0021, 0.0024, 0, 9e-04, 0, 0.0013,
0.0015, 0, 0, 0, 0, 0.0024, 0.0014, 0.0068, 0.0202, 0.0908, 0.7694,
0.0744, 0.0136, 0.0079, 0.0045, 9e-04, 0.0024, 0, 0, 0.0024,
0, 0, 0.0016, 0, 0.0014, 0.004, 0.0089, 0.0175, 0.0983, 0.8066,
0.1032, 0.0267, 0.0063, 0.0054, 0.0024, 0, 0.003, 0, 0, 0, 0,
0.0024, 0, 0.0022, 0.002, 0.0079, 0.0178, 0.0632, 0.7605, 0.1422,
0.0308, 0.0099, 0.006, 0.0013, 0.003, 0, 0, 0, 0, 0, 0, 0, 0.0017,
0.0014, 0.0086, 0.0117, 0.0574, 0.6787, 0.1014, 0.0425, 0.006,
0.0039, 0.003, 0.0047, 0, 0, 0, 0, 0, 3e-04, 0.0012, 0.0014,
0.0022, 0.0109, 0.0227, 0.0589, 0.6814, 0.1058, 0.041, 0.0078,
0.0045, 0.0024, 0, 0, 0, 6e-04, 0, 0, 2e-04, 0.0096, 0.0038,
0.0034, 0.012, 0.0212, 0.0661, 0.6609, 0.159, 0.0362, 0.012,
0.0024, 0, 0, 0, 0, 0, 0, 2e-04, 3e-04, 0.0016, 0.0029, 0.0058,
0.0118, 0.029, 0.0597, 0.6205, 0.1332, 0.0331, 0.0047, 0, 0,
0, 0, 0, 0, 0.001, 0.0011, 3e-04, 0.002, 0.0074, 0.0157, 0.0244,
0.0515, 0.0916, 0.6546, 0.1203, 0.0353, 0, 0, 0, 0, 4e-04, 0,
0, 3e-04, 0, 6e-04, 8e-04, 0.0047, 0.0199, 0.0172, 0.0325, 0.0699,
0.7098, 0.1318, 0, 0, 0, 0, 0, 0, 5e-04, 0.0017, 0.0022, 0.004,
0.0021, 0.0102, 0.0217, 0.0244, 0.0241, 0.044, 0.0737, 0.5271,
0, 0, 0, 0, 7e-04, 0, 7e-04, 0.0023, 0.0019, 0.0014, 0.0062,
0.0165, 0.0136, 0.0199, 0.0145, 0.044, 0.0316, 0.2894, 1), .Dim = c(18L,
18L), .Dimnames = list(c(1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16, 17, 18), c(AAA,
AAp, AA, AAm, Ap, A, Am, BBBp, BBB, BBBm, BBp,
BB, BBm, Bp, B, Bm, CCC.to.C, D)))


-- BEGIN PASTE --

# create a matrix of eigenvectors of the transition matrix
X - eigen(trans_matrix)$vectors

# create a diagonalized matrix of the eigenvalues of the transition matrix
L - diag(eigen(trans_matrix)$values)

# calculate inverse of matrix of eigenvectors of the transition matrix
X_inv - solve(X)

# calculate the 12th root of the eigenvalues in the diagonal matrix
L_star - L ^ (1/12)

# calculate the 12th root of the transition matrix
nth_root - X_inv %*% L_star %*% X

-- END PASTE --


References:

[1] Hull, John. Risk Management and Financial Institutions. Prentice Hall, 2007.

__
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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE

Re: [R] Use of .Fortran

2010-06-18 Thread Duncan Murdoch

On 18/06/2010 9:59 AM, David Scott wrote:
I have no experience with incorporating Fortran code and am probably 
doing something pretty stupid.


I want to use the following Fortran subroutine (not written by me) in 
the file SSFcoef.f


   subroutine SSFcoef(nmax,nu,A,nrowA,ncolA)
   implicit double precision(a-h,o-z)
   implicit integer (i-n)
   integer l,i,nmax
   double precision nu,A(0:nmax,0:nmax)
   A(0,0) = 1D0
   do l=1,nmax
do i=1,l-1
A(l,i) = (-nu+i+l-1D0)*A(l-1,i)+A(l-1,i-1)
end do
A(l,0) = (-nu+l-1D0)*A(l-1,0)
A(l,l) = 1D0
   end do
   return
   end


I created a dll (this is windows) using R CMD SHLIB SSFcoef.f

Then my R code is:

### Load the compiled shared library in.
dyn.load(SSFcoef.dll)

### Write a function that calls the Fortran subroutine
SSFcoef - function(nmax, nu){
   .Fortran(SSFcoef,
as.integer(nmax),
as.integer(nu)
)$A
}

SSFcoef(10,2)

which when run gives

  SSFcoef(10,2)
NULL

I am pretty sure the problem is that I am not dealing with the matrix A 
properly. I also tried this on linux and got a segfault.


Can anyone supply the appropriate modification to my call (and possibly 
to the subroutine) to make this work?


Two problems:

Your subroutine takes 5 arguments, you're only passing two. 
You didn't name your arguments, but are trying to retrieve A by name.


So this will get you closer (it's untested, so there might still be 
problems...):


SSFcoef - function(nmax, nu){
  .Fortran(SSFcoef,
   as.integer(nmax),
   as.integer(nu),
A = numeric((nmax+1)^2),
nrowA = as.integer(nmax+1), # These are unused...
ncolA = as.integer(nmax+1)
   )$A
}


Duncan Murdoch

__
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] Call by reference or suggest workaround

2010-06-19 Thread Duncan Murdoch

On 19/06/2010 10:32 AM, Chidambaram Annamalai wrote:

I have written code to compute multi-indices in R [1] and due to the
recursive nature of the computation I need to pass around the *same*
matrix object (where each row corresponds to one multi-index). As pass
by reference wasn't the default behavior I declared a global matrix
(mat) and used the - operator to write to the global matrix. So the
usage would be to call genMultiIndices(3,2) for side effects to
generate all multi-indices of length 3 and sum 2. And then access the
global matrix.

However, after coding this I can't seem to export the global matrix
object (in the NAMESPACE file) and still retain mutability since its
binding is locked (R throws an error). Can I somehow unlock this?

Ideally I would want to pass around the same matrix to the recursive
function. Is that possible? If not, could someone please suggest a
workaround to use the code in an R package?



If you pass the object to multiple functions it will only create a new 
copy when necessary due to modifying it, so the cost of passing it down 
to every recursive call is not so large as you seem to think.  But it's 
not zero cost, passing arguments to functions costs a little bit.


You can avoid this using nested functions and - as you had before.  
That is, instead of making your recursive function a top level function 
so that - assigns into the namespace environment (which is what's 
causing the error), make it a nested function within another, and do 
your assignments to the outer frame.  For example,


outer - function(args) {

 mat - matrix(NA, 3,3)

 recursive - function() {
   mat - newvalue  # does the assignment into outer's frame
   if (!stop) recursive()
 }

}

Duncan Murdoch

__
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] Popularity of R, SAS, SPSS, Stata...

2010-06-20 Thread Duncan Murdoch

On 20/06/2010 6:36 PM, Muenchen, Robert A (Bob) wrote:
  

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Ivan Calandra
Sent: Sunday, June 20, 2010 3:47 PM
To: r-help@r-project.org
Subject: Re: [R] Popularity of R, SAS, SPSS, Stata...

Bob,

I have no idea whether it is realistic, but if you look for the papers
that used R or SAS (or anything), you might get better results by
searching for the way R and SAS are cited.



Hi Ivan, that was what I tried when more generic keywords failed. However, almost no one 
seems to use that citation. For example, in 2009, only 28 papers contain R 
Foundation and 61 contain Bioconductor, which uses R. One single paper contains 
both. I appreciate the idea though!



If you use Web of Science, then the abbreviation for the author in the 
standard citation for R is R DEV COR TEAM.   Doing a search for 
citations to that author in 2009 or 2010 finds 249 papers.  Variations 
on the spelling that I see include


  
R DEV C3R TEAM

R DEV CAR GROUP
R DEV CAR TEAM
R DEV CIR TEAM
R DEV COD TEAM
R DEV COR
R DEV COR T
R DEV COR TEA
R DEV COR TEAM
R DEV COR TEAM C
R DEV COR TEAM CO
R DEV COR TEAM FD
R DEV COR TEAM OR
R DEV COR TEAM R
R DEV COR TEAM RD
R DEV COR TEAM VI
R DEV COR TEAMR
R DEV COR TEMA
R DEV COR TRAM
R DEV CORE TEAM
R DEV CORETEAM
R DEV CORR TEAM
R DEV CORT TEAM
R DEV CPR TEAM
R DEV CT
R DEV TEAM
R DEVCOR TEAM
R DEVELOPMENTCORE

Not all of those might really be R.  For example, there's probably a 
north Atlantic codfishing team named R DEV COD TEAM.  But most of them 
are, and they lead to 289 cited papers in 2009/10.


Duncan Murdoch

__
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] Popularity of R, SAS, SPSS, Stata...

2010-06-21 Thread Duncan Murdoch

On 21/06/2010 2:49 AM, Peter Dalgaard wrote:

Duncan Murdoch wrote:
  

On 20/06/2010 6:36 PM, Muenchen, Robert A (Bob) wrote:

  
  

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Ivan Calandra
Sent: Sunday, June 20, 2010 3:47 PM
To: r-help@r-project.org
Subject: Re: [R] Popularity of R, SAS, SPSS, Stata...

Bob,

I have no idea whether it is realistic, but if you look for the papers
that used R or SAS (or anything), you might get better results by
searching for the way R and SAS are cited.



Hi Ivan, that was what I tried when more generic keywords failed. However, almost no one 
seems to use that citation. For example, in 2009, only 28 papers contain R 
Foundation and 61 contain Bioconductor, which uses R. One single paper contains 
both. I appreciate the idea though!
  
If you use Web of Science, then the abbreviation for the author in the 
standard citation for R is R DEV COR TEAM.   Doing a search for 
citations to that author in 2009 or 2010 finds 249 papers.  Variations 
on the spelling that I see include


   
R DEV C3R TEAM

R DEV CAR GROUP
R DEV CAR TEAM
R DEV CIR TEAM
R DEV COD TEAM
R DEV COR
R DEV COR T
R DEV COR TEA
R DEV COR TEAM
R DEV COR TEAM C
R DEV COR TEAM CO
R DEV COR TEAM FD
R DEV COR TEAM OR
R DEV COR TEAM R
R DEV COR TEAM RD
R DEV COR TEAM VI
R DEV COR TEAMR
R DEV COR TEMA
R DEV COR TRAM
R DEV CORE TEAM
R DEV CORETEAM
R DEV CORR TEAM
R DEV CORT TEAM
R DEV CPR TEAM
R DEV CT
R DEV TEAM
R DEVCOR TEAM
R DEVELOPMENTCORE

Not all of those might really be R.  For example, there's probably a 
north Atlantic codfishing team named R DEV COD TEAM.  But most of them 
are, and they lead to 289 cited papers in 2009/10.


Duncan Murdoch



That sound a bit low. Last I checked R DEV COR TEAM, for ALL publication
years, it came up with about 13000 references within 511 different
misspellings of the R manual reference ( a few more).  Papers currently
being registered  tend to reference the version of R that was used when
the research was done, and with review delays etc. that can be a few
years back.

  


Yes, you're right.  The 289 count was the number of cited works 
(variations on R.)  The number of papers citing a similar list was 6864.


Duncan Murdoch

Another matter is that software citation varies widely by field. Of the
above 13000 references, I think about 3000 were from ecology (or was it
environmental science?). In economics, or indeed in mathematical
statistics, the tradition is to cite methods, but not software. (And one
sinner is the R Journal, in which is would be absurd to have every
paper cite R...)




__
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] S3 generics need identical signature?

2010-06-21 Thread Duncan Murdoch

On 21/06/2010 9:31 AM, Gábor Csárdi wrote:

Dear all,

Writing R Extensions explicitly says that

A method must have all the arguments of the generic, including ...
if the generic does.
A method must have arguments in exactly the same order as the generic.
If the generic specifies defaults, all methods should use the same
defaults.

This is clear. R CMD check even checks for this.

But then how is it possible that for plot(), which is an S3 generic,
plot.default(), plot.formula() and plot.table(), etc. all have
different arguments?

The question is not simply theoretical, I have two S3 generics in my
package, and one is reported by R CMD check, but the other not, and I
fail to see why the difference.

Moreover, R CMD check reports:
* checking S3 generic/method consistency ... WARNING
plot:
  function(x, ...)
plot.communities:
  function(communities, graph, colbar, col, mark.groups, layout,
   edge.color, ...)

But actually, the signature of plot() seems to be
 plot
function (x, y, ...)
[...]

I am confused. What am I missing?


The requirement is that the methods need to have signatures that contain 
all the arguments of the generic.  If the generic includes ..., then the 
methods can add other arguments, too.  So with the generic for plot() as 
you show above, any plot method is required to have x and y as the first 
two arguments, and ... as an argument, but they can have other args 
too.  Looking at them:


head(plot.default)
1 function (x, y = NULL, type = p, xlim = NULL, ylim = NULL, 
2 log = , main = NULL, sub = NULL, xlab = NULL, ylab = NULL, 
3 ann = par(ann), axes = TRUE, frame.plot = axes, panel.first = NULL,
4 panel.last = NULL, asp = NA, ...)   



This is okay.

head(graphics:::plot.formula)
1 function (formula, data = parent.frame(), ..., subset, ylab = 
varnames[response],
2 ask = dev.interactive())


This violates the rule, so if someone does this:

y - rnorm(10)
x - 1:10
formula - y ~ x
plot(formula)

they'll get what they want, but

plot(x = formula)

they'll get an obscure error message:

 plot(x=formula)
Error in terms.formula(formula, data = data) :
 argument is not a valid model

head(graphics:::plot.table)
1 function (x, type = h, ylim = c(0, max(x)), lwd = 2, xlab = NULL,
2 ylab = NULL, frame.plot = is.num, ...) 

This also violates the rule, but it's hard to think of an example where 
it might cause trouble.


HOWEVER, plot() is a very old function, and methods were written for it 
long before the current rule was established.  So it is handled 
specially by the check code.
The y argument is not required (see the checkArgs code in 
src/library/tools/R/QC.R), and apparently the first arg doesn't need to 
be named x in plot.formula, due to some other exception which I can't 
spot right now.  So I would not use the base code for plot() as an 
example of what you should do.


Duncan Murdoch

__
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] how to efficiently compute set unique?

2010-06-21 Thread Duncan Murdoch

On 21/06/2010 9:06 PM, G FANG wrote:

Hi,

I want to get the unique set from a large numeric k by 1 vector, k is
in tens of millions

when I used the matlab function unique, it takes less than 10 secs

but when I tried to use the unique in R with similar CPU and memory,
it is not done in minutes

I am wondering, am I using the function in the right way?

dim(cntxtn)
[1] 135847631
uniqueCntxt = unique(cntxtn);# this is taking really long


What type is cntxtn?  If I do that sort of thing on a numeric vector, 
it's quite fast:


 x - sample(10, size=13584763, replace=T)
 system.time(unique(x))
  user  system elapsed
  3.610.143.75

__
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] Problem with writing a CSV file in UTF-8 formate

2010-06-22 Thread Duncan Murdoch

On 22/06/2010 9:00 AM, venkata kirankumar wrote:

Hi all,
I have a problem with writing a *.CSV file in UTF-8 formate

I tried to write a dataframe named  dfPREINDX to the new file named
preindx.csv in below formate

write.table(dfPREINDX,PreIndex,fileEncoding=UTF-8,sep=|,row.names=FALSE)

but its throed an error  like

Error in write.table(dfPREINDX, preindx.csv, fileEncoding = UTF-8, sep =
|,  :
  unused argument(s) (fileEncoding = UTF-8)

can any one please help me how to create a file in UTF-8  formate.


The write.table has no fileEncoding argument.  To write to a non-native 
encoding, you need to open a connection with that encoding, and write to 
that.  For example:


con - file(preindx.csv, open=w, encoding=UTF-8)
write.table(dfPREINDX, con, sep=|,row.names=FALSE)
close(con)

Duncan Murdoch

__
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] Displaying Iteration Count

2010-06-22 Thread Duncan Murdoch

On 22/06/2010 9:14 AM, jim holtman wrote:

Just put the code in yourself; use 'cat' with a test to print every
'n' iterations.  You can also check out the 'winProgressBar' in the
plyr package.

  


In Windows (and other GUIs?) console output is buffered, so by default 
the results won't appear until the end.  However, you can change this; 
in Windows you use the Misc | Buffered output menu item (or Ctrl-W), or 
make a call to flush.console() as Henrique showed.


Duncan Murdoch

On Tue, Jun 22, 2010 at 9:07 AM, Downey, Patrick pdow...@urban.org wrote:
 Hello,

 I'm running a very long for loop that usually takes hours. For my own piece
 of mind, it would be nice if I could check periodically and see which
 iteration the loop is on. A line of code that told R to print the iteration
 number every 100 or 200 iterations would be perfect.

 Does anyone know something like this? I've never known how to print
 anything within a for loop before the loop ends.



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


<    2   3   4   5   6   7   8   9   10   11   >