Like kile for LaTeX, Linux/KDE's kate editor is an excellent editor for R, with easy code submission to a running R process. Syntax highlighting is good. I have not been able to figure out two things: - how to automatically reformat a line or region of text using good indentation rules (Emacs/ESS make this so easy by just hitting Tab while the cursor is in a line, or highlighting a region and hitting Esq q) - how to cause auto-indenting as you type braces. For me, kate puts a { in column one Thanks for any pointers. Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University
On Thu, 2007-01-18 at 20:30 -0600, Frank E Harrell Jr wrote:> Like kile for LaTeX, Linux/KDE's kate editor is an excellent editor for > R, with easy code submission to a running R process. Syntax > highlighting is good. I have not been able to figure out two things: > > - how to automatically reformat a line or region of text using good > indentation rules (Emacs/ESS make this so easy by just hitting Tab while > the cursor is in a line, or highlighting a region and hitting Esq q) > > - how to cause auto-indenting as you type braces. For me, kate puts a { > in column one > > Thanks for any pointers.Frank, I'm not sure if what I found provides an optimistic outlook, however, you might find the following helpful: See the questions: Can I use different indenters for different files? How can I get KatePart to autoindent XXX code? at http://kate-editor.org/faq. KatePart is the text editing component in Kate. In the two answers, there are links to articles that provide additional insight into implementing indentation functionality in Kate. HTH, Marc
On Friday 19 January 2007 03:30, Frank E Harrell Jr wrote:> Like kile for LaTeX, Linux/KDE's kate editor is an excellent editor for > R, with easy code submission to a running R process. Syntax > highlighting is good. I have not been able to figure out two things: > > - how to automatically reformat a line or region of text using good > indentation rules (Emacs/ESS make this so easy by just hitting Tab while > the cursor is in a line, or highlighting a region and hitting Esq q) > > - how to cause auto-indenting as you type braces. For me, kate puts a { > in column one > > Thanks for any pointers.Dear Frank, May I ask why you are moving to Kate from Emacs? I tried Kate with R (and Python and LaTeX) and I really liked the folding (which seems a lot better than all the not-really-functional hacks for getting folding with R and Python code) and some of the function/class browsers. However, I specially missed: a) the possibility of opening as many R processes as I want, and placing that buffer in wherever place and with whichever size I want. b) most of the rest of emacs, actually (hey, where did my shells go? and my org-mode buffer? and my ...; not to talk about the keybindings). If you feel like it, I'd like to hear about your impressions. R.> > Frank-- Ram?n D?az-Uriarte Centro Nacional de Investigaciones Oncol?gicas (CNIO) (Spanish National Cancer Center) Melchor Fern?ndez Almagro, 3 28029 Madrid (Spain) Fax: +-34-91-224-6972 Phone: +-34-91-224-6900 http://ligarto.org/rdiaz PGP KeyID: 0xE89B3462 (http://ligarto.org/rdiaz/0xE89B3462.asc) **NOTA DE CONFIDENCIALIDAD** Este correo electr?nico, y en s...{{dropped}}
Re-sending to the list as I just got nailed by the "too many recipients" issue... On Sat, 2007-01-20 at 11:05 -0600, Marc Schwartz wrote:> On Sat, 2007-01-20 at 17:37 +0100, Peter Dalgaard wrote: > > Ramon Diaz-Uriarte wrote: > > > Hi Marc, > > > > > > > > > Thanks a lot for the detailed explanation! I'll give it a try. (But > > > still, why emacs23? what is missing in v. 21 that you get in 23?). > > > > > > Best, > > > > > > R. > > > > > Ability to load files with UTF-8 characters in the name? (This is pretty > > maddening if you find yourself with such a beast.) > > > > BTW, any inkling when/whether this is heading for Fedora N?Peter, 21.4 is what is presently in the FC7 development trunk (aka rawhide), so I would not expect to see it as a mainstream offering for some time. Needless to say, 23 is still alpha, so the FC timeline is likely more dependent on the upstream timeline to bring 23 to a stable release. Bill Nottingham at RH recently posted this summary of planned key updates to FC7: http://www.redhat.com/archives/fedora-devel-list/2007-January/msg00091.html and based upon subsequent communications, there has been at least one addition, which is the previously discussed replacement of teTeX with TeXLive: http://fedoraproject.org/wiki/Releases/FeatureTexLive BTW, for the Ubuntu users in the audience, I happened to come across these sites: http://peadrop.com/blog/2007/01/06/pretty-emacs/ http://debs.peadrop.com/dists/edgy/backports/ HTH, Marc
Thomas Lumley
2007-Jan-22 15:48 UTC
[R] How to get correct integration in C for step function?
On Sun, 21 Jan 2007, Lynette wrote:> Dear all, > > I am using Rdqags in C to realize the integration. It seems for the > continous C function I can get correct results. However, for step functions, > the results are not correct. For example, the following one, when integrated > from 0 to 1 gives 1 instead of the correct 1.5 >Using integrate() in R for an R-defined step function gives the right answer (eg on the example in ?ecdf). This suggests a problem in your C code, since integrate() just calls dqags. -thomas
Well, I have no idea either. I can get correct answers for continous functions but incorrect for step functions. Sign, I have been trying to realize the integration in C for long time. Thank you for your answering. Best, Lynette ----- Original Message ----- From: "Thomas Lumley" <tlumley at u.washington.edu> To: "Lynette" <fuyaonv at hotmail.com> Cc: <r-help at stat.math.ethz.ch>; "AJ Rossini" <blindglobe at gmail.com>; <ess-help at stat.math.ethz.ch> Sent: Monday, January 22, 2007 10:48 AM Subject: Re: [R] How to get correct integration in C for step function?> On Sun, 21 Jan 2007, Lynette wrote: > >> Dear all, >> >> I am using Rdqags in C to realize the integration. It seems for the >> continous C function I can get correct results. However, for step >> functions, >> the results are not correct. For example, the following one, when >> integrated >> from 0 to 1 gives 1 instead of the correct 1.5 >> > > Using integrate() in R for an R-defined step function gives the right > answer (eg on the example in ?ecdf). > > This suggests a problem in your C code, since integrate() just calls > dqags. > > -thomas >
Thomas Lumley
2007-Jan-22 17:42 UTC
[R] [ESS] How to get correct integration in C for step function?
On Mon, 22 Jan 2007, Lynette wrote:> Well, > > I have no idea either. I can get correct answers for continous functions but > incorrect for step functions. >I have just tried using Rdqags from C for the function x>0 and it worked fine (once I had declared all the arguments correctly). The code is below. -thomas #include "Rinternals.h" #include "R_ext/Applic.h" double stepfn(double x){ return (x>0); } SEXP call_stepfn(SEXP x){ SEXP answer; int i,n; n=length(x); PROTECT(answer=allocVector(REALSXP,n)); for(i=0;i<n;i++){ REAL(answer)[i]=stepfn(REAL(x)[i]); } UNPROTECT(1); return answer; } void vec_stepfn(double *x, int n, void *ex){ int i; for (i=0;i<n;i++) x[i]=stepfn(x[i]); return; } void Cvec_stepfn(double *x, double *n){ vec_stepfn(x, *n, (void *) NULL); return; } SEXP int_stepfn(SEXP lower, SEXP upper){ SEXP answer; double result, abserr; int last, neval, ier; int lenw; int *iwork; double *work; int limit=100; double reltol=0.00001; double abstol=0.00001; lenw = 4 * limit; iwork = (int *) R_alloc(limit, sizeof(int)); work = (double *) R_alloc(lenw, sizeof(double)); Rdqags(vec_stepfn, (void *) NULL, REAL(lower), REAL(upper), &abstol, &reltol, &result, &abserr, &neval, &ier, &limit, &lenw, &last, iwork, work); printf("%f %f %d\n", result,abserr, ier); PROTECT(answer=allocVector(REALSXP,1)); REAL(answer)[0]=result; UNPROTECT(1); return answer; }
Dear all, especially to Thomas, I have figured out the problem. For the step function, something wrong with my C codes. I should use the expression ((x>=0.25)&&(x<=0.75)) ? 2:1 instead of ((x>=1/4)&&(x<=3/4)) ? 2:1 ). Have no idea why 0.25 makes difference from 1/4 in C. But now I can go ahead with the correct integration in C. Thank you all. And hope this helps to others. Best wishes, Lynette ----- Original Message ----- From: "Lynette" <fuyaonv at hotmail.com> To: <r-help at stat.math.ethz.ch> Cc: "AJ Rossini" <blindglobe at gmail.com>; <ess-help at stat.math.ethz.ch> Sent: Sunday, January 21, 2007 6:24 PM Subject: [R] How to get correct integration in C for step function?> Dear all, > > I am using Rdqags in C to realize the integration. It seems for the > continous C function I can get correct results. However, for step > functions, > the results are not correct. For example, the following one, when > integrated > from 0 to 1 gives 1 instead of the correct 1.5 > > void func( double *x, int n, void *ex ) > { > int i; > > for(i=0;i<n;i++) { x[i]=( ((x>=1/4)&&(x<=3/4)) ? 2:1 ) ; } > return; > } > > while the following one when integrated from 0 to 1 gives the correct > 0.7853983 > > void func( double *x, int n, void *ex ) > { > int i; > > for(i=0;i<n;i++) { x[i]= pow(1-x[i]*x[i],.5); } > return; > } > > Please advise the problems. Thanks a lot. > > Best, > Lynette > > ______________________________________________ > R-help at 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. >
Thomas Lumley
2007-Jan-22 19:37 UTC
[R] How to get correct integration in C for step function?
On Mon, 22 Jan 2007, Lynette wrote:> Dear all, especially to Thomas, > > I have figured out the problem. For the step function, something wrong with > my C codes. I should use the expression ((x>=0.25)&&(x<=0.75)) ? 2:1 instead > of ((x>=1/4)&&(x<=3/4)) ? 2:1 ). Have no idea why 0.25 makes difference from > 1/4 in C. But now I can go ahead with the correct integration in C. Thank you > all. And hope this helps to others. >1 and 4 are ints in C, so 1/4 is 0 (integer division). -thomas