[R] [R-pkgs] brew 1.0-1
brew implements a templating framework for mixing text and R code for report generation. brew template syntax is similar to PHP, Ruby's erb module, Java Server Pages, and Python's psp module. brew is written in R with no package dependencies, and it's not just for the web. It can be used as an alternative to Sweave in a limited context. See the brew-test-1.brew file in the distribution for some salient differences between the two. brew can also complement Sweave since it can be written to do conditional inclusion of or loop over Sweave code chunks. The 1.0-1 version should show up on the CRAN mirrors shortly, but in the mean time it can be got from: http://www.rforge.net/brew/ Best, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] using loops to create multiple images
Donatas G. wrote: I have a data.frame with ~100 columns and I need a barplot for each column produced and saved in some directory. I am not sure it is possible - so please help me. this is my loop that does not work... vars - list (substitute (G01_01), substitute (G01_02), substitute (G01_03), substitute (G01_04)) results - data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE) for (i in 1:length (vars)) { barplot(table(i),xlab=i,ylab=Nuomonės) dev.copy(png, filename=/my/dir/barplot.i.png, height=600, width=600) dev.off() } questions: Is it possible to use the i somewhere _within_ a file name? (like it is possible in other programming or scripting languages?) Oh yes, very easy. two options: 1) Use sprintf, e.g. filename=sprintf(/my/dir/barplot.%d.png,i) 2) Use paste, i.e., filename=paste('/my/dir/barplot.',i,'.png',sep='') Since I hate to type in all the variables (they go from G01_01 to G01_10 and then from G02_01 to G02_10 and so on), is it possible to shorten this list by putting there another loop, applying some programming thing or so? Well sure! Just loop over each column of your data frame. The column names are gotten from the names() function. I don't see a data frame in your code so I assume d is below: for (i in names(d)){ barplot(d[,i],filename=sprintf(/my/dir/barplot.%s.png,i)) } Notice that names(d) returns a character vector, thus i is a string, whereas in my sprintf example in 1) presumed it an int. Also, be sure to read up on the apply family of functions as an alternative to using loops in R code. Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] from R to html
Henrique Dallazuanna wrote: Use the package R2HTML. Or xtable. Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] Using R to create pdf's from each file in a directory
gecko951 wrote: The Platform I am using R on is RHEL3. I run a bash script that collects data into many CSV files and have been processing them one at a time on my local machine with an excel macro. I would like to use R to take data points from each of the CSV files and create line graphs in PDF format because it will save me ALOT of time. I am able to successfully do this when I call the file name directly...however my script bombs when I try to do multiple files. I would like the created pdf's to have the same filename as the original csv files. I have looked quite a bit and not found much help on batch processing an entire directory. My current code is as follows: list - dir(/tmp/data) for(x in list){ d - read.table(x, sep=\t, header=TRUE) # read data pdf(/tmp/graph/x.pdf) # file for graph plot(d$BlockSeqNum, d$MBs, # Blocks as x, MB/s as y type=l, # plot lines, not points xlab=Blocks, # label x axis ylab=MB/s, # label y axis main=x) # add title dev.off() # close file q()# quit Below will get you closer to what you want, assuming that your files end in .csv, which they should, especially if you'll be creating new files in the same directory with a different extension. You certainly don't want to re-run your R code and call read.table on a pdf. Another point is that your current working directory for R, returned by getwd(), is already '/tmp/data'. Otherwise read.table wouldn't work, and a more portable solution is to use a variable to hold the directory name: workdir - '/tmp/data' for (x in dir(workdir,pattern='.csv$')){ d - read.table(paste(workdir,'/',x,sep=''), sep=\t, header=TRUE) pdf(paste(workdir,'/',sub('.csv$','.pdf',x),sep='')) plot(d$BlockSeqNum, d$MBs, type=l, xlab=Blocks, ylab=MB/s, main=x) dev.off() } q() Best, Jeff --- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] Accessing R applications from Web
d. sarthi maheshwari wrote: Hi I am trying to provide web interface to my R application. My requirements are simple and can be written down as follows : 1) User must provide all the input parameters on web interface. 2) Based on the input values, R will do some computations. 3) Project the numerical results as well as plots as html page to the user on web. Kindly tell me which package can help me in doing this. Your help would be highly appreciated. There are many options according to the R FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-Web-Interfaces Best, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] Runing R in a bash script
Prof Brian Ripley wrote: On Wed, 18 Apr 2007, Ulrik Stervbo wrote: As I har problems installing the Cairo package, I went for Henriks solution - and it works almost perfect. I would like to have been able to generate transparent png. You cannot do transparency via postscript. I would suggest using pdf() and converting the output of that, which often works even better (and does have full transparency support). Cairo also has full transparency support, both for png and pdf. Ulrik, I presume the problem you ran into was the absence of the cairo library dependency: configure: error: Cannot find cairo.h! Please install cairo (http://www.cairographics.org/) and/or set CAIRO_CFLAGS/LIBS correspondingly. which has it's own library dependencies as well. Most all Linux distributions (I'm presuming you're running Linux) have ways to install these dependencies easily: apt-get, rpm, etc. Otherwise, if you had other problems installing Cairo, please let me know and I can fix them. Jeff Thanks for the help Ulrik On 18/04/07, Henrik Bengtsson [EMAIL PROTECTED] wrote: Or see png2() in R.utils, which imitates png() but uses bitmap(), which in turn uses postscript-to-png via ghostscript. BTW, personally I think PNGs generated via bitmap() look way better than the ones generated via png(). As there are two separate versions of png() for different OSes, comments like that are very system-dependent. Other postings suggest this is Windows, and if png() is giving poor results there it suggests a problem with the way Windows' GDI is configured (which depends on the graphics card). And of course, PNGs don't 'look' at all: they are rendered by some other tool, and quite often the perceived problem with R graphical output is in fact with the rendering tool. /Henrik On 4/17/07, Jeffrey Horner [EMAIL PROTECTED] wrote: Ulrik Stervbo wrote: Hello! I am having issues trying to plot to a ong (or jpg) when the R-code in a bash script is executed from cron. I can generate a pdf file, but when I try to write to a png, the file is created, but nothing is written. If I execute the bash script from my console, everything works file. Any ideas? In my cron I have SHELL=/bin/bash - otherwise /bin/shell is used and the folowing enery, so example is executed every minute * * * * * [path]/example.sh I am running R version 2.4.1 (2006-12-18) Here's a minimal example - two files one R-script ('example.r') and one bash-script ('example.sh') example.r # Example R-script x - c(1:10) y - x^2 png(file=example2.png) #pdf(file=example2.pdf) plot(x,y) graphics.off() example.sh #/bin/bash # # Hello world is written to exhotext every time cron executes this script echo Hello world echotext # This works, but not when executed from cron n=`R --save example.r` # using exec as in `exec R --save example.r` dosent work with cron either # This also works, but nothing is written to the png when executed from cron R --save RSCRIPT x - c(1:10) y - x^2 png(file=example2.png) #pdf(file=example2.pdf) plot(x,y) graphics.off() #dev.off() dosent work at all when executed from cron RSCRIPT The png() device requires an X server for the image rendering. You might be able to get away with exporting the DISPLAY environment variable export DISPLAY=:0.0 # try and connect to X server on display 0.0 within your script, but it will only work if the script is executed by the same user as is running the X server, *and* the X server is running at the time the script is executed. There are a handful of packages that will create a png without the presence of an X server, and I'm partial to Cairo (since I've done some work on it). You can install the latest version like this: install.packages(Cairo,,'http://rforge.net/',type='source') Cairo can also outputs nice pdf's with embedded fonts... useful if you want to embed high-quality OpenType or TrueType fonts. Best, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] Runing R in a bash script
Ulrik Stervbo wrote: Hello! I am having issues trying to plot to a ong (or jpg) when the R-code in a bash script is executed from cron. I can generate a pdf file, but when I try to write to a png, the file is created, but nothing is written. If I execute the bash script from my console, everything works file. Any ideas? In my cron I have SHELL=/bin/bash - otherwise /bin/shell is used and the folowing enery, so example is executed every minute * * * * * [path]/example.sh I am running R version 2.4.1 (2006-12-18) Here's a minimal example - two files one R-script ('example.r') and one bash-script ('example.sh') example.r # Example R-script x - c(1:10) y - x^2 png(file=example2.png) #pdf(file=example2.pdf) plot(x,y) graphics.off() example.sh #/bin/bash # # Hello world is written to exhotext every time cron executes this script echo Hello world echotext # This works, but not when executed from cron n=`R --save example.r` # using exec as in `exec R --save example.r` dosent work with cron either # This also works, but nothing is written to the png when executed from cron R --save RSCRIPT x - c(1:10) y - x^2 png(file=example2.png) #pdf(file=example2.pdf) plot(x,y) graphics.off() #dev.off() dosent work at all when executed from cron RSCRIPT The png() device requires an X server for the image rendering. You might be able to get away with exporting the DISPLAY environment variable export DISPLAY=:0.0 # try and connect to X server on display 0.0 within your script, but it will only work if the script is executed by the same user as is running the X server, *and* the X server is running at the time the script is executed. There are a handful of packages that will create a png without the presence of an X server, and I'm partial to Cairo (since I've done some work on it). You can install the latest version like this: install.packages(Cairo,,'http://rforge.net/',type='source') Cairo can also outputs nice pdf's with embedded fonts... useful if you want to embed high-quality OpenType or TrueType fonts. Best, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] Question for install Rapache package.
Hi Charlie, Charlie wrote: Hi, this is Charlie and I am trying to embed R in my apache server. However, I am having problem with installation. The R projet says that we can install add-on package with command $R CMD (rapache.0.1.4.tar.gz). However, I try to use it in command windows (windows xp) and an error shows. Please tell me when I can use the command (in c?? or in the same folder with the file). thx. [[alternative HTML version deleted]] The RApache distribution of software, rapache-0.1.4.tar.gz, is a combination of glue code for embedding R into Apache and a proper R package (RApache) which is installed via R CMD INSTALL. You can find installation instructions right on the project home page: http://biostat.mc.vanderbilt.edu/RApacheProject RApache runs extremely well under Unix-alikes, but as I don't have access to develop on a MS Windows box, your mileage may vary. Best, Jeff --- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] Fractals with R
kone wrote: Hi everybody, I put some R-code to a web page for drawing fractals. See http://fractalswithr.blogspot.com/ If you have some R-code for fractal images, I'm willing to include them to the page. Has somebody tried L-systems or Markov algorithm (http:// en.wikipedia.org/wiki/Markov_algorithm) with R? Here's an interactive example of how to draw pretty pictures with polynomials and other R functions: http://biostat3.mc.vanderbilt.edu/polyart/ ...without the pop-up windows ;) Cheers, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with installation of littler-0.0.10. under Free BSD 6.2
Hello, Dirk Eddelbuettel wrote: On 12 March 2007 at 13:38, ronggui wrote: [...] | MyBSD% make | R_HOME= /usr/local/bin/R --silent --vanilla --slaveautoloads.h | Syntax error: redirection unexpected | *** Error code 2 | | Stop in /home/ronggui/software/littler-0.0.10. | | Anyone knows why and any hints to the solution? Thanks in advance. This is a problem with your make command not expanding '$' . CCan you ruun make -v to tell us what version it is? Thanks, jeff Jeff and I know that the world was created inside a bash shell. And indeed it was! ;) Seriously, can you try running configure inside a shell with working redirects? If you can't then you may need to simulate by hand what this would do, outside of configure, and then run make. Let us know. Dirk | -- | Ronggui Huang | Department of Sociology | Fudan University, Shanghai, China | 黄荣贵 | 复旦大学社会学系 __ 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] gsub: replacing a.*a if no occurence of b in .*
Charilaos Skiadas wrote: On Feb 24, 2007, at 11:37 AM, Gabor Grothendieck wrote: The _question_ assumed that, which is why the answers did too. Oh yes, I totally agree, the file snippet the OP provided did indeed assume that, though nothing in the text of his question did, so I wasn't entirely clear whether the actual file that is going to be processed has this form or not. So I just wanted to make sure the OP is aware of this limitation, in case the actual file is more problematic. But most importantly, I wanted to suggest a reevaluation, if possible, of the process that generates these XML's, and perhaps fixing that, instead of patching the problem after it has been created. Also, I wouldn't tolerate R *crashing* in package code on malformed xml input. Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] write fixed format
YIHSU CHEN wrote: Dear R users; Is there a function in R that I can put text with proper alignments in a fixed format. For instance, if I have three fields: A, B and C, where both A and C are text with 3 characters and left alignment; B is a numeric one with 2 decimals and 3 integer space digits. How can I put the following row in a file? (note there is a space between a and 2, and after b.) (A=aaa, B=23.11 and C=bb) aaa 23.11bb Use sprintf: A=aaa B=23.11 C=bb sprintf(%s %.2f%s,A,B,C) [1] aaa 23.11bb Be sure to read the documentation for sprintf, as you'll want to fully understand left and right adjustment, and field width and precision. Best, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] scripts with littler
John Lawrence Aspden wrote: John Lawrence Aspden wrote: I'm actually tempted to use #!/usr/bin/env r rm(list=ls()) Ahem, it turns out to be better to use: #!/usr/bin/env r rm(list=ls()[ls()!=argv]) Eww!! I'm not sure you want to do that. I would recommend sticking with: #!/usr/bin/r -v as that gives you a truer scripting environment. I understand that won't load the libraries in your home area automatically, but consider the way scripts in other languages are written and distributed: they usually load the libraries at the beginning of the script. Silently loading them before the script is run hides behavior from the script user. If you have libraries installed outside of the library search path, consider expanding it with .libPaths() before calling library() or require(). Cheers, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] littler+dget+stdin - segmentation fault
John Lawrence Aspden wrote: Hi, I'm trying to write a series of pipes using littler, and I get the following behaviour: Sorry if I'm just doing something witless, I'm new to R. I'm using the latest versions from debian testing (2.4.0 and 0.0.8). $ r -e 'a-dget(file=stdin()); print(a)' ?list(a=2) Segmentation fault You've found a bug which has been fixed. Expect a new version 0.0.9 of littler later tonight from here: http://dirk.eddelbuettel.com/code/littler/ and soon after than in debian. What exactly are you trying to accomplish? Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] Help with filled.contour()
Dieter Menne wrote: Michael Kubovy kubovy at virginia.edu writes: I tried and it gave a strange result. See http://people.virginia.edu/~mk9y/mySite/twoGaussian.R and http://people.virginia.edu/~mk9y/mySite/twoGaussian.pdf * Session Info * sessionInfo() R version 2.4.1 (2006-12-18) powerpc-apple-darwin8.8.0 Hmm, strange, I can reproduce your problem on Windows (otherwise same config) with pdf, but it looks beautifully on screen for me if I mentally remove the ugly legend. Try the image function. The smoothness of the plot will be proportional to the length of x and y. For instance 200 isn't bad: mu1 - 0 mu2 - 5 s - 1 x - seq(-2.5, 7.5, length = 200) y - seq(-2.5, 2.5, length = 200) f - function(x,y){ term1 - 1/(2*pi*sqrt(s*s)) term2 - -1/2 term3 - (x - mu1)^2/s term4 - (y - mu1)^2/s term5 - (x - mu2)^2/s term1*(.5 * exp(term2*(term3 + term4)) + .5 * exp(term2*(term5 + term4))) } # setting up the function of the multivariate normal density z - outer(x, y, f) # persp(x, y, z) require(grDevices) #pdf('twoGaussian.pdf') #filled.contour(x, y, z, axes = F, frame.plot = F, asp = 1, # col = gray(seq(0, 0.9, len = 25)), nlevels = 25) image(x,y,z,col=gray(seq(0,0.9,len=200))) Cheers, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] running R without X11
Laurence Darby wrote: Prof Brian Ripley wrote: On Tue, 14 Nov 2006, Laurence Darby wrote: Is there anyway to remove this dependency on X11? Please read the help page. R's png device uses X11 for its fonts. You need fonts from somewhere, and vanilla Unix systems don't come with any other sets. You can use ghostscript or libgdd or other resources for other graphics devices. I normally just use an Xvfb frame buffer (but, hint, it defaults to 12bit and you want a 24bit screen). Thanks for your prompt answer, although getting gs to work the way I want or setting up Xvfb, on top of learning R, is too many hoops to jump through, much more than reproducing a small R script I have in gnuplot. You can also use Simon Urbanek's GDD or Cairo packages, located on CRAN and on www.rosuda.org/R. They both create png's without an X server. Currently, there are issues with GDD: minimal truetype font support, an inability to draw lines thicker than lwd=1, and the worst is it's dependence on the neglected libgd graphics library, but apparently there's been some active development on it. Check www.libgd.org. I'm currently adding truetype font support and some antialiasing properties to the Cairo package, for the sole purpose of creating better graphics for the web. Cairo probably has a longer future as it depends on cairo (www.cairographics.org) which is used in the Firefox browser. Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] get compressed data via a socket connection
Prof Brian Ripley wrote: ?gzcon may help, depending exactly what you mean by `zlib-compressed data'. If not, its code will provide you with a prototype to work on. There are also private entry points in connections.c to (de)compress blocks of data to/from a raw vector which again may be a useful statring point for ideas. There is no public API to the connections code. You might want to look at the proposed R Connections API here: http://wiki.r-project.org/rwiki/doku.php?id=developers:r_connections_api Cheers, Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] R CMD BATCH: unable to start device PNG
[EMAIL PROTECTED] wrote: Dear r-helpers: Any ideas how to avoid problem described below? I am having the same problem when I run R remotly (not from cgi script); somehow png device wants to talk to X11 and X11 complains... Best regards, Ryszard error msg from batch R process (Linux/R-2.4.0) (executed on Apache server from cgi script): Error in X11(paste(png::, filename, sep = ), width, height, pointsize, : unable to start device PNG In addition: Warning message: unable to open connection to X11 display '' Execution halted Here's a snippet from the png help page: 'bitmap' provides an alternative way to generate PNG and JPEG plots that does not depend on accessing the X11 display but does depend on having GhostScript installed. (Device 'GDD' in 'GDD' is another alternative using several other additional pieces of software.) You can find GDD and another alternative Cairo here: http://www.rosuda.org/R Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] littler release 0.0.6
For those of you who are littler fans, you'll be pleased to know that we've already decommissioned version 0.0.6 in light of the new and improved 0.0.7 (actually 0.0.6 was broken because of a missing file). You can get it from the links below. Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner Dirk Eddelbuettel wrote: What ? -- We are pleased to announce version 0.0.6 of littler What's new ? This version includes a bug fix or two as well as a number of small enhancements to the documentation. For OS X and the r/R confusion, our recommended suggestion is to call configure using either the --program-suffix=X or --program-prefix=Y option to have the binary and manual page renamed when 'make install' runs. In this example, r would be renamed to rX and Yr, resptively. Suitable choices of X and Y are left to the user. Where ? --- You can find the source tarball at both http://dirk.eddelbuettel.com/code/littler/ and http://biostat.mc.vanderbilt.edu/LittleR Comments are welcome, as are are suggestions, bug fixes, or patches. - Jeffrey Horner [EMAIL PROTECTED] - Dirk Eddelbuettel [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to dowload mod_R.so
khao_lek wrote: i don't know url address how to dowload mod_R.so for use R and Apache webserver. i'm want to try R on the web. please tell me. Please visit: http://biostat.mc.vanderbilt.edu/RApacheProject to download the latest release, and also read the paper near the end of the page. Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] New project: littler for GNU R
What ? == littler - Provides hash-bang (#!) capability for R (www.r-project.org) Why ? = GNU R, a language and environment for statistical computing and graphics, provides a wonderful system for 'programming with data' as well as interactive exploratory analysis, often involving graphs. Sometimes, however, simple scripts are desired. While GNU R can be used in batch mode, and while so-called 'here' documents can be crafted, a long-standing need for a scripting front-end has often been expressed by the R Community. littler (pronounced 'little R' and written 'r') aims to fill this need. It can be used directly on the command-line just like, say, bc(1): $ echo 'cat(pi^2,\n)' | r 9.869604 Equivalently, commands that are to be evaluated can be given on the command-line $ r -e 'cat(pi^2, \n)' 9.869604 But unlike bc(1), GNU R has a vast number of statistical functions. For example, we can quickly compute a summary() and show a stem-and-leaf plot for file sizes in a given directory via $ ls -l /boot | awk '!/^total/ {print $5}' | \ r -e 'fsizes - as.integer(readLines()); print(summary(fsizes)); stem(fsizes)' Min. 1st Qu. MedianMean 3rd Qu.Max. 13 512 110100 486900 768400 4735000 Loading required package: grDevices The decimal point is 6 digit(s) to the right of the | 0 | 002223 0 | 5557778899 1 | 112233 1 | 5 2 | 2 | 3 | 3 | 4 | 4 | 7 And, last but not least, this (somewhat unwieldy) expression can be stored in a helper script: $ cat examples/fsizes.r #!/usr/bin/env r fsizes - as.integer(readLines()) print(summary(fsizes)) stem(fsizes) (where calling /usr/bin/env is a trick from Python which allows one to forget whether r is installed in /usr/bin/r, /usr/local/bin/r, ~/bin/r, ...) A few examples are provided in the source directories examples/ and tests/. Where ? === littler can either be downloaded from http://biostat.mc.vanderbilt.edu/LittleR accessed by anonymous SVN: $ svn co http://littler.googlecode.com/svn/trunk/ littler or (soon !) be gotten from Debian mirrors via $ agt-get install littler littler is known to build and run on Linux and OS X. Who ? = Copyright (C) 2006 Jeffrey Horner and Dirk Eddelbuettel littler is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Comments are welcome, as are are suggestions, bug fixes, or patches. - Jeffrey Horner [EMAIL PROTECTED] - Dirk Eddelbuettel [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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] New project: littler for GNU R
Seth Falcon wrote: Wow, looks neat. OS X users will be unhappy with your naming choice as the default filesystem there is not case-sensitive :-( IOW, r and R do the same thing. I would expect it to otherwise work on OS X so a change of some sort might be worthwhile. (I'm always amazed at how I can miss the simplest details. I probably knew at some point that OS X shipped with a case-sensitive file system, which you can turn off somehow, but forgot. Thank goodness for peer review.) littler will install into /usr/local/bin by default, so I don't think there's a clash with the Mac binary provided by CRAN, right? Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] New project: littler for GNU R
Duncan Murdoch wrote: On 9/26/2006 1:04 PM, Jeffrey Horner wrote: [...] It can be used directly on the command-line just like, say, bc(1): $ echo 'cat(pi^2,\n)' | r 9.869604 Is there a technical reason that this couldn't work by modifying the script that invokes R? That would avoid the r/R clash on MacOSX and Windows. In Windows R is R.exe, not a script, so some adjustment would be needed there, but that shouldn't be difficult. In fact, it does work: $ echo 'cat(pi^2,\n)' | R --vanilla --slave 9.869604 but what's more compelling is the ability to utilize the UNIX hash-bang mechanism. Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] New project: littler for GNU R
Seth Falcon wrote: Jeffrey Horner [EMAIL PROTECTED] writes: [...] littler will install into /usr/local/bin by default, so I don't think there's a clash with the Mac binary provided by CRAN, right? It depends what you mean by clash :-) If both are on the PATH, then you get the first one, I suspect, when running either 'R' or 'r'. I haven't tested this bit yet, but on my OS X laptop I can invoke a new R session using either 'R' or 'r' (using an R built from source, not the R GUI app thingie). Good point, but the executable path can be named absolutely in hash-bang scripts. Relative paths work as well with the use of '/usr/bin/env program' as is described in the littler announcement, but then you don't get to pass arguments to 'program', just to the hash-bang script. So IMO, a different name or an integration into the R script in some way would be a big improvement. But I'd like to know why there's an R script in the first place. Why not just an executable as on windows? 'r' is cute, but going down the road of tools with the same name except for caps leads to confusion (for me). For example, R CMD build/INSTALL still catches me up after a number of years. That's a different problem than case-sensitivity. The word 'build' must have had a different semantic than INSTALL, and I'm not sure why one was all caps and the other isn't. Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] Creating Movies with R
If you run R on Linux, then you can run the ImageMagick command called convert. I place this in an R function to use a sequence of PNG plots as movie frames: make.mov.plotcol3d - function(){ unlink(plotcol3d.mpg) system(convert -delay 10 plotcol3d*.png plotcol3d.mpg) } Examples can be seen here: http://biostat.mc.vanderbilt.edu/JrhRgbColorSpace Look for the 'Download Movie' links. Cheers, Jeff Lorenzo Isella wrote: Dear All, I'd like to know if it is possible to create animations with R. To be specific, I attach a code I am using for my research to plot some analytical results in 3D using the lattice package. It is not necessary to go through the code. Simply, it plots some 3D density profiles at two different times selected by the user. I wonder if it is possible to use the data generated for different times to create something like an .avi file. Here is the script: rm(list=ls()) library(lattice) # I start defining the analytical functions needed to get the density as a function of time expect_position - function(t,lam1,lam2,pos_ini,vel_ini) {1/(lam1-lam2)*(lam1*exp(lam2*t)-lam2*exp(lam1*t))*pos_ini+ 1/(lam1-lam2)*(exp(lam1*t)-exp(lam2*t))*vel_ini } sigma_pos-function(t,q,lam1,lam2) { q/(lam1-lam2)^2*( (exp(2*lam1*t)-1)/(2*lam1)-2/(lam1+lam2)*(exp(lam1*t+lam2*t)-1) + (exp(2*lam2*t)-1)/(2*lam2) ) } rho_x-function(x,expect_position,sigma_pos) { 1/sqrt(2*pi*sigma_pos)*exp(-1/2*(x-expect_position)^2/sigma_pos) } Now the physical parameters tau-0.1 beta-1/tau St-tau ### since I am in dimensionless units and tau is already in units of 1/|alpha| D=2e-2 q-2*beta^2*D ### Now the grid in space and time time-5 # time extent tsteps-501 # time steps newtime-seq(0,time,len=tsteps) Now the things specific for the dynamics along x lam1- -beta/2*(1+sqrt(1+4*St)) lam2- -beta/2*(1-sqrt(1+4*St)) xmin- -0.5 xmax-0.5 x0-0.1 vx0-x0 nx-101 ## grid intervals along x newx-seq(xmin,xmax,len=nx) # grid along x # M1 - do.call(g, c(list(x = newx), mypar)) mypar-c(q,lam1,lam2) sig_xx-do.call(sigma_pos,c(list(t=newtime),mypar)) mypar-c(lam1,lam2,x0,vx0) exp_x-do.call(expect_position,c(list(t=newtime),mypar)) #rho_x-function(x,expect_position,sigma_pos) #NB: at t=0, the density blows up, since I have a delta as the initial state! # At any t0, instead, the result is finite. #for this reason I now redefine time by getting rid of the istant t=0 to work out # the density rho_x_t-matrix(ncol=nx,nrow=tsteps-1) for (i in 2:tsteps) {mypar-c(exp_x[i],sig_xx[i]) myrho_x-do.call(rho_x,c(list(x=newx),mypar)) rho_x_t[ i-1, ]-myrho_x } ### Now I also define a scaled density rho_x_t_scaled-matrix(ncol=nx,nrow=tsteps-1) for (i in 2:tsteps) {mypar-c(exp_x[i],sig_xx[i]) myrho_x-do.call(rho_x,c(list(x=newx),mypar)) rho_x_t_scaled[ i-1, ]-myrho_x/max(myrho_x) } ###Now I deal with the dynamics along y lam1- -beta/2*(1+sqrt(1-4*St)) lam2- -beta/2*(1-sqrt(1-4*St)) ymin- 0 ymax- 1 y0-ymax vy0- -y0 mypar-c(q,lam1,lam2) sig_yy-do.call(sigma_pos,c(list(t=newtime),mypar)) mypar-c(lam1,lam2,y0,vy0) exp_y-do.call(expect_position,c(list(t=newtime),mypar)) # now I introduce the function giving the density along y: this has to include the BC of zero # density at wall rho_y-function(y,expect_position,sigma_pos) { 1/sqrt(2*pi*sigma_pos)*exp(-1/2*(y-expect_position)^2/sigma_pos)- 1/sqrt(2*pi*sigma_pos)*exp(-1/2*(y+expect_position)^2/sigma_pos) } newy-seq(ymin,ymax,len=nx) # grid along y with the same # of points as the one along x rho_y_t-matrix(ncol=nx,nrow=tsteps-1) for (i in 2:tsteps) {mypar-c(exp_y[i],sig_yy[i]) myrho_y-do.call(rho_y,c(list(y=newy),mypar)) rho_y_t[ i-1, ]-myrho_y } rho_y_t_scaled-matrix(ncol=nx,nrow=tsteps-1) for (i in 2:tsteps) {mypar-c(exp_y[i],sig_yy[i]) myrho_y-do.call(rho_y,c(list(y=newy),mypar)) rho_y_t_scaled[ i-1, ]-myrho_y/max(myrho_y) } # The following 2 plots are an example of the plots I'd like to use to make an animation g - expand.grid(x = newx, y = newy) instant-100 mydens-rho_x_t[ instant, ]%o%rho_y_t[ instant, ]/(max(rho_x_t[ instant, ]%o%rho_y_t[ instant, ])) lentot-nx^2 dim(mydens)-c(lentot,1) g$z-mydens jpeg(dens-t-3.jpeg) print(wireframe(z ~ x * y, g, drape = TRUE,shade=TRUE, scales = list(arrows = FALSE),pretty=FALSE, aspect = c(1,1), colorkey = TRUE ,zoom=0.8, main=expression(Density at t=2), zlab = list(expression(density),rot = 90),distance=0.0, perspective=TRUE,#screen = list(z = 150, x = -55,y= 0) ,zlim=range(c(0,1 dev.off() instant-300 mydens-rho_x_t[ instant, ]%o%rho_y_t[ instant, ]/(max(rho_x_t[ instant, ]%o%rho_y_t[ instant, ])) lentot-nx^2 dim(mydens)-c(lentot,1) g$z-mydens jpeg(dens-t-3.jpeg) print(wireframe(z ~ x * y, g, drape = TRUE,shade=TRUE, scales = list(arrows = FALSE),pretty=FALSE, aspect = c(1,1), colorkey = TRUE ,zoom=0.8, main=expression(Density
Re: [R] remotely saving an R session
Gamal Azim wrote: Is it possible to remotely save an R session then terminate R? Of course the destructive task after 'then' is rather straightforward by itself. Yes. Sending the process a SIGUSR1 signal: $ kill -USR1 pid will save the global environment in the file .RData, but you'll need to remember the current working directory of the process to find it. Good luck! Jeff -- http://biostat.mc.vanderbilt.edu/JeffreyHorner __ 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] graphic output file format
Luiz Rodrigo Tozzi wrote: Hi I had some problems using GDD, especially with colors and with some advanced plottings. In my case I didnt try the Cairo, I just got back to the png() using Xvfb (its almost 3 or 4 times slower than my first tries qith GDD, but using GDD would cause me to rewirte some parts of my script) Since my Xvfb came back to normal in cron mode, I didnt use the Cairo, but mr urbanek really suggested it to me. I've had a little experience with both GDD and Cairo: GDD has served my needs well when drawing thin lines and pixels, although, the current implementation has problems with the background color and the line width (lwd) not being honored. I've hacked around a bit, and I can now set the background correctly, but I need to clean up the patch to submit to Simon. Also, libgdd rasterizes pngs very well. If you're interested in examples, check out the png images here: http://biostat.mc.vanderbilt.edu/DiffGraphics For the same needs, Cairo does very poorly rasterizing for fine pixel detail; it's not so much libcairo's fault as much as the package Cairo not being able to handle this, if it can at all. A better explanation of this issue is here: http://cairographics.org/FAQ. Read the first question: Why does my 1-pixel wide horizontal/vertical line come out fat and blurry (eg. 2 pixels wide and half-intensity)? I'm not sure why you're having trouble with colors in GDD; I've never run into this issue. I dont know if you have something similar to Xvfb in Mac OSX Tozzi 2006/8/10, [EMAIL PROTECTED] [EMAIL PROTECTED]: I received the following communication from the package maintainer for GDD (Simon Urbanek) when I was having compile problems on linux... gd.x86_642.0.28-4.4E.1 installed Matched from: ^^ +--- your GD is too old. You'll need at least gd-2.0.29 (see README in GDD) and 2.0.33 is recommended. You may want to try Cairo (see the nightly page) instead of GDD, because cairographics has some features that GD is lacking and it is actively maintained (unfortunately libgd is pretty much dead). Cheers, Simon Disclaimer: I actually cannot get the Cairo to work either! Eric On Thu, 10 Aug 2006 19:00:08 +0200, Stefan Grosse [EMAIL PROTECTED] said: Please mail always also to the list, since it may be that there is someone who could reply better and/or faster. [Case in point.] Especially in this case since I am only experienced in M$ Windows and Linux so I am unable to guess whats wrong with OSX. does not even the postscript device work? With postscript I get the best quality for printing. e.g.: postscript(test.eps, width = 8.0, height = 6.0, horizontal = FALSE, onefile =FALSE, paper = special) curve(x^2) dev.off() Conan Phelan schrieb: Thanks for the feedback and link Stefan, Perhaps if I provide a little more background. (Pls forgive both my ignorance and my long windedness.) I am on Mac OSX and am only able to load the Quartz graphic device (is that normal?). From quartz, I've only been able to generate pdf files, which do not match the quartz display to my satisfaction. I've been attempting to find a way to generate other output files for comparison. (I've managed to generate a bmp file that looked awful, after acquiring Gostscript). Anyway, I figure R must able to produce high quality graphic outputs, so I'm trying different things. To this end I was hoping that the GDD package would allow me to load the x11 module but it seems to be a no-go (is there some system requirement I'm missing?). Conan -- Jeffrey Horner Computer Systems Analyst School of Medicine 615-322-8606 Department of Biostatistics Vanderbilt University __ 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] RODBC on linux
Armstrong, Whit wrote: Thanks, everyone. I'll give freeTDS a try. One final hitch to be aware of when using FreeTDS: MS SQL Server authenticates db connections in two different ways (well actually three, but it's just the combination of 1 and 2): 1) Sql server authenticates the connection, meaning you must have an SQL server account. FreeTDS will handle this fine. 2) the SQL server OS authenticates the connection with an NT Domain login. That's the domain\username you use to login to your Windows machine. FreeTDS will ONLY handle this over TCP/IP, not over DCE/RPC, so be aware. More info here: http://www.freetds.org/userguide/domains.htm and here: http://www.freetds.org/userguide/troubleshooting.htm Jeff -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Thursday, July 27, 2006 1:17 AM To: Marc Schwartz Cc: Armstrong, Whit; r-help@stat.math.ethz.ch Subject: Re: [R] RODBC on linux On Wed, 26 Jul 2006, Marc Schwartz wrote: On Wed, 2006-07-26 at 17:52 -0400, Armstrong, Whit wrote: Anyone out there using Linux RODBC and unixODBC to connect to a Microsoft SQL server? If possible can someone post a sample .odbc.ini file? I saw a few discussions on the archives a few years ago, but no config file details were available. Thanks, Whit Whit, Do you have a Linux ODBC driver for SQL Server? unixODBC is simply the driver manager, not the driver itself. MS does not offer (not surprisingly) an ODBC driver for Unix/Linux. There are resources available however and these might be helpful: http://www.sommarskog.se/mssql/unix.html Note that Easysoft provides (at a cost) an ODBC-ODBC bridge for Unix/Linux platforms which supports ODBC connections to SQL Server: http://www.easysoft.com/products/data_access/odbc_odbc_bridge/index.ht ml Several people have successfully used that, from the earliest days of RODBC: I believe it was part of Michael Lapsley's motivation to write RODBC. __ 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-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] useR! Thanks
Achim Zeileis wrote: [...] The plan is to provide the original presentation slides of the panelists and a video of the whole panel disc, and probably some minutes and/or further information. Did you happen to video Ivan Mizera's talk as well? I'd really like to see that again! -- Jeffrey Horner Computer Systems Analyst School of Medicine 615-322-8606 Department of Biostatistics Vanderbilt University __ 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 ViM
Bill West wrote: Yes, my r.vim ftplugin file is a windows only solution. It is not yet at the point, however, where it may be called a solution. :) It currently only handles single lines of code. I posted it before only as a proof of concept. I should have been clearer in my earier post. For my Linux computer I have been successfully using the R.vim script by Johannes Ranke found in the vim scripts: http://www.vim.org/scripts/script.php?script_id=1048 This also uses Perl, but depends on IO::Pty, which (although I am no expert) I do not believe is available for Windows. --Bill I've been following this thread with some interest as I use both R and VIM, but I just want to point out that we have come full circle by *not* answering the original thread creator's question: https://stat.ethz.ch/pipermail/r-help/2006-April/092554.html My question now is, whether there are already people out there knowing how to do this in a similar easy way as with Emacs, and if those would be willing to share this knowledge. I did already research on the web on this topic, but i couldn't find satisfying answers, except one good looking approach on the ViM-website with a perl-script called funnel.pl, which I couldn't make running on my mac OSX 10.3.9 so far. So this last post suggests that the VIM script (id 1048) is useful (which it is), but in fact the original thread creator already stated that it doesn't work for his platform. The real answer is: there's probably no current 'similar way as with Emacs [and ESS]' to integrate R and VIM on mac OSX 10.3.9, but I bet you might find a better answer on the R-SIG-Mac email list here: https://stat.ethz.ch/mailman/listinfo/r-sig-mac So I hope this helps, Michael. ... I point all this out to illuminate how hard it is to both convey a message in email and also to interpret a message in email, to the point that responses to questions on this list can really wander off on tangents (which is not necessarily a bad thing; I had no clue the R.vim script existed for Linux). I personally find benefit in reading both the R-help and R-devel mailing lists, and I commend and am thankful for all those email authors who convey their message in email with sincerity, honesty, etc. There was a recent Wired article here: http://www.wired.com/news/technology/0,70179-0.html that cited a Journal of Personality and Social Psychology paper titled Egocentrism over e-mail: Can we communicate as well as we think?: http://content.apa.org/journals/psp/89/6 which essentially points out the fact that determining the tone of an author's email is no better than chance, which I believe can lead to misinterpretation of message and meaning, and especially when authors use negative messages like RTFM (google it; you'll figure it out quickly). -- Jeffrey Horner Computer Systems Analyst School of Medicine 615-322-8606 Department of Biostatistics Vanderbilt University __ 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] using GDD fonts
Luiz Rodrigo Tozzi wrote: Hi Tim, It really worked!! thanks! now my only problem is about the image size, that is huge! im using the type=png and switching to png8 does not reduce the color depth.. do you know something about is? I've hacked around on the GDD code before. From what I remember, all png files are created in true color. 2006/4/12, Tim Churches [EMAIL PROTECTED]: Luiz Rodrigo Tozzi wrote: Hi I was searching for some X replacement for my job in R and i found the GDD I installed it and I match all the system requirements. My problem (maybe a dumb one) is that every plot comes with no font and i cant find a simgle example of a plot WITH FONT DETAIL in the list can anybody help me? a simple example: library(GDD) GDD(something.png, type=png, width = 700, height = 500) par(cex.axis=0.65,lab=c(12,12,0),mar=c(2.5, 2.5, 2.5, 2.5)) plot(rnorm(100)) mtext(Something,side=3,padj=-0.33,cex=1) dev.off() thanks in advance! This might help - we found that we needed to install the MS TT fonts and make sure that GDD can find them, as per the README. : Simon Urbanek [EMAIL PROTECTED] wrote: Tim, On Jun 9, 2005, at 3:51 AM, Tim CHURCHES wrote: I tried GDD 0.1-7 with Lattice graphs in R 2.1.0 (on Linux). It doesn't segfault now but it is still not producing any usable output - the output png file is produced but nly with a few lines on it. Still the alpha channel problem? Have you been able to produce any Lattice graphs with it? I know of no such problem, I tested a few lattice graphics and they worked. Can you, please, send me reproducible example and your output? Also send me, please output of library(GDD) .Call(gdd_look_up_font, NULL) Sorry, my laziness. GDD was unable to find any fonts. After I installed the MS TT fonts and set their location as per the GDD README, it worked perfectly with both old-style R graphics and lattice graphics. The output looks very nice indeed. We'll do a bit more testing (and let you know if we find any problems), but it looks like we can at last drop the requirement for Xvfb when using R in a Web application. Great work! From our point of view, GDD solves one the biggest problem with R for Web applications. Cheers, Tim C -- Luiz Rodrigo Lins Tozzi [EMAIL PROTECTED] (21)91318150 http://luizrodrigotozzi.multiply.com/ http://www.flogao.com.br/luizrodrigotozzi __ 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 -- Jeffrey Horner Computer Systems Analyst School of Medicine 615-322-8606 Department of Biostatistics Vanderbilt University __ 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] RMySQL's column limit
Mark Van De Vyver wrote: My apologies, I'm using R v2.2.1 via the JGR Editor GUI, RMySQL v0.5.7 under windows XP with latest patches. MySQL is server version: 4.1.12 I'm pretty sure it's running on a linux box. It turns out that this may be a MySQL limit: http://bugs.mysql.com/bug.php?id=4117 The dimension of template is 2000, I know the error kicks in at 3000, but haven't iterated to find the exact point - if it would help I can do this. Regards Mark On 3/24/06, David James [EMAIL PROTECTED] wrote: Hi, Mark Van De Vyver wrote: Dear R-users, First, thank you to the developers for the very useful R-library RMySQL. While using this library a recieved an error message: RS-DBI driver: (could not run statement: Too many columns) The statement that generated the error was: dbWriteTable(dbcon, simdataseries, template, overwrite = TRUE, row.names = FALSE ) I am assuming this is a RMySQL rather than MySQL limit. We need more information, e.g., what's dim(template), what version of MySQL you're using, etc. If that is the case I was wondering just what this limit is and if it is possible to raise it? Thanks again for all the hard work. Sincerely Mark -- Mark Van De Vyver, PhD -- My research is available from my SSRN Author page: http://ssrn.com/author=36577 -- Finance Discipline School of Business The University of Sydney Sydney NSW 2006 Australia Telephone: +61 2 9351-6452 Fax: +61 2 9351-6461 -- Mark Van De Vyver, PhD -- My research is available from my SSRN Author page: http://ssrn.com/author=36577 -- Finance Discipline School of Business The University of Sydney Sydney NSW 2006 Australia Telephone: +61 2 9351-6452 Fax: +61 2 9351-6461 __ 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 -- David -- Mark Van De Vyver, PhD -- My research is available from my SSRN Author page: http://ssrn.com/author=36577 -- Finance Discipline School of Business The University of Sydney Sydney NSW 2006 Australia Telephone: +61 2 9351-6452 Fax: +61 2 9351-6461 __ 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 -- Jeffrey Horner Computer Systems Analyst School of Medicine 615-322-8606 Department of Biostatistics Vanderbilt University __ 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] extracting RGB values from a colorspace class object
Dylan Beaudette wrote: Greetings, After pouring over the documentation for the 'colorspace' package, I have not been able to figure out how the plot() method converts colorspace coordinates to RGB values for display on the screen. I am convert between colorspaces with the various as() methods... but cannot seem to find a way to extract RGB (i.e. for displaying on a computer screen) triplets from color space coordinates. I don't know how it's done (I get really confused when trying to understand color spaces), but you'll have to download the code for the colorspace package and study the c code since that's where the conversion is done. To get the RGB and hex triplets, this small example should help: ## Generate white in XYZ space white = XYZ(95.047, 100.000, 108.883) as(white,RGB) R GB [1,] 1.08 0.907 1.81 hex(white) [1] #FF Here is a sample of the data that I am working with: H V C x y Y 2.5Y0.2 2 1.43 0.97 0.237 2.5Y0.4 2 0.729 0.588 0.467 2.5Y0.6 2 0.563 0.491 0.699 2.5Y0.6 4 0.995 0.734 0.699 2.5Y0.8 2 0.479 0.439 0.943 2.5Y0.8 4 0.82 0.64 0.943 2.5Y 1 20.43620.4177 1.21 I have converted xyY coordinates to XYZ coordinates, based on the equations presented here: http://www.brucelindbloom.com/index.html?ColorCalcHelp.html #read in the soil colors: munsell + xyY soil - read.table(soil_colors, header=F, col.names=c(H,V,C,x,y,Y)) #convert to XYZ X - (soil$x * soil$Y ) / soil$y Y - soil$Y Z - ( (1- soil$x - soil$y) * soil$Y ) / soil$y #make an XYZ colorspace object: require(colorspace) soil_XYZ - XYZ(X,Y,Z) #visualize the new XYZ colorspace object in the L*U*V colorspace: plot(as(soil_XYZ, LUV), cex=2) here is an example of the output: http://169.237.35.250/~dylan/temp/soil_colors-LUV_space.png Somehow the plot() method in the colorspace package is converting color space coordinates to their RGB values... Does anyone have an idea as to how to access these RGB triplets? Thanks in advance! -- Jeffrey Horner Computer Systems Analyst School of Medicine 615-322-8606 Department of Biostatistics Vanderbilt University __ 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] Command-line editing history
John McHenry wrote: Hi all, Are there any plans to add more functionality to command-line editing and history editing on the command line? Presuming you're running R from a Unix console (I'm unsure of the windows port, maybe?), it is sufficient, insofar as how well you like the GNU readline library and if it's been compiled into R: http://cnswww.cns.cwru.edu/php/chet/readline/rluserman.html I can even use VI style key bindings to work with historical commands: Typing K recalls previous commands, J goes forward through the commands. I can even search through the commands. Auto completion of function names doesn't work but file names do. One point that was a bit of work for me to set up was automatically saving history. In order to do this, you must first set the environment variable R_HISTFILE to the location of your saved history file. Then, at the end of your R session, you can run: savehistory(Sys.getenv(R_HISTFILE) Or better yet, put the following in your .Rprofile: .Last - function() savehistory(Sys.getenv(R_HISTFILE)) In MATLAB (I know, comparisons are odious ...), you can type p and up-arrow on the command line and scroll through the recently entered commands beginning with p. This is a very useful feature and something that I believe is not replicated in R. Please correct me if I'm wrong; currently I use history(Inf) in R, search for what I want and cut and paste if I find what I'm looking for. Also in MATLAB, tab completion is available for directory listings and also for function name completion. Again, I'm unaware of how to do this in R. The added MATLAB functionality makes finding files easy on the command line and it also saves the fingers on long function names. Thanks, Jack. - [[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 -- Jeffrey Horner Computer Systems Analyst School of Medicine 615-322-8606 Department of Biostatistics Vanderbilt University __ 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] Infinite loop running Mod_R/Rapache
BJ wrote: I installed mod_r according to the specifications, and have been trying to get the demo script to work correctly. I am running debian, the latest build of R, apache 2 with prefork mpm, and the latest mod_r. Is anyone else using this module successfully? I added: LoadModule R_module mod_R.so Location /test/hello SetHandler r-handler Rsource /var/www/html/test.R RreqHandler handler /Location to my http.conf and test.R in /var/www/html is: handler-function(r){ apache.write(r,h1Hello World!/h1) OK } When I start apache2, my /tmp directory fills with rtmp directories until memory is exausted. The first time it created 32,000 before I noticed. Does anyone have any idea as to what I could be doing wrong, or have a software configuration that works? Thank you for all of your help. ~BJ This is definitely an apache configuration problem. After responding to you privately about this issue, I got paranoid and checked the latest R/Apache code release (rapache-0.1.1) with the following debian packages: apache2-common/unstable uptodate 2.0.55-4 apache2-utils/unstable uptodate 2.0.55-4 apache2-mpm-prefork/unstable uptodate 2.0.55-4 apache2-prefork-dev/unstable uptodate 2.0.55-4 I could not reproduce the behavior you are witnessing. Maybe you can send me (off-list) your /etc/apache2/apache2.conf, /etc/apache2/sites-enabled/* and see if I can't help you troubleshoot. But this bit of R creating a temp dir (for transient files?) needs to be handled more delicately in a server environment. I'm going to do some more digging in the R source... I hope I haven't made some glaringly wrong assumptions. -- Jeffrey Horner Computer Systems Analyst School of Medicine 615-322-8606 Department of Biostatistics Vanderbilt University __ 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] [R-pkgs] [ANNOUNCE] mod_R: The R/Apache Integration Project
What is it? --- mod_R is a project dedicated to embedding the R interpreter inside the Apache 2.0 (and beyond) web server for the purpose of writing web applications in R. It's composed of three parts: mod_R: the Apache 2.0 module that implements the glue to load the R interpreter. RApache: the R package that provides the API for programming web applications in R. libapreq 2.0.4: an Apache sponsored project for parsing request input. If you don't want to compile and install this version, then you can specify which libapreq2 library to use during configuration. The Latest Version -- Details of the latest version can be found at the mod_R project page: http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/ApacheRproject (mind the wrap) Prerequisites - This release has been tested under Debian Linux with Apache 2.0.54, R 2.1.1, and libapreq 2.0.4. Apache2 _MUST_ be compiled with the prefork MPM to compile mod_R. Also, R must have been compiled with the --enable-R-shlib configure flag. Installation The following is the preferred way to compile and install mod_R: $ ./configure --with-apache2-apxs=/path/to/apxs --with-R=/path/to/R $ make $ make install Both --with-apache2-apxs and --with-R _MUST_ be specified. Otherwise, trying to figure out the dependencies between the sources and headers and library paths becomes quite complex. If you don't want to compile and install the bundled libapreq2 version, then add --with-apreq2-config=/path/to/apreq2-config. The version _MUST_ be equal to or greater than 2.0.4. Configuration - In order to use mod_R and RApache, you must configure apache to find it. Type help(directives,package=RApache) once mod_R is installed for a little more detail. Add something similar to this to the apache config file: LoadModule R_Module /path/to/mod_R.so Location /URL SetHandler r-handler Rsource /path/to/R/code.R RreqHandler function-name Rlibrary library-name /Location Also, libR.so _MUST_ be found in the shared library path as it is linked to by mod_R, RApache and the rest of the packages containing shared libraries. You can either set LD_LIBRARY_PATH like this: $ export LD_LIBRARY_PATH=`/path/to/R RHOME`/lib or add that path to /etc/ld.so.conf and then run ldconfig. NOTE: the latest apache2 debian packages cause the web server to run in a very reduced environment, thus one is unable to set LD_LIBRARY_PATH before calling /etc/init.d/apache2. One option is to actually edit that file and add the LD_LIBRARY_PATH explicitly. Another is to use the apache2ctl scripts which are also bundled with the debian packages. Or you can add it to /etc/ld.so.conf. Documentation - All of the documentation is currently in the RApache package. Once you install mod_R, start R and load the RApache package. You'll get a warning that you're currently not running the R interpreter within Apache; just don't try to run any of the code. Sample session: library(RApache) Warning message: RApache is only useful within the Apache web server. It is loaded now for informational purposes only in: firstlib(which.lib.loc, package) help(package=RApache) Information on package 'RApache' Description: Package: RApache Version: 0.1-0 Date: 2005-08-02 Title: An R interface to the Apache 2.0 web server Author:Jeffrey Horner Maintainer:Jeffrey Horner [EMAIL PROTECTED] License: Apache License, Version 2.0 Description: RApache allows web applications to be written in R and executed within the Apache 2.0 web server. Built: R 2.1.0; i386-pc-linux-gnu; 2005-08-02 01:06:26; unix Index: IO IO in RApache apache.add_cookie Adding Cookies to Outgoing Headers apache.add_header Adding HTTP headers apache.allow_methodsRApache Methods apache.log_errorLogging Errors to the Apache error log apache.set_content_type Setting the Content Type header apr_table Structure of the apr_table type in RApache as.html Converting RApache objects to HTML directives RApache directives used in Apace config file intro Introduction to RApache request_rec Structure of the RApache request record return_codesRApache handler return codes Licensing - Please see the file called LICENSE. -- Jeffrey Horner Computer Systems Analyst School of Medicine 615-322-8606 Department of Biostatistics Vanderbilt University ___ R-packages
[R] Multiple assignments in one statement
Is this possible? For instance, I have a function that returns a vector length 3. In one statement I'd like to assign each element of the vector to different variables. Syntactically, I hoped this would work: c(x,y,z) - myfun(); Thanks, -- Jeffrey Horner Computer Systems Analyst School of Medicine 615-322-8606 Department of Biostatistics Vanderbilt University __ 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] Rinternals.h and iostream don't play nice together'
Faheem Mitha wrote: On Sun, 30 Jan 2005, Paul Roebuck wrote: and if you use the following instead of Rinternals.h? extern C { #include Rdefines.h } Still the same errors. As Dirk pointed out, putting iostream first makes the errors go away in either case. You have to define R_NO_REMAP in your code before you include Rinternals.h, as the Writing R Extensions manual states. If not, Rinternals.h will define the length macro (and others...) which is defined somewhere within iostream or included from iostream. I caught this in the 7th line of error output: $ g++ -I/usr/local/lib/R/include -g -c foo.cc In file included from /usr/include/c++/3.3/bits/locale_facets.h:528, from /usr/include/c++/3.3/bits/basic_ios.h:44, from /usr/include/c++/3.3/ios:51, from /usr/include/c++/3.3/ostream:45, from /usr/include/c++/3.3/iostream:45, from foo.cc:3: /usr/include/c++/3.3/bits/codecvt.h:110:52: macro length passed 4 arguments, but takes just 1 ... It's good to read error messages. Cheers, -- Jeffrey Horner Computer Systems Analyst School of Medicine 615-322-8606 Department of Biostatistics Vanderbilt University __ 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