Re: [R] decimal values
?format elyakhlifi mustapha wrote: hello, how can I do to drop decimal after the comma please for example for tthis line print(P) [1] 62.00 1.00 7.661290 5.20 17.10 2.318801 how canI do to keep only 62 1 7.66 5.2 17.12.32 thanks __ ble contre les messages non sollicités [[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 and provide commented, minimal, self-contained, reproducible code. -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] Hardware for a new Workstation for best performance using R
For any kind of R plots that need to be inserted in office documents either on Windows OR on Linux you will always achieve the best result by using the postscript device, then converting *.ps to *.eps and inserting *.eps into Office (OpenOffice as well). *.eps files contain previews for you to edit the documents on screen, but the final output can be done using Print to file using a Postscript driver and converting to PDF -- this will ensure all your R-graphics, but also ALL of your vector illustrations, to be displayed in high quality vector manner. In fact this is about the only way to put high quality plots into presentations or word processing documents (ANY, MSOffice included). In general it works easier on Linux because you will have all tools in the repository and for free. On Windows you will probably end up using Distiller, which costs quite a lot or FreePdfXP if it still exists and works correctly. There is only one place where Windows, or for that sake Mac, scores better, and yet not ultimately: if you want to draw or design vector illustrations then you have larger selection of tools on Windows (Corel, Illustrator, Xara etc), on Mac - Illustrator and on Linux - InkScape (recommnded) and Xara. Now if you go this way, the workflow looks like: postscript(fig1.ps, width=5,height=5) plot(x~y) dev.off() q() $ ps2eps --ignoreBB --gsbbox -r 300 -R + -f fig1.ps # 300dpi thumbnail $ ooffice - import eps file, you will see the same as usual hi-res preview - Print, print to file, on request Reduce Transparency - YES $ ps2pdf13 mydoc.ps result: mydoc.pdf For presentations simply use US Letter landscape instead of A4 for paper size and printing (to file) and this will nicely fit into the screen with minimal loss of space. If the question is in the impossibility to do things on Linux: Windows will not help you to do the above -- there are no tools. You may find another solution, but for the quality of output the above is the best. Other formats, like WMF, EMF, AI, CDR are either of no good use for anything (the first 2) or are incompatible with Office (AI, CDR). Moreover, using InkScape and RSvgDevice you can create SVG plots to which you can add whatever illustrations you want just in the same document because SVG is native for InkScape. Oleg PS. If you want to see examples of how such plots and illustrations look like (created fully on Linux with the above workflow, drop me a line, I will send a PDF). Dalphin, Mark wrote: On Mon, 19 Mar 2007, Thomas Lumley wrote: On 3/19/07, Thomas Lumley [EMAIL PROTECTED] wrote: On Thu, 15 Mar 2007, Andrew Perrin wrote: (in part) 2.) Yes, by all means you should use linux instead of windows. The graphics output is completely compatible with whatever applications you want to paste them into on Windows. This turns out not to be the case. It is not trivial to produce good graphics off Windows for adding to Microsoft Office documents (regrettably an important case for many people). There has been much discussion of this on the R-sig-mac mailing list, for example, where PNG bitmaps (at sufficiently high resolution) seem to be the preferred method. On Windows one can produce metafile output directly from R. Yes, indeed. However, this fact is of limited help when working on another operating system, which was the focus of the original question. -thomas One solution which has not been covered here is to use both operating systems. For example, I need to present in Powerpoint, yet my work is done under Linux where I have substantially more RAM and CPU power. Typically, I'll run my analysis under Linux and then take advantage of the binary compatibility of the .RData file and move my final values from Linux to Windows via Samba; I may delete large intermediate results before the transfer to compendate for my lack of RAM under Windows. Some small scripts which may have been developed under Linux are used to create the plots which are placed in my Powerpoint presentations. By an large, the plots developed under Linux drop right into the Windows presentations, although there are occasional font size difficulties that require adjustments. Mark Dalphin -- Mark Dalphin Dept Comp Biol, M/S AW2/D3262 Amgen, Inc. 1201 Amgen Court W Seattle, WA 98119 __ 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. -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 __ 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] reading BMP into R
Try EBImage from Bioconductor.org Best, Oleg Milton Cezar Ribeiro wrote: Hi R-gurus How can I read my bmp files into R? Kind regards, miltinho Brazil __ [[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 and provide commented, minimal, self-contained, reproducible code. -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] Passing command line parameters to a script
#!/bin/sh echo 'a=${1}; b=${2}; source(myRcodeUsing_a_and_b.R); ' | R --vanilla --quiet and you can run this from shell like: ./callR valueOfa valueOfb Best, Oleg akintayo holder wrote: Hi, Does any one know if it is possible to create an R script that can use command line parameters. I can execute an R script from the command line, but I cannot figure out how to pass parameters to the script. The only resources I have found seem somewhat involved or incomplete. Any help is appreciated. Akintayo [[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 and provide commented, minimal, self-contained, reproducible code. -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 __ 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] Wrinting integers in a matrix faile
write.matrix(as.integer(b),'data.out') Mohsen Jafarikia wrote: Hello everyone, I am using the following program to get the p-value of some numbers (column 'LR' of the data.dat file). I want to write the 1st and 2nd column of the output file (data.out) as an integer while the program change them to double. Could anybody please tell me how I can write the code which writes the values of the first two columns as integer? Thanks library ('MASS') MP-read.table(file='data.dat') names(MP)-c('B','R','S','L','LR','Q') a-as.matrix((1-pchisq(MP$LR, df=1))) b-cbind(MP$B,MP$R,a,MP$S,MP$L,MP$LR,MP$Q) write.matrix(b,'data.out') __ 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. -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 __ 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] Omiting repeated values
Hi, 'unique' or its combination with 'match' if you need to keep the vector the same length will do it: a-c(1,2,4,2,5,5,6,7,8) unique(a) [1] 1 2 4 5 6 7 8 a[ which( is.na( match(1:length(a), match(unique(a),a)) ) ) ]=NA a [1] 1 2 4 NA 5 NA 6 7 8 This is probably not the best implementation, but it does the job. 'table' will also give you the number of occurances of unique values: a-c(1,2,4,2,5,5,6,7,8) table(a) a 1 2 4 5 6 7 8 1 2 1 2 1 1 1 Oleg stat stat wrote: Dear all R users, Is there any function to omit repeated values in a vector? Your help will be highly appreciated. Thanks stat - Here’s a new way to find what you're looking for - Yahoo! Answers [[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 and provide commented, minimal, self-contained, reproducible code. -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] Installing Package rgl - Compilation Fails
Check again your error message: opengl.hpp:24:20: error: GL/glu.h: No such file or directory you need to install mesa-libGLU-devel FC6 version is 6.5.1-7 which will provide development files for glut3. Needless to say the above will probably pool some dependencies and (-devel) means it will install *.h files as well. Start your FC package manager and search for GLU, install the above and try again. Best, Oleg Rick Bilonick wrote: I'm running R 2.4.1 (with the latest versions of all packages) on an FC6 32-bit system. When I try to install the rgl package, compilation fails: install.packages(rgl) --- Please select a CRAN mirror for use in this session --- Loading Tcl/Tk interface ... done trying URL 'http://lib.stat.cmu.edu/R/CRAN/src/contrib/rgl_0.70.tar.gz' Content type 'application/x-gzip' length 705556 bytes opened URL == downloaded 689Kb * Installing *source* package 'rgl' ... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -E checking for X... libraries , headers checking for libpng-config... yes configure: using libpng-config configure: using libpng dynamic linkage configure: creating ./config.status config.status: creating src/Makevars ** libs g++ -I/usr/lib/R/include -I/usr/lib/R/include -I -DHAVE_PNG_H -I/usr/include/libpng12 -Iext -I/usr/local/include-fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -c api.cpp -o api.o In file included from glgui.hpp:9, from gui.hpp:11, from rglview.h:10, from Device.hpp:11, from DeviceManager.hpp:9, from api.cpp:14: opengl.hpp:24:20: error: GL/glu.h: No such file or directory Disposable.hpp:13: warning: ‘struct IDisposeListener’ has virtual functions but non-virtual destructor types.h:77: warning: ‘class DestroyHandler’ has virtual functions but non-virtual destructor gui.hpp:56: warning: ‘class gui::WindowImpl’ has virtual functions but non-virtual destructor gui.hpp:90: warning: ‘class gui::GUIFactory’ has virtual functions but non-virtual destructor pixmap.h:39: warning: ‘class PixmapFormat’ has virtual functions but non-virtual destructor api.cpp: In function ‘void rgl_user2window(int*, int*, double*, double*, double*, double*, int*)’: api.cpp:764: error: ‘gluProject’ was not declared in this scope api.cpp: In function ‘void rgl_window2user(int*, int*, double*, double*, double*, double*, int*)’: api.cpp:792: error: ‘gluUnProject’ was not declared in this scope make: *** [api.o] Error 1 chmod: cannot access `/usr/lib/R/library/rgl/libs/*': No such file or directory ERROR: compilation failed for package 'rgl' ** Removing '/usr/lib/R/library/rgl' The downloaded packages are in /tmp/RtmpJY8uNp/downloaded_packages Warning message: installation of package 'rgl' had non-zero exit status in: install.packages(rgl) I was able to install this on an 64-bit system running FC4 and R 2.4.1. Any ideas on why it fails on FC6? Rick B. __ 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. -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 __ 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] Ubuntu Linux and X11
The problem occurs after updating from Dapper to Edgy. Dapper had font paths: /usr/share/X11/fonts and Edgy, to make the whole font system unified, moved X11 fonts to /usr/share/fonts/X11. Oleg Yuelin Li wrote: If you are using edgy, try changing your FontPath settings in /etc/X11/xorg.conf (mine listed below). Reboot, and check to see there are no warnings about missing font files in /var/log/Xorg.0.log. Yuelin. Section Files FontPath/usr/share/fonts/X11/100dpi/:unscaled FontPath/usr/share/fonts/X11/75dpi/:unscaled FontPath/usr/share/fonts/X11/Type1 FontPath/usr/share/fonts/X11/100dpi FontPath/usr/share/fonts/X11/75dpi FontPath/usr/share/fonts/X11/TTF FontPath/usr/share/fonts/X11/OTF FontPath/usr/share/fonts/X11/CID FontPath/usr/share/fonts/X11/misc # path to defoma fonts FontPath /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType EndSection On Fri, Feb 16, 2007 at 05:05:35PM -0600, Dirk Eddelbuettel wrote: On Fri, Feb 16, 2007 at 09:53:39PM +0100, [EMAIL PROTECTED] wrote: i have a problem with creating histograms and plots under ubuntu linux. After creating a vector test i want to make a histogram, but the following error appears: hist (test) Error in X11() : could not find any X11 fonts Check that the Font Path is correct. Does anybody know this problem and a solution for this? Hm, you didn't by chance built this yourself and thereby ignored the BIG FAT warnings about x11 headers not being found ? Take a shortcut, install the (backported) Ubuntu packages from any of the CRAN mirrors and then sit back and enjoy a nice hist() chart? Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ 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. = Please note that this e-mail and any files transmitted with it may be privileged, confidential, and protected from disclosure under applicable law. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any reading, dissemination, distribution, copying, or other use of this communication or any of its attachments is strictly prohibited. If you have received this communication in error, please notify the sender immediately by replying to this message and deleting this message, any attachments, and all copies and backups from your computer. __ 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. -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 __ 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] Ubuntu Linux and X11
Good point. But on my systems , the upgrade only affected Emacs which 'looked ugly' but still worked. In other words, nothing failed after the After I updated to Edgy 'convert' of ImageMagick stopped working as well as its 'display' API command and also nedit stopped functioning -- all because of X11 fonts. And in fact, I now recall that I had for while no test in my R plots, I thought some R options were set wrongly. But correcting the paths in xorg.conf solved all these issues. Oleg -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 __ 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] anyone has C++ STL classes stability issue if used with R
Hello, is there any one who uses C++ STL classes when programming shared libs for R and has had any problems with STL? In the very simple example below I am constantly getting segfaults when trying to populate the queue. The segfault occurs at what looks like a random index in the loop when pushing another element to the queue. Reproduced on 4 machines. Object x is an Image as in EBImage, i.e. a 3D R-array of numerics for the purpose of this code. LENGTH(x) can be up to 1e6 and the number of elements potentially to be in the queue is about 20% of those. But I get segfaults often on a third of fours element being added. Tried on R2.5.0-devel, R2.4.1-release and all machines were 64bit Linux with kernels 2.6.9 (stable CentOS), 2.6.17 (stable Ubuntu) and 2.6.20 (Ubuntu devel). Here are the compilation options of this particular module (built as part of EBImage, which generally compiles and works just fine): -- g++ -I/home/osklyar/R/R-2.5.0-40659/include -I/home/osklyar/R/R-2.5.0-40659/include -I/usr/local/include -DUSE_GTK -DGLIB_GETTEXT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -g -O2 -Wall -pthread -I/usr/include -O2 -g -O2 -g -fpic -O2 -g -c filters_watershed.cpp -o filters_watershed.o -- And the linker: -- g++ -shared -L/usr/local/lib64 -o EBImage.so colors.o conversions.o display.o filters_distmap.o filters_magick.o filters_morph.o filters_propagate.o filters_thresh.o filters_watershed.o init.o io.o object_counting.o tools.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -L/usr/lib -L/usr/X11R6/lib -lfreetype -lz -L/usr/lib -lMagick -llcms -ltiff -lfreetype -ljasper -ljpeg -lpng -lXext -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lpthread -lm -lpthread -- It could be I am missing something totally simple and therefore get these errors, but I cannot identify what. Thanks for help, Oleg - // common.h also includes R includes: // #include R.h // #include Rdefines.h // #include R_ext/Error.h #include common.h #include queue using namespace std; struct Pixel { int x, y; double intens; /* the code will also fail with the same segfault if I remove all * the constructors here and use the commented block below instead * of pq.push( Pixel(i, j, val) */ Pixel() {x = 0; y = 0; intens = 0; }; Pixel(const Pixel px) { x = px.x; y = px.y; intens = px.intens; }; Pixel(int i, int j, double val): x(i), y(j), intens(val) {}; }; bool operator (const Pixel a, const Pixel b) { return a.intens b.intens; }; typedef priority_queuePixel PixelPrQueue; SEXP lib_filterInvWS (SEXP x) { SEXP res; int i, j, index; double val; PixelPrQueue pq; int nx = INTEGER ( GET_DIM(x) )[0]; int ny = INTEGER ( GET_DIM(x) )[1]; int nz = INTEGER ( GET_DIM(x) )[2]; int nprotect = 0; PROTECT ( res = Rf_duplicate(x) ); nprotect++; // Pixel px; for (int im = 0; im nz; im++ ) { double * src = ( REAL(x)[ im * nx * ny ] ); double * tgt = ( REAL(res)[ im * nx * ny ] ); for ( j = 0; j ny; j++ ) for ( i = 0; i nx; i++ ) { index = i + nx * j; val = src[ index ]; if ( val BG ) { tgt[ index ] = -1; // px.x = i; px.y = j; px.intens = val; pq.push(px); pq.push( Pixel(i, j, val) ); continue; } tgt[ index ] = BG; } } /* my main code was here, but deleted for debug */ UNPROTECT (nprotect); return res; } -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] anyone has C++ STL classes stability issue if used with R
Continued: With the following modifications (using pointers) it works (needs memory cleaning afterwards and new less operator though) and I do not understand why: typedef priority_queuePixel * PixelPrQueue; ... pq.push( new Pixel(i, j, val) ); ... Oleg Sklyar wrote: Hello, is there any one who uses C++ STL classes when programming shared libs for R and has had any problems with STL? In the very simple example below I am constantly getting segfaults when trying to populate the queue. The segfault occurs at what looks like a random index in the loop when pushing another element to the queue. Reproduced on 4 machines. Object x is an Image as in EBImage, i.e. a 3D R-array of numerics for the purpose of this code. LENGTH(x) can be up to 1e6 and the number of elements potentially to be in the queue is about 20% of those. But I get segfaults often on a third of fours element being added. Tried on R2.5.0-devel, R2.4.1-release and all machines were 64bit Linux with kernels 2.6.9 (stable CentOS), 2.6.17 (stable Ubuntu) and 2.6.20 (Ubuntu devel). Here are the compilation options of this particular module (built as part of EBImage, which generally compiles and works just fine): -- g++ -I/home/osklyar/R/R-2.5.0-40659/include -I/home/osklyar/R/R-2.5.0-40659/include -I/usr/local/include -DUSE_GTK -DGLIB_GETTEXT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -g -O2 -Wall -pthread -I/usr/include -O2 -g -O2 -g -fpic -O2 -g -c filters_watershed.cpp -o filters_watershed.o -- And the linker: -- g++ -shared -L/usr/local/lib64 -o EBImage.so colors.o conversions.o display.o filters_distmap.o filters_magick.o filters_morph.o filters_propagate.o filters_thresh.o filters_watershed.o init.o io.o object_counting.o tools.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -L/usr/lib -L/usr/X11R6/lib -lfreetype -lz -L/usr/lib -lMagick -llcms -ltiff -lfreetype -ljasper -ljpeg -lpng -lXext -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lpthread -lm -lpthread -- It could be I am missing something totally simple and therefore get these errors, but I cannot identify what. Thanks for help, Oleg - // common.h also includes R includes: // #include R.h // #include Rdefines.h // #include R_ext/Error.h #include common.h #include queue using namespace std; struct Pixel { int x, y; double intens; /* the code will also fail with the same segfault if I remove all * the constructors here and use the commented block below instead * of pq.push( Pixel(i, j, val) */ Pixel() {x = 0; y = 0; intens = 0; }; Pixel(const Pixel px) { x = px.x; y = px.y; intens = px.intens; }; Pixel(int i, int j, double val): x(i), y(j), intens(val) {}; }; bool operator (const Pixel a, const Pixel b) { return a.intens b.intens; }; typedef priority_queuePixel PixelPrQueue; SEXP lib_filterInvWS (SEXP x) { SEXP res; int i, j, index; double val; PixelPrQueue pq; int nx = INTEGER ( GET_DIM(x) )[0]; int ny = INTEGER ( GET_DIM(x) )[1]; int nz = INTEGER ( GET_DIM(x) )[2]; int nprotect = 0; PROTECT ( res = Rf_duplicate(x) ); nprotect++; // Pixel px; for (int im = 0; im nz; im++ ) { double * src = ( REAL(x)[ im * nx * ny ] ); double * tgt = ( REAL(res)[ im * nx * ny ] ); for ( j = 0; j ny; j++ ) for ( i = 0; i nx; i++ ) { index = i + nx * j; val = src[ index ]; if ( val BG ) { tgt[ index ] = -1; // px.x = i; px.y = j; px.intens = val; pq.push(px); pq.push( Pixel(i, j, val) ); continue; } tgt[ index ] = BG; } } /* my main code was here, but deleted for debug */ UNPROTECT (nprotect); return res; } -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] anyone has C++ STL classes stability issue if used with R
Duncan, you are right about Rf_..., otherwise the lengths are checked in the R side, this is just one of the functions I have in the package and all arguments are thoroughly checked. But apparently, the same code if redefined for using pointers instead of references works just perfectly fine (given below). And I do not see why the one I posted before fails. I will try to run it outside of R to see if the issue is anyhow connected to R. // comparison operator redefined for pointers: struct Pixel_compare: public binary_functionPixel*, Pixel*, bool { bool operator() (Pixel* a, Pixel* b) { return a-intens b-intens; } }; // was: // struct Pixel_compare: public binary_functionPixel, Pixel, bool { //bool operator() (Pixel a, Pixel b) { //return a.intens b.intens; //} // }; // the queue redefined for pointers typedef priority_queuePixel*, vectorPixel*, Pixel_compare PixelPrQueue; // was: typedef priority_queuePixel, vectorPixel, Pixel_compare PixelPrQueue; SEXP lib_filterInvWS (SEXP x) { SEXP res; int i, j, index; double val; int nx = INTEGER ( GET_DIM(x) )[0]; int ny = INTEGER ( GET_DIM(x) )[1]; int nz = INTEGER ( GET_DIM(x) )[2]; int nprotect = 0; PROTECT ( res = Rf_duplicate(x) ); nprotect++; for (int im = 0; im nz; im++ ) { double * src = ( REAL(x)[ im * nx * ny ] ); double * tgt = ( REAL(res)[ im * nx * ny ] ); PixelPrQueue pq; for ( j = 0; j ny; j++ ) for ( i = 0; i nx; i++ ) { index = i + nx * j; val = src[ index ]; if ( val BG ) { tgt[ index ] = -1; // new pixels are created as pointer to objects // was: pq.push( Pixel(i, j, val) ); pq.push( new Pixel(i, j, val) ); continue; } tgt[ index ] = BG; } // printed and all pointers deleted Pixel * px; while ( !pq.empty() ) { px = pq.top(); pq.pop(); Rprintf(%f\n, px-intens); delete px; } } UNPROTECT (nprotect); return res; } The above works fine. The Compare operator is defined differently from my previous post, but both fail if used with references. Oleg Duncan Murdoch wrote: On 2/13/2007 3:55 AM, Oleg Sklyar wrote: Hello, is there any one who uses C++ STL classes when programming shared libs for R and has had any problems with STL? I don't, but I'd suggest asking a technical question like this on R-devel instead of R-help if you don't get help here. I can see a few probably innocuous changes I'd suggest in your code below, but nothing obvious: use Rinternals.h instead of Rdefines.h, don't use the Rf_ prefix, check the length of inputs before working with the values. Duncan Murdoch In the very simple example below I am constantly getting segfaults when trying to populate the queue. The segfault occurs at what looks like a random index in the loop when pushing another element to the queue. Reproduced on 4 machines. Object x is an Image as in EBImage, i.e. a 3D R-array of numerics for the purpose of this code. LENGTH(x) can be up to 1e6 and the number of elements potentially to be in the queue is about 20% of those. But I get segfaults often on a third of fours element being added. Tried on R2.5.0-devel, R2.4.1-release and all machines were 64bit Linux with kernels 2.6.9 (stable CentOS), 2.6.17 (stable Ubuntu) and 2.6.20 (Ubuntu devel). Here are the compilation options of this particular module (built as part of EBImage, which generally compiles and works just fine): -- g++ -I/home/osklyar/R/R-2.5.0-40659/include -I/home/osklyar/R/R-2.5.0-40659/include -I/usr/local/include -DUSE_GTK -DGLIB_GETTEXT -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wall -g -O2 -Wall -pthread -I/usr/include -O2 -g -O2 -g -fpic -O2 -g -c filters_watershed.cpp -o filters_watershed.o -- And the linker: -- g++ -shared -L/usr/local/lib64 -o EBImage.so colors.o conversions.o display.o filters_distmap.o filters_magick.o filters_morph.o filters_propagate.o filters_thresh.o filters_watershed.o init.o io.o object_counting.o tools.o -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -L/usr/lib -L/usr/X11R6/lib -lfreetype -lz -L/usr/lib -lMagick -llcms -ltiff -lfreetype -ljasper -ljpeg
Re: [R] Help with interfacing C R
On Windows you need: - download and install Cygwin (cygwin.com) with default options, supposedly you install into c:\cygwin. Add path to c:\cygwin\bin;c:\cygwin\lib to your system PATH - download and unpack Rtools (http://www.murdoch-sutherland.com/Rtools/tools.zip) Assuming you have them in C:\Rtools, add c:\RTools\bin to your PATH _in front of_ cygwin - download and install MinGW, you will want to get MinGW-5.1.3.exe, which will download and install the rest. You will want to select at least gcc and make. Add the path to c:\MinGW\bin to your system PATH, right in front of Rtools (http://sourceforge.net/projects/mingw/) - download and install ActivePerl from (activestate.com), ensure path is added to your PATH For help files: - get MS hhc, comes as part of htmlhelp.exe from here: http://www.microsoft.com/downloads/details.aspx?FamilyID=00535334-c8a6-452f-9aa0-d597d16580ccDisplayLang=en this is Microsoft HTML Help Compiler, add path to it to your PATH - you might want to consider MikTex, dowload, install, add to path if you have a package and a help system a should be built Be sure that when installing R you included sources for compilation! You might need to reinstall R. When this done, you can try executing R CMD SHLIB or R CMD build --binary if you have a package. Please refer to Writing R Extensions (CRAN) for complete reference and to this guide for step-by-step description: http://www.ebi.ac.uk/~osklyar/kb/CtoRinterfacingPrimer.pdf Regards, Oleg -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 Tim Smith wrote: Hi all, I was trying to set up an interface for using C functions in R. For this, my R file hello2.r is: - hello2 - function(n) { .C(hello, as.integer(n)) } hello2(3) and my hello.c file is: -- #include R.h void hello(int *n) { int i; for(i=0; i *n; i++) { Rprintf(Hello, world!\n); } } --- From my windows command line, I execute: R CMD SHLIB hello.c but I get the error message: Error: syntax error in R CMD. I am trying to look up information on the web page at: http://cran.r-project.org/doc/manuals/R-exts.html#dyn_002eload-and-dyn_002eunload As I understand it, I need to load some files, but I don't understand which commands I need to execute to compile execute my 'hello world' code. I am running R 2.4.0 on Windows XP machine. Any help would be highly appreciated. thanks! - Food fight? Enjoy some healthy debate [[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 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] Running source from Unix line
See the previous reply, but also if you want to run a shell script and need to pass arguments like file names or dir names or anything else, you cane you the following (${1} -- 1st argument to the shell script, ${2} -- second etc): #!/bin/sh echo 'a=${1};b=${2}; source(codeWith_a_and_b.R) | R --vanilla --quiet The from shell (e.g. to process smth in this dir, a, with b=2): ./thisScript `pwd` 2 Oleg -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 Amir Herman wrote: How can I run something like source(filename) from the Unix command line? Maybe somthing like ./R CMD source(filename) - this does not work. I need to run an R source code file with a command from the Unix command line. assuming that I have R installed on my system. Thank you all Amir. __ 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 interfacing C R
Roland, Sure, this code also compiles on my Linux box straight away, it also compiles on my Windows box -- because everything is _already_ set up there. The question was not whether the code was wrong -- such a huge chunk of code could hardly be wrong and it was apparent it was written just to try if one can _at all_ compile something for R. The question was that something was missing to compile it and Tim did not specify anything about his system except that it was Windows! One might not need Cygwin if the code is like Tim's, i.e. has no configuration whatsoever, that is right, but one in any case needs at least MinGW (for gcc, visible in your output) and ActivePerl (for R CMD) and RTools and R includes (visible in your output). You do have them installed, does Tim also have them installed? If one adds a simple config file (it will rather not work with a full UNIX-like configure) then one might want to have Cygwin or MSYS as well. Tim, when you get all those, add paths to smth\bin and smth\lib (as there might be dlls and Windows searches for dlls in the PATH) to your PATH. This includes R! One requirement: MinGW must be added in front of Cygwin (for MinGW make) and RTools in front of both MinGW and Cygwin (for all RTools to be used instead of those). And the pdf file pointed to in my previous post was exactly written for someone to start doing these things! It was written for Linux, but the only difference on Windows is that you need those tools I mentioned above! Oleg -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 Roland Rau wrote: Hi, On 2/8/07, *Oleg Sklyar* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On Windows you need: - download and install Cygwin (cygwin.com http://cygwin.com) with default options, supposedly you install into c:\cygwin. Add path to c:\cygwin\bin;c:\cygwin\lib to your system PATH No. You don't need Cygwin. I don't have it and I can compile Tim's code without any problem. Please see bottom of my message for which I used Tim's code without any modification. My assumption is rather that the path is not set correctly so he can call R from the command line. Maybe you could check, Tim, if you can start Rterm.exe or Rgui.exe from the command line. If not, this should be the first thing to fix. For help files: - get MS hhc, comes as part of htmlhelp.exe from here: http://www.microsoft.com/downloads/details.aspx?FamilyID=00535334-c8a6-452f-9aa0-d597d16580ccDisplayLang=en http://www.microsoft.com/downloads/details.aspx?FamilyID=00535334-c8a6-452f-9aa0-d597d16580ccDisplayLang=en this is Microsoft HTML Help Compiler, add path to it to your PATH - you might want to consider MikTex, dowload, install, add to path if you have a package and a help system a should be built Yes, as you write for the help files. But I think it is not necessary if someone wants to make his/her first steps to interface to C from R. Best, Roland P.S. Here is the transcript of my shell session in emacs using Tim's code: Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. c:\deletefolder\RsandboxR CMD SHLIB hello.c R CMD SHLIB hello.c making hello.d from hello.c gcc -IC:/rolandprogs/R- 2.3.1/include -Wall -O2 -c hello.c -o hello.o gcc -shared -s -o hello.dll hello.def hello.o -LC:/rolandprogs/R-2.3.1/bin -lR c:\deletefolder\RsandboxRterm --no-save Rterm --no-save R : Copyright 2006, The R Foundation for Statistical Computing Version 2.3.1 (2006-06-01) ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. source(hello2.r) source(hello2.r) dyn.load(hello) dyn.load(hello) hello2(3) hello2(3) Hello, world! Hello, world! Hello, world! [[1]] [1] 3 __ 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 interfacing C R
Try the following: Let's assume you put your R and C code into: E:\MyProgram I assume R is in E:\prg_files\R\R-2.4.1\bin. I also assume MinGW is present and ActivePerl is present. I also assume the following directories are present (and full of files): E:\prg_files\R\R-2.4.1\include; E:\prg_files\R\R-2.4.1\src\gnuwin32. If they are not present -- you probably need to reinstall R with development files. Now click on Start in Windows, run Run As... or anything that allows to run programs by name, type in the dialog cmd and hit OK. This will start a black DOS box! Type: E: Enter it should prompt that you are in E: now cd MyProgram Enter now you are in E:\MyProgram R CMD SHLIB hello.c Enter If this does not work, type in the same box: echo %PATH% Enter and send us the contents of this printout (PATH). Oleg -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 Tim Smith wrote: Hi All, Thanks so much for all the responses. I think I don't know enough about R, and I don't know what other information would be required to diagnose what I may be doing wrong. I have installed all the software, and reinstalled R as per Olegs earlier email. I have all programs installed on my E:\ partition (R on it's own works fine from here). When I had executed the code: R CMD SHLIB hello.c it was clicking on the 'Rterm.exe' (R for windows front end, at E:\prg_files\R\R-2.4.1\bin). I had put my hello.c and the hell.r file in the bin directory too. So, my question is where should I put my files, and which DOS box do I have to use? I started cygwin and got a bash command window - what do I do from here? Thanks again for all the help, and I do apologize if I'm not giving the 'right' information. Tim */Roland Rau [EMAIL PROTECTED]/* wrote: Dear Oleg, to avoid any misunderstandings: My intention was not to offend you. I just thought that the original poster's idea was to compile simply some C-code and interface it from R. I am sorry if my previous email sounded impolite. Best, Roland On 2/8/07, *Oleg Sklyar* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Roland, Sure, this code also compiles on my Linux box straight away, it also compiles on my Windows box -- because everything is _already_ set up there. The question was not whether the code was wrong -- such a huge chunk of code could hardly be wrong and it was apparent it was written just to try if one can _at all_ compile something for R. The question was that something was missing to compile it and Tim did not specify anything about his system except that it was Windows! One might not need Cygwin if the code is like Tim's, i.e. has no configuration whatsoever, that is right, but one in any case needs at least MinGW (for gcc, visible in your output) and ActivePerl (for R CMD) and RTools and R includes (visible in your output). You do have them installed, does Tim also have them installed? If one adds a simple config file (it will rather not work with a full UNIX-like configure) then one might want to have Cygwin or MSYS as well. Tim, when you get all those, add paths to smth\bin and smth\lib (as there might be dlls and Windows searches for dlls in the PATH) to your PATH. This includes R! One requirement: MinGW must be added in front of Cygwin (for MinGW make) and RTools in front of both MinGW and Cygwin (for all RTools to be used instead of those). And the pdf file pointed to in my previous post was exactly written for someone to start doing these things! It was written for Linux, but the only difference on Windows is that you need those tools I mentioned above! Oleg -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 Roland Rau wrote: Hi, On 2/8/07, *Oleg Sklyar* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On Windows you need: - download and install Cygwin (cygwin.com http://cygwin.com http://cygwin.com) with default options, supposedly you install into c:\cygwin. Add path to c:\cygwin\bin;c:\cygwin\lib to your system PATH No. You don't need Cygwin. I don't have it and I can compile Tim's code without any problem. Please see bottom of my message for which I used Tim's code without any modification. My assumption is rather
Re: [R] Help with interfacing C R
E:\My Documents\work\projects\landmarks\trycls hello.c hello2.r It is always advisable not to have spaces in such directories (like the ones you want to include into a system variable), but fine. E:\My Documents\work\projects\landmarks\trycR CMD SHLIB hello.c 'R' is not recognized as an internal or external command, operable program or batch file. Your R is not in the PATH! You need to add it, see also below! E:\My Documents\work\projects\landmarks\trycecho %PATH% C:\texmf\miktex\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\P rogram Files\ATI Technologies\ATI Control Panel;E:\PROGRA~1\F-Secure\Ssh;E:\Prog ram Files\ESTsoft\ALZip\;C:\Program Files\QuickTime\QTSystem\;E:\prg_files\tools \bin;E:\prg_files\cygwin\bin;E:\prg_files\cygwin\lib;E:\prg_files\ActivePerl\Act ivePerl\Perl\bin;E:\prg_files\ActivePerl\ActivePerl\Perl\lib;E:\Program Files\ES Tsoft\ALZip\ There are at least 2 mistakes that I see in your PATH above: - you need to add: E:\prg_files\R\R-2.4.1\bin; - you need to add path to wherever MinGW\bin is and add it before cygwin! if you do not have MinGW installed, download and install it. I guess E:\prg_files\tools\bin are RTools, if so, this is fine. Your own program must not necessarily be in the PATH -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 __ 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 interfacing C R
Glad it worked for you. Unfortunately I will not help you with dyn.load, I do not use it and am not well familiar with the technicalities about its use. Why?.. please read the pdf file I mentioned in my first post and you will see why. Anyway as it compiles now it might probably be the best time time to read it to prevent further questions that could be prevented. It does not cover Windows, but the part it does not cover you have just mastered :) Again here is the address: http://www.ebi.ac.uk/~osklyar/kb/CtoRinterfacingPrimer.pdf Best, Oleg -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 Tim Smith wrote: Hi Oleg, Thanks !! I did as you said, and it works from the Rterm window now. My only other question is, that now I have the C code compiled, how do I make 'hello2.r' run from the RGui? I tried to execute the r code from this after I was able to run the code in the Rterm and got the following errors: source(tryc/hello2.r) Error in .C(hello, as.integer(n)) : C symbol name hello not in load table I also tried with putting 'dyn.load(hello)' at the begining of the r code block, but got the following error: --- Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library 'E:/My Documents/work/projects/landmarks/hello': LoadLibrary failure: The specified module could not be found. --- Thanks again for all your help. I guess I'll try to figure out the RGui error tomorrow. take care, Tim */Oleg Sklyar [EMAIL PROTECTED]/* wrote: E:\My Documents\work\projects\landmarks\trycls hello.c hello2.r It is always advisable not to have spaces in such directories (like the ones you want to include into a system variable), but fine. E:\My Documents\work\projects\landmarks\trycR CMD SHLIB hello.c 'R' is not recognized as an internal or external command, operable program or batch file. Your R is not in the PATH! You need to add it, see also below! E:\My Documents\work\projects\landmarks\trycecho %PATH% C:\texmf\miktex\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\P rogram Files\ATI Technologies\ATI Control Panel;E:\PROGRA~1\F-Secure\Ssh;E:\Prog ram Files\ESTsoft\ALZip\;C:\Program Files\QuickTime\QTSystem\;E:\prg_files\tools \bin;E:\prg_files\cygwin\bin;E:\prg_files\cygwin\lib;E:\prg_files\ActivePerl\Act ivePerl\Perl\bin;E:\prg_files\ActivePerl\ActivePerl\Perl\lib;E:\Program Files\ES Tsoft\ALZip\ There are at least 2 mistakes that I see in your PATH above: - you need to add: E:\prg_files\R\R-2.4.1\bin; - you need to add path to wherever MinGW\bin is and add it before cygwin! if you do not have MinGW installed, download and install it. I guess E:\prg_files\tools\bin are RTools, if so, this is fine. Your own program must not necessarily be in the PATH -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 Be a PS3 game guru. Get your game face on with the latest PS3 news and previews at Yahoo! Games. http://us.rd.yahoo.com/evt=49936/*http://videogames.yahoo.com __ 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] problems installing R on Linux
Hi, in general Prof. Ripley is right that more information is needed, but here's a hint that you might try first. /usr/local/lib/R/bin/exec/R: relocation error: /usr/local/lib/R/lib/libRlapack.so: undefined symbol: s_copy # thrown out of R Could simply mean that the /usr/local/lib/R/lib/libRlapack.so is not found, and considering that you say make was alright, then maybe it was make install that did not copy it. But what you can try, try running R from the directory where you compiled it in: get a fresh R tarball, untar it. configure it with ./configure --prefix=`pwd` and do make. Do not do make install, simply run it from the bin dir here. You might need to install the packages though if they are not in R_LIBS. This will ensure that all files are there, nothing was left behind by make install. rpm -q zlib zlib-1.1.3-25.7 After you installed zlib with ./configure make make install, your rpm request will not give you the just installed zlib version because it refers to a different source. If by doing make install you overwrite the files from zlib*.rpm, it will still report the version written in the rpm database. And you cannot uninstall this rpm without braking half of your system dependencies. Best, Oleg -- Dr Oleg Sklyar | EBI-EMBL, Cambridge CB10 1SD, UK | +44-1223-494466 __ 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] Step-by-step guide for using C/C++ in R; WAS: [Rd] Speed of for loops
I know this should not go to [Rd], but the original post was there and the replies as well. Thank you all who expressed interest in the Step-by-step guide for using C/C++ in R! Answering some of you, yes it is by me and was written to assist other group members to start adding c/c++ code to their R coding. You can now download it from: http://www.ebi.ac.uk/~osklyar/kb/CtoRinterfacingPrimer.pdf I would also appreciate your comments if you find it useful or not, or maybe what can be added or modified. But not on the list, directly to my email please. Best wishes, Oleg Tamas K Papp wrote: On Tue, Jan 30, 2007 at 12:15:29PM +, Oleg Sklyar wrote: magnitude using c-functions for complex vector indexing operations. If you need instructions, I can send you a very nice Step-by-step guide for using C/C++ in R which goes beyond Writing R Extensions document. Hi Oleg, Can you please post this guide online? I think that many people would be interested in reading it, incl. me. Tamas -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] Making TIFF images with rtiff
http://www.ebi.ac.uk/~osklyar/EBImage or http://bioconductor.org/packages/2.0/bioc/html/EBImage.html will read/write more than 90 formats including TIFF. Trivial to install and run on Windows. Regards, Oleg On 12/01/07, Inman, Brant A. M.D. [EMAIL PROTECTED] wrote: Many medical journals and publishers require that images, whether photographs or line art, be submitted as high resolution .TIFF images. One option for R users is to produce an image in one format and to convert it to a .TIFF file using a second software program. My experience has been that this option often results in images of poorer quality, often with blurry contours, and a loss of resolution. A second and better option would be to make .TIFF files directly from the graphic output of R. I recently noticed that there is a library called rtiff that may be able to do this. However, I have not been able to get it to work, principally because I do not know how to install the required supporting software, libtiff and tiffio.h, correctly on my computer. I am running R 2.4.0 on a Windows XP machine. So far I have done the following: 1) Loaded the rtiff library 2) Downloaded and installed the TIFF library 3.8.2 (complete package and sources) from the following website: http://gnuwin32.sourceforge.net/packages/tiff.htm I would like to ask the R experts for help with the following things: 1) Where do I get the tiffio.h file? 2) Where do I install or relocate the tiffio.h and TIFF library to so that rtiff will work? Thanks for your help. Brant Inman Mayo Clinic __ 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. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot .jpeg image in margins?
I am not sure what you mean by in margins, if this is keeping the aspect ration, then the answer is yes. Please check EBImage, http://www.ebi.ac.uk/~osklyar/EBImage/ . The package will allow to read/write images in most image formats, the method image() redefined for the Image class will produce an image plot using R graphics device keeping the aspect ratio and display() can display images with zoom and browse functions. Best regards, Oleg On 08/01/07, Kari [EMAIL PROTECTED] wrote: Is it possible to plot an image (currently a jpeg) in the margins? Thanks, Kari [[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 and provide commented, minimal, self-contained, reproducible code. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] importing bitmap images to R
http://bioconductor.org/packages/2.0/bioc/html/EBImage.html This will read/write about 95 image formats into R, all those supported by ImageMagick and provide many image processing filters. If Windows is your platform, this version will work on Windows as well (the version release in Bioconductor 1.9 will not). It is a development version and even though it shows 1.9.12 now, it is already 1.9.14 on the SVN with many bug fixes. Go grab it, if using Windows, let me know I will send you a binary if it does not appear on the bioconductor page -- it takes several days until a new build. Best, Oleg On 28/12/06, Michael Wolosin [EMAIL PROTECTED] wrote: All - I'm creating some plots in R that I would like to overlay on images that are created outside of R. I've used image before to plot image-like data within R, and have added vector plots on top of them, but I can't find a way to read in an external bitmap file into R and use that. Currently the external files are .png's, but I could generate a few other types, if something else might be easier to import. Thanks, -Mike __ 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. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] rimage package broken with fedora upgrade
Cannot help you much with that as the thing seems to compile normally. As you use a global R installation, try giving yourself write permissions in /usr/lib/R/library, this might help. Otherwise, try installing R from source in your home or elsewhere where you have all write permissions and check it again. Anyway, I wanted also to advertise my package because you use rimage: http://bioconductor.org/packages/2.0/bioc/html/EBImage.html The difference is - it supports up to 95 image formats and implements many image processing methods. In fact you can combine this with functions from rimage. If interested, go for a development version above and it works on Fedora 6 Zod and 2.4.1 - did try just today. Best regards, Oleg On 31/12/06, John Kornak [EMAIL PROTECTED] wrote: Dear R list members I would be grateful if anyone could guide me to a solution for fixing my rimage package problem described below. I recently upgraded my machine from fedora core 3 to fedora core 6 and then upgraded R from version 2.3.1 from version 2.4.1. I then fired up R, tried to load the rimage library and received the following messages: library(rimage) Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/usr/lib/R/library/rimage/libs/rimage.so': /usr/lib/R/library/rimage/libs/rimage.so: cannot restore segment prot after reloc: Permission denied Error in library(rimage) : .First.lib failed for 'rimage' I tried removing and re-installing rimage. The install seemed to go well but I received the identical error messages upon loading. (I provide the output from the package re-install at the very end of this email in case it is useful.) I am running R version 2.4.1 and fc6 on a dual boot (with XP) Pentium 4 Dell Dimension 8250. I have both fftw-2.1.5 and fftw-3.1.2 on my machine within /usr/local and . rimage was working fine on the same machine before I upgraded from R 2.3.1 and fc3. I searched online but was unable to find any relevant posts. Thanks again John -- John Kornak,PhD Assistant Professor Departments of Radiology, and Epidemiology Biostatistics University of California, San Francisco Box 0946 San Francisco, CA 94143 Tel: (415) 353-4740 fax: (415) 353-9423 Email: [EMAIL PROTECTED] # install.packages(rimage) trying URL 'http://cran.cnr.Berkeley.edu/src/contrib/rimage_0.5-7.tar.gz' Content type 'application/x-gzip' length 331029 bytes opened URL == downloaded 323Kb * Installing *source* package 'rimage' ... checking for g++... g++ checking for C++ compiler default output... a.out checking whether the C++ compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking for gcc... gcc checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking how to run the C preprocessor... gcc -E checking for egrep... grep -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking fftw.h usability... yes checking fftw.h presence... yes checking for fftw.h... yes checking jpeglib.h usability... yes checking jpeglib.h presence... yes checking for jpeglib.h... yes checking for inline... inline checking for stdlib.h... (cached) yes checking for GNU libc compatible malloc... yes configure: creating ./config.status config.status: creating src/Makevars ** libs g++ -I/usr/lib/R/include -I/usr/lib/R/include -g -O2 -I/usr/local/include-fpic -O3 -g -c equalize.cpp -o equalize.o gcc -I/usr/lib/R/include -I/usr/lib/R/include -g -O2 -I/usr/local/include-fpic -O3 -g -std=gnu99 -c fftw_access_func.c -o fftw_access_func.o g++ -I/usr/lib/R/include -I/usr/lib/R/include -g -O2 -I/usr/local/include-fpic -O3 -g -c freqfilters.cpp -o freqfilters.o g++ -I/usr/lib/R/include -I/usr/lib/R/include -g -O2 -I/usr/local/include-fpic -O3 -g -c interface.cpp -o interface.o gcc -I/usr/lib/R/include -I/usr/lib/R/include -g -O2 -I/usr/local/include-fpic -O3 -g -std=gnu99 -c jpegio.c -o jpegio.o gcc -I/usr/lib/R/include -I/usr/lib/R/include -g -O2 -I/usr/local/include-fpic -O3 -g -std=gnu99 -c laplacian.c -o laplacian.o laplacian.c: In function 'laplacian': laplacian.c:14: warning: implicit declaration of function 'clearFrame' g++ -I/usr/lib/R/include -I/usr/lib/R/include -g -O2 -I/usr/local/include-fpic -O3 -g -c matrix.cpp -o matrix.o gcc
Re: [R] Erosion, mathematical morphology
Hi. My bioconductor.org package, EBImage, should do that -- it allows you to specify the structuring element, which can be a circle of any given radius if you want. The package includes erosion, dilation, opening and closing. It is also a general package for image analysis and processing built around ImageMagick library with many functions added. The only minus, still no Windows support -- Linux, Unix or Mac. Best, Oleg Sklyar On 20/11/06, Milton Cezar Ribeiro [EMAIL PROTECTED] wrote: Hi there, Try this require(adehabitat) ?morphology You can also try this for binary image require(rimage) ?maxImg HTP Miltinho Brazil [EMAIL PROTECTED] escreveu: Hello! I need a function to compute the erosion of a binary image by a structuring element. I need the structuring element to be a ball of a given radius. As far as I know the libraries adehabitat and spatstat include functions of mathematical morphology but I couldn't find a function which computes the erosion by a ball. Any idea? Thanks! __ 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. - Você quer respostas para suas perguntas? Ou você sabe muito e quer compartilhar seu conhecimento? Experimente o Yahoo! Respostas! [[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 and provide commented, minimal, self-contained, reproducible code. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] changing image dimensions
'EBImage' R-package from www.bioconductor.org. It's based on ImageMagick and will allow you to do this and much more with images of any time. The prerequisite: either Linix/Unix or Mac (from source) -- will not work on Windows. On 07/11/06, Milton Cezar Ribeiro [EMAIL PROTECTED] wrote: Hi there, I have some 1024x1024 binary images (as matrix), and I need change the dimensions to 1280x1280. Any idea? Regards, Miltinho Brazil - Música para ver e ouvir: You're Beautiful, do James Blunt [[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 and provide commented, minimal, self-contained, reproducible code. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to start R with a file loaded?
Assume you want to execute code in 'mycode.R', the easiest way is: echo source('mycode.R') | R --vanilla --quiet If you do it in a shell script, you can also pass variables to your code like this (list of shell script): #!/bin/sh echo var1=${1};var2=${2};source('mycode.R') | R --vanilla -- quiet Good luck, Oleg On 24/10/06, Grateful Frog [EMAIL PROTECTED] wrote: Hi! I've made great progress in my R programming, but I am again stuck on a beginner's problem. I would like to start R with a command line that loads a file, and if possible, executes a function. Can anyone give me an example of how to do this? For example, in lisp, I would say: $ lisp -load toto.lisp -eval '(do-something $PORT)' to load the file toto.lisp, then evaluate the expression with the shell envt variable bound properly. I'd like to do this in R, but can't figure it out! Thanks, GF. [[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 and provide commented, minimal, self-contained, reproducible code. [[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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] The old question: R vs MATLAB vs...: image analysis
For image analysis and general image processing in R, please check EBImage from bioconductor (www.bioconductor.org). Best, Oleg Ben Bolker wrote: Ali - saveez at hotmail.com writes: R introduces itself as a 'statistical' language and environment. There are many discussions about comparing R to MATLAB or mathematica (or other similar software). It seems to me that these other software have a broader range of applications. For example, in Mathematica one can solve a partial differential equation numberically or do image processing, or, one can connect a data acquisition card to MATLAB to acquire data from a measurement and analyse the results. - Does R already provide such facilities? some ... RSiteSearch(image analysis) http://finzi.psych.upenn.edu/R/Rhelp02a/archive/69200.html RSiteSearch(PDE) -- suggests not much in the way of numeric PDE solutions RSiteSearch(data acquisition) -- suggests not much (but see http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81317.html ) - Was R design to be merely a statistical tool or was it designed with an idea of a general mathematical tool in mind? It was designed as a language and environment for statistical computing and graphics. However, since it provides interfaces to routines written in other languages (Tcl/Tk, C, Fortran, ...) and other programs (databases, GIS, etc.), it can do lots of other things. - If the answer to the above is no, can R already be extended to include the missing features simply by extra packages yes. or does it need some rational [???] changes to support these features? no. You should think about why you want to extend R in these ways. If you already have access to Mathematica/MATLAB and are happy with their capabilities, you should just use them. Perhaps you can't afford them; are there other free/open tools that do what you want? If so, you should think about using them, or perhaps writing interfaces between them and R. cheers Ben Bolker __ 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. -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] Compiling R 2.4.0 in ubuntu/linux
use synaptic or apt-get to get readline and readline-dev, you also do not need f2c as there is a real fortran, so use synaptic/apt-get to get gfortran and use the following syntax when running ./configure: env F77=/usr/bin/gfortran-4.0 ./configure I have Ubuntu Edgy and the above works with almost any R, not only 2.4.0 Best, Oleg PS. This is not a question for R-devel :) T C wrote: I'm not sure if this is the place to post this question, but, I am having trouble compiling the source code. I do have a suitable C compiler and f2c but I get this error when I run ./configure configure: error: --with-readline=yes (default) and headers/libs are not available Any ideas? Thanks. __ 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. -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] Anyone managed to run JGR on amd64 Linux? SegFault
Hi, is there anyone who successfully used JGR (Java GUI for R) on Linux machines, more specific on 64bit AMD? Tried to get JGR running but after installing it as recommended (all installs ok), got a segfault with a very nice implement me message: [EMAIL PROTECTED]: R install.packages(JGR,dep=TRUE) library(JGR) Loading required package: rJava Loading required package: JavaGD Loading required package: iplots LOG: [(nil)] JNI_GetCreatedJavaVMs: IMPLEMENT ME!!! Segmentation fault compaq # Any ideas? Thanks, Oleg -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 System information below: --- Ubuntu Edgy, 2.6.17-6-amd64-k8 #2 SMP, nvidia X11 --- [EMAIL PROTECTED]: java -version java version 1.5.0_08 Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03) Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_08-b03, mixed mode) --- well, I know I need to update to release [EMAIL PROTECTED]: R sessionInfo() R version 2.4.0 alpha (2006-09-15 r39323) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] methods stats graphics grDevices utils datasets [7] base --- R is now configured for x86_64-unknown-linux-gnu Source directory: . Installation directory:/home/osklyar/R C compiler:gcc -O3 -march=x86-64 -g Fortran 77 compiler: /usr/bin/gfortran-4.0 -O3 -march=x86-64 -g C++ compiler: g++ -O3 -march=x86-64 -g Fortran 90/95 compiler: Interfaces supported: X11 External libraries:readline Additional capabilities: PNG, JPEG, iconv, MBCS, NLS Options enabled: shared R library, shared BLAS, R profiling Recommended packages: yes __ 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] SOLVED: Anyone managed to run JGR on amd64 Linux? SegFault
Hi, my post about failing JGR on amd64 solved and here is how I got it running, hopefully it helps others. Suppose your JDK (and you need JDK, not only JRE) is in /usr/lib/jvm/java-1.5.0-sun (thus JRE in /usr/lib/jvm/java-1.5.0-sun/jre). Set JAVA_HOME to point there to JDK. Run R CMD javareconf (thanks Prof. Ripley). RE-install rJava, install JGR. Start JGR - worked for me with sun-java binary deb of Ubuntu Edgy and R2.4.0alpha from source. Best, Oleg Oleg Sklyar wrote: Hi, is there anyone who successfully used JGR (Java GUI for R) on Linux machines, more specific on 64bit AMD? Tried to get JGR running but after installing it as recommended (all installs ok), got a segfault with a very nice implement me message: [EMAIL PROTECTED]: R install.packages(JGR,dep=TRUE) library(JGR) Loading required package: rJava Loading required package: JavaGD Loading required package: iplots LOG: [(nil)] JNI_GetCreatedJavaVMs: IMPLEMENT ME!!! Segmentation fault compaq # Any ideas? Thanks, Oleg -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] 2 linux/R environment questions
Hi, my post about failing JGR on amd64 solved and here is how I got it running, hopefully it helps as well. Suppose your JDK (and you need JDK, not only JRE) is in /usr/lib/jvm/java-1.5.0-sun (thus JRE in /usr/lib/jvm/java-1.5.0-sun/jre). Set JAVA_HOME to point there to JDK. Run R CMD javareconf (thanks Prof. Ripley). RE-install rJava, install JGR. Start JGR - worked for me with sun-java binary deb of Ubuntu Edgy and R2.4.0alpha from source. Best, Oleg Prof Brian Ripley wrote: On Wed, 11 Oct 2006, Stefan Grosse wrote: Joe Byers schrieb: JGR, when I manually compiled it for my system by specifying my location of java 1.5.0_06, worked fairly nicely. The autoinstall does not find my installation of this java version since Redhat EL4 does not support it. Redhat EL5 will in the near future. Maybe JGR will autoinstall then. Can you tell how you worked that out (the manual compilation)? I failed on Fedora Core 5 with JRE 1.5.0_08 with install.packages and dep=true. I tried a hint from the JGR mailing list but failed... Which arch and how did you install R? For me, it works with R compiled from the sources (but not installed from RPM) on FC5 i686, but not x86_64. The issue is a run-time one: library(JGR) Loading required package: rJava Loading required package: JavaGD Loading required package: iplots createObject.FindClass org/rosuda/iplots/Framework failed Exception in thread main java.lang.InternalError and that class of problem seems all too common on amd64 versions of Sun JRE. (On FC3, I managed to make it work with a self-compiled gcc 4.1.1, and haven't yet tried that on FC5.) The key is to use alternatives(8) to make sure the right jre is found, or to set JAVA_HOME. If you install R from RPMs you will probably need to run R CMD javareconf to get the right environment variables set in R itself. -- Dr Oleg Sklyar * EBI/EMBL, Cambridge CB10 1SD, England * +44-1223-494466 __ 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] parsing '...' function argument?
Dear community, I am writing a wrapper for '[' operator, which is a generic method declared as function(x, i, j, ..., drop). It turns out that I need to parse the '...' argument and this is where I am stuck. Generally what I need is the following. Say the call is obj[1, 1, 1:10, 3] - here '1:10, 3' is passed into '...'. What I need to evaluate that '...' contains now 2 arguments, first is a vector of 10 elements and second is a single value. Even nicer situation is in call obj[1, 1, , 3] - where ' , 3' is passed in '...' with one missing argument, which for an array would mean the full range. Any ideas? (Just to mention - if there were only one argument in '...', say '1:10', then length(...) would return 10 and one could access elements by ...[[i]], but all this fails if there are two arguments or more). Thanks Oleg -- Dr Oleg Sklyar European Bioinformatics Institute Wellcome Trust Genome Campus Hinxton, Cambridge CB10 1SD United Kingdom tel +44 1223 492537 fax +44 1223 494468 email [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] passing command line arguments to 'R CMD BATCH myScript.R'
Hi Community, I have a question about how to pass command line parameters to R script running in the batch mode. The problem is: there is a banch of data files which are to be processed by R script called from a web-server, i.e. in the batch mode. The web server generates data files and passes their names calling 'R CMD BATCH' one by one for every file. Now the question is how to call 'R CMD BATCH myScript.R' with parameters, like file name to process? I know how to read the parameters passed to an R script, but I don't know how to pass them. There is an option --args that should cut the rest of the line off the command line. The problem is however that BATCH syntax is: 'R CMD BATCH [options] inFile [outFile]', i.e. if I write 'R CMD BATCH --args myDataFile myScript.R' or 'R CMD BATCH --args myDataFile myScript.R' (similar was posted on some R help under Windows) it is not going to work because then BATCH doesn't know about myScript.R - it is considered as a parameter, so only 'R CMD BATCH' is executed. If however I use 'R CMD BATCH myScript --args myDataFile' then R understands --args as an output file and generates a file with that name. Does anyone has a solution for the problem? Best regards Oleg -- Dr Oleg Sklyar European Bioinformatics Institute Wellcome Trust Genome Campus Hinxton, Cambridge, CB10 1SD England phone/fax +44(0)1223 49 4478/4468 e-mail [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
[R][Rdev] any way to generate bitmap (tif,jpeg,png etc) files in R CMD BATCH
Hi Community, here is the problem, Linux problem (reported to work on Windows). I need to generate graphical output in any of bitmap format under the 'R CMD BATCH'. Whereas the script generating png-s works perfectly in the R session, such things as X11, png and jpeg are not usable in BATCH (they cannot be switched on by --gui-X11 etc) and X11 is prompted to be required for png. At the same time, such things as postscript and pdf, which are generally X-independent work fine. The problem is that as a result I need something previewable in the web browser: png, jpeg. Any suggestions how to proceed? Generally I could use command line linux tools to convert from almost any bitmpa format to the required png or jpeg, but it would be nicer to have them as direct R output. Kind regards Oleg -- Dr Oleg Sklyar European Bioinformatics Institute Wellcome Trust Genome Campus Hinxton, Cambridge, CB10 1SD England phone/fax +44(0)1223 49 4478/4468 e-mail [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
[R] Keeping the data of C structure in R variables?..
Dear all, does anybody know if there is a way to implement the following idea: if for example I have a C/C++ structure of form: struct { int size; char * data; } SData; in C code I could create some implementation that would create this structure by pointer and fill in the data, so I would have a variable something like SData* myData; Now what I need is to pass this data to a certain SEXP structure and keep it completely in R, thus setting myData = NULL and _unloading the C library_; then later I want to create another variable, in another C call, SData* myOldData and reload it with values from R. Is there a way to do that, keeping also in mind that char* data is generally binary data. Would be greatful for any suggestions. Regards Oleg __ 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