Re: [R] Speed up R

2007-06-20 Thread Michael Prager
Matthew Keller wrote:

 So Mike, let me ask you a question. If R runs out of RAM, does it
 begin to use virtual RAM, and hence begin to swap from the hard drive?
 If so, I could see how a faster hard drive would speed R up when you
 don't have enough RAM...

Yes. Virtual memory management is done by any modern operating
system. The slowdown will be extreme.  (Therefore, a minimum
of 2Gb is a good idea for serious crunching -- I'd recommend 3
or 4 if possible.  Don't forget that any programming language
may have two copies of some arrays in memory during certain
operations.)

But even when R itself is not using VM, any significant I/O
load on a Windows CPU (when (S)ATA disks are used) slows down
*at least* all other I/O, and it seems to me that it slows
down other interrupt servicing (e.g., responding to mouse
clicks) as well.  Even if the latter is not strictly true, it
may be that the mouse click requires paging something in, like
the stupid animation that plays when files are copied.  

Aside:  On a old PC, copying files from the command line was
fine, but if I forgot  did it from the Windows Explorer, the
stupid animation swapped in from disk and the machine froze
for ~30 seconds.)

Windows Vista can take advantage of a new gizmo Intel has
introducted with a 1 Gb solid-state disk cache. That might
reduce such problems.

Mike

Mike Prager
Southeast Fisheries Science Center, NOAA
Beaufort, North Carolina  USA

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] TCL/TK and R documentation?

2007-01-10 Thread Michael Prager

I am hoping something has changed since I last asked about this.

Is there any good source of documentation, including examples, of using 
tcl/tk as a gui for R applications? 

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Matrix dimnames

2006-11-01 Thread Michael Prager
Daniel Gatti wrote:

 How does one assign names to the columns of a matrix so that the columns 
 can be accesses using the '$' operator? It seem that x$c1 below should 
 return column 1.
 
   x = matrix(1:4,2)
   dimnames(x) = list(c(r1, r2), c(c1, c2))
   x
 c1 c2
 r1  1  3
 r2  2  4
   x$c1
 NULL
   x$c2
 NULL
 

Is this useful?--

 x[,c1]
r1 r2 
 1  2 

I have only seen $ used with lists.  A data frame is a kind
of list, but a matrix isn't.  

From the R Reference Manual: The form [of indexing] using $
applies to recursive objects such as lists and pairlists.

HTH

Mike Prager
Southeast Fisheries Science Center, NOAA
Beaufort, North Carolina  USA

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Saving a function

2006-11-01 Thread Michael Prager
Matt,

patopatasfrias wrote:

 Hey, I'm a real novice...  how do I go about saving a function that I created 
 eg. If I created this function: Fun-function(x1,X2) {..}, how can I
 store it so that the next time I use R I can load it and not have to type it
 out again

If you search the list archives, you may find a solution to
this that I posted several months ago.  It involves moving
one's own functions to a dedicated directory, saving them in
an R workspace in that directory, and then loading that
workspace in the .Rprofile file.  

My method is a LOT simpler than making an R package but it is
more complex than saving the functions with dput or otherwise
in a file to be reloaded.  Its advantage is that (like making
a package) it makes the functions available to you even when
you open R in a different directory.

HTH

Mike Prager
Southeast Fisheries Science Center, NOAA
Beaufort, North Carolina  USA

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Package development on Windows - latest guidance?

2006-10-28 Thread Michael Prager
I would like to start building R packages under Windows XP.  I
have programming experience and a minimal but working knowlege
of many Unix (-like) programming tools. The package functions
(for now) will be from R source, not C or Fortran.

I've installed Rtools, Perl, the MS hhc, and so on.  I am
setting up a command shell with the correct PATH for building
packages.  (The master Windows PATH points to different
versions of make and grep that I prefer for my usual work.)

Two questions:

1.  GUIDANCE.  Is the Peter Rossi document now the best place
to look for detailed guidance?  I have located it at

http://www1.appstate.edu/~arnholta/Software/MakingPackagesUnderWindows.pdf

The links to it on the R Project Website are no longer good. I
am also reading at the latest version of Writing R
Extensions.

2. LATEX.  In Rossi's paper, fpTeX is recommended (I use VTeX
in everyday work).  However, fpTeX has been discontinued by
the author.  What is the best way to get an R-compatible TeX
installation for this work? (or might I get VTeX working --
its command line is idiosyncratic but it can create PDF, DVI,
or HTML directly from LaTeX source)?

Mike Prager
Southeast Fisheries Science Center, NOAA
Beaufort, North Carolina  USA

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Package development on Windows - latest guidance?

2006-10-28 Thread Michael Prager
Thanks to Gabor G., Duncan M., and Hong O. for helpful
replies.  I've made some progress, but have two questions.

Can anyone explain *how* R CMD searches for latex?  I have
provided a batch file (shell script) and and alias (I use a
Windows command shell with aliasing) that each provide the
proper VTeX command when latex is typed from the command
line. The batch file in on my PATH, but R CMD check still
fails when it searches for latex.  Is there any way around
this, or will I have to relent and install MikTeX solely for
this purpose? 

Also, R CMD build makes a tarball.  Can I simply ZIP the same
material that's in the tarball to make a working Windows
installable package?

Mike Prager
Southeast Fisheries Science Center, NOAA
Beaufort, North Carolina  USA

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Package development on Windows - latest guidance?

2006-10-28 Thread Michael Prager
Thanks again to D. M. and G. G. for help.  I have built a
small package successfully, although latex is not working
quite right.  I might be able to get it working, but I'm
unclear what the latex compiler is used for when building a
package.  Otherwise, I'll just install MikTeX and treat it as
a black box.

M

Mike Prager
Southeast Fisheries Science Center, NOAA
Beaufort, North Carolina  USA

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Command equivalent of rgui File, Save to File?

2006-09-12 Thread Michael Prager
Duncan Murdoch wrote:

 On 9/11/2006 3:57 PM, Michael Prager wrote:
  R 2.3.1 on Windows XP Professional.
  
  I am writing some scripts to generate examples.  The Rgui menu
  item File, Save to File is helpful.  Is there perhaps an
  equivalent R function that can be incorporated into a script?
 
 I think sink() is the closest you can get: set R to write to a file 
 before generating whatever output you want to save.
 
 The menu item writes out the GUI text buffer; the R core doesn't know 
 what's in that buffer.  Other front ends don't have a buffer at all.
 
[...]

Thanks, Duncan, for the helpful response.  Unless I have
overlooked something (quite possible), sink() saves only the
output, not the input as well.  I'll continue using the menu
system -- which I am delighted to have.

Mike

Mike Prager
Southeast Fisheries Science Center, NOAA
Beaufort, North Carolina  USA

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Command equivalent of rgui File, Save to File?

2006-09-11 Thread Michael Prager
R 2.3.1 on Windows XP Professional.

I am writing some scripts to generate examples.  The Rgui menu
item File, Save to File is helpful.  Is there perhaps an
equivalent R function that can be incorporated into a script?

Mike Prager
Southeast Fisheries Science Center, NOAA
Beaufort, North Carolina  USA

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Successive Graphs

2006-09-11 Thread Michael Prager
[EMAIL PROTECTED] wrote:

 Hello! I have written an R script on a Windows platform where I
 calculate eight result matrices I plot using matplot. I would like to
 display the resulting plots successively, rather than simultaneously,
 and I was wondering if anyone could point me in the right direction as
 to how to do this. The graphs pop up in this manner by default when I
 run my script in S-PLUS, with tabs separating them so I can view each
 graph at my leisure. However when I run my script in R, each graph pops
 up only for a moment before it is replaced by the next until I am left
 with only the plot of the eighth matrix at the end of the script. Thanks
 in advance for your help!

Others have pointed out the R plot history mechanism, which is
very nice.  A few additions.

If you are re-running the script often and want to get rid of
old windows, you can put near the top of your script

graphics.off()

You can open a graphics window -- with history enabled -- with

windows(record=TRUE)

Plot history is saved.  If desired, you can clear the old
history before making new plots with

.SavedPlots - NULL


Mike Prager
Southeast Fisheries Science Center, NOAA
Beaufort, North Carolina  USA

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] macro facility in R

2006-07-03 Thread Michael Prager
Here is one user's perspective on this, with no pretense of being 
definitive.  In the S (R) world, the expression computing on the 
language is used to encompass what I would call the tasks of macro 
programming.  This involves uses of various S (R) expressions that 
convert between names of objects and the object themselves; pasting 
together expressions out of fixed and variable text; and executing 
them.  I for one have been able to do everything I could do in the SAS 
macro language, but it has taken trial and error.

To get started, you might consult section 3.5 of S Programming by 
Venables and Ripley.

MHP

John Sorkin wrote on 7/3/2006 7:39 AM:
 R 2.2 on windows XP
 I have a dataset with multiple columns. Some of the columns represent
 independent variables, some represent dependent variables. I would like
 to run the same analyses on a fixed set of independent variables,
 changing only the dependent variable, e.g.
 y1-y2=x1+x2+x3
 y3-y4=x1+x2+x3
 y5-y6=x1+x2+x3, etc.
 I know I can write a function to perform the analyses, however in order
 to make the analyses easy to do, I really need a macro scripting
 language that will allow preprocessing of the function and substitution
 of macro variables with parameters passed to the macro, i.e. I need
 someting akin to the macro facility in SAS. Is there a macro facility
 that I can use with R? I have tried help.search(macro) and did not
 have any success.
 Thanks,
 John  

 John Sorkin M.D., Ph.D.
 Chief, Biostatistics and Informatics
 Baltimore VA Medical Center GRECC,
 University of Maryland School of Medicine Claude D. Pepper OAIC,
 University of Maryland Clinical Nutrition Research Unit, and
 Baltimore VA Center Stroke of Excellence

 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

 410-605-7119
 [EMAIL PROTECTED]

 __
 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
   

-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


Re: [R] warning messages

2006-06-25 Thread Michael Prager
You might consider passing the output file name to the function as an 
argument.


Matthew Bridgman wrote on 6/25/2006 10:49 AM:
 I want to put warning messages into some of my functions to remind 
 myself to change the output file names each time I run them. Is there a 
 way to do this that will allow me to respond to the warning message 
 (i.e. continue function or cancel)?

 Thanks,
Matt

 __
 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
   

-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


Re: [R] how to make a series with decimal increment

2006-06-14 Thread Michael Prager
Gavin Simpson wrote on 6/14/2006 12:44 PM:
 On Tue, 2006-06-13 at 05:24 +, anil kumar rohilla wrote:
   
   Hi List, 
I am new to this Rsoftware, i want to make a sereis for example
 which is having values like this, s- 0,0.1,0.2,0.3,0.4,1  

 [...]
 Hi Anil,

 see ?seq for the solution, which is:

 s - seq(0, 1, by = 0.1)
 for(i in s) {
   print(i)
 }
   

I don't know if R avoids this somehow, but in many languages, generated 
noninteger sequences are sometimes one item shorter than expected, 
because of rounding errors.  For that reason, I would prefer to generate 
an integer sequence and then form a noninteger one from it.  For example:

 s  - (1:10) / 10

Another option in R would be using the argument length.out, as in

s = seq(from = 0.1, to = 1, length.out = 10)

...Mike


-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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] Variable number of arguments to function

2006-05-25 Thread Michael Prager
Dear R List,

I have used ... to pass a varying number of arguments to a function.  
The function takes parts of specialized data objects (they happen to be 
lists) and makes comparative graphs and analyses.  The code shell looks 
like this:

models.compare - function(...) {
   ## Get the data objects passed
   models - list(...)
   nmodels - length(models)
   ## Get names of models:
   modelnames - as.character(substitute(c(...))[-1])
   # much code omitted here #
}


Now I would like to pass a few named arguments to the function as well, 
to control how it prints, plots, makes files.  I am seeking advice on 
the simplest way to do this (along with the varying number of data 
arguments).

Mike

-- 
Michael H. Prager
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
Beaufort, North Carolina 28516 USA

__
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


Re: [R] Contour plot overlayed with line plot

2006-05-13 Thread Michael Prager
It seems you have figured out a solution; for another example, you could 
look here:

http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=90

Mike

Jonathan Greenberg wrote on 5/10/2006 7:46 PM:
 I apologize for what may be a newbie question: I have two sets of data, one
 is X,Y,Z data that I'd like to make a contour plot of (Z defining the
 contours), and a second set of X,Y data (Y as a function of X) which I would
 like made into a line plot OVERLAYED on the contour plot (X and Y from both
 plots are in the same units and will have overlapping values).  Any
 suggestions on how to do this in R?  Thanks!

 --j 

   

-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


Re: [R] GUI font size

2006-04-24 Thread Michael Prager
Erin,

I was able to set it larger by making the change manually in the 
Rconsole file.

For details of Rgui (Windows) configuration, try

  ?Rconsole

from the prompt.

MHP


Erin Hodgess wrote on 4/24/2006 6:44 PM:
 Dear R People:

 On the Edit menu, there is a GUI preference tab.

 On the Font option, the highest value is 18.

 Has anyone ever had the font size set larger than that will any 
 success, please?

 Thanks,
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: [EMAIL PROTECTED]
 PS Windows, R 2-2-1

 __
 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
   

-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


Re: [R] is there a formatted output in R? [User functions]

2006-03-12 Thread Michael Prager
There is a slightly easier way to make your own functions available.

1. Set up a directory for your R configuration.  I use d:\r\mhp.  Copy 
.Rprofile, Rconsole, Rdevga there.

2. Set up a Windows environment variable R_USER pointing to that 
directory.  For example: R_USER=d:\r\mhp

The point of the preceding is to set R to load the same .Rprofile each 
time it starts.

3. Set up a separate directory for your own functions.  I use 
d:\r\mhp\mhpmisc.

4. Put your own functions in the directory from step 3.  Open R there.  
Source the functions.  Save the workspace as .Rdata.

5. In your .Rprofile file, add a line like this:

attach(d:/R/MHP/MHPmisc/.RData)

Now your functions will be available from every instance of R you start 
up.  If you have many functions, I have written an R script that 
searches the current directory for all of them, clears the workspace, 
sources them all, and saves the workspace.  Reply to me by email if you 
want a copy.

I have been told by Gurus that my method is too complicated, but I find 
it a lot simpler than creating a package.

...MHP



Michael wrote on 3/11/2006 1:33 PM:
 Thank you for your reminder!

 I think you don't have to tell me to read the document.

 I have done that many times already.

 My feeling after reading the creating package manual is that my god, this
 job needs a Computer Science degree to do it. It is way too complicated.

 There should be simpler ways.

 Perhaps I don't need a package.

 I just need to be able to call my clearscreen function from all of my
 other scripts...

 Where do I put my clearscreen function?

 Is there a command similar to include in C++?

 Is there a path management that I can call clearscreen function from
 anywhere as long as its in path?


 On 3/11/06, Gavin Simpson [EMAIL PROTECTED] wrote:
   
 On Fri, 2006-03-10 at 22:50 -0800, Michael wrote:
 
 Great! It worked! Thank you so much!

 Now since it worked greatly, how can I put this function into my own
   
 library
 
 or package, so later on I can call this function from my other scripts?

 Thanks a lot!
   
 Michael,

 Read the two manuals that cover writing functions and preparing
 *packages* of code, which come with R or get them here:

 http://cran.r-project.org/manuals.html

 An Introduction to R and Writing R Extensions,

 After reading and digesting, if you still have questions then post them
 to the list. People here provide their time for free and it is not much
 to expect posters to try to help themselves out first - especially as
 the developers have gone to such great lengths to produce quality
 documentation that explains all of this.

 HTH

 G

 
 On 3/10/06, jim holtman [EMAIL PROTECTED] wrote:
   
  The archives had the following in it:

  [R] how to clear screen in R-console?

- *This message*: [ Message body
 
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70722.html#start] [ More
 
options
 
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70722.html#options2]
 
- *Related messages*: [ Next message
 
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70723.html] [ Previous
 
message http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70721.html]
 
 [ In
 
reply tohttp://finzi.psych.upenn.edu/R/Rhelp02a/archive/70708.html]
 
 [ Next
 
in thread
 
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70800.html] [
 
Replies
 
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/70722.html#replies]
 
  *From*: Gabor Grothendieck
 
 ggrothendieckggrothendieck?Subject=Re:%20[R]%20how%20to%20clear%20screen%20in%20R-console?
 
 *Date*: Fri, 17 Feb 2006 12:36:51 -0500

 Here is a version that uses rcom instead of RDCOMClient.
 This has the advantage that rcom is on CRAN.

 cls - function() {
 require(rcom)
 wsh - comCreateObject(Wscript.Shell)
 comInvoke(wsh, SendKeys, \014)
 invisible(wsh)
 }
 cls() # test

 On 2/17/06, Gabor Grothendieck ggrothendieck at gmail.com wrote:
 * Here is a translation of Norm Olsen's vbscript code into pure R. *
 * This is intended for use with the Windows Rgui interface. *




  On 3/10/06, Michael [EMAIL PROTECTED] wrote:

 
 something like sprintf in C?
   
 so I can do:

 print(sprintf(the correct result is %3.4f\n, myresult));

 ---

 Also, I am desperately looking for a clear console screen  function
 
 in
 
 R...

 thanks a lot!

[[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
 
 http://www.r-project.org/posting-guide.html
 


 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390 (Cell)
 +1 513 247 0281 (Home)

 What the problem you are trying to solve?

 
   [[alternative HTML version deleted]]

 

Re: [R] 2nd R console?

2006-03-09 Thread Michael Prager
On Windows, I often have more than one R console (instance of Rgui.exe) 
open at the same time.  Unless by mistake, each instance is open on a 
unique working directory.

MHP

mark garey wrote on 3/9/2006 8:05 PM:
 hello all, i'm forwarding this question for a colleague.

 Is it possible to open a 2nd R Console?

 regards,

 mark+

 --
 mark garey
 ucsf
 department of epidemiology and biostatistics
 division of biostatistics
 185 berry street, suite 5700
 san francisco, ca. 94107-1739
 415.514.8147

 __
 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
   

-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


Re: [R] Optimal platform for R

2006-03-09 Thread Michael Prager
[EMAIL PROTECTED] wrote on 3/9/2006 4:47 PM:
 I'm looking to buy a new desktop which will primarily be used for
 analyses of large datasets (100s of MB). I've seen postings from several
 years back re the 'optimal' platform for running R, but nothing more
 recently. 
  

 Specifically, I want to know: 1) if I run R under Windows, does having a
 dual-processor machine help speed things up? And 2) is it still true
 that R performs about as well under Windows as Linux? 
   

Duncan Murdoch has already answered your questions about operating
systems.  I would like to add that if there is significant I/O in what
you are doing, fast SCSI disks are a worthwhile investment.  The speed
increase over ATA or SATA disks has been, in my experience, quite
noticeable.

-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


Re: [R] R and Power Point

2006-02-14 Thread Michael Prager
Erin,

 From an Rgui graphics window (windows() device), Ctrl-W will save the 
current graph to the clipboard as a metafile; Ctrl-C will save as a 
bitmap.  In PPt, Ctrl-V will paste either into a blank spot on a slide.

The metafile is a Windows vector spec that will be sharper and smaller.  
However, I have had trouble when viewing them on different PCs with 
different fonts installed.  Bitmaps will get around that but have all 
the usual limitations of ... bitmaps.

MHP


Erin Hodgess wrote on 2/14/2006 1:46 AM:
 Dear R People:

 I'm using R in a time series class.  This class is being
 broadcast live to 2 remote sites via closed circuit TV.

 My people at the remote sites are having a terrible time
 seeing the computer screen as it is broadcast(resolution issues).  I have
 decided to put together Power Point slides for the teaching.

 I am currently saving the R screen as WMF files and inserting them
 into PowerPoint.  While this works, it seems that there
 might be a simpler method.  

 Does anyone have any suggestions for the Power Point, please?

 Thanks so much!
 R Version 2.2.1 Windows
 Sincerely,
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: [EMAIL PROTECTED]

 __
 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
   

-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


Re: [R] Plotting contour filled.contour in one graph

2006-02-12 Thread Michael Prager
Besides the answers you already have, you might look at my 4D graph 
example (with code) on the R Graphics Gallery:

http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=90

I think it does exactly what you are asking, and therefore it might fit 
your needs with only slight code modification.

Mike Prager


Abd Rahman Kassim wrote on 2/12/2006 11:12 PM:
 Dear All,

 I have a question on overlaying a filled.contour (e.g. on soil properties 
 data) and contour (by elevation) in one graph. Both have the same z matrix 
 dimension. I'm able to overlay both graph, but the plots dimension did not 
 overlap well on the same plots. How can I have both filled.contour and 
 contour on the same graph? The commands that I have written are as follows:

 filled.contour(0:15,0:10,t(matrix(Total.C,nrow=11,ncol=16)))
 contour(0:15,0:10,as.matrix(elev),add=T)

 Thanks for anay assistance.

 Regards.


 Abd Rahman Kassim
 Forest Research Institute Malaysia
 Kepong 52109
 Selangor, MALAYSIA

 *


 *
   [[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
   

-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


Re: [R] Plotting contour filled.contour in one graph

2006-02-12 Thread Michael Prager
GG

Yes, gladly.  It is an idealized example of the following data 
situation:  There are two control or independent variables.  They are 
represented here as x and y, on the horizontal and vertical axes 
respectively.  There are two different responses or dependent 
variables plotted as different types of contours.  The filled contours 
show response z.  The heavy lines show response zz.

Thus such a plot displays two different responses from a two-dimensional 
range of conditions.  As an example, in fishery biology, x might be the 
age at which fish are first subject to capture, y might be the fishing 
mortality rate (intensity) applied, z might be the resulting yield per 
fish, and zz might be the resulting spawning per fish.  There is usually 
a trade-off between yield and spawning potential, and such a graph (if 
done with real data) allows one to look at that trade-off. 

The OP seemed to be seeking a way of contouring two responses against 
two independent variables, and that's what this graph does.

Is that clearer?  Would the graph would be better if I used real data?

MHP



Gabor Grothendieck wrote on 2/12/2006 11:31 AM:
 Could you walk us through, in detail, what that graph is showing?


 On 2/12/06, Michael Prager [EMAIL PROTECTED] wrote:
   
 Besides the answers you already have, you might look at my 4D graph
 example (with code) on the R Graphics Gallery:

 http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=90

 I think it does exactly what you are asking, and therefore it might fit
 your needs with only slight code modification.

 Mike Prager


 Abd Rahman Kassim wrote on 2/12/2006 11:12 PM:
 
 Dear All,

 I have a question on overlaying a filled.contour (e.g. on soil properties 
 data) and contour (by elevation) in one graph. Both have the same z matrix 
 dimension. I'm able to overlay both graph, but the plots dimension did not 
 overlap well on the same plots. How can I have both filled.contour and 
 contour on the same graph? The commands that I have written are as follows:

 filled.contour(0:15,0:10,t(matrix(Total.C,nrow=11,ncol=16)))
 contour(0:15,0:10,as.matrix(elev),add=T)

 Thanks for anay assistance.

 Regards.


 Abd Rahman Kassim
 Forest Research Institute Malaysia
 Kepong 52109
 Selangor, MALAYSIA

 *


 *
   [[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

   
 --
 Michael H. Prager, Ph.D.
 Population Dynamics Team
 NOAA Center for Coastal Habitat and Fisheries Research
 NMFS Southeast Fisheries Science Center
 Beaufort, North Carolina  28516  USA
 http://shrimp.ccfhrb.noaa.gov/~mprager/

 __
 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

 

-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


Re: [R] A comment about R: (sort.data.frame)

2006-01-03 Thread Michael Prager

Gabor Grothendieck wrote on 1/3/2006 2:37 PM:

Looking at the first few queries,
see how easy it is to take the top few in Stata whereas in R one would
have a complex use of order.  Its not hard in R to write a function
that would make it just as easy but its not available off the top
of one's head though RSiteSearch(sort.data.frame) will find one
if one knew what to search for.
  

Yes, R has a few peculiar gaps.  As to sort.data.frame(), it should be 
added to R base, in my opinion.  It is silly to make people download 
code for such a basic operation.

MHP

__
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


Re: [R] copy contributed packages from R 2.2.0 to 2.2.1

2005-12-23 Thread Michael Prager
When I asked this question, I got some good answers.  Based on them, I 
wrote a pair of functions to accomplish this.  I have tested them in 
exactly ONE installation, and they worked.

Of course these are not needed by R gurus, but I attach them (with many 
more comment lines than actual source) for the use of anyone else who 
would like to use them.

MHP

Helmut Kudrnovsky wrote on 12/23/2005 9:43 AM:

hi R-users,

a few days ago R 2.2.1 came out. on my win xp i'installed R 2.2.0. along the 
time i've installed a lot of contributed packages. my internet-connection is 
not very fast.

 so my question:  is it possible after installing R 2.2.1 to do copy/paste the 
 contributed packages from the C:\Programme\R221 to the  C:\Programme\R2.2.1- 
 location in the files system?

or have i to download and install the packages new?

  

##
#  Functions to (1) save names of installed package from an R 
installation to#
#  a file and (2) install the same packages on a new R 
installation. #
##
#  HOW TO MOVE PACKAGES FROM ONE R INSTALLATION TO 
ANOTHER:  #
#  Put this file in your R working directory.  Source it.  Run 
SaveMyPackages()  #
#  under the old installation.  Save your workspace and exit.  Open the 
new  #
#  installation on the same directory.  Run InstallMyPackages().  The 
packages   #
#  will be installed.  You may now rm(SaveMyPackages,InstallMyPackages) 
if you   #
#  like.  Also, you may delete the file pkg.list in the working 
directory. #
##
#  M. H. Prager  
[EMAIL PROTECTED]#
#  with much from posted code of U. Ligges, H. Nilsson,  B. Ripley   
   #
#  December, 
2005#
##

SaveMyPackages - function(filename = pkg.list, savepkg = TRUE)
   {  #  Saves a character vector with names of non-default
  #  packages installed. Writes it to a dput ASCII file.
  #  --- Run this from old installation. ---
  #  Arguments:
  # filename --Character, name of file to write.
  # savepkg -- Logical, if TRUE save the file; if not, return
  #the vector of package names instead.
  foo - installed.packages()
  foo - as.vector(foo[is.na(foo[, Priority]), 1])
  if (savepkg) dput(foo, file = filename) else return(foo)
   }

InstallMyPackages - function(x = dget(file = filename), filename = 
pkg.list,
  install = TRUE)
   {  #  Install or print list of packages .
  #  --- Run this from new installation. ---
  #  Arguments:
  # x-- character, contains names of packages to 
install; default is
  # vector read from argument filename.
  # filename--  character, name of file containing vector (in 
dput format);
  # default is pkg.list as in SaveMyPackages.
  # install--   logical, should actual installation be done?  If 
not,
  # the vector of package names in x is returned instead
  # of being installed.
  if (install) install.packages(x) else return(x)
   }
##

__
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


Re: [R] Writing a list to a file !

2005-12-06 Thread Michael Prager
Here is a function I use to send lists to ASCII files.

list2ascii - function(x,file=paste(deparse(substitute(x)),.txt,sep=))
{
   # MHP July 7, 2004
   # R or S function to write an R list to an ASCII file.
   # This can be used to create files for those who want to use
   # a spreadsheet or other program on the data.
   #
   tmp.wid = getOption(width)  # save current width
   options(width=1)  # increase output width
   sink(file)# redirect output to file
   print(x)  # print the object
   sink()# cancel redirection
   options(width=tmp.wid)# restore linewidth
   return(invisible(NULL))   # return (nothing) from function
}


I hope it's helpful.

To write it to a file that can be read by R, I would suggest using 
dput instead.

Regards,
Mike Prager



A Ezhil wrote:

Hi All,

This may be trivial in R but I have been trying with
out any success. I have a list of 100 elements each
having a sub list of different length. I would like to
write the list to a ASCII file. I tried with
write.table(), after converting my list to a matrix.
Now it looks like

Robert  c(90, 50, 30)
Johnc(91, 20, 25, 45)

How can I get rid off c(, ..)? In my file, I would
like to have 

Robert  90, 50, 30
John91, 20, 25, 45

Thanks in advance.

Regards,
Ezhil

__
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] Tip: Working directory in titlebar

2005-09-25 Thread Michael Prager
I hope others may find this useful.  I use R in many different 
directories.  By adding the following line to the .Rprofile file:

utils:::setWindowTitle(paste(-,getwd()))

the titlebar of each R instance shows the directory from which it was 
started. I have tested this with rterm.exe and rgui.exe under Windows 
and with RECENT versions of R only.

-

For changing directories during a session, I use the following function, 
a slight modification of Andy Liaw's cd() function that also changes the 
titlebar:

cd - function(dir = tclvalue(tkchooseDirectory()), saveOld=NA, 
loadNew=TRUE) {
# From Andy Liaw  ... additions by MHP
# Change the working directory during an R session
#
# First check that the tcl-tk package is available:
stopifnot(require(tcltk))
# Print any error message from trying to load:
if (.Platform$OS.type==windows) flush.console()  ## MHP
# Warn user if saving existing workspace was not chosen: (MHP)
if (is.na(saveOld)) {
  tmp = tclvalue(tkmessageBox(message=Save current workspace image?,
 type=yesnocancel,title=Changing directories,icon=question))
 saveOld = switch(tmp, yes=TRUE, no=FALSE, 
cancel=return(invisible(NULL)))
 }
# Save old workspace:
if (saveOld) save.image(compress=TRUE)
# Change directory:
# Note: the need to evaluate dir on the next line causes the 
tclvalue call
#in the function definition (first line) to take place now:
if (dir==) return(invisible(NULL))  # Fail gracefully if CANCEL 
chosen from TK dialog (MHP)
setwd(dir)
# Remove all the data from the old working directory:
rm(list=ls(all=TRUE, envir=.GlobalEnv), envir=.GlobalEnv)
# Change the window title:
setWindowTitle(paste(-,dir))
# Load the new data:
if (loadNew) {
 if (file.exists(.RData)) {
loaded - load(.RData, envir=.GlobalEnv)
return(invisible(loaded))
 }
 else {
cat(Warning: .RData not found in new directory\n)
return(invisible(FALSE))
 }
}
}

-

Although both these bits of code have been used, they may have errors.  
Comments and corrections welcome.

-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


Re: [R] Calling R from fortran

2005-07-12 Thread Michael Prager
Simon,

An hour's worth of contour plots (12) should be able to be saved in far
less than 1 Gb, depending on the detail desired.

Here is one way to do your task. There are other, and probably better, ones.

At each time step (5 mins), you could have the Fortran program write a
data file and then write and execute a script file.  The script file
would call R as a batch process to make a contour graph and save it (as
PNG perhaps), and then the script would delete the data file.  You might
want to have the generated script files omit the delete step once per
hour, just in case the R step should fail when you are not around to
observe the failure.

I don't know if R can easily read Fortran unformatted (sometimes called
binary) data, or how.  That would speed up the Fortran I/O and
possibly reduce file size.  If you go with formatted output, consider
limiting the number of decimal places you write to save disk space.  In
most applications, you won't need great precision for simply making
graphs. Also, for writing large amounts of data, test various block
sizes on the Fortran OPEN statement to get best I/O speed.

Another possibility would be to use a Fortran library (like the free or
inexpensive DISLIN) that can make the contour plots directly, without
using R.

...Mike


simon wrote on 7/12/2005 4:02 PM:

Hi,
The following may sound stupid so please forgive my stupidness. I have a 
question which I don't know how to name it so I have to start from the 
beginning. In an attempt to gain better understand how a photochemical 
air qaulity model works, I plotted hourly ozone concentration contour 
from the model's standard output to observe the changes in simulation. 
Because the model actually peroform simulation in time steps of 5 
minutes, it will give a better resoultion if I can plot the ozone 
concentration with time resolution close to the model. However, if I 
modify the model to output data at every time step, it will be 
impossible for the computer to store this much information( the hourly 
standard output is close to 1gb). I was wondering if it is possible to 
modify fortran to call R or something, which can just plot a contour at 
every time step rather than put it as data. I am not sure about how to 
call this act. Also, if this is possible, will output of a contour give 
a smaller file size than data?
Thanks in advance,
simon

  


-- 
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/

__
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


Re: [R] inserting R code in a latex document

2005-05-11 Thread Michael Prager
Thibaut Jombart wrote:
I'm trying to insert R source code (functions) in an appendix of a 
latex document. I guess the easiest way to do so is to use the package 
Sweaved (file : Sweaved.sty) 

I have had very good results with the LaTeX package listings.  It is 
easy to use, and it does the job.

--
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
Beaufort, North Carolina  28516  USA
__
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


Re: [R] Graphics file to disk

2005-05-11 Thread Michael Prager
If you want to write directly to file,
?Devices
will get you more information

Guy Forrester wrote on 5/11/2005 7:08 PM:
Dear All,
I have some code that works in S-Plus for writing saving a graphics file to 
disk :-
[...]
--
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/
__
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


Re: [R] Producing Editable Graphs for PowerPoint

2004-12-20 Thread Michael Prager
Paul--
It is hard to fight the tide, even when it contains sewage, but (you 
probably agree) this is an idiotic requirement.  Not only does this 
journal want to change your work (which journals do much too much), they 
also want you to help them use of low-class tools to do so.

You could try asking the journal to tell you what changes they feel are 
needed  promising to make them yourself.  That's what I would do, but 
there's no guarantee it will succeed.

An alternative would be to make EPS files from R and send them to them. 
The XP version (and presumably above) of MSPP can import and edit EPS 
files. If the journal doesn't like the *way* it edits them, well, what 
can you do?  Maybe that will allow you to gently suggest that their 
requirement is all wet.

We need somehow to restore the roles of authors and journals.  Authors 
are supposed to write the stuff, and journals figure how to get it into 
print.  Somewhere along the line, journals have taken on all the 
prerogatives of collaborators.  It seems to me that is a conflict of 
interest.

Good luck!
Regards,
...Mike

Paul Hewson wrote:
Hello,
(apologies, I'm not entirely sure whether this question is about R or my
limitations with PowerPoint).   I've submitted a paper (which has been
accepted) but the journal now require me to submit graphs that are
editable in PowerPoint.   I would be grateful for suggestions as to
how I should do this.
The best route seems to be to copy-and-paste the figures from the
windows() device as a metafile.   However, on converting the graphs to
an editable format and ungrouping them, it appears that every line,
tickmark, dot and dash is treated as a separate entity by PowerPoint
(for example even the horizontal and vertical parts of + are
separated).   Alternatively, reading in the files from a saved metafile
is even more problematic: having used par(new = TRUE) I have a set of
layered graphs and all but the last one dissapear once I open the
graphic for editing.
Is this normal for a figure editable by PowerPoint or am I doing
something horribly wrong somewhere?

Many thanks
Paul
 

--
Michael H. Prager, Ph.D.
Population Dynamics Team
NOAA Center for Coastal Habitat and Fisheries Research
NMFS Southeast Fisheries Science Center
Beaufort, North Carolina  28516  USA
http://shrimp.ccfhrb.noaa.gov/~mprager/
__
[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