Re: [Rd] Strange behavior of C compiled program
Thanks, that was a stupid mistake (I did not know that this is so important). So I still have a problem realy more complex and I do not know was is wrong. I am running a .C procedure in a R loop. After 4, 5 or sometimes 6 call to the C procedure, Rgui crash (it closes asking me if I want to send a report to Microsoft). Is there a debuger that can run the C code with some R in it ? And what kind of mistake can provoque such a crash ? Thanks Christophe So I thaught that I find t On 08/02/2009 5:37 PM, Christophe Genolini wrote: Hi the list, I need to include some C code in R, but the behavior of the C code is strange : Here is my code : --- 8< --- Rprintf("\n mTraj=%f mClus=%f",mTraj[i+nbId*c],mClustersCenter[j+nbClusters*c]); Rprintf("\nDistA=%d Tmp=%d",dist,tmp); tmp = mTraj[i+nbId* c] - mClustersCenter [j+nbClusters* c]; Rprintf("\nDistB=%d Tmp=%d",dist,tmp); dist += (tmp * tmp); Rprintf("\nDistC=%d Tmp=%d",dist,tmp); --- 8< Herer are the stranges results it gives : mTraj=1.00 mClus=3.00 DistA=0 Tmp=0 DistB=0 Tmp=0 DistC=0 Tmp=1074790400 I ask on a C chat, but no one can answer me. Any idea of what wrong ? You likely have the wrong types for the variables you're printing. In C, the format has to match the type of the variable; if you use the wrong one, you get garbage. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] best reference on generics
> "SpG" == Spencer Graves > on Mon, 02 Feb 2009 12:42:52 -0800 writes: SpG> Hello, All: What would you say is the best succinct SpG> reference to cite on use of generic functions, SpG> especially S3 generics? In a very strict sense, S3 generics don't exist; S4 ones do. Less strictly, an R function that uses UseMethod() is an S3-generic. ?UseMethod is a pretty good reference, and BTW, contains >> Note: >> >> This scheme is called _S3_ (S version 3). For new projects, it is >> recommended to use the more flexible and robust _S4_ scheme >> provided in the 'methods' package. [so for a forthcoming book and package, it's pity that S4 had not been used... Yes, now I go hide before the flames roar at me ! ] Martin Maechler, ETH Zurich SpG> I want to add an appropriate citation on this to SpG> a forthcoming book in the Springer "useR!" series SpG> (discussing the use of the 'fda' package, which uses SpG> the S3 standard). SpG> Thanks, Spencer Graves SpG> __ SpG> R-devel@r-project.org mailing list SpG> https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Strange behavior of C compiled program
You might have a look at the "Writing R Extensions" manual - especially valgrind and/or gdb. By the way, your error is probably due to array size problem - i.e. tmp is of size n and you call tmp[n+1] for example. Valgrind will detect in automagically for you. Best, Mathieu Le lundi 09 février 2009 à 10:05 +0100, Christophe Genolini a écrit : > Thanks, that was a stupid mistake (I did not know that this is so > important). > > So I still have a problem realy more complex and I do not know was is > wrong. I am running a .C procedure in a R loop. > After 4, 5 or sometimes 6 call to the C procedure, Rgui crash (it closes > asking me if I want to send a report to Microsoft). > Is there a debuger that can run the C code with some R in it ? And what > kind of mistake can provoque such a crash ? > > Thanks > Christophe > > > So I thaught that I find t > > On 08/02/2009 5:37 PM, Christophe Genolini wrote: > >> Hi the list, > >> > >> I need to include some C code in R, but the behavior of the C code is > >> strange : Here is my code : > >> --- 8< --- > >> Rprintf("\n mTraj=%f > >> mClus=%f",mTraj[i+nbId*c],mClustersCenter[j+nbClusters*c]); > >> > >> Rprintf("\nDistA=%d Tmp=%d",dist,tmp); > >> tmp = mTraj[i+nbId* c] - mClustersCenter [j+nbClusters* c]; > >> > >> Rprintf("\nDistB=%d Tmp=%d",dist,tmp); > >> dist += (tmp * tmp); > >> > >> Rprintf("\nDistC=%d Tmp=%d",dist,tmp); > >> --- 8< > >> > >> Herer are the stranges results it gives : > >> > >> mTraj=1.00 mClus=3.00 > >> DistA=0 Tmp=0 > >> DistB=0 Tmp=0 > >> DistC=0 Tmp=1074790400 > >> > >> I ask on a C chat, but no one can answer me. > >> Any idea of what wrong ? > > > > You likely have the wrong types for the variables you're printing. In > > C, the format has to match the type of the variable; if you use the > > wrong one, you get garbage. > > > > Duncan Murdoch > > > -- Institute of Mathematics Ecole Polytechnique Fédérale de Lausanne STAT-IMA-FSB-EPFL, Station 8 CH-1015 Lausanne Switzerland http://stat.epfl.ch/ Tel: + 41 (0)21 693 7907 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Strange behavior of C compiled program
On 09/02/2009 4:05 AM, Christophe Genolini wrote: Thanks, that was a stupid mistake (I did not know that this is so important). So I still have a problem realy more complex and I do not know was is wrong. I am running a .C procedure in a R loop. After 4, 5 or sometimes 6 call to the C procedure, Rgui crash (it closes asking me if I want to send a report to Microsoft). Is there a debuger that can run the C code with some R in it ? And what kind of mistake can provoque such a crash ? Debugging C code in R on Windows is a little painful. valgrind doesn't run on Windows (as far as I know), and none of the commercial debuggers support the debug format that gcc uses. However, you can run gdb, and it mostly works. See my page http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/ for details. (I use the Cygwin version of gdb, but it usually gets the backtrace wrong if you look for a stack dump. I understand the MinGW version is better at that, but I've been unable to get the Insight graphical front end to work with it. I'd love to hear from someone who has a modern graphical front end working for debugging MinGW code on Windows.) Duncan Murdoch Thanks Christophe So I thaught that I find t On 08/02/2009 5:37 PM, Christophe Genolini wrote: Hi the list, I need to include some C code in R, but the behavior of the C code is strange : Here is my code : --- 8< --- Rprintf("\n mTraj=%f mClus=%f",mTraj[i+nbId*c],mClustersCenter[j+nbClusters*c]); Rprintf("\nDistA=%d Tmp=%d",dist,tmp); tmp = mTraj[i+nbId* c] - mClustersCenter [j+nbClusters* c]; Rprintf("\nDistB=%d Tmp=%d",dist,tmp); dist += (tmp * tmp); Rprintf("\nDistC=%d Tmp=%d",dist,tmp); --- 8< Herer are the stranges results it gives : mTraj=1.00 mClus=3.00 DistA=0 Tmp=0 DistB=0 Tmp=0 DistC=0 Tmp=1074790400 I ask on a C chat, but no one can answer me. Any idea of what wrong ? You likely have the wrong types for the variables you're printing. In C, the format has to match the type of the variable; if you use the wrong one, you get garbage. Duncan Murdoch __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] CMD check puzzle
I am getting an error that I don't understand from R CMD check on my current instance of the survival code. R2.7.1 on Linux. Here is the last of the log * checking line endings in Makefiles ... OK * checking for portable use of $BLAS_LIBS ... OK * creating survival-Ex.R ... OK * checking examples ... OK * checking tests ... make[1]: Entering directory `/home/therneau/research/surv/Rforge/pkg/survival.Rcheck/tests' Running 'aareg.R' make[1]: *** [aareg.Rout] Error 1 ... > tfit <- aareg(Surv(time, status) ~ x, test1) Error: could not find function "aareg" Execution halted -- The manual page aareg.Rd has a call to the function in the examples and that runs ok, and aareg is in the NAMESPACE exports. I'm almost certainly missing something obvious - please point it out. Thanks, Terry T. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] One more note
There are some warnings earlier in the log about my .Rd files (missing a description of weights and subset in a couple). The only message that I don't completely understand is * checking foreign function calls ... OK * checking R code for possible problems ... NOTE Error in firstlib(which.lib.loc, package) : Tcl/Tk support is not available on this system I'm also curious about this. But I get the same aareg error on the Sun server at work, without the Tcl message, so I know it is not primary. Terry T __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] One more note
Terry Therneau wrote: > There are some warnings earlier in the log about my .Rd files (missing a > description of weights and subset in a couple). The only message that I > don't completely understand is > > * checking foreign function calls ... OK > * checking R code for possible problems ... NOTE > Error in firstlib(which.lib.loc, package) : > Tcl/Tk support is not available on this system > > I'm also curious about this. But I get the same aareg error on the Sun > server > at work, without the Tcl message, so I know it is not primary. The most obvious reason would be if Tcl/Tk support is not available on your system (a) Which system? (b) Do you have > capabilities("tcltk") tcltk TRUE -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] CMD check puzzle
On Mon, 9 Feb 2009, Terry Therneau wrote: > tfit <- aareg(Surv(time, status) ~ x, test1) Error: could not find function "aareg" Execution halted -- The manual page aareg.Rd has a call to the function in the examples and that runs ok, and aareg is in the NAMESPACE exports. I'm almost certainly missing something obvious - please point it out. Based on the r-forge code it looks like you need library(survival) in R code in tests/. It doesn't happen automatically like it does for examples. -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] One more note
On Mon, 9 Feb 2009, Peter Dalgaard wrote: Terry Therneau wrote: There are some warnings earlier in the log about my .Rd files (missing a description of weights and subset in a couple). The only message that I don't completely understand is * checking foreign function calls ... OK * checking R code for possible problems ... NOTE Error in firstlib(which.lib.loc, package) : Tcl/Tk support is not available on this system I'm also curious about this. But I get the same aareg error on the Sun server at work, without the Tcl message, so I know it is not primary. The most obvious reason would be if Tcl/Tk support is not available on your system (a) Which system? (b) Do you have capabilities("tcltk") tcltk TRUE Because so many people assume that tcltk is present, those checks look for unexplained symbols in package tcltk. As it is not on your system, you will not be able to use the symbols and it does not matter. The call is inside try(), so the error is ignored. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] CMD check puzzle
> ... you need library(survival) in R code in tests/. It doesn't happen > automatically like it does for examples. Thanks Thomas, that is exactly the hint I needed. I had read the "check" part of the manual 3 times in vain; once you pointed it out I was able to fine the answer in the manual's description of the 'test' subdirectory. Terry T. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] heatmap without dendrogams (PR#13512)
Full_Name: Jelle Goeman Version: 2.8.1 OS: Win XP Submission from: (NULL) (87.212.67.197) I get the following error message when I try to make a heatmap (package stats), without the associated dendrograms. X <- matrix(rnorm(200),20,10) XX <- crossprod(X) heatmap(XX, Rowv= NA, revC=TRUE) Error in rev(ddr) : object "ddr" not found heatmap(XX, Rowv= NA, sym=TRUE) Error in heatmap(XX, Rowv = NA, sym = TRUE) : object "ddr" not found According to the help file, this should work; indeed it does if I set revC or sym to FALSE. Seems like ddr should be initialized to something like 1:ncol(X) for the no-dendrogram case. Kind regards, Jelle __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel