[R] provide extra variables to environment in call
Hi all, Situation: there is a function `f' already defined by someone and provided in package. `f' looks like that: f - function() { x+1 } i.e. `f' is not closed i.r.t. term `x' now I have my own function `g', where I'd like to override variable `x' while calling `f': x - dummy gloabal value g - function() { x - 42 eval(f(), environment()) # how to make loacl `x' visible in `f'? } g() # = Error in x + 1 : non-numeric argument to binary operator Here comes the question: What is the right way to call `f' in order to override global value of `x' with the local value defined within of function `g' ? I see that i've missed something in docs for eval/environments and related. Thank you in advance. -- Valery. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
AW: AW: [R] constructing specially ordered factor
Please follow the posting guide and do your homework before posting, 1. my last homework in university was done a lot of years ago. 2. I always try to follow posting guide. An object of the same type of 'x'. but if an element is equal to one with a smaller index, it is removed. so the order is preserved, by definition. Here stated when element is removed. There is no explicit statement, that the order is preserved. If one writes its own implementation with reodered output, it still matches the docs. Or? BTW it uses hashing for `acceleration', not something as slow as sorting. BTW, do you mean that current hash-based implementation brings *clearly* better performance than any O(n*log(n)) sort based algorithm? If I have correctly understood src/main/unique.c then current hash function is niether minimal perfect hash function nor even minimal hash function. In addition, as might be expected, current hash function uses full pass through the string to get a hash key. So, in particular, can anyone clearly show that the current hash-based algorithm will be quicker then sort-based algorithm if the input has: 1. a lot of strings; 2. strings are very long; 3. strings are quite unsimilar ? Hm, I don't believe you are ready to prove smth. like that. P.S. Sorry for broken email-reference. I am bound to Outlook Express now. -- Valery __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] constructing specially ordered factor
Hi all, my colleagues deal with tables, where every factor is represented in two columns. The first column contains some numeric codes and the second contains the corresponding symbolic name. For example: ISEXSSEX 0 Female 1 Male 0 Female 0 Female ... another example: ICONC SCONC 10 Normal 1000ExtraHigh 10 Normal 0 Nothing 100 High ... Colleagues require that the ordering should be done always by numeric column and not by the column with symbolic equivalents. Here comes the question: Is it possible to create factor with properly ordered and labeled values in nicer form then in the following long solution: Factor-function(Names,Weights) { iunique = !duplicated(Weights) uniqueWeights = Weights[iunique] uniqueNames = Names[iunique] # corresponding unique names factor(Names, uniqueNames[order(uniqueWeights)]) } Factor(SSEX, ISEX) Factor(SCONC, ICONC) Thank you in advance for the comments, Valery. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
AW: [R] constructing specially ordered factor
Hi Petr, Thank you for your reply. Factor - function(f,n, decreasing=TRUE, ...) { ooo-order(levels(factor(n)), decreasing=decreasing) my.order-levels(factor(f))[ooo] factor(f, levels=my.order) } it works incorrectly. Indeed, let's apply with your Factor: unames - c(thousands, units, dozens, hundreds, thousands, dozens) u - c(1000, 1,10,100, 1000, 10) Factor(unames, u) the above produces the following output: [1] thousands units dozenshundreds thousands dozens Levels: units thousands hundreds dozens where dozens hundreds --- Valery __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to save graphics in portable way in batch mode?
Hi all, What is the right portable way to save graphics in batch mode? Remarks: 1. Problem is STFWed and RTFMed. In particular a short note about png() is found in R-FAQ. In fact, there were stated that png() is not reliable under Linux in batch mode. 2. savePlot under windows is quite convenient, but not supplied under Linux. 3. pdf() + postscript() savePlot() Indeed, savePlot does support much more image formats and is flexible in changing type of output via its argument. 4. The scheme postscript(); plot(); dev.off(); makes R-scripts not really nice. Indeed, if one's script had about 15 plot calls then in order to save graphics one need to add 15 times the postscript() in prior of plot() call and then 15 times the dev.off() as epilogue to plot() call. 5. Hm, one could create function similar to Sweave() (see R-1.9.1\src\library\utils\R\Sweave.R) and benefit from automatic name generation and saving. But it is quite unnatural, isn't it? so, it would be nice to know what is the right way. P.S. BTW, will be there any specific changes in R-2.x? Thank you a priori for your comments, Valery. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
AW: [R] How to save graphics in portable way in batch mode?
pdf(onefile=FALSE) plot() plot() plot() dev.off() oh, nice hint. The following: pdf(file=aaa%02d.pdf, onefile=FALSE) is very close to compromise, thank you, Chunk! -- Valery. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
AW: AW: [R] built-in Sweave-like documentation in R-2.x
An simpler alternative to code would be to allow one to eval-chunk-and-step, stepping through chunks, similar to C-c C-n for stepping through lines. Would this solve the basic problem? 3 x (2 or 3 keystrokes) for 3 chunks. hm, not really ideal... I can't imagine an evaluation which would cross chunks but use only part of chunks (this suggests bad programming design to me), but perhaps you (or others) have an example of when this functionality would be useful? (i.e. actual regions to eval which cross code-chunk boundaries but contain 1 or 2 incomplete code-chunks?). hm, when?.. The very typical situation for me today is R-code with structure like this: ## # Section 1. Loading data # sometime execution time is *very* long (up to 5 minuutes with read.table) # This section have to be executed quite rarely ... # Section 2. Some initial data preparations and preprocessing # execution time might be long. This section have to be # executed a bit more often then Section 1. ... # Section 3. Task-oriented part # execution time might be very long, # this section is executed very often. ... ## actually the Section 3 motivated me to start this thread. because it usually consists of many chunk alternations and should be reexecuted many times during development. -- Valery __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
AW: AW: [R] built-in Sweave-like documentation in R-2.x
Is selecting and 'C-c C-r'-ing the 3 chunks separately that bad? Yes. The UI should take care of it for him. right. Others may have better suggestions. A bit more work on the chunk evaluation approach within Emacs is one; it almost does what is needed, but not quite. why almost, but not quite? ...without these almost, but not quite I would rather confirm your statemnt :) -- Valery __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
AW: [R] built-in Sweave-like documentation in R-2.x
hi tony, What exactly do you mean by this? 1. generation of Sweave-style docs from R programs or interaction? neither (if i correctly interpret your question). 2. tools for doing docs and analysis at the same time? Emacs Speaks Statistics has supported this with R since last century (1997 or so). as you have seen, i use emacs and even since last century :) 3. the vignettes of Bioconductor? not sure. 4. a text book in line with the above? nope. I think just smarter C-c C-r would be kind of trade-off here. hm, maybe there are some other voices here similar to mine? It would be easier to discuss the subj. -- Valery. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] built-in Sweave-like documentation in R-2.x
Hi devels, i did not find at this page: http://developer.r-project.org/ideas.txt any ideas concerning incorporating documentation possibilities (say, Sweave-based) into R-scripts. Was it discussed already? (If discussed, then what is the decision/conclusion then?) thanks, Valery __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
AW: [R] built-in Sweave-like documentation in R-2.x
See the 'Writing R Extensions' manual, specifically Creating R Packages - Writing package vignettes thank you, i saw this entry. However, this entry is rather about how to include documents (in particular Sweave-based) into a package. But I have meant smth else. Let me explain in example. Today I use emacs as environment for my R-sessions. I am quite happy to use Sweave, but not happy, that there is no good possibility to run some selected *part* of the R-code. Indeed, the R-chunks are alternated with Latex-chunks in Sweave. So, if one would like to execute, say, three consequent R-chunks (C-c C-r in ESS-mode), then the corresponding Latex-chunks between the R-chunks will cause side-effects. Actually, it is because neither ESS nor R could accept Latex-chunks and the markup symbols of Sweave. This makes interactive work in .Rnw files not fully convenient. Making the above short: would it be a bad idea to allow Latex-friendly documentation chunks in R-language? Thank you. P.S. I am sorry if i missed something well-known concerning the subj. -- Valery. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] SMP, Single System Image clustering, multithreading
Hi All, I have looked through the following thread: http://tolstoy.newcastle.edu.au/R/help/02b/4551.html and would like to ask after 1.5 year the same question: Are there any plans to involve multithread computations in R? Few word about my motivation: I use R on my OpenSSI cluster with 7 CPUs, so one could simply think of this cluster as of single computer with 7 CPU. My own C++ maths run good in parallel on the cluster. What is even better for me: my C++ code has *no* any statements about parallelization. All parallezation is done at command line. When I start a new piece of calculation from command line, the process is migrated to a free cluster node automatically, it migrates even during the calculation. The whole project is calculated nearly up to 7 time quicker then on a single CPU. Thus, I do see the boost clearly. However the same approach applied to R will force me to use batch mode instead of nice interactive mode. Now I am writing this mail and R is still busy with stats in usual interactive mode. Other 6 processors are idling unfortunately. It would be really nice to change this situation. my best regards, Valery. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] LLVM for next R generations
Hi R-developers, R (unlike say C++) is rather interactive/interpreter language with some high-order functions support. There is a nice project, which able to bring exactly these type of language implementations to a next performance level. I mean LLVM (http://llvm.cs.uiuc.edu/) LLVM could bring performance of R very close to compilable languages like C++ or even overperform them in some cases. Every function in LLVM might be compiled in run-time before execution, what is very nice for interactive environments. It would be nice if R-developers could take a glance at LLVM before they start to move towards next major version of R. P.S. i guess this mail is rather for this page with other ideas: http://developer.r-project.org/ideas.txt with best regards -- Valery __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] calling R from C
Hi All, We'd like to use functions provided in R in our application. Our application is written in C/C++ and currently runs on win32, Linux and Mac. We'd be happy to attach the whole R ( i.e. not just transfer some function by hand). The important detail is that we deal with big amount of data, so command line-like invocations won't be very interesting. We'd like to link R's code statically or dynamically. Any comments and/or links to docs on subj would be highly appreciated. (Especially comments on Mac) Thank you in advance. P.S. If this message appears twice -- I'm sorry (first one was sent in default HTML format) kind regards, Valery A.Khamenya --- Bioinformatics Department BioVisioN AG, Hannover __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] calling R from C
Hi All, We'd like to use functions provided in R in our application. Our application is written in C/C++ and currently runs on win32, Linux and Mac. We'd be happy to attach the whole R ( i.e. not just transfer some function by hand). It is important that we deal with big amount of data, so command line-like invocations won't be very interesting. We'd like to link R's code statically or dynamically. Any comments and/or links to docs on subj would be highly appreciated. (Especially comments on Mac) Thank you in advance. kind regards, Valery A.Khamenya --- Bioinformatics Department BioVisioN AG, Hannover __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help