[R] R crashes when loading library/package; Windows, Cygwin

2006-03-24 Thread Sixten Borg

Dear list members,

This is a question is about building an R package under windows and cygwin. 
Please bear with me.

I have a package in R that compiles well on my stationary computer (WINDOWS NT, 
R 1.8.1 and prior), and the resulting (package_version).zip  file works well 
there. It contains an R script file and a C file.

After installing tools to build the package on my laptop, the package builds 
successfully in the sense that both
(a)rcmd build -binary -docs=normal cultosaurus
and 
(b)  R CMD BUILD -binary -docs=normal cultosaurus
will successfully create a zipfile. (R version and compiler version below).

When I install the package from the local zip file, R seems happy and says
package 'cultosaurus' successfully unpacked and MD5 sums checked
updating HTML package descriptions

Trying to load the library, however, causes R to freeze for 10 seconds or so, 
without giving any message and then exit (Exit 5).

A subset of this package with the C source file removed will successfully 
build, and successfully load. Then of course there will be an error saying C 
entry point ... not in load table

Therefore the DLL seems to be causing this problem.


Any hints or advice would be highly appreciated.

Thanks in advance,
Sixten

 version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major2  
minor2.1
year 2005   
month12 
day  20 
svn rev  36812  
language R  
 

$ gcc -v
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /gcc/gcc-3.4.4/gcc-3.4.4-1/configure --verbose --prefix=/usr --
exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --man
dir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,
java,objc --enable-nls --without-included-gettext --enable-version-specific-runt
ime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --ena
ble-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=b
oehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchroniza
tion --enable-libstdcxx-debug : (reconfigured)
Thread model: posix
gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125)

$ perl -v

This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 21 registered patches, see perl -V for more detail)

Copyright 1987-2006, Larry Wall

Binary build 816 [255195] provided by ActiveState http://www.ActiveState.com 
Built Mar  1 2006 18:00:52




Output from building the package.__
$ make
rcmd build -binary -docs=normal cultosaurus
* checking for file 'cultosaurus/DESCRIPTION' ... OK
* preparing 'cultosaurus':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking whether 'INDEX' is up-to-date ... OK
* removing junk files
* checking for LF line-endings in source files
* checking for empty directories
WARNING: directory cultosaurus/data is empty
* building binary distribution
 WARNING
* some HTML links may not be found
installing R.css in c:/DOCUME~1/Sixten/LOKALA~1/Temp/Rinst.432

Using auto-selected zip options ''
/bin/sh: latex: command not found
/bin/sh: latex: command not found
/bin/sh: latex: command not found

-- Making package cultosaurus 
/bin/sh: latex: command not found
  adding build stamp to DESCRIPTION
/bin/sh: latex: command not found
/bin/sh: latex: command not found
  making DLL ...
/bin/sh: latex: command not found
/bin/sh: latex: command not found
/bin/sh: latex: command not found
making erectus.d from erectus.c
gcc   -Ic:/program/R/R-2.2.1/include -Wall -O2   -c erectus.c -o erectus.o
ar cr cultosaurus.a erectus.o
ranlib cultosaurus.a
windres --include-dir c:/program/R/R-2.2.1/include  -i cultosaurus_res.rc -o cul
tosaurus_res.o
gcc  --shared -s  -o cultosaurus.dll cultosaurus.def cultosaurus.a cultosaurus_r
es.o  -Lc:/program/R/R-2.2.1/src/gnuwin32   -lg2c -lR
  ... DLL made
  installing DLL
/bin/sh: latex: command not found
  installing R files
/bin/sh: latex: command not found
/bin/sh: latex: command not found
  installing man source files
  installing indices
  installing help
  Building/Updating help pages for package 'cultosaurus'
 Formats: text html latex example
  sygehus   texthtmllatex   example
 missing link(s):  ~~fun~~
/bin/sh: latex: command not found
  adding MD5 sums

packaged installation of package 'cultosaurus' as cultosaurus_0.1.zip
* DONE (cultosaurus)

$

Sixten Borg

IHE
Box 2127
S-220 02 Lund
Sweden

tel: +46 46 32 91 07
fax:+46 46 12 16 04

Kommer man inte upp före klockan fyra på 
morgonen, så vaknar man inte på hela dan.

www.ihe.se
***
Note: The information contained in this message and attachments may be 
privileged
and confidential and protected from

Re: [R] R seems to stall after several hours on a long series of analyses... where to start?

2005-11-09 Thread Sixten Borg
Hi,

I saw something similar, when I had R to look in a file every half minute if 
there was a request to do something, and if so, do that something and empty the 
file. (This was my way of testing if I coud do an interactive web page, somehow 
I managed to get the web page to write the requests to the file that R would 
look in. R would update a graph that was visible on that same web page).

Anyway, this ran smoothly for while (40 minutes I think), then it just stopped. 
When I examined the situation, R suddenly woke up and continued its task as if 
nothing had happened (which was quite correct).

My amateur interpretation was that the system put R to sleep since it appeared 
to be inactive according to the system. When I swithed to R, it became 
interactive and was given CPU time again. 

Maybe this gives some inspiration to solve the problem. The system was Windows 
NT, R version 1.8, I think.

Kind regards.
Sixten


 David L. Van Brunt, Ph.D. [EMAIL PROTECTED] 2005-11-07 16:09 
Great suggestions, all.

I do have a timer in there, and it looks like the time to complete a loop is
not increasing as it goes. From your comments, I take it that suggests there
is not a memory leak. I could try scripting the loop from the shell, rather
than R, to see if that works, but will do that as a last resort as it will
require a good deal of re-writing (the loop follows some setup code that
builds a pretty large data set... the loop then slaps several new columns on
a copy of that data set, and analyses that...)

I'll still try the other platform as well, see if the same problem occurs
there.

On 11/7/05, jim holtman [EMAIL PROTECTED] wrote:

 Here is some code that I use to track the progress of my scripts. This
 will print out the total cpu time and the memory that is being used. You
 call it with 'my.stats(message)' to print out message on the console.
  Also, have you profiled your code to see where the time is being spent?
 Can you break it up into multiple runs so that you can start with a fresh
 version of memory?
  ==script===
 my.stats - local({
 # local variables to hold the last times
 # first two variables are the elasped and CPU times from the last report
 lastTime - lastCPU - 0
 function(text = stats, reset=F)
 {
 procTime - proc.time()[1:3] # get current metrics
 if (reset){ # setup to mark timing from this point
 lastTime - procTime[3]
 lastCPU - procTime[1] + procTime[2]
 } else {
 cat(text, -,sys.call(sys.parent())[[1]], : ,
 round((procTime[1] + procTime[2]) - lastCPU,1),
 round(procTime[3] - lastTime,1), , procTime,
  : , round(memory.size()/2.^20., 1.), MB\n)
 invisible(flush.console()) # force a write to the console
 }
 }
 })
  = here is some sample output=
  my.stats(reset=TRUE) # reset counters
  x - runif(1e6) # generate 1M random numbers
  my.stats('random')
 random - my.stats :  0.3 31.8  96.17 11.7 230474.9 : 69.5 MB
  y - x*x+sqrt(x) # just come calculation
  my.stats('calc')
 calc - my.stats :  0.7 71.2  96.52 11.74 230514.3 : 92.4 MB
 
  You can see that memory is growing. The first number is the CPU time and
 the second (in ) is the elapsed time.
  HTH


  On 11/7/05, David L. Van Brunt, Ph.D. [EMAIL PROTECTED] wrote:

  Not sure where to even start on this I'm hoping there's some
  debugging I
  can do...
 
  I have a loop that cycles through several different data sets (same
  structure, different info), performing randomForest growth and
  predictions... saving out the predictions for later study...
 
  I get about 5 hours in (9%... of the planned iterations.. yikes!) and R
  just
  freezes.
 
  This happens in interactive and batch mode execution (I can see from the
  .Rout file that it gets about 9% through in Batch mode, and about 6%
  if in
  interactive mode... does that suggest memory problems?)
 
  I'm thinking of re-executing this same code on a different platform to
  see
  if that's the issue (currently using OS X)... any other suggestions on
  where
  to look, or what to try to get more information?
 
  Sorry so vague... it's a LOT of code, runs fine without error for many
  iterations, so I didn't think the problem was syntax...
 
  --
  ---
  David L. Van Brunt, Ph.D.
  mailto: [EMAIL PROTECTED] 
 
  [[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help 
  PLEASE do read the posting guide! 
  http://www.R-project.org/posting-guide.html 
 
 



 --
 Jim Holtman
 Cincinnati, OH
 +1 513 247 0281

 What the problem you are trying to solve?




--
---
David L. Van Brunt, Ph.D.
mailto:[EMAIL PROTECTED] 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Sv: [R] Using locator() to digitise

2005-03-21 Thread Sixten Borg
Hi,
Splus allows pasting a graphics object into the plotting window, which makes it 
possible to do what you describe below.
Now I use R which doesn't seem to allow pasting the picture into the graphics 
window, so I copy the graph onto a transparency 
sheet, and stick it onto my screen using tape. The coordinates need to be 
converted to make sense (as you describe).

My methodology with the transparency has a stoneage appearance, but it works 
quite well, if I may say so myself.

I have written down some notes that describes what I did, but it's in Swedish 
so I guess it's not of much help.

Kind regards,
Sixten.


 Ted Harding [EMAIL PROTECTED] 2005-03-20 17:09 
Hi Folks,

I'm contemplating using locator() to digitise external
graphics. To set context, I would be using X11 display
on Linux.

To pre-empt the obvious comment: I've found on the R site
the suggestion to use the 'pixmap' package. I've tried
this, and it works; but it involves building a big R
object (the internal pixmap representation), and this
chokes my somewhat puny laptop (e.g. it can take about
1 minute to draw the graphic inside a plot area using
addlogo(), with mucho swappo, and subsequently working
knee-deep in treacle). The following idea would be a lot
slicker.

For examples: I have something like

a) A scatterplot of data printed in a journal (but the
   data values are not available;

b) A contour map (on paper) of a region.

So, I can scan the document, and obtain a file in some
graphics format (jpeg, pbm or png, say).

Now: an idea which I find attractive is to be able to
overlay an R plot with axes onto a display of the graphics
file (produced as an X window by any suitable program such
as 'xv' or 'display') so that (if the overlay were possible)
clicking on the points of the graphic would in fact be
clicking on the R plot and, via locator(), generate the
R-plot coordinates of the mouse clicks which would correspond
to the selected points on the graphic.

Provided the coordinate system of the R plot were properly
related to the graphic, the results would be a digitisation
of the selected points on the graphic.

What seems to be needed for this idea to work is that
the R-plot should be displayed in an X11() device whose
background was completely transparent, so that when
moved over the (independently generated) display of the
graphic the latter would be visible (but locator() would
still be working on the R-plot itself). Window resizing
could look after the correspondence between graphic coordinates
and R-plot coordinates.

The R plot itself could be empty (apart from coordinate axes)
or could contain helper elements such as grid lines, circles
(e.g. I want to digitise graphics points within a certain circle),
etc. Helper elements could be added to the R-plot by subsequent
'lines' or 'points' commands (e.g. I identify two points on
the graphic, R-plot the line joining them, and then pick off
graphic-points which lie on the R-line).

So this question is really about producing a bare R plot
on, as it were, a virtual acrylic transparency. It's certainly
possible to do such a thing in X: e.g. the cute xteddy is
in fact a picture of a bear on a completely transparent
rectangular background, though you'd never know by looking!

Any comments?

With thanks, and best wishes to all,
Ted.



E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 20-Mar-05   Time: 16:09:11
-- XFMail --

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Advice on good programming practice, lexical scope

2004-09-01 Thread Sixten Borg

In An Introduction to R (See R help menu), there is an example of a function 
'open.account' that makes use of the lexical scope in R.

I have a set of functions that can be used to output R tables and graphics into a 
single report document. (I am aware that several tools can do this already).

While reorganizing my code, I realize that I can collect my functions in a list, in 
the style of 'open.account' above. This will result in a list containing data and 
operations on those data. The data is for example the file name of the report. This 
also results in a rather large object instead of a set of rather small functions and a 
list of data.

Writing a package of these functions (or this object containing functions), would 
require documentation of each function. The style that I see in the R help is that the 
functions are not enclosed like this in a list. 

I like the idea of having the functions collected in a single list, but I think the 
documentation might be messy. 
Any ideas, opinions, anyone?

Thanks in advance,
Sixten.

Example:

myreport - report(filename=report.rtf)
my.report$add.table(my.data.frame, Table of ...)
plot(runif(10))
my.report$add.picture(Plot of ...)

or...

r - report(filename=report.rtf)
r - add.table(r, my.data.frame, Table of...)
plot(runit(10))
r - add.picture(r, Plot of...)

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Simulation from a model fitted by survreg.

2004-07-28 Thread Sixten Borg
Dear list,

I would like to simulate individual survival times from a model that has been fitted 
using the survreg procedure (library survival). Output shown below.

My plan is to extract the shape and scale arguments for use with rweibull() since my 
error terms are assumed to be Weibull, but it does not make any sense. The mean 
survival time is easy to predict, but I would like to simulate individual survival 
times.

I am probably missing something completely obvious. Any hints or advice are 
appreciated.

Thanks
Sixten

 summary(mod1)

Call:
survreg(formula = Surv(tid, study$first.event.death) ~ regim + 
age + stadium2, data = study, dist = weibull)
  Value Std. Error  zp
(Intercept) 11.6005 0.7539 15.387 2.01e-53
regimposto  -0.1350 0.1558 -0.867 3.86e-01
age -0.0362 0.0102 -3.533 4.11e-04
stadium2ii  -0.0526 0.2794 -0.188 8.51e-01
Log(scale)  -0.5148 0.1116 -4.615 3.93e-06

Scale= 0.598 

Weibull distribution
Loglik(model)= -680.7   Loglik(intercept only)= -689.2
Chisq= 16.87 on 3 degrees of freedom, p= 0.00075 
Number of Newton-Raphson Iterations: 8 
n=1183 (4 observations deleted due to missing)

 version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major1  
minor8.1
year 2003   
month11 
day  21 
language R  


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] R 1.9.0, special characters in variable names.

2004-06-24 Thread Sixten Borg
Hello all,

I upgraded from R 1.8.1 to 1.9.0 (Windows XP), and spotted an odd thing.

The last three letters in the Swedish alphabet are å, ä and ö. (In case they don't 
show correctly: they are a with a ring, a with two dots, and o with two dots (HTML: 
aring;  auml; ouml;).

When I use these as variable names in a data.frame, odd things happen:
In R 1.8.1, å (aring;) doesn't work while the others do.
In R 1.9.0, ö (ouml;) doesn't work while the others do.

Please find examples below. It would be nice if all three could be used in variable 
names. At least in Sweden :-)

Thanks...
Sixten.

#
# R 1.9.0: ö is renamed to X.
#

 data.frame(a=1, å=2, ä=3, ö=4)
  a å ä X.
1 1 2 3  4
 version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major1  
minor9.0
year 2004   
month04 
day  12 
language R  
 


#
# R 1.8.1: å is renamed to X.
#

 data.frame(a=1, å=2, ä=3, ö=4)
  a X. ä ö
1 1  2 3 4
 version
 _  
platform i386-pc-mingw32
arch i386   
os   mingw32
system   i386, mingw32  
status  
major1  
minor8.1
year 2003   
month11 
day  21 
language R  


#

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Summary [R] R 1.9.0, special characters in variable names.

2004-06-24 Thread Sixten Borg

Summary: 
The locale setting in the operating system seems to be involved in what confused me a 
little bit.
Thank you all for your help, especially the suggested work-around  data.frame(..., 
check.names=F) which works very well.

A mystery still to be solved is why two versions of R, running on the same machine on 
the same time, behaves differently.
Please do not respond to this on the list. I very much welcome you not to respond at 
all.

Sixten.

 Prof Brian Ripley [EMAIL PROTECTED] 2004-06-24 10:20:55 
 Can we stop blaming R for things which are not its fault, especially as 
 that has already been pointed out twice this morning?

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Extracting the survival function estimate from a survreg object.

2004-04-06 Thread Sixten Borg

Hello all,

I want to extract the survival function estimate from a model fitted by survreg().
Using predict.survreg(..., type=quantile, p=seq(0,1,0.001)), gives the quantiles, 
which
I managed to turn around into a survival function estimate (Prob{T  t} as function of 
t).

Is there a more straightforward way of doing this? I have had difficulties using 
pweibull() with
the coefficients reported by summary(survreg object).

I am enclosing an outline of my code for reference if anyone is interested.

Thanks in advance,

Sixten

-
sure - survreg(formula = Surv(time, dead) ~ age + group + sex, data = modb)

nd - data.frame(
  age=50, 
  group=factor(A, levels=c(A, B, C)),
  sex=factor(M, levels=c(F, M)))

y - seq(0, 1, 0.001)

#
# For a range of p-values, predict the quantiles.
#
sufu - list(
  y=1-y,
  x=predict.survreg(sure, nd, type=quantile, p=y)
)

#
# Find the p value for each t, by locating the last quantile no larger than t.
# The pairs (t,p) forms a step function.
#
sufu2 - list(
  x=0:14,
  y=unlist(lapply(0:14,function(x){rev(sufu$y[sufu$x=x])[1]}))
)

# Looks ok?
plot(sufu, type=s, xlim=c(0,20))
points(sufu2,  pch=20, col=blue)

#EOF#

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Ang: [R] How to write efficient R code

2004-02-18 Thread Sixten Borg
Hej Lennart,

I would like to add one thing:
Often, there already exists an R function that solves the problem at hand. Instead of 
writing your own function, search the help files [apropos(), help.search()]. What I 
some times find difficult though, is guessing what key words will produce relevant 
search hits...

Mvh
Sixten

 [EMAIL PROTECTED] 2004-02-17 15:36:12 
I have been lurking in this list a while and searching in the archives to
find out how one learns to write fast R code. One solution seems to be to
write part of the code not in R but in C. However after finding a benchmark
article (http://www.sciviews.org/other/benchmark.htm) I have been more
interested in making the R code itself more efficient. I would like to find
more info about this. I have tried to mail the contact person for the
benchmark, but I have so recieved no reply.

I am not an R programmer (or statistican) so I do not know R well. I am
looking for some advice about writing fast R code. What about the different
data types for example? Is there some good place to start to look for more
info about this? 


Thanks for any pointers
Lennart

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] (no subject)

2004-01-08 Thread Sixten Borg

Hello,

I have trouble converting a character string to a R object. Let me describe this by an 
example;

 dim(a)
[1] 270  14
 dim(a)
NULL

 names(a)
 [1] Var1  Var2  Var3  Var4  Var5  Var6  Var7  Var8  Var9 
[10] Var10 Var11 Var12 Var13 Var14
 names(a)
NULL

I realise that the character string lacks both a dimension and any column names; my 
question is how to make R understand that I look for the object a when I write a.

Like a type cast in C;  (R data.frame) a  for those familiar with C.

The underlying reason for this is that I am writing a script that imports several 
datasets. The file names of the datasets contain the '_' character which forces me to 
construct a valid dataset name for each file. Although I can do this by hand, I would 
like to know if there is any solution to my first approach.

Thanks in advance,
Sixten


Sixten Borg

IHE
Box 2127
S-220 02 Lund
Sweden

tel: +46 46 32 91 07
fax:+46 46 12 16 04

www.ihe.se
***
Note: The information contained in this message and attachments may be privileged
and confidential and protected from disclosure. If the reader of this message is not 
the intended recipient you are hereby notified that any dissemination, distribution
or copying of this communication is strictly prohibited. If you have received this 
communication in error, please notify us immediately by replying to the message 
and deleting it from your computer. Thank you. IHE

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html