Re: [R] How to use curve() function without using x as the variable name inside expression?
Also note that ifelse() should be avoided as much as possible. To define a piecewise function you can use this trick: func <- function (x, min, max) 1/(max-min) * (x >= min & x <= max) The performances are much better. This has no impact here, but it is a good habit to take in case you manipulate such kind of functions in a more computing-intensive context (numerical integration, nls(), etc.). funcIfElse <- function (x, min, max) ifelse(x < min | x > max, 0, 1/(max - min)) min <- 100; max <- 200; x <- 1:300 microbenchmark::microbenchmark(func(x, min, max), funcIfElse(x, min, max)) ## Unit: microseconds ## exprmin lq mean median uq max neval ## func(x, min, max) 10.242 16.0175 18.43348 18.446 19.8680 47.266 100 ## funcIfElse(x, min, max) 90.386 125.1605 148.18555 143.455 148.6695 1203.292 100 Best, Philippe Grosjean > On 31 Jan 2015, at 09:39, Rolf Turner wrote: > > On 31/01/15 21:10, C W wrote: >> Hi Bill, >> >> One quick question. What if I wanted to use curve() for a uniform >> distribution? >> >> Say, unif(0.5, 1.3), 0 elsewhere. >> >> My R code: >> func <- function(min, max){ >> 1 / (max - min) >> } >> >> curve(func(min = 0.5, max = 1.3), from = 0, to = 2) >> >> curve() wants an expression, but I have a constant. And I want zero >> everywhere else. > > Well if that's what you want, then say so!!! > > func <- function(x,min,max) { > ifelse(x < min | x > max, 0, 1/(max - min)) > } > > curve(func(u,0.5,1.3),0,2,xname="u") > > Or, better (?) curve(func(u,0.5,1.3),0,2,xname="u",type="s") > > which avoids the slight slope in the "vertical" lines. > > cheers, > > Rolf Turner > > -- > Rolf Turner > Technical Editor ANZJS > Department of Statistics > University of Auckland > Phone: +64-9-373-7599 ext. 88276 > Home phone: +64-9-480-4619 > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] some question about vector[-NULL]
..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. On 11 Sep 2014, at 17:18, Duncan Murdoch wrote: > On 11/09/2014 3:29 AM, Philippe GROSJEAN wrote: >> On 11 Sep 2014, at 08:24, PIKAL Petr wrote: >> >> > Hi >> > >> > You still do not disclose important info about details of your functions. >> > However, when you want to perform indexing like you show, you maybe can >> > get rid of NULL and use zero instead. >> > >> >> a<-1:5 >> >> a[-c(1,3)] >> > [1] 2 4 5 >> >> a[-c(0,1,3)] >> > [1] 2 4 5 >> >> a[-c(1,0,3)] >> > [1] 2 4 5 >> >> a[-c(0,1,0,3,0)] >> > [1] 2 4 5 >> > >> > However I am almost sure that you are fishing in murky waters and what you >> > do by cycle and fiddling with NULL elements can be achieved by more >> > efficiently. >> > >> … and also look at this weird case: >> >> > a <- 1:5 >> > a[-0] >> integer(0) >> > a[-c(0, 0)] >> integer(0) > > What do you find to be weird about this? As far as I can see it is acting > exactly as the documentation suggests it should: -0 is treated the same as > 0. Zero as an index selects nothing. Two zeroes also select nothing. > What's the surprise? > > Duncan Murdoch > No, it is not a surprise, nor a problem with the behaviour of R, really. It is just in connection with Petr's suggestion to replace NULL by 0. I just wanted to indicate that it could produce unwanted results in several cases. Philippe >> >> Best, >> >> Philippe >> >> >> > Regards >> > Petr >> > >> > >> >> -Original Message- >> >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- >> >> project.org] On Behalf Of PO SU >> >> Sent: Thursday, September 11, 2014 3:54 AM >> >> To: Duncan Murdoch >> >> Cc: R. Help >> >> Subject: Re: [R] some question about vector[-NULL] >> >> >> >> >> >> Tks, i think using logical index is a way, but to do that, i have to >> >> keep a vector as long as the original vector. that's, to exclude >> >> position 1 and 3 from >> >> a<-1:5 >> >> I have to let b<-c(F,T,F,T,T) and exec a[b], not a[-c(1,3)]. which >> >> c(1,3) is much shorter than b if a is a long vector. that's, b would >> >> be c(F,T,F,T,T,T,T,..,T) I thought a way , >> >> let d<-c(a,1) >> >> that d<-c(1,2,3,4,5,1) >> >> and initialize the index vector iv to length(d). that is iv<-6. >> >> then, d[-iv] is always equal a[- i ] , whether i is NULL or not. >> >> Because if i is NULL ,then iv is 6, if i is 2.then iv is c(2,6) and so >> >> on... >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> -- >> >> >> >> PO SU >> >> mail: desolato...@163.com >> >> Majored in Statistics from SJTU >> >> >> >> >> >> >> >> >> >> At 2014-09-11 01:58:46, "Duncan Murdoch" >> >> wrote: >> >>> On 10/09/2014 12:20 PM, William Dunlap wrote: >> >>>> Can you make your example a bit more concrete? E.g., is your 'index >> >>>> vector' A an integer vector? If so, integer(0), an integer vector >> >>>> with no elements, would be a more reasonable return value than NULL, >> >>>> an object of class NULL with length 0, for the 'not found' case and >> >>>> you could check for that case by asking if length(A)==0. >> >>>> >> >>>> Show us typical inputs and expected outputs for your function (i.e., >> >>>> the problem you want to solve). >> >>> >> >>> I think the problem with integer(0) and NULL is the same: a[-i] >> >> doesn't >> >>> act as expected (leaving out all the elements of i, i.e. nothing) if i >> >>> is either of those. The solution is to use logical indexing, not >> >>> negative numerical indexing. >> >>> >> >>> Duncan Murdoch >> >>>> >> >>>&g
Re: [R] some question about vector[-NULL]
On 11 Sep 2014, at 08:24, PIKAL Petr wrote: > Hi > > You still do not disclose important info about details of your functions. > However, when you want to perform indexing like you show, you maybe can get > rid of NULL and use zero instead. > >> a<-1:5 >> a[-c(1,3)] > [1] 2 4 5 >> a[-c(0,1,3)] > [1] 2 4 5 >> a[-c(1,0,3)] > [1] 2 4 5 >> a[-c(0,1,0,3,0)] > [1] 2 4 5 > > However I am almost sure that you are fishing in murky waters and what you do > by cycle and fiddling with NULL elements can be achieved by more efficiently. > … and also look at this weird case: > a <- 1:5 > a[-0] integer(0) > a[-c(0, 0)] integer(0) Best, Philippe > Regards > Petr > > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- >> project.org] On Behalf Of PO SU >> Sent: Thursday, September 11, 2014 3:54 AM >> To: Duncan Murdoch >> Cc: R. Help >> Subject: Re: [R] some question about vector[-NULL] >> >> >> Tks, i think using logical index is a way, but to do that, i have to >> keep a vector as long as the original vector. that's, to exclude >> position 1 and 3 from >> a<-1:5 >> I have to let b<-c(F,T,F,T,T) and exec a[b], not a[-c(1,3)]. which >> c(1,3) is much shorter than b if a is a long vector. that's, b would >> be c(F,T,F,T,T,T,T,..,T) I thought a way , >> let d<-c(a,1) >> that d<-c(1,2,3,4,5,1) >> and initialize the index vector iv to length(d). that is iv<-6. >> then, d[-iv] is always equal a[- i ] , whether i is NULL or not. >> Because if i is NULL ,then iv is 6, if i is 2.then iv is c(2,6) and so >> on... >> >> >> >> >> >> >> >> -- >> >> PO SU >> mail: desolato...@163.com >> Majored in Statistics from SJTU >> >> >> >> >> At 2014-09-11 01:58:46, "Duncan Murdoch" >> wrote: >>> On 10/09/2014 12:20 PM, William Dunlap wrote: Can you make your example a bit more concrete? E.g., is your 'index vector' A an integer vector? If so, integer(0), an integer vector with no elements, would be a more reasonable return value than NULL, an object of class NULL with length 0, for the 'not found' case and you could check for that case by asking if length(A)==0. Show us typical inputs and expected outputs for your function (i.e., the problem you want to solve). >>> >>> I think the problem with integer(0) and NULL is the same: a[-i] >> doesn't >>> act as expected (leaving out all the elements of i, i.e. nothing) if i >>> is either of those. The solution is to use logical indexing, not >>> negative numerical indexing. >>> >>> Duncan Murdoch Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Sep 10, 2014 at 8:53 AM, PO SU >> wrote: > > Tks for your > > a <- list(ress = 1, res = NULL) > And in my second question, let me explain it : > Actually i have two vectors in global enviroment, called A and B >> .A is initialized to NULL which used to record some index in B. > Then i would run a function F, and each time, i would get a index >> value or NULL. that's, D<-F(B). D would be NULL or some index >> position in B. > But in the function F, though input is B, i would exclude the >> index value from B recorded in A. That's : > F<-function( B ) { > B<-B[-A] > some processing... > res<-NULL or some new index not included in A > return(res) > } > so in a loop, > A<-NULL > for( i in 1:10) { > D<-F(B) > A<-c(A,D) > } > I never know whether D is a NULL or a different index compared >> with indexes already recorded in A. > Actually, A<-c(A,D) work well, i never worry about whether D is >> NULL or a real index, but in the function F, B<-B[-A] won't work. > so i hope that, e.g. > a<-1:3 > a[-NULL] wouldn't trigger an error but return a. > Because, if i wrote function like the following: > > F<-function( B ) { > if( is.null(A)) > B<-B > else > B<-B[-A] > some processing... > res<-NULL or some new index not included in A > return(res) > } > May be after 5 or 10 loops, A would already not NULL, so the added >> if ..else statement would be repeated in left loops which i would >> not like to see. > > > > > > -- > > PO SU > mail: desolato...@163.com > Majored in Statistics from SJTU > > > > At 2014-09-10 06:45:59, "Duncan Murdoch" >> wrote: >> On 10/09/2014, 3:21 AM, PO SU wrote: >>> >>> Dear expeRts, >>> I have some programming questions about NULL in R.There >> are listed as follows: >>> 1. I find i can't let a list have a element NULL: >>> a<-list() >>> a$ress<-1 >>> a$res<-NULL >>> a >>> str(a) >> >> You can do it using >> >> a <- list(ress = 1, res = NULL) >> >>> How can i know i have a named element but it is NULL, not just >> get a$,a$,a$ there all get NULL >> >> That's
[R] Default argument not passed to subfunction when argument name matches default expression
Hello, I have difficulties to understand this one: foo <- function (y = 2) { bar <- function (y = y) y^2 bar() } foo() #! Error in y^2 : 'y' is missing foo(3) #! Error in y^2 : 'y' is missing Note that this one works: foo <- function (y = 2) { bar <- function (y = y) y^2 bar(y) # Not using default value for y= argument } foo() #! [1] 4 foo(3) #! [1] 9 … as well as this one: foo <- function (y = 2) { bar <- function (Y = y) Y^2 bar() # Default, but different names for argument Y= and value 'y' } foo() #! [1] 4 foo(3) #! [1] 9 Best, PhG > sessionInfo() R version 3.0.2 (2013-09-25) Platform: x86_64-apple-darwin10.8.0 (64-bit) locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with do.call().
On 28 Mar 2014, at 00:57, Duncan Murdoch wrote: > On 27/03/2014, 7:38 PM, Thomas Lumley wrote: >> You get what you wanted from >> >> do.call(plot,list(x=quote(x),y=quote(y))) >> >> By the time do.call() gets the arguments it doesn't know how y was >> originally computed, just what values it has. > > This works, but it doesn't make sense to me. The arguments end up with the > expressions x and y, but why are they evaluated in the right place? Quote > doesn't bind an environment to its expressions, does it? How does plot() > know where to evaluate them? > > Duncan Murdoch > I am puzzled here… Isn't it the same when you write plot(x = x, y = y)? You don't tell the environment for your 'x' and 'y' expressions, isn't it? And they are defined from the context the function call and definition. You do the same with the env= argument of do.call() which is equal to parent.frame() by default. As far as I understand, it is behaving similarly. I have tried a few "risky" situations: 1) S3 dispatch: ## do.call() with quote() inside S3 methods ## Trying to be silly by defining x and y inside the generic too to make sure do.call() isn't confused myPlot <- function (x, y, ...) { x <- 101:110 y <- rep(1, 10) UseMethod("myPlot") } ## A method that uses plot() directly myPlot.anObj1 <- function (x, y, ...) plot(x = x, y = y) x <- structure(1:10, class = "anObj1") y <- (x - 5.5)^2 myPlot(x = x, y = y) # right ## A method that uses do.call() with quote() myPlot.anObj2 <- function (x, y, ...) do.call(plot, list(x = quote(x), y = quote(y))) x <- structure(1:10, class = "anObj2") myPlot(x = x, y = y) # same result ## A dispatch to the default method myPlot.default <- function (x, y, ...) do.call(plot, list(x = quote(x), y = quote(y))) x <- 1:10 myPlot(x = x, y = y) # same result This seems to give the same thing. 2) A really crazy and tortuous closure where I try to confuse do.call() with lexical scoping and all the stuff: ## This one uses plot() directly makePlotFun1 <- function () { x <- 1:10 y <- (x - 5.5)^2 Y <- y ## If I use y directly as default value for argument y= in the next instruction ## I got a "promise already under evaluation" error! function (x, y = Y) plot(x = x, y = y) } ## This one uses do.call(plot, ….) makePlotFun2 <- function () { x <- 1:10 y <- (x - 5.5)^2 Y <- y ## Same remark as for makePlotFun1() function (x, y = Y) { do.call(plot, list(x = quote(x), y = quote(y))) } } ## Different x and y values in .GlobalEnv x <- 101:110 y <- rep(1, 10) myPlotFun1 <- makePlotFun1() myPlotFun1(x = x, y = y) ## and... myPlotFun1(x = x) # It uses y from the closure. It's fine. ## Now, using do.call() myPlotFun2 <- makePlotFun2() myPlotFun2(x = x, y = y) ## and... myPlotFun2(x = x) # Same result You are probably right, but I cannot think of a situation where do.call(plot, list(x = quote(x), y = quote(y)) do not give the same result as list(x = x, y = y). Have you an example? Best, Philippe > >> >>-thomas >> >> >> On Thu, Mar 27, 2014 at 6:17 PM, Rolf Turner wrote: >> >>> >>> >>> I was under the impression that >>> >>> do.call(foo,list(x=x,y=y)) >>> >>> should yield the same result as >>> >>> foo(x,y). >>> >>> However if I do >>> >>> x <- 1:10 >>> y <- (x-5.5)^2 >>> do.call(plot,list(x=x,y=y)) >>> >>> I get the expected plot but with the y-values (surrounded by c()) being >>> printed (vertically) in the left-hand margin of the plot. >>> >>> The help for do.call() says: >>> >>> The behavior of some functions, such as substitute, will not be the same for functions evaluated using do.call as if they were evaluated from the interpreter. The precise semantics are currently undefined and subject to change. >>> >>> Am I being bitten by an instance of this phenomenon? Seems strange. >>> >>> I would be grateful for enlightenment. >>> >>> cheers, >>> >>> Rolf Turner >>> >>> __ >>> R-help@r-project.org 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@r-project.org 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@r-project.org 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] delayedAssign list members
> delayedAssign("foo$bar", 2) > > foo$bar # 1 > > `foo$bar` # 2 Yes, you assign to the new variable `foo$bar`, not to bar component of the foo variable! You can use an environment for doing what you want: e <- new.env() e$bar <- 1 delayedAssign("bar", 2, assign.env = e) e$bar But notice also the eval.env= argument of delayedAssign()… Depending on what you want do, you have to provide this also. Note also that the use of environments, as well as playing with lazy evaluation are advanced techniques you should really well understand, or you will encounter many other surprises. Take care, for instance, about how you save and reload, or dump(), etc. environment objects, if that happens to be something you want do too. So, unless you really find an advantage with this, you would be better to continue using plain list() and try to forget about delayedAssign(). Best, Philippe Grosjean On 04 Mar 2014, at 09:23, "Shan Huang" wrote: > I am fascinated by lazy evaluation mechanism provided by delayedAssign. Like > > > > delayedAssign("foo", { > > Sys.sleep(1) # or any other time consuming operations > > 1 > > } > > > > Time consuming operations will be evaluated only if object "foo" is used. > > But when I try: > > > > foo <- list() > > foo$bar <- 1 > > delayedAssign("foo$bar", 2) > > foo$bar # 1 > > `foo$bar` # 2 > > > > Shows that delayedAssign can't be applied to list members, instead symbol > with "$" will be assigned. > > What I actually want is a lazy evaluation wrapper for large complex > hierarchical datasets. Like: > > > > MyDatasets <- list( > > Dataset1 = complexData1 > > Dataset2 = complexData2 > > ) > > > > There is no need for loading whole datasets when I only use Dataset1. And I > want to implement some > > incremental updating mechanism fetching data from remote host. > > Can any one give me some tips to implement this? > > __ > R-help@r-project.org 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@r-project.org 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] sub function problem
Hi, Despite OS is not provided, we can guess it is Windows, since Tinn-R works only on Windows. The error message is quite clear, I think: R must start a socket server in order for Tinn-R to communicate with it. Did you look at ?startSocketServer in the svSocket package? Then, you would have a clue of what it is. Now, why is your communication between Tinn-R and R broken once you have crashed R (or for some reasons, R did not close completely and a zombie R process remains in memory)? Simply because the zombie process has still the corresponding socket open, and you cannot start another R process and create a server on the same port. You have to kill the zombie first! In Linux, people are used to that kind of situation, but many Windows users have difficulties to deal with this. See for instance here: http://www.techrepublic.com/blog/windows-and-office/quick-tip-kill-rogue-processes-with-taskkill-in-microsoft-windows/3585/ Best, Philippe Grosjean On 04 Mar 2014, at 08:33, PIKAL Petr wrote: > Hi > > I also used Tinn-R but an old version 1.18.5.6 and did not experience such > error. Maybe you could try to use plain Notepad for your code just to check > if it is Tinn-R issue. > > I have no idea what the error means. However for anybody to have sensible > answer you definitelly need to reveal your OS, R version, Tinn-R version and > code which leads to such error. > > Regards > Petr > >> -Original Message- >> From: Massimiliano Tripoli [mailto:mtrip...@istat.it] >> Sent: Monday, March 03, 2014 5:39 PM >> To: PIKAL Petr >> Cc: r-help@r-project.org >> Subject: Re: [R] sub function problem >> >> Hi Petr, >> thanks for your response. >> You're right. I counted incorrectly the numbers of spaces at the >> beginning of the sub function directly called as you can see at the >> end. >> If the string has a length more than 10 it works correctly returning >> the same string of input except if there are some spaces at the >> beginning, that correctly it reduces to one as it expected. >> But what about the error 10061 that I usually encountered ? In this >> case I used Tinn-R (I know it's not a Tinn-R forum sorry). Is it >> correlated with it. >> >> Thanks >> >> >> >> - Messaggio originale - >> Da: "PIKAL Petr" >> A: "Massimiliano Tripoli" , r-help@r-project.org >> Inviato: Lunedì, 3 marzo 2014 10:36:02 >> Oggetto: RE: [R] sub function problem >> >> Hi >> >> Everything works for me as expected. Nothing happens R starts as usual. >> >> You can shorten your function >> >> corregge2 <- function(stringa){ >> nc <- nchar(stringa) >> stringa <- sub("^ ", "", stringa) >> stringa <- sub(" +$", "", stringa) >> if (nc <9) stringa <- NA >> if (nc == 9) stringa <- paste("0",stringa,sep="") if (nc == 10) stringa >> <- paste("00",stringa,sep="") stringa } >> >> What if your string has length more than 10? >> >> Regards >> Petr >> >>> -Original Message- >>> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- >>> project.org] On Behalf Of Massimiliano Tripoli >>> Sent: Friday, February 28, 2014 5:44 PM >>> To: r-help@r-project.org >>> Subject: [R] sub function problem >>> >>> >>> Dear all, >>> >>> I write a R function that it should handles strings like removing >>> spaces at the beginning or returning NA according an IF condition. >>> Here you are the code: >>> >>> corregge.CF <- function(stringa){ >>> nc <- nchar(stringa) >>> stringa <- sub("^ ", "", stringa) >>> stringa <- sub(" +$", "", stringa) if (nc == 1) stringa <- NA if >>> (nc == 2) stringa <- NA if (nc == 3) stringa <- NA if (nc == 4) >>> stringa <- NA if (nc == 5) stringa <- NA if (nc == 6) stringa <- NA >> if >>> (nc == 7) stringa <- NA if (nc == 8) stringa <- NA if (nc == 9) >>> stringa <- paste("0",stringa,sep="") if (nc == 10) stringa <- >>> paste("00",stringa,sep="") >>>stringa >>> } >>> >>> I had this result: >>> >>>> corregge.CF <- function(stringa){ >>> + nc <- nchar(stringa) >>> + stringa <- sub("^ ", "", stringa) >>> + stringa <- sub(" +$", &q
Re: [R] shapiro.test
Greg, I really like that TeachingDemos::SnowsPenultimateNormalityTest()… even the tortuous way to always return a p-value == 0: # the following function works for current implementations of R # to my knowledge, eventually it may need to be expanded is.rational <- function(x){ rep( TRUE, length(x) ) } tmp.p <- if( any(is.rational(x))) { 0 } else { # current implementation will not get here if length # of x is positive. This part is reserved for the # ultimate test 1 } (p.value is then returned as tmp.p). Also, the nice and sexy printing of that p-value in R as: p-value < 2.2e-16 which looks much more serious than 'p-value = 0'… Here you has nothing to do. The stats::format.pval() function called from stats:::print.htest() already does the job for you! I am just curious… Are there teachers out there pointing to that test? If yes, what fraction of the students realise what happens? I guess, it is closer to zero than to one, unfortunately. Wait… I need another SnowsPenultimateXxxxTest() here to check the null hypothesis that all my students are doing what they are supposed to do when discovering a new statistical tool! Best, Philippe Grosjean On 21 Feb 2014, at 23:53, Greg Snow <538...@gmail.com> wrote: > Rui, > > Note this quote from the last paragraph of the Details section of ?ks.test: > > "If a single-sample test is used, the parameters specified in '...' > must be pre-specified and not estimated from the data." > > Which is the exact opposite of your example. > > > > Gonzalo, > > Why are you testing your data for normality? For large sample sizes > the normality tests often give a meaningful answer to a meaningless > question (for small samples they give a meaningless answer to a > meaningful question). > > If you really feel the need for a p-value then > SnowsPenultimateNormalityTest in the TeachingDemos package will work > for large sample sizes. But note that the documentation for that > function is considered more useful than the function itself. > > > > On Fri, Feb 21, 2014 at 3:04 PM, Rui Barradas wrote: >> Hello, >> >> Not answering directly to your question, if the sample size is a documented >> problem with shapiro.test and you want a normality test, why don't you use >> ?ks.test? >> >> m <- mean(HP_TrinityK25$V2) >> s <- sd(HP_TrinityK25$V2) >> >> ks.test(HP_TrinityK25$V2, "pnorm", m, s) >> >> >> Hope this helps, >> >> Rui Barradas >> >> Em 21-02-2014 15:59, Gonzalo Villarino Pizarro escreveu: >> >>> Dear R users, >>> Please help with with this maybe basic question. I am trying to see if my >>> data is normal but is a large file and the test does not work. >>> I keep getting the message : "Error in shapiro.test(x = HP_TrinityK25$V2) >>> : sample size must be between 3 and 5000" >>> thanks! >>> >>> shapiro.test(x=HP_TrinityK25$V2) >>> Error in shapiro.test(x = HP_TrinityK25$V2) : sample size must be between >>> 3 >>> and 5000 >>> >>> ##Note: >>> HP_TrinityK25= my file >>> HP_TrinityK25$V2= data in my file >>> >>>[[alternative HTML version deleted]] >>> >>> __ >>> R-help@r-project.org 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@r-project.org 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. > > > > -- > Gregory (Greg) L. Snow Ph.D. > 538...@gmail.com > > __ > R-help@r-project.org 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@r-project.org 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] Performance issue with attributes
You can use setattr() in the data.table package. It can be used too on data.frames or other objects. Best, Philippe Grosjean On 22 Feb 2014, at 03:13, Smart Guy wrote: > Hi All > > I am having problem running the 'attributes' command to set a attribute on > each column of a large dataset. Dataset has 80 columns and 312407 rows. Its > taking more than 60 seconds to set simple attributes like split=TRUE, > usermissing=FALSE. > > Here is the source code, assuming Dataset1 is the one that is large :- > > myfunction <- function() > { > cat("Before for loop:") > print(Sys.time()) > for( colIndex in 1 : 80) > { > cat("Before Attr", colIndex) > print(Sys.time()) > > attributes(Dataset1[1]) <- c(attributes(Dataset1[, colIndex]), list(coldesc > = c(), usermissing = c(FALSE), missingvalues = NULL, split = c(FALSE), > levelLabels = c(""))) > > cat("After Attr:") > print(Sys.time()) > } > cat("After for loop:") > print(Sys.time()) > } > > Its my feeling that R is passing all 312407 rows to set 'attributes' on a > cloumn. > > Is there a more efficent way to do this? > > > Thanks, > SG > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org 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@r-project.org 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] memory use of copies
For the last case with the list: > x <- 1:2; y = list(x)[rep(1, 4)] > .Internal(inspect(y)) @102bbe090 19 VECSXP g0c3 [MARK,NAM(2)] (len=4, tl=0) @106119628 13 INTSXP g0c1 [MARK] (len=2, tl=0) 1,2 @106119628 13 INTSXP g0c1 [MARK] (len=2, tl=0) 1,2 @106119628 13 INTSXP g0c1 [MARK] (len=2, tl=0) 1,2 @106119628 13 INTSXP g0c1 [MARK] (len=2, tl=0) 1,2 > y[[1]][1] <- 2L # everybody copied > .Internal(inspect(y)) @102fca698 19 VECSXP g0c3 [NAM(1)] (len=4, tl=0) @1061196b8 13 INTSXP g0c1 [] (len=2, tl=0) 2,2 @106119688 13 INTSXP g0c1 [] (len=2, tl=0) 1,2 @106119658 13 INTSXP g0c1 [] (len=2, tl=0) 1,2 @106119718 13 INTSXP g0c1 [] (len=2, tl=0) 1,2 > y1 <- y[[1]]; y1[1] <- 3L; y[[1]] <- y1 # only one copied > .Internal(inspect(y)) @102fca698 19 VECSXP g0c3 [MARK,NAM(1)] (len=4, tl=0) @10610b7a8 13 INTSXP g0c1 [MARK] (len=2, tl=0) 3,2 @106119688 13 INTSXP g0c1 [MARK] (len=2, tl=0) 1,2 @106119658 13 INTSXP g0c1 [MARK] (len=2, tl=0) 1,2 @106119718 13 INTSXP g0c1 [MARK] (len=2, tl=0) 1,2 Assignment to "double subset" of a list seems to trigger full copy of the list, but `[[<-` alone appears smart enough to avoid copying the other elements of the list. Best, Philippe ..<°}))><.... ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. On 29 Jan 2014, at 00:53, Ross Boylan wrote: > Thank you for a very thorough analysis. It seems whether or not an > operation makes a full copy really depends on the specific operation, > and that it is not safe to assume that because I know something is > unchanged there will be no copy. For example, in your last case only > one element of a list was modified, but all the list elements got new > memory. > > BTW, one reason I got into this, aside from wanting to save memory, is > that I found my code was spending a lot of time in areas that probably > involved getting new memory. So it mattered for speed too. > > Ross > > On Mon, 2014-01-27 at 06:33 -0800, Martin Morgan wrote: >> Hi Ross -- >> >> On 01/23/2014 05:53 PM, Ross Boylan wrote: >>> [Apologies if a duplicate; we are having mail problems.] >>> >>> I am trying to understand the circumstances under which R makes a copy >>> of an object, as opposed to simply referring to it. I'm talking about >>> what goes on under the hood, not the user semantics. I'm doing things >>> that take a lot of memory, and am trying to minimize my use. >>> >>> I thought that R was clever so that copies were created lazily. For >>> example, if a is matrix, then >>> b <- a >>> b & a referred to to the same object underneath, so that a complete >>> duplicate (deep copy) wasn't made until it was necessary, e.g., >>> b[3, 1] <- 4 >>> would duplicate the contents of a to b, and then overwrite them. >> >> Compiling your R with --enable-memory-profiling gives access to the >> tracemem() >> function, showing that your understanding above is correct >> >>> b = matrix(0, 3, 2) >>> tracemem(b) >> [1] "<0x7054020>" >>> a = b## no copy >>> b[3, 1] = 2 ## copy >> tracemem[0x7054020 -> 0x7053fc8]: >>> b = matrix(0, 3, 2) >>> tracemem(b) >>> tracemem(b) >> [1] "<0x680e258>" >>> b[3, 1] = 2 ## no copy >>> >> >> The same is apparent using .Internal(inspect()), where the first information >> @7053ec0 is the address of the data. The other relevant part is the 'NAM()' >> field, which indicates whether there are 0, 1 or (have been) at least 2 >> symbols >> referring to the data. NAM() increments from 1 (no duplication on modify >> required) on original creation to 2 when a = b (duplicate on modify) >> >>> b = matrix(0, 3, 2) >>> .Internal(inspect(b)) >> @7053ec0 14 REALSXP g0c4 [NAM(1),ATT] (len=6, tl=0) 0,0,0,0,0,... >> ATTRIB: >> @7057528 02 LISTSXP g0c0 [] >> TAG: @21c5fb8 01 SYMSXP g0c0 [LCK,gp=0x4000] "dim" (has value) >> @7056858 13 INTSXP g0c1 [NAM(2)] (len=2, tl=0) 3,2 >>> b[3, 1] = 2 >>> .Internal(inspect(b)) >> @7053ec0 14 REALSXP g0c4 [NAM(1),ATT] (len=6, tl=0) 0,0,2,0,0,... >> ATTRIB: >> @7057528 02 LISTSXP g0c0 [] >> TAG: @21c5fb8 01 SYMSXP g0c0 [LCK,gp=0x4000] "dim" (has value) >> @7056858 13 INTSXP g0c1 [NAM(2)] (len=2, tl=0) 3,2 >>> a = b >>> .Internal(insp
Re: [R] bug in rle?
Wouldn't it make sense to be able to use rle() on factor/ordered too? For instance: rle2 <- function (x) { if (!is.factor(x)) return(rle(x)) ## Special case for factor and ordered res <- rle(as.integer(x)) ## Change $values into factor or ordered with correct levels if (is.ordered(x)) { res$values <- ordered(res$values, levels = levels(x)) } else res$values <- factor(res$values, levels = levels(x)) res } ## Example fac <- factor(sample(1:3, 20, replace = TRUE)) ord <- as.ordered(fac) (fac.rle <- rle2(fac)) (ord.rle <- rle2(ord)) ## Inverse.rle() does not need to change: identical(fac, inverse.rle(fac.rle)) identical(ord, inverse.rle(ord.rle)) Best, Philippe Grosjean On 08 Jan 2014, at 18:48, Bert Gunter wrote: > Thanks Bill: > > Personally, I don't need it. Once Brian made me aware of the > underlying issue, I can handle it. > > Cheers, > Bert > > Bert Gunter > Genentech Nonclinical Biostatistics > (650) 467-7374 > > "Data is not information. Information is not knowledge. And knowledge > is certainly not wisdom." > H. Gilbert Welch > > > > > On Wed, Jan 8, 2014 at 9:30 AM, William Dunlap wrote: >> If you need an rle for factor data (or lists, or anything for >> which match(), unique(), and x[i] act in a coherent way), try the >> following. It is based on the S+, all-S code, version of rle. >> >> (It does not work on data.frames because unique is row oriented >> and match is column oriented for data.frames. If that were >> changed, it still would need a x[ends,] instead of x[ends] in the >> closing statement.) >> >> myRle <- function (x) >> { >>if (length(x) == 0) { >>list(lengths = integer(0L), values = x) >>} >>else { >>x.int <- match(x, unique(x)) >>ends <- c(diff(x.int) != 0L, TRUE) >>list(lengths = diff(c(0L, seq(along = x)[ends])), values = x[ends]) >>} >> } >> >> Bill Dunlap >> Spotfire, TIBCO Software >> wdunlap tibco.com >> >> >>> -Original Message- >>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On >>> Behalf >>> Of Bert Gunter >>> Sent: Wednesday, January 08, 2014 8:56 AM >>> To: Prof Brian Ripley >>> Cc: r-help@r-project.org >>> Subject: Re: [R] bug in rle? >>> >>> Thank you Brian for your clear and informative answer. I was >>> (obviously!) unaware of this and appreciate the response. >>> >>> Best, >>> Bert >>> >>> Bert Gunter >>> Genentech Nonclinical Biostatistics >>> (650) 467-7374 >>> >>> "Data is not information. Information is not knowledge. And knowledge >>> is certainly not wisdom." >>> H. Gilbert Welch >>> >>> >>> >>> >>> On Wed, Jan 8, 2014 at 8:53 AM, Prof Brian Ripley >>> wrote: >>>> On 08/01/2014 16:23, Bert Gunter wrote: >>>>> >>>>> Is the following a bug? >>>>> ##(R version 3.0.2 (2013-09-25) >>>>> ## Platform: i386-w64-mingw32/i386 (32-bit)) >>>>> >>>>> >>>>> d <- data.frame(a=rep(letters[1:3],4:6)) >>>>> rle(d$a) >>>>> ##Error in rle(d$a) : 'x' must be an atomic vector >>>>> >>>>> is.atomic(d$a) >>>>> ##[1] TRUE >>>> >>>> >>>> But >>>> >>>>> is.vector(d$a) >>>> [1] FALSE >>>> >>>> The discrepancies in what a 'vector' is in R are very long standing, but a >>>> factor is not a vector. >>>> >>>> >>>>> rle(c(d$a)) >>>> >>>> >>>> That loses the class and other attributes, giving a vector. >>>> >>>>> ## Run Length Encoding >>>>> ## lengths: int [1:3] 4 5 6 >>>>> ## values : int [1:3] 1 2 3 >>>>> >>>>> Cheers, >>>>> Bert >>>>> >>>>> Bert Gunter >>>>> Genentech Nonclinical Biostatistics >>>>> (650) 467-7374 >>>> >>>> >>>> >>>> -- >>>> 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-help@r-project.org 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@r-project.org 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@r-project.org 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] Package dependencies in building R packages
On 30 Dec 2013, at 20:01, Axel Urbiz wrote: > Thanks for your kind response Duncan. To be more specific, I'm using the > function mvrnorm from MASS. The issue is that MASS depends on survival and > I have a function in my package named tt() which conflicts with a function > in survival of the same name. I can think of 2 alternatives solutions to my > problem, but I'm to an expert: As of version 7.3-29 of MASS, it only depends on R (>= 3.0.0), grDevices, graphics, stats and utils. survival appears in the 'Suggests' field, which is very different. When you do 'library(MASS)' or 'require(MASS)', it does not import survival's NAMESPACE, at least at startup (and if it did, this would not cause interferences with your package… precisely the purpose of namespaces). It also does not attach survival to the search path, logically… and if it did, your package 'foo' would be attached higher on that search path, causing survival's tt() function being masked by your foo::tt() function, e.g., from the Global Environment with a warning. So, the only inconvenience in this case would be for users that need to use tt() from 'survival', and it would be better to always indicate explicitly foo::tt() or survival::tt() in order to eliminate the ambiguity. > 1) Copy mvrnorm into my package, which I thought was not a good idea Absolutely, think about future bug fixes. Moreover, it will not solve the problem in case someone attaches the 'survival' package higher in the search path than 'foo', e.g., using this in .GlobalEnv: require(foo) require(survival) tt() # This would be survival::tt() that is called! > 2) Rename my tt() function to something else in my package, but this is > painful as I have it all over the place in other functions. Definitely the best solution, providing your package is not on CRAN yet and has no other CRAN packages depending on it, and especially on your tt() function. Otherwise, you should declare tt() deprecated (see ?.Deprecated), make sure you inform maintainers of dependent packages of your changes, and wait long enough before removing tt() totally for user to adapt. Otherwise, choose a good code editor, with regexpr search on all files in a directory makes it easy to change calls to tt() all over the places. RStudio, Emacs+ESS, Eclipse+StatEt, Komodo+SciViews-K come to me mind first, but there are many others. Best, Philippe > Any suggestions would be much appreciated. > > Best, > Axel. > > > On Mon, Dec 30, 2013 at 7:51 PM, Duncan Murdoch > wrote: > >> On 13-12-30 1:24 PM, Axel Urbiz wrote: >> >>> Dear users, >>> >>> My package {foo} depends on a function "miscFUN" which is on package >>> {foo_depend}. This last package also depends on other packages, say {A, B, >>> C}, but miscFUN is not dependent on A, B, C (only on foo_depend). >>> >>> In my package {foo}, is there a way to only have it depend on the function >>> miscFUN from {foo_depend} without having the user to have installed A, B, >>> C? (as none of those packages are needed for my package to work properly). >>> Also, is this a best practice? >>> >> >> There's no way for your package to tell R to ignore the dependencies >> declared by foo_depend. >> >> If you really only need one function from that package, simply copy the >> source of miscFUN into your package (assuming foo_depend's license permits >> that). But this is not best practice, unless that function is very simple. >> Best practice is to declare your dependence by importing that function >> from foo_depend. >> >> Duncan Murdoch >> >> >> > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org 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@r-project.org 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] convert list of lists to simple list
On 10 Oct 2013, at 13:17, ivan wrote: > test <- foreach(i = 1:3) %:% > foreach (j = 1:3) %do% { > paste(i,j,sep=",") > } Not easily reproducible, unless you write #install.packages("foreach") require(foreach) in front of your code. Here is a starting point: unlist(test, recursive = FALSE) … but you would probably need to build a recursive call of the function down to the last 'list level'. unlist(recursive = TRUE) goes one level too far. Best, Philippe Grosjean __ R-help@r-project.org 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] Vector of char generated by Sys.getenv function is not available when the package is loaded
Hi JCFaria, You package is supposed to be used only under Windows, right? Then, use: OS_type=windows in the DESCRIPTION file… and, of course, use R CMD check/R CMD build/ R CMD INSTALL under Windows only. Best, Philippe On 23 Sep 2013, at 20:55, Jose Claudio Faria wrote: > I have been developing a new package (TinnRcom) to avoid the necessity > of any script > (as below) in the Rprofile.site file related to the use of Tinn-R Editor and > R: > > #=== > # Tinn-R: necessary packages and functions > # Tinn-R: >= 2.4.1.1 with TinnR package >= 1.0.3 > #=== > # Set the URL of the preferred repository, below some examples: > options(repos='http://cran.at.r-project.org/') # Austria/Wien > #options(repos='http://cran-r.c3sl.ufpr.br/') # Brazil/PR > #options(repos='http://cran.fiocruz.br/') # Brazil/RJ > #options(repos='http://www.vps.fmvz.usp.br/CRAN/') # Brazil/SP > #options(repos='http://brieger.esalq.usp.br/CRAN/') # Brazil/SP > > library(utils) > > # Check necessary packages > necessary <- c('TinnR', > 'svSocket', > 'formatR') > > installed <- necessary %in% installed.packages()[, 'Package'] > if (length(necessary[!installed]) >=1) > install.packages(necessary[!installed]) > > # Load packages > library(TinnR) > library(svSocket) > > # Uncoment the two lines below if you want Tinn-R to always start R at > start-up > # (Observation: check the path of Tinn-R.exe) > options(IDE='C:/Tinn-R/bin/Tinn-R.exe') > trStartIDE() > > # Short paths > .trPaths <- paste(paste(Sys.getenv('APPDATA'), >'\\Tinn-R\\tmp\\', >sep=''), > c('', >'search.txt', >'objects.txt', >'file.r', >'selection.r', >'block.r', >'lines.r', >'reformat-input.r', >'reformat-output.r'), > sep='') > > library(Matrix) > library(cluster) > library(Hmisc) > #=== > > For this it is necessary to put the object trPaths in the new TinnRcom > package. > > I make this as follows in the folder TinnRcom/R/trPaths.R: > > trPaths <- paste(paste(Sys.getenv('APPDATA'), > '\\Tinn-R\\tmp\\', > sep=''), > c('', > 'search.txt', > 'objects.txt', > 'file.r', > 'selection.r', > 'block.r', > 'lines.r', > 'reformat-input.r', > 'reformat-output.r'), > sep='') > > > The NAMESPACE file is as below: > > import(utils, tcltk, Hmisc, R2HTML) > importFrom(formatR, tidy.source) > importFrom(svSocket, evalServer) > > export( > trArgs, > trComplete, > trCopy, > trExport, > trObjList, > trObjSearch, > trPaths, > trStartIDE) > > S3method(trExport, default) > S3method(trExport, data.frame) > S3method(trExport, matrix) > > > After to load the package > >> library(TinnRcom) > > the result is always: >> trPaths > [1] "\\Tinn-R\\tmp\\" "\\Tinn-R\\tmp\\search.txt" > [3] "\\Tinn-R\\tmp\\objects.txt" "\\Tinn-R\\tmp\\file.r" > [5] "\\Tinn-R\\tmp\\selection.r" "\\Tinn-R\\tmp\\block.r" > [7] "\\Tinn-R\\tmp\\lines.r" "\\Tinn-R\\tmp\\reformat-input.r" > [9] "\\Tinn-R\\tmp\\reformat-output.r" > > When should be: >> trPaths > [1] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\" > [2] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\search.txt" > [3] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\objects.txt" > [4] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\file.r" > [5] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\selection.r" > [6] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\block.r" > [7] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\lines.r" > [8] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\reformat-input.r" > [9] "C:\\Users\\jcfaria\\AppData\\Roaming\\Tinn-R\\tmp\\reformat-output.r" > > What is wrong? > Why the Sys.getenv function is not making the job when in the package? > > Anyone can help please? > > P.S: The beta version of the TinnRcom package is available to download at: > http://nbcgib.uesc.br/lec/download/R/TinnRcom_1.0-09.zip > -- > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ > Jose Claudio Faria > Estatistica > UESC/DCET/Brasil > joseclaudio.faria at gmail.com > Telefones: > 55(73)3680.5545 - UESC > 55(73)9100.7351 - TIM > 55(73)8817.6159 - OI > ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-proj
Re: [R] error loading tcltk2
There is indeed a bug in tcltk2, while I introduced some changes targeting a better look of Tk widgets on Ubuntu. This new code is assuming 'cat' is available on all platforms. Indeed on Windows, it *is* available iff Rtools are installed, which is the case apparently on all test machines so far, but the code fails otherwise. I'll solve this bug this week-end (just testing if the platform is Windows makes the job here) and submit a new version as soon as possible. Sorry to all of you for the inconvenience it may have brought to your workflow. Waiting for this fix to propagated on all mirrors, if you urgently need tcltk2, you know that you still can install Rtools as a temporary work-around on one or the other test machine, which could be useful anyway, if you are developing/compiling R packages... Best, Philippe On 20/04/12 17:21, peter dalgaard wrote: On Apr 20, 2012, at 16:03 , Duncan Murdoch wrote: On 20/04/2012 8:41 AM, Roberto Ugoccioni wrote: Hello, I just installed R-2.15.0 on windows XP and cannot load package tcltk2 (which I just downloaded from CRAN as tcltk2_1.2-1.zip; package install reported no problems): library(tcltk2) Carico il pacchetto richiesto: tcltk Loading Tcl/Tk interface ... done Error : .onLoad failed in loadNamespace() for 'tcltk2', details: call: system("cat /etc/issue", intern = TRUE, ignore.stderr = TRUE) error: 'cat' not found Errore: package/namespace load failed for ‘tcltk2’ It seems .onLoad is trying to run a unix command 'cat' but i'm on a windows platform: str(.Platform) List of 8 $ OS.type : chr "windows" $ file.sep : chr "/" $ dynlib.ext: chr ".dll" $ GUI : chr "Rgui" $ endian: chr "little" $ pkgType : chr "win.binary" $ path.sep : chr ";" $ r_arch: chr "i386" sessionInfo() R version 2.15.0 (2012-03-30) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=Italian_Italy.1252 LC_CTYPE=Italian_Italy.1252 [3] LC_MONETARY=Italian_Italy.1252 LC_NUMERIC=C [5] LC_TIME=Italian_Italy.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base I looked for an R file in the tcltk2 installed package tree containing the above system() call but could not find it. This looks like a bug to me but I'd like to ask for further advice before reporting it as such, I might have overlooked something. Thanks for any help. I'd suggest you should contact the package maintainer. It's not hard to find a copy of the cat utility function (e.g. in the Rtools used for building R and packages), but the error does suggest the package may not be intended to be used on Windows. It's intended for Windows alright... However, the nit seems to be this: tcltk2:::.isUbuntu function () return(grepl("^Ubuntu", suppressWarnings(system("cat /etc/issue", intern = TRUE, ignore.stderr = TRUE))[1])) which gets called unconditionally in tcltk:::.onLoad(). It could at least check that there is room to swing a cat Duncan Murdoch __ R-help@r-project.org 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@r-project.org 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] Sweave UFT8 problem
Hello, Have you tried to put that command in a comment: %\usepackage[utf8]{inputenc} I haven't tested it in this particular case, but it works in some other situations. Best, Philippe ..<¡}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. On 14/04/12 22:37, Mark Heckmann wrote: Hi, I work on MacOS, trying to Sweave an UFT8 document. AFAI remember R 2.14 used to render a warning when the encoding was not declared when using Sweave. With R 2.15 it seems to render an error. Sweave("sim_pi.Rnw") Error: 'sim_pi.Rnw' is not ASCII and does not declare an encoding Declaring an encoding by adding a line like \usepackage[utf8]{inputenc} in the preamble does the job. In my case though the .Rnw document does no have a preamble as it is just one chapter. All chapters are Sweaved separately (due to computation time). Hence I cannot inject the above line as LaTex will cause an error afterwards. (usepackage{} is only allowed in the preamble which only appears once in the main document, not in each chapter). How can I get around this not using the terminal for Sweaving, like e.g. R CMD Sweave --encoding=utf-8 sim_pi.Rnw ? Thanks Mark [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] A little exercise in R!
Hi all, I got another solution, and it would apply probably for the ugliest one :-( I made it general enough so that it works for any series from 1 to n (n not too large, please... tested up to 30). Hint for a better algorithm: inspect the object 'friends' in my code: there is a nice pattern appearing there!!! Best, Philippe ..<¡}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. findSerie <- function (n, tmax = 500) { ## Check arguments n <- as.integer(n) if (length(n) != 1 || is.na(n) || n < 1) stop("'n' must be a single positive integer") tmax <- as.integer(tmax) if (length(tmax) != 1 || is.na(tmax) || tmax < 1) stop("'tmax' must be a single positive integer") ## Suite of our numbers to be sorted nbrs <- 1:n ## Trivial cases: only one or two numbers if (n == 1) return(1) if (n == 2) stop("The pair does not sum to a square number") ## Compute all possible pairs omat <- outer(rep(1, n), nbrs) ## Which pairs sum to a square number? friends <- sqrt(omat + nbrs) %% 1 < .Machine$double.eps diag(friends) <- FALSE # Eliminate pairs of same numbers ## Get a list of possible neighbours neigb <- apply(friends, 1, function(x) nbrs[x]) ## Nbr of neighbours for each number nf <- sapply(neigb, length) ## Are there numbers without neighbours? ## then, problem impossible to solve.. if (any(!nf)) stop("Impossible to solve:\n", paste(nbrs[!nf], collapse = ", "), " sum to square with nobody else!") ## Are there numbers that can have only one neighbour? ## Must be placed at one extreme toEnds <- nbrs[nf == 1] ## I must have two of them maximum! l <- length(toEnds) if (l > 2) stop("Impossible to solve:\n", "More than two numbers form only one pair:\n", paste(toEnds, collapse = ", ")) ## The other numbers can appear in the middle of the suite inMiddle <- nbrs[!nbrs %in% toEnds] generateSerie <- function (neigb, toEnds, inMiddle) { ## Allow to generate serie by picking candidates randomly if (length(toEnds) > 1) toEnds <- sample(toEnds) if (length(inMiddle) > 1) inMiddle <- sample(inMiddle) ## Choose a number to start with res <- rep(NA, n) ## Three cases: 0, 1, or 2 numbers that must be at an extreme ## Following code works in all cases res[1] <- toEnds[1] res[n] <- toEnds[2] ## List of already taken numbers taken <- toEnds ## Is there one number in res[1]? Otherwise, fill it now... if (is.na(res[1])) { taken <- inMiddle[1] res[1] <- taken } ## For each number in the middle, choose one acceptable neighbour for (ii in 2:(n-1)) { prev <- res[ii - 1] allpossible <- neigb[[prev]] candidate <- allpossible[!(allpossible %in% taken)] if (!length(candidate)) break # We fail to construct the serie ## Take randomly one possible candidate if (length(candidate) > 1) take <- sample(candidate, 1) else take <- candidate res[ii] <- take taken <- c(taken, take) } ## If we manage to go to the end, check last pair... if (length(taken) == (n - 1)) { take <- nbrs[!(nbrs %in% taken)] res[n] <- take taken <- c(take, taken) } if (length(taken) == n && !(res[n] %in% neigb[[res[n - 1]]])) res[n] <- NA # Last one pair not allowed ## Return the series return(res) } for (trial in 1:tmax) { cat("Trial", trial, ":") serie <- generateSerie(neigb = neigb, toEnds = toEnds, inMiddle = inMiddle) cat(paste(serie, collapse = ", "), "\n") flush.console() # Print text now if (!any(is.na(serie))) break } if (any(is.na(serie))) { cat("\nSorry, I did not find a solution\n\n") } else cat("\n** I got it! **\n\n") return(serie) } findSerie(17) On 13/04/12 23:34, (Ted Harding) wrote: Greetings all! A recent news item got me thinking that a problem stated therein could provide a teasing little exercise in R programming. http://www.bbc.co.uk/news/uk-england-cambridgeshire-17680326 Cambridge University hosts first European 'maths Olympiad' for girls The first European girls-only "mathematical Olympiad" competition is being hosted by Cambridge Univ
Re: [R] Easier ways to create .Rd files?
On 24/08/11 01:55, Jonathan Greenberg wrote: R-helpers: Are there any ways to auto-generate R-friendly (e.g. will pass a compilation check) .Rd files given a set of .R code? How about GUIs that help properly format the .Rd files? Thanks! I want a basic set of .Rd files that I can update as I go, but as with most things my documentation typically lags behind my coding by a few days. --j See inlinedocs package on CRAN. There are several examples included. Best, Philippe Grosjean __ R-help@r-project.org 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] Wiki/revision control to management of CRAN package repository
Hello, For the R Wiki, not very realistic to think about fusing it with the other tools, due to the nature of a wiki on one hand, and the necessity to share the CRAN site across different repositories on the other hand. Also, I think that packages development is in the hand of their respective developers/maintainers. Except for making sure they pass R CMD check and respect a limited amount of requirements (license, size of enclosed documents, ...), it is probably not a good idea to FORCE people to collaborate, or share the same point of view for a given R extension. There are sometimes very different implementations of the same concept, e.g., object oriented approaches in S3/S4 (official), but see also R.oo or proto for alternative ideas. Another example: RUnit vs svUnit vs testthat. Would not be a good idea to force all these people to share the same implementation and fuse everything in a single package,... unless they decide by themselves, and completely freely, to do so. This is an Open Source community, and it evolves a little bit like natural living ecosystems... with different ideas that could emerge and are ultimately selected by a kind of natural selection mechanism, related to (1) adoption of one or the other tool by the R community, and (2) the energy put in the project by their developers to maintain or make it better suitable to the community. That mechanism can only work if you are not too rigid in constraints for R packages. The drawback is a little bit of confusion for the end-user that does not always easily know which of the different implementations he should adopt. Best, Philippe Grosjean On 22/08/11 06:02, Etienne Low-Décarie wrote: I propose the following humbly, with little know how as to how to implement, and realize it may have been proposed many times. It is just something I had on my mind. Would it be possible/desirable to have the whole CRAN package repository accessible through a public wiki, forge or version control interface (ideally a fusion of the wiki and forge approach)? It appears it would be a first for a software repository. CRAN package repository is becoming a jungle of R code and may do well with currating and editorial effort. This can not/should not be the task of a single person or small group of people. Using a crowd sourced method by implementing a wiki approach to the CRAN package repository would allow for the rapid editing, sorting and improvement of this impressive and precious resource, while also improving the accessibility, visibility and quality of individual packages. It would also bind the For example, such an interface would allow the cleaning up of the repository through the use of tagging of packages, using similar approaches to the wikipedia project (http://en.wikipedia.org/wiki/Wikipedia:Template_messages#Cleanup). Such a tagging approach could be used within existing vcs, if the repository was migrated/mirrored within one of these systems. Packages could be marked using tags for all following actions prior to implementing the action. Actions could be undertaken directly by package users after a delay or discussion. Packages management/editorial effort: -Merging/ -Combining packages that have: -Large overlap in functionality -Are largely interdependant -Are only minor extensions of another package -… -Split/fork -Subdividing behemoth packages into smaller packages with more specific tasks -Categorization -Packages could be sorted by use, improvement of Task View -Tags, keywords could be added to packages for searching -Packages could be placed in a hierarchy, not only by true dependance and reverse dependance, but also by logical dependance/reverse dependance -ie. which package should probably be used with which package, an improvement on the see also help section -Deletion -Marking/tagging -a stub/prototype -broken Package improvements -Improving help files -Adding functions -Adding examples -Requiring, improving or adding references -References to the theory or approach used... -A section could include a list of articles making use of the package, with package users encourage to enter this information -This would allow package author recognition and allow a package impact factor -Adding key words for indexing and searching -Function improvement -Adding compatibility with other packages/formats (including when merging packages) -Speed improvements Discussion -On package improvements, management steps directly attached to the package -Help discussion
Re: [R] Missing datasets (2.13.1)
On 15/08/11 10:44, Uwe Ligges wrote: On 15.08.2011 10:26, Sierra Bravo wrote: Thanks Uwe, Dennis. However, I'm unable to make progress...this is what I get: data(ToothGrow) Warning message: In data(ToothGrow) : data set 'ToothGrow' not found ToothGrow Error: object 'ToothGrow' not found Just read the error message to understand what happens. Basically, it says that 'ToothGrow' does not exist. I suspect that you are looking for: data(ToothGrowth) Best, Philippe Grosjean What happens if you type library("datasets") Sounds like your R installation is either broken or misconfigured. Best, Uwe Ligges TIA s.b. -- View this message in context: http://r.789695.n4.nabble.com/Missing-datasets-2-13-1-tp3743896p3744123.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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@r-project.org 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@r-project.org 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] "try-error" can not be test. Why?
On 08/09/10 19:25, David Winsemius wrote: On Sep 8, 2010, at 1:18 PM, telm8 wrote: Hi, I am having some strange problem with detecting "try-error". From what I have read so far the following statement: try( log("a") ) == "try-error" should yield TRUE, however, it yields FALSE. I can not figure out why. Can someone help? > class(try( log("a"), silent=TRUE )) == "try-error" [1] TRUE This is perfectly correct in this case, but while we are mentioning a test on the class of an object, the better syntax is: > inherits(try(log("a)), "try-error") In a more general context, class may be defined with multiple strings (R way of subclassing S3 objects). For instance, this does not work: > if (class(Sys.time()) == "POSIXct") "ok" else "not ok" ... because the class of a `POSIXct' object is defined as: c("POSIXt", "POSIXct"). This works: > if (inherits(Sys.time(), "POSIXct")) "ok" else "not ok" Alternate valid tests would be (but a little bit less readable): > if (any(class(Sys.time()) == "POSIXct")) "ok" else "not ok" or, by installing the "operators" package, a less conventional, but cleaner code: > install.packages("operators") > library(operators) > if (Sys.time() %of% "POSIXct") "ok" else "not ok" Best, Philippe Grosjean Many thanks -- View this message in context: http://r.789695.n4.nabble.com/try-error-can-not-be-test-Why-tp2531675p2531675.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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. David Winsemius, MD West Hartford, CT __ R-help@r-project.org 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@r-project.org 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] non-linear plot parameters
On 26/08/10 19:48, David Winsemius wrote: On Aug 26, 2010, at 1:35 PM, Marlin Keith Cox wrote: I need the parameters estimated for a non-linear equation, an example of the data is below. # rm(list=ls()) I really wish people would add comments to destructive pieces of code. Time<-c( 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 8, 8, 8, 8, 8) Level<-c( 100, 110, 90, 95, 87, 60, 65, 61, 55, 57, 40, 41, 50, 47, 44, 44, 42, 38, 40, 37, 37, 35, 40, 34, 32, 20, 22, 25, 27, 29) plot(Time,Level,pch=16) You did not say what sort of "non-linear equation" would best suit, nor did you offer any background regarding the domain of study. There must be many ways to do this. After looking at the data, a first pass looks like this: > lm(log(Level) ~Time ) Call: lm(formula = log(Level) ~ Time) Coefficients: (Intercept) Time 4.4294 -0.1673 > exp(4.4294) [1] 83.88107 > points(unique(Time), exp(4.4294 -unique(Time)*0.1673), col="red", pch=4) Maybe a Weibull model would be more appropriate. ... and to continue David's analysis: Time <- c(0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 8, 8, 8, 8, 8) Level <- c(100, 110, 90, 95, 87, 60, 65, 61, 55, 57, 40, 41, 50, 47, 44, 44, 42, 38, 40, 37, 37, 35, 40, 34, 32, 20, 22, 25, 27, 29) plot(Time, Level, pch = 16) # First look at log-transformed Level (what David did) plot(Time, log(Level), pch = 16) lmod <- lm(log(Level) ~ Time) summary(lmod) abline(lmod) # It is not that clear if log transformation stabilizes variance... # Given these results, I would tend to use something like this: plot(Time, Level, pch = 16) nlmod <- nls(Level ~ exp(a * Time + b) + c, start = list(a = coef(lmod)[2], b = coef(lmod)[1], c = 0)) summary(nlmod) Time2 <- seq(0, 8, by = 0.1) lines(Time2, predict(nlmod, newdata = list(Time = Time2)), col = "red") You don't tell us enough information about what you study to help further. Choosing a regression model should also be dependent upon a priori knowledge about what you study. This looks like an exponential decay until a non-null value (c) estimated here around 20.6. Do you know it in advance? On the contrary, are you looking for this value? If yes, it would be nice, perhaps, to measure 'Level's also for a little bit longer 'Time's (until 10 or 12 here). Hope this helps Best, Philippe __ R-help@r-project.org 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] list of closures
Unless for learning R, you should really consider R.oo or proto packages that may be more convenient for you (but you don't provide enough context to tell). Best, Philippe On 26/08/10 06:28, Gabor Grothendieck wrote: On Thu, Aug 26, 2010 at 12:04 AM, Stephen T. wrote: Hi, I wanted to create a list of closures. When I use Map(), mapply(), lapply(), etc., to create this list, it appears that the wrong arguments are being passed to the main function. For example: Main function: adder<- function(x) function(y) x + y Creating list of closures with Map(): plus<- Map(adder,c(one=1,two=2))> plus$one(1)[1] 3> plus$two(1)[1] 3 Examining what value was bound to "x": Map(function(fn) get("x",environment(fn)),plus)$one[1] 2$two[1] 2 This is what I had expected: plus<- list(one=adder(1),two=adder(2))> plus$one(1)[1] 2> plus$two(1)[1] 3 Map(function(fn) get("x",environment(fn)),plus)$one[1] 1$two[1] 2 Anyone know what's going on? Thanks much! R uses lazy evaluation of function arguments. Try forcing x: adder<- function(x) { force(x); function(y) x + y } plus<- Map(adder,c(one=1,two=2)) plus$one(1) [1] 2 plus$two(1) [1] 3 __ R-help@r-project.org 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@r-project.org 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] Latex no where to be seen
On 20/08/10 13:22, Duncan Murdoch wrote: Philippe Grosjean wrote: On 20/08/10 09:11, Joshua Wiley wrote: On Thu, Aug 19, 2010 at 9:18 PM, Donald Paul Winston wrote: I'm experimenting using R as a report writer. I'm told LaTex is the destination for my quest. But ?latex() gives me an error. The package Just as a side note, using ?foo() will always return an error. If there were a latex() function, you would drop the parentheses (i.e., ?latex ) to bring up the documentation. No, it does not. ? is the operator that has the top priority. So, something like: ?ls() brings you the help page for function 'ls'. That said, you are right that the correct syntax is: It's actually slightly more complicated: ?ls() really is parsed as ? of ls(), not (?ls)(). The help system needs to know the arguments to functions to know which help page to show you in the case of S4 methods. One simple example is the following: library(stats4) example(mle) Now ?summary will give you the base page, but ?summary(fit2) will give you the stats4 page. Many thanks! Good to know. Philippe Duncan Murdoch ?ls PhG manager does not have it. The package installer can't find it. Where is it? It amazes me that there's not a built in "report" function that can produce the same kinds of reports that every report writer and data analysis software in the whole word can do. (see SAS, Crystal Reports, SPSS, Oracle Reports, Actuate, Hyperion, Cognos, ..etc) -- View this message in context: http://r.789695.n4.nabble.com/Latex-no-where-to-be-seen-tp2332139p2332139.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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@r-project.org 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@r-project.org 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] Latex no where to be seen
On 20/08/10 09:11, Joshua Wiley wrote: On Thu, Aug 19, 2010 at 9:18 PM, Donald Paul Winston wrote: I'm experimenting using R as a report writer. I'm told LaTex is the destination for my quest. But ?latex() gives me an error. The package Just as a side note, using ?foo() will always return an error. If there were a latex() function, you would drop the parentheses (i.e., ?latex ) to bring up the documentation. No, it does not. ? is the operator that has the top priority. So, something like: ?ls() brings you the help page for function 'ls'. That said, you are right that the correct syntax is: ?ls PhG manager does not have it. The package installer can't find it. Where is it? It amazes me that there's not a built in "report" function that can produce the same kinds of reports that every report writer and data analysis software in the whole word can do. (see SAS, Crystal Reports, SPSS, Oracle Reports, Actuate, Hyperion, Cognos, ..etc) -- View this message in context: http://r.789695.n4.nabble.com/Latex-no-where-to-be-seen-tp2332139p2332139.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org 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@r-project.org 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] as.logical(factor) behaviour
Thank you, but I already know that. I am not surprised by this behavior, but by an inconsistency between that behavior and the documentation that says "For factors, this uses the levels (labels).", which it does not. Best, Philippe On 15/08/10 16:09, R Help wrote: The problem is that, underneath the factors are actually numbers (1 and 2), where as, if you extract the levels and then get the logical, it converts them to strings and then to logicals. I run into this problem ALL THE TIME with numerics in a dataset. Consider the following: factor(c(3,6,5,2,7,8,4)) [1] 3 6 5 2 7 8 4 Levels: 2 3 4 5 6 7 8 as.numeric(factor(c(3,6,5,2,7,8,4))) [1] 2 5 4 1 6 7 3 as.numeric(as.character(factor(c(3,6,5,2,7,8,4 [1] 2 3 4 5 6 7 8 as.logical converts all non-zeros to TRUE, and 0 to false: as.logical(0:10) [1] FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE Hope that helps, Sam On Sun, Aug 15, 2010 at 5:32 AM, Philippe Grosjean wrote: Hello, According to ?as.logical: "as.logical attempts to coerce its argument to be of logical type. For factors, this uses the levels (labels)." However, as.logical(factor(c("FALSE", "TRUE"))) [1] TRUE TRUE Shouldn't it be the same as: as.logical(levels(factor(c("FALSE", "TRUE" [1] FALSE TRUE according to the documentation? Did I miss something here? sessionInfo() R version 2.11.1 RC (2010-05-29 r52140) x86_64-apple-darwin9.8.0 locale: [1] C/UTF-8/C/C/C/C attached base packages: [1] stats graphics grDevices utils datasets methods base Thanks, Philippe -- ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. __ R-help@r-project.org 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@r-project.org 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] as.logical(factor) behaviour
Hello, According to ?as.logical: "as.logical attempts to coerce its argument to be of logical type. For factors, this uses the levels (labels)." However, > as.logical(factor(c("FALSE", "TRUE"))) [1] TRUE TRUE Shouldn't it be the same as: > as.logical(levels(factor(c("FALSE", "TRUE" [1] FALSE TRUE according to the documentation? Did I miss something here? > sessionInfo() R version 2.11.1 RC (2010-05-29 r52140) x86_64-apple-darwin9.8.0 locale: [1] C/UTF-8/C/C/C/C attached base packages: [1] stats graphics grDevices utils datasets methods base Thanks, Philippe -- ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. __ R-help@r-project.org 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] Interrupt R?
Take a look also at ?tclTaskSchedule in package tcltk2. Best, Philippe Grosjean On 12/07/10 08:53, Prof Brian Ripley wrote: On Sun, 11 Jul 2010, Spencer Graves wrote: Hi, Richard and Duncan: Thank you both very much. You provided different but workable solutions. 1. With Rgui 2.11.1 on Vista x64, the escape worked, but neither ctrl-c nor ctrl-C worked for me. Why did you expect them too? Ctrl-C is documented to implement 'Copy' (the standard Windows shortcut). (Did you mean Ctrl-Shift-C by 'Ctrl-C' as distinct from 'Ctrl-c'? I don't think that works anywhere.) As Duncan said, Ctrl-C works in Rterm, and in almost all other R implementations (the Mac R.app GUI is the only other exception I know: it also uses Escape). This is documented in the README (called something like README.R-2.11.1 in the binary distribution) and in the rw-FAQ Q5.1. Maybe it would be a good idea to refresh your memory of the basic documentation? 2. The TCLTK version works but seems to require either more skill from the programmer or more user training than using escape under Rgui or ctrl-g/c under Emacs. Best Wishes, Spencer On 7/11/2010 12:02 PM, Duncan Murdoch wrote: On 11/07/2010 2:29 PM, Spencer Graves wrote: How can one interrupt the following gracefully: while(TRUE){ Sys.sleep(1) } In R2.11.1 under Emacs+ESS, some sequence of ctrl-g, ctrl-c eventually worked for me. Under Rgui 2.11.1, the only way I've found was to kill R. Suggestions on something more graceful? This is an Emacs+ESS bug. In the Windows GUI or using Rterm, the standard methods (ESC or Ctrl-C resp.) work fine. Duncan Murdoch Beyond this, what would you suggest to update a real-time report when new data arrives in a certain directory? A generalization of the above works, but I'd like something more graceful. Thanks, Spencer Graves sessionInfo() R version 2.11.1 (2010-05-31) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] SIM_0.5-0 RCurl_1.4-2 bitops_1.0-4.1 R2HTML_2.1 oce_0.1-80 -- Spencer Graves, PE, PhD President and Chief Operating Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 __ R-help@r-project.org 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@r-project.org 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@r-project.org 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] OOP and passing by value
I think you should be interested by section 5.4 (non-local assignments; closures) in Chamber's "Software for Data Analysis" book published in 2008 by Springer (http://www.springer.com/statistics/computanional+statistics/book/978-0-387-75935-7). Besides the solution proposed in the book, which uses assignment outside functions, there is another possibility: environment objects. They are passed by reference and there are tricks to use them in this situation, but you have to be extremely careful because you break the rules for functional programming. Don't forget generics like "Data<-" to assign in R. See for instance help("names<-"). This is the most conventional and easier way to do this. Best, Philippe Grosjean On 09/06/10 14:28, michael meyer wrote: Greetings, I love the R system and am sincerely grateful for the great effort the product and contributors are delivering. My question is as follows: I am trying to use S4 style classes but cannot write functions that modify an object because paramter passing is by value. For example I want to do this: setGeneric("setData", function(this,fcn,k){ standardGeneric("setData") }) setClass( "test", representation(f="numeric", t="numeric") ) setMethod("setData","test", function(this,fcn,k){ t...@t<- as.numeric(seq(-k,k))/(2*k+1) t...@f<- sapply(t,FUN=fcn) } ) #--- tst<- new("test") fcn<- function(u){ sin(2*pi*u) } setData(tst,fcn,100) t...@t # it's still empty because of pass by value How can this be handled? Many thanks, Michael [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating pdf report
On 06/06/10 19:26, bjlwilkin...@gmail.com wrote: I'm looking for a way to create a pdf report that contains multiple graphs on one page as well as tables (ideally with some lines below categories etc.) . I have used the pdf(filename) followed by dev.off() to date but this prints one graph per page and does not seem to have functionality for tables. Thanks Look at ?Sweave. PhG Sent from my BlackBerry® wireless device __ R-help@r-project.org 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@r-project.org 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] SciViews-K / Komodo as editor on the Mac [was: StatET plot problem]
On 06/06/10 10:45, Bunny, lautloscrew.com wrote: Philippe, ad 2) I totally agree that alt+f1 is the better and more comfortable option here. The main reason I tried to test some of the functionality that is typically display outside the R console, such as plotting and ?topic (and honestly, I did not realize from the start that alt+f1 was meant to fully replace traditional ways). I´d really like to use R outside the terminal, but it was the only I way I got it to work from within Komodo. Both R.app and R64.app did not work. All I get when I run R is the open -a mydirectory/R64.app message at the bottom and then after a couple of seconds I get the "Ready" message. No R pops up, because it obviously does not start. open -a mydirectory/R64.app So, is R64.app located in "mydirectory"? If not, then, you know why it does not work. Running R from the terminal worked, but the Command output inside Komodo appeared to have problems, when I run about 100 lines of code or display data.frames with a couple of hundred rows. Is there a way to move the command output around, i.e. relocate the window or even open it in another window? That would be really helpful particularly if you work on two screens. Well, what you are asking is having a R console displayed in a separate window that you could place on your second screen... and you have it: it is your terminal window where R is running. Best, Philippe thx for all the help! best Matt On 05.06.2010, at 19:52, Philippe Grosjean wrote: Matt, Yes, I see this problem. Thanks for report. Also ??topic is wrong. Note two points: 1) ?topic works with R.app/R64.app. So, just in case you would consider using R.app instead of R inside a terminal session, 2) I have not noticed this bug because using ?topic inside SciViews-K / Komodo is a little bit silly. There is a much better mechanism: place your cursor on a word (the 'topic' in ?topic) and hit Alt-F1, and you got the corresponding help page displayed. It is much more natural to type the name of your function, then Alt-F1 to see the man page, than to type ?myfun, then move back to eliminate '?', move forward and continue typing your code, isn't it? Also try Alt-Shift-F1 for a better alternative to ??topic from within SciViews-K / Komodo. Best, Philippe ..<°}))><.... ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. On 05/06/10 18:54, Bunny, lautloscrew.com wrote: Philippe, now I tried to run the SciViews-K / Komodo combo on my Mac. It did work and I like it. Thx for your suggestion. On first sight everything works really well. The only thing that bothers me a little bit, is that I was only able to run it with the "directly in terminal" option. Everytime I start ?whateverhelp from Komodo R inside the terminal crashes. If I run ?myhelp directly from the terminal, everything works just fine. Probably I could just live with that, but somehow I want to fix it or at least know why this is happening. Besides, I think the code folding, syntax highlighting and auto-complete / command+t stuff is really an advantage over the standard editor on a mac and it´s well worth the hustle. best matt On 04.06.2010, at 11:13, Philippe Grosjean wrote: On 04/06/10 10:37, Bunny, lautloscrew.com wrote: Dear all, after trying several suggestions from the list for a nice R-Editor / IDE for MacOS X and really trying some of those that needed to be configured a little more (such as emacs, aquamacs and StatET / Eclipse), I prefer StatET at the moment. I found more experienced like John suggesting this combination (http://www.mail-archive.com/r-help@r-project.org/msg38883.html) on Mac OS X. So far I am really happy with it except for the plotting. I just can´t get plots to go. everytime I plot(x) nothing happens. What´s striking is that the edit() works and opens up in X11. Is there some configuration option I just missed ? best regards You haven't try SciViews-K/Komodo, don't you? (http://www.sciviews.org/SciViews-K). Best, Philippe matt __ R-help@r-project.org 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@r-project.org 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinf
Re: [R] SciViews-K / Komodo as editor on the Mac [was: StatET plot problem]
Matt, Yes, I see this problem. Thanks for report. Also ??topic is wrong. Note two points: 1) ?topic works with R.app/R64.app. So, just in case you would consider using R.app instead of R inside a terminal session, 2) I have not noticed this bug because using ?topic inside SciViews-K / Komodo is a little bit silly. There is a much better mechanism: place your cursor on a word (the 'topic' in ?topic) and hit Alt-F1, and you got the corresponding help page displayed. It is much more natural to type the name of your function, then Alt-F1 to see the man page, than to type ?myfun, then move back to eliminate '?', move forward and continue typing your code, isn't it? Also try Alt-Shift-F1 for a better alternative to ??topic from within SciViews-K / Komodo. Best, Philippe ..<°}))><.... ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. On 05/06/10 18:54, Bunny, lautloscrew.com wrote: Philippe, now I tried to run the SciViews-K / Komodo combo on my Mac. It did work and I like it. Thx for your suggestion. On first sight everything works really well. The only thing that bothers me a little bit, is that I was only able to run it with the "directly in terminal" option. Everytime I start ?whateverhelp from Komodo R inside the terminal crashes. If I run ?myhelp directly from the terminal, everything works just fine. Probably I could just live with that, but somehow I want to fix it or at least know why this is happening. Besides, I think the code folding, syntax highlighting and auto-complete / command+t stuff is really an advantage over the standard editor on a mac and it´s well worth the hustle. best matt On 04.06.2010, at 11:13, Philippe Grosjean wrote: On 04/06/10 10:37, Bunny, lautloscrew.com wrote: Dear all, after trying several suggestions from the list for a nice R-Editor / IDE for MacOS X and really trying some of those that needed to be configured a little more (such as emacs, aquamacs and StatET / Eclipse), I prefer StatET at the moment. I found more experienced like John suggesting this combination (http://www.mail-archive.com/r-help@r-project.org/msg38883.html) on Mac OS X. So far I am really happy with it except for the plotting. I just can´t get plots to go. everytime I plot(x) nothing happens. What´s striking is that the edit() works and opens up in X11. Is there some configuration option I just missed ? best regards You haven't try SciViews-K/Komodo, don't you? (http://www.sciviews.org/SciViews-K). Best, Philippe matt __ R-help@r-project.org 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@r-project.org 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@r-project.org 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] StatET plot problem
On 04/06/10 10:37, Bunny, lautloscrew.com wrote: Dear all, after trying several suggestions from the list for a nice R-Editor / IDE for MacOS X and really trying some of those that needed to be configured a little more (such as emacs, aquamacs and StatET / Eclipse), I prefer StatET at the moment. I found more experienced like John suggesting this combination (http://www.mail-archive.com/r-help@r-project.org/msg38883.html) on Mac OS X. So far I am really happy with it except for the plotting. I just can´t get plots to go. everytime I plot(x) nothing happens. What´s striking is that the edit() works and opens up in X11. Is there some configuration option I just missed ? best regards You haven't try SciViews-K/Komodo, don't you? (http://www.sciviews.org/SciViews-K). Best, Philippe matt __ R-help@r-project.org 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with Tinn-R communicating with REvolution R
Hello, DDE communication requires and additional 'dde' Tcl package. That one is installed usually with the default Tcl/Tk 8.4/8.5 under Windows, but it seems Revolution R uses a different install where the dde Tcl package is not installed, or is not accessible where Tcl think it should be. One solution would be to install a full Tcl/Tk from ActiveState and use it instead (read Windows FAQ, I think instruction is there). Best, Philippe ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. On 27/04/10 13:00, Mike White wrote: I have been using Tinn-R with R without any problems but when I try to use it with REvolution R I get the following error message when Tinn-R runs the configuration script and gets to the trDDEInstall() function: ## Start DDE trDDEInstall() trDDEInstall() Error in structure(.External("dotTcl", ..., PACKAGE = "tcltk"), class = "tclObj") : [tcl] invalid command name "dde". In addition: Warning message: In tclRequire("dde", warn = TRUE) : Tcl package 'dde' not found I have not found anything about this on the Tinn-R forum and have had no repsonse from the REvolution R forum. I have checked other R-Help queries but these relate to adding the code for .trPaths which I already have. Does anyone know how to solve this problem? [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] GUI /IDE
Not really *named* regions, but an easy way to run portions of code quickly in SciViews-K (http://www.sciviews.org/SciViews-K): * R -> Run marked block (or Ctrl+Shift+M) runs code between two bookmarks, * R -> Run function (or Ctrl+Shift+F) runs the code of the whole current function (you may prefer R -> Source function in this particular case), * R -> Run paragraph (or Ctrl+Shift+H) runs code in the current paragraph ("paragraphs" are consecutives lines or R code separated from other "paragraphs" by empty lines). I will think at your proposal to include it in SciViews... It is very interesting! As a bonus, with the 'TODO' plugin or a derived 'Named regions' plugin, named regions of the current file/all opened files/current project could be listed automatically. From this list, a click runs the region and/or move to its code. As a second bonus: rather easy to activate code folding on named regions too. This is put on my "to do" list! Best, Philippe ......<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. On 30/03/10 23:41, Peter wrote: Emacs allows you run regions. Not sure about naming them Peter ManInMoon wrote: Does anyone know of a gui for R that has "regions" i.e areas of code in a script that can be named and hopefully run as a section? @region Init library(whatever) myprint<-function(...){print(...)} @endregion __ R-help@r-project.org 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@r-project.org 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] rpad ?
Hello, You could try svSocket that creates a socket server where several clients can connect simultaneously. The server is restricted to local clients for obvious security reasons, but if you would like to access it though a network, you can use stunnel to transfer the data crypted with SSL. Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. On 23/03/10 20:57, sjaffe wrote: Sharpie wrote: You could try Sage: http://www.sagemath.org Yes, I've tried Sage (briefly) and it is very interesting. But what I'm looking for here is a client-server system that allows multiple users to access the results of R without exposing the details. __ R-help@r-project.org 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] C# DLL Library
Hello, Also, if you go for socket connection, you could give a try to svSocket. Best, Philippe ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. On 17/03/10 09:16, Dieter Menne wrote: JSmaga wrote: I was aware of the R(D)COM. In the last public version, there is now splash screen appearing which is kind of boring so I think I need to buy it or something. I would pay for RDCOM, but it requires that you explain the details of you application spread (which is mostly 1 in my case, since I only work "on request"), and that's unacceptable to me. I think there is a way to get around that using the Rcommander (?) version, but I found a better solution: I have moved to using RServe with c# recently; it has nice support for all types of structures, and works under Linux (at server side) or Windows. While RServe is Java, you can use IKVM to make it accessible to c#, and it works out of the box. Getting this translation to work within an hour was one of the biggest miracles in my 40-year programmer's life; kudos to the IKVM (and to rserve, clearly). You can download my simple test application (no support, and it may not even work) for Visual Studio from http://www.menne-biomed.de/uni/rserve.zip. You can use it with a local, Windows rserve, or, more reliably, with a virtual linux box running under VMWare. The latter works great as a development environment, and I can create complex installations, for example with NONMEM, and provide my colleagues the virtual machine as a no-brainer. Dieter __ R-help@r-project.org 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] Three most useful R package
On 03/03/10 09:26, Karl Ove Hufthammer wrote: On Tue, 2 Mar 2010 15:13:54 -0500 Ralf B wrote: 1) What are your 3 most useful R package? and plyr ggplot2 lattice Well, as you ask the question, the three most useful R packages are: base, stats and methods ;-) ... But I guess you mean: the three most useful OPTIONAL packages? Best, Philippe Grosjean __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R wiki link ?
Prof. John C Nash wrote: Is this a transient problem, or has the link to the R wiki on the R home page (www.r-project.org) to http://wiki.r-project.org/ been corrupted? I can find http://rwiki.sciviews.org that works. Yes, the problem is known. I have to fix it. Best, Philippe Grosjean JN __ R-help@r-project.org 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@r-project.org 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] color palette for points, lines, text / interactive Rcolorpicker?
If you use tcltk package package, you can do: > as.character(.Tcl("tk_chooseColor")) Best, Philippe Greg Snow wrote: I don't know of any existing palettes that meet your conditions, but here are a couple of options for interactive exploration of colorsets (this is quick and dirty, there are probably some better orderings, base colors, etc.): colpicker <- function( cols=colors() ) { n <- length(cols) nr <- ceiling(sqrt(n)) nc <- ceiling( n/nr ) imat <- matrix(c(seq_along(cols), rep(NA, nr*nc-n) ), ncol=nc, nrow=nr) image( seq.int(nr),seq.int(nc), imat, col=cols, xlab='', ylab='' ) xy <- locator() cols[ imat[ cbind( round(xy$x), round(xy$y) ) ] ] } colpicker() ## another approach library(TeachingDemos) cols <- colors() n <- length(cols) par(xpd=TRUE) # next line only works on windows HWidentify( (1:n) %% 26, (1:n) %/% 26, label=cols, col=cols, pch=15, cex=2 ) # next line works on all platforms with tcltk HTKidentify( (1:n) %% 26, (1:n) %/% 26, label=cols, col=cols, pch=15, cex=2 ) # reorder cols.rgb <- col2rgb( cols ) d <- dist(t(cols.rgb)) clst <- hclust(d) colpicker(cols[clst$order]) HWidentify( (1:n) %% 26, (1:n) %/% 26, label=cols[clst$order], col=cols[clst$order], pch=15, cex=2 ) ## or HTKidentify cols.hsv <- rgb2hsv( cols.rgb ) d2 <- dist(t(cols.hsv)) clst2 <- hclust(d2) HWidentify( (1:n) %% 26, (1:n) %/% 26, label=cols[clst2$order], col=cols[clst2$order], pch=15, cex=2 ) ## or HTKidentify Hope this helps, __ R-help@r-project.org 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] Emacs vs Eclipse vs Rcmdr
Hello, You can probably add SciViews in the list. There are many, many interesting features in SciViews-K/Komodo for developing new user interfaces rapidly and easily. Unfortunately, there is no documentation yet, and thus, most of the functions remain "hidden" (but you can play with it and ask questions). Hint: look at Komodo help about snippets, and then explore the R reference toolkit you can install separately. You can download it from http://www.sciviews.org/SciViews-K. Best, Philippe ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. Barry Rowlingson wrote: On Sun, Jan 3, 2010 at 10:59 PM, Charlotte Maia wrote: I'm not so much interested in which is the best user interface for R. Rather which is the best ***platform*** for developing ***new*** user interfaces for R. Noting I'm using the term user interface is a very general sense. (i.e. Can include anything from console/pseudoterminal widgets, to text editors with customised syntax highlighting, to elaborate menus and dialog boxes). Here are my initial thoughts: Emacs Pros: - A lot of computer "experts" use it. - Plus some high profile R people are involved in the development of ESS. - High level of customisation. Emacs Cons: - Need to know Lisp. - Counter intuitive. - It's really ugly. - No decent widget set (which is probably why it's ugly). Eclipse Pros: - It's kind of fashionable and nice looking. Eclipse Cons: - Unnecessarily complicated. - Need to know SWT (and maybe XML too?). - The process for installing (and finding) add on packages, is terrible. Rcmdr Pros and Cons: - I haven't used it for a long time, so can't really comment. - However, I was surprised by how many reverse dependencies it has. So I will assume it has some potential. Other people's thoughts welcome... Python + Rpy + Widget set of your choice (Qt or wx would be the front-runners) Pros: cross-platform full, mature, and standard widget set easy integration between R and Python can integrate existing code for editing (e.g. Scintilla) I'd say it was a medium-weight solution - you need R, Python, Rpy, and PyQt/wx but they are all open source so you can distribute them with your code or get your users to install them quite easily. There appears to be an effort to make a direct interface to Qt from R: http://qtinterfaces.r-forge.r-project.org/ but that seems to be in a very early stage, but would let you not need Python. Barry __ R-help@r-project.org 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@r-project.org 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] [Off-topic] problem with Tinn-R editor
Ask directly to Jose-Claudio Faria (jcfa...@users.sourceforge.net). He is the author and maintainer of Tinn-R. Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. Bogaso wrote: This is not directly related with R however I would like to ask for a solution for my TINN-R editor because, I feel that lot many people perhaps use it as a reliable R editor and secondly I could not find any other forum only deals with TINN over net to discuss with. For quite sometime I have been using Tinn-R as an editor for R-code however for some days I am noticing a strange problem on that, I cannot edit anything after typing something there, specially 'back-space' is not working at all. I feel, perhaps I have changed some default setting unintentionally which creates that pinching. Would anyone guide me how to get rid from that? Your help will be highly appreciated. Thanks, __ R-help@r-project.org 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] where can I download package svIO?
Hello, All sv packages are undergoing a major revision that makes them incompatible for some functions with the previous ones (among them, functions that were used by Tinn-R. However, Tinn-R is now supposed to use its own TinnR packages that uses its own version of the old functions, so that refarctoring of new ones is possible. On CRAN, you find this description: TinnR: Resources of Tinn-R GUI/Editor for R Environment Implements a set of customized functions, adapted from svIDE, svMisc and svIO packages of Philippe Grosjean, necessary to Tinn-R GUI/Editor for R environment Version:1.0.3 Depends:R (? 2.6.0), utils, tcltk, Hmisc, R2HTML Published: 2009-02-10 Author: Jose Claudio Faria, based on the sources of Philippe Grosjean Maintainer: Jose Claudio Faria License:GPL (? 2) Citation: TinnR citation info CRAN checks:TinnR results So, you are better to contact Jose Claudio Faria, because you should not have a dependecy on svIO any more for Tinn-R. Abest, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. Dagmar Orlikowski wrote: Hello, today I upgraded R to 2.10 and Tinn-R to 2.3.3.1. Tinn-R needs the package svIO, but it is not available anymore on the package lists. Every session I start R and chose the CRAN-Mirror I receive the following warning: Bitte einen CRAN Spiegel für diese Sitzung auswählen --- Warnmeldung: In getDependencies(pkgs, dependencies, available, lib) : package ‘svIO’ is not available Lade Tcl/Tk Interface ... fertig Fehler in library(svIO) : es gibt kein Paket 'svIO' I found a similar problem for svMisc a few weeks ago (http://www.mail-archive.com/r-help@r-project.org/msg74057.html). Will there be a new svIO-package the next weeks or is it included anywhere elso now? Thanks for your help, dagmar __ R-help@r-project.org 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@r-project.org 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] package:svMisc
A new version of svMisc was send today to CRAN. It should be available soon for R 2.10. Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. Frank Lawrence wrote: I am using Tinn-R 2.3.2.3 and R 2.10.0 on a windows vista [64bit] machine. When I activate R from Tinn-R I get the following warning message: Warning message: package 'svMisc' was built under R version 2.9.1 and help will not work correctly Please re-install it However, when I attempt to install it I receive the following: Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'svMisc' is not available How do I get a current version of svMisc? Respectfully, Frank Lawrence __ R-help@r-project.org 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@r-project.org 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] svDialogs
Hello, Now, the *bundle* SciViews has disappeared from CRAN, but the *package* svDialogs is still there. Best, Philippe ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons University, Belgium ( ( ( ( ( .. Tubin wrote: Did you ever get a response on this? I have been having a similar problem. Thanks, Sarah antje-4 wrote: Hi there, I was using Open/Save-dialogs from the package svDialogs (SciViews). But now the package has dissapeared? How do I have to set up my R-installation to further use these dialogs??? (beside copying my old packages to the new installation). Ciao, Antje __ R-help@r-project.org 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@r-project.org 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] Turning points in a series
Hello, I don't see what's wrong with turnpoints() from pastecs. It is easy to use, and provides additional information for each turnpoints, i.e., probability of occurrence against the null hypothesis that the series is purely random, and the number of bits of information associated with the points according to Kendall's information theory. See ?turnpoints. Rewriting the function is a nice exercise, but a small explanation on how to use turnpoints() is much easier. So, nobody is able to tell that simply using: > library(pastecs) > turnpoints(dat$count) does the job? Am I the only one interested by the extra information provided by turnpoints()? Here is a more extensive example that shows also how to get date or counts associated to pits/peaks: txt <- " y m d count 93 02 07 3974.6 93 02 08 3976.7 93 02 09 3955.2 93 02 10 3955.0 93 02 11 3971.8 93 02 12 3972.8 93 02 13 3961.0 93 02 14 3972.8 93 02 15 4008.0 93 02 16 4004.2 93 02 17 3981.2 93 02 18 3996.8 93 02 19 4028.2 93 02 20 4029.5 93 02 21 3953.4 93 02 22 3857.3 93 02 23 3848.3 93 02 24 3869.8 93 02 25 3898.1 93 02 26 3920.5 93 02 27 3936.7 93 02 28 3931.9 " con <- textConnection(txt) dat <- read.table(con, header = TRUE) close(con) dat$date <- as.Date(paste(dat$y, dat$m, dat$d), format = "%y %m %d") library(pastecs) tp <- turnpoints(dat$count) tp summary(tp) # Indicate which turnpoints are significant (see ?turnpoints) plot(tp, level = 0.05) # Another plot plot(dat$count, type = "l") lines(tp) # Get counts for all turnpoints allcounts <- <- dat$count[extract(tp, no.tp = FALSE, peak = TRUE, pit = TRUE)] # Get dates for all turnpoints alldates <- dat$date[extract(tp, no.tp = FALSE, peak = TRUE, pit = TRUE)] alldates # Get dates for "informative" turnpoints (5%) only (see ?turnpoints) alldates[tp$proba < 0.05] # Get dates for peaks only dat$date[extract(tp, no.tp = FALSE, peak = TRUE, pit = FALSE)] # Etc... Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. (Ted Harding) wrote: On 17-Sep-09 08:10:47, ogbos okike wrote: Good morning once more. My problem of yesterday has been addressed. Having learned a few tricks from that, I wish to ask another question in connection with that. My data is a cosmic ray data consisting of dates and counts. When I plot a graph of counts versus dates, the resultant signal shows a number of maximum and minimum points. These minimum points (turning points) are of interest to me. Reading these dates and counts off from the plot is difficult as I am dealing with a large data. I have been looking at turnpoints function in pastecs library but have not been able to figure out the appropriate commands that one can use to find the minima/maxima (turning points) or pits/peaks in a series. My data is of the form shown below where y stands for year, m month, d day and finally count. Is there a way I could find these minima together with the dates they occurred? I would be indebted to those of you who will show me the way out of these problem. Thank you. Best regards Ogbos y m d count 93 02 07 3974.6 93 02 08 3976.7 93 02 09 3955.2 93 02 10 3955.0 93 02 11 3971.8 93 02 12 3972.8 93 02 13 3961.0 93 02 14 3972.8 93 02 15 4008.0 93 02 16 4004.2 93 02 17 3981.2 93 02 18 3996.8 93 02 19 4028.2 93 02 20 4029.5 93 02 21 3953.4 93 02 22 3857.3 93 02 23 3848.3 93 02 24 3869.8 93 02 25 3898.1 93 02 26 3920.5 93 02 27 3936.7 93 02 28 3931.9 The following simple function TP() (for "Turning Point") locates the positions i where x[i] is greater than both of its immediate neighbours (local maximum) or less than both of its neighbours (local minimum). TP <- function(x){ L <- length(x) which( ((x[1:(L-2)]x[3:L])) |((x[1:(L-2)]>x[2:(N-1)])&(x[2:(L-1)] Fax-to-email: +44 (0)870 094 0861 Date: 17-Sep-09 Time: 09:47:53 -- XFMail -- __ R-help@r-project.org 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@r-project.org 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] Google's R Style Guide
Max Kuhn wrote: Perhaps this is obvious, but Ive never understood why this is the general convention: An opening curly brace should never go on its own line; I tend to do this: f <- function() { if (TRUE) { cat("TRUE!!\n") } else { cat("FALSE!!\n") } } (I don't usually put one-liners in if/else blocks; here I would have used ifelse) I haven't seen many others format code in this way. Is there an objective reason for this (such as the rule for the trailing "}") or is this just aesthetics? I think the problem is not much putting the opening brace after function(), or after if (...), like you do. The problem is putting the else at a new line like in: if (TRUE) { cat("TRUE!!\n") } else { cat("FALSE!!\n") } When you source this code, the first part until the first closing brace is considered complete by the R parser, and then, 'else' is considered as the begining of a new command, which is a syntax error: > if (TRUE) { + cat("TRUE!!\n") + } TRUE!! > else Error: syntax error > { + cat("FALSE!!\n") + } FALSE!! If you put the same code in a function, you got the expected behaviour: > f <- function () { + if (TRUE) { + cat("TRUE!!\n") + } + else + { + cat("FALSE!!\n") + } + } > f() # No syntax error! TRUE!! Thus, this is technical reason for NOT putting else on another line. For the rest, I share Hadley's feeling that you consumes "too much lines" and I tend to prefer the "regular" R syntax you got when you source your code. Best, Philippe Thanks, Max __ R-help@r-project.org 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@r-project.org 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] [Fwd: Re: Video demo of using svSocket with data.table]
Forwarded to R-Help, because I think it could interest people following this thread. Clearly, RServe and svSocket have different goals and very little overlap. Best, Philippe Original Message Subject: Re: Video demo of using svSocket with data.table Date: Wed, 26 Aug 2009 20:34:19 +0100 From: Matthew Dowle Reply-To: Matthew Dowle To: Philippe Grosjean , Romain Francois References: <4a8e632d.6060...@sciviews.org><4a8e6af1.9060...@dbmail.com> <4a8e9e7d.9070...@sciviews.org> Hi Philippe & Romain, Thanks - interesting discussion on the list - I just caught up with it now. I agree with everything basically and look forward to the 'planned for the future'. The 'feature' of "every clients and the CLI are working with the same objects on the same environment" is really important to keep btw - got a bit worried by your "*feature*" in case you thought it was a bad thing. Rserve doesn't do that! Its a great feature and really important. I compared Rserve to svSocket and came up with this list (confirmed with Simon U). You probably already know this but just in case : 1. The main thing is Rserve's clients each have their own workspace. Its not one shared workspace, unlike with svSocket. So one client can't write something and another client then read it because they only see their own workspaces within Rserve. You might as well start lots of R's basically. 2. There is no CLI (command line interface) to Rserve i.e. no prompt to type at. Its just a process that sits there and responds to clients only. 3. Rserve on windows is limited to only one client connection, no more. The docs say that Windows is not recommended (for this reason). 4. You have to start Rserve first before you send commands to it. With svSocket, you can startup any old R, do some analysis and gather data, then decide to become a server and let clients connect. This is a really important workflow feature. With Rserve you have to think in advance and know that you'll need to be a server. You can't do any of those things with Rserve, but you can with svSocket. Rserve does do binary data transfer though. Regards, Matthew - Original Message - From: "Philippe Grosjean" Newsgroups: gmane.comp.lang.r.general To: "Romain Francois" Cc: "Matthew Dowle" ; Sent: Friday, August 21, 2009 2:17 PM Subject: Re: Video demo of using svSocket with data.table Romain Francois wrote: Hi Philippe, When Matthew brought this up the first time on this list, there were several replies to warn about potential problems related to R not being thread safe, and that this might cause trouble. Well, that is true, R is not thread safe. What happens, basically, is that R clients run in the tcltk event loop. When a client is doing something, R is locked, processing the client's request before returning to the main loop. On the contrary, something running in the main loop can be interrupted pretty much anytime by a client's request. Regarding different clients, it is first in, first served rule: requests are processed in the order they appear. It would be possible to adapt svSocket to delay processing of (asynchronous only) requests from clients, waiting from flags set by, either the main loop, or another client. That would be rather easy to do. Otherwise, every clients and the CLI are working with the same objects on the same environment (.GlobalEnv, as primary one), but that is a *feature*! One constraint for designing svSocket is that the behaviour of R has to be as much as possible identical when a command is run on the main loop through the CLI, or from within a client. Of course, you can imagine all sorts of bad interactions, and it is very, very easy to write a bad-behaving client. The goal is not to write a client-server architecture, but a multitasking way of manipulating R by the same end-user (thus, not likely to feed bad code from one side to destroy what he is doing from another side :-) Best, Philippe Since you were on holidays, we did not get your viewpoint. Could you elaborate on how you deal with this. "browser" works off the REPL, so this is unlikely that svSocket can take advantage of it, since the socket runs on a different loop. or maybe you can add something that feeds the R main loop, but I'm not sure this is possible unless you embed R ... Romain On 08/21/2009 11:04 AM, Philippe Grosjean wrote: Hello Matthew and all R-UseRs, You video demo is very nice. This suggests various uses of svSocket that I had not think about! The primary goal was to make it: - flexible (I think it is clear from the demo), - running in the background while not blocking the CLI (Rgui, R.app, or the terminal, very clear from your demo too), - stateful (yes, this is not in your demo, but a client can disconnect and reconnect and got the same server state
Re: [R] Video demo of using svSocket with data.table
Romain Francois wrote: Hi Philippe, When Matthew brought this up the first time on this list, there were several replies to warn about potential problems related to R not being thread safe, and that this might cause trouble. Well, that is true, R is not thread safe. What happens, basically, is that R clients run in the tcltk event loop. When a client is doing something, R is locked, processing the client's request before returning to the main loop. On the contrary, something running in the main loop can be interrupted pretty much anytime by a client's request. Regarding different clients, it is first in, first served rule: requests are processed in the order they appear. It would be possible to adapt svSocket to delay processing of (asynchronous only) requests from clients, waiting from flags set by, either the main loop, or another client. That would be rather easy to do. Otherwise, every clients and the CLI are working with the same objects on the same environment (.GlobalEnv, as primary one), but that is a *feature*! One constraint for designing svSocket is that the behaviour of R has to be as much as possible identical when a command is run on the main loop through the CLI, or from within a client. Of course, you can imagine all sorts of bad interactions, and it is very, very easy to write a bad-behaving client. The goal is not to write a client-server architecture, but a multitasking way of manipulating R by the same end-user (thus, not likely to feed bad code from one side to destroy what he is doing from another side :-) Best, Philippe Since you were on holidays, we did not get your viewpoint. Could you elaborate on how you deal with this. "browser" works off the REPL, so this is unlikely that svSocket can take advantage of it, since the socket runs on a different loop. or maybe you can add something that feeds the R main loop, but I'm not sure this is possible unless you embed R ... Romain On 08/21/2009 11:04 AM, Philippe Grosjean wrote: Hello Matthew and all R-UseRs, You video demo is very nice. This suggests various uses of svSocket that I had not think about! The primary goal was to make it: - flexible (I think it is clear from the demo), - running in the background while not blocking the CLI (Rgui, R.app, or the terminal, very clear from your demo too), - stateful (yes, this is not in your demo, but a client can disconnect and reconnect and got the same server state it had just before disconnection, including possibly, partial command send to R server), Not implemented yet, but planned for the future: - binary transfer of R objects, - connection to distant secured server using TSL (of course, distant connection requires a lot of extra precautions because R is NOT an Internet-secure language and environment, but that applies to all client/server R solutions like Rserve or Rpad), - mirroring of the commands, results and history on the different clients to make a simple collaborative R session. The primary use in SciViews is the communication engine between the client (a code editor, or IDE program like Komodo Edit) and server (R). Your demo gives an idea on the flexibility one got with it, including the possibility to inspect and/or change objects while R is running a long process. Your example of changing the plot in real-time without interrupting the main server's process is very illustrative. So now, imagine the debugging flexibility for long running tasks, and/or combination of svSocket with browser()... But that's another story, because svSocket does not work nicely with browser() for the moment. All the best, Philippe ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( ( Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Matthew Dowle wrote: Dear r-help, If you haven't already seen this then : http://www.youtube.com/watch?v=rvT8XThGA8o The video consists of typing at the console and graphics, there is no audio or slides. Please press the HD button and maximise. Its about 8 mins. Regards, Matthew __ R-help@r-project.org 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] Video demo of using svSocket with data.table
Hello Matthew and all R-UseRs, You video demo is very nice. This suggests various uses of svSocket that I had not think about! The primary goal was to make it: - flexible (I think it is clear from the demo), - running in the background while not blocking the CLI (Rgui, R.app, or the terminal, very clear from your demo too), - stateful (yes, this is not in your demo, but a client can disconnect and reconnect and got the same server state it had just before disconnection, including possibly, partial command send to R server), Not implemented yet, but planned for the future: - binary transfer of R objects, - connection to distant secured server using TSL (of course, distant connection requires a lot of extra precautions because R is NOT an Internet-secure language and environment, but that applies to all client/server R solutions like Rserve or Rpad), - mirroring of the commands, results and history on the different clients to make a simple collaborative R session. The primary use in SciViews is the communication engine between the client (a code editor, or IDE program like Komodo Edit) and server (R). Your demo gives an idea on the flexibility one got with it, including the possibility to inspect and/or change objects while R is running a long process. Your example of changing the plot in real-time without interrupting the main server's process is very illustrative. So now, imagine the debugging flexibility for long running tasks, and/or combination of svSocket with browser()... But that's another story, because svSocket does not work nicely with browser() for the moment. All the best, Philippe ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Matthew Dowle wrote: Dear r-help, If you haven't already seen this then : http://www.youtube.com/watch?v=rvT8XThGA8o The video consists of typing at the console and graphics, there is no audio or slides. Please press the HD button and maximise. Its about 8 mins. Regards, Matthew __ R-help@r-project.org 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@r-project.org 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] What command lists everything in a package?
If you want a quick overview of a package (not just the name of the objects), you can also do: > library(help = zoo) Duncan Murdoch wrote: On 7/3/2009 1:21 PM, Mark Knecht wrote: Hi, Two easy questions I'm sure. 1) As an example if I use the code require(zoo) then once it's loaded is there a command that lists everything that zoo provides so that I can study the package? ls("package:zoo") will list all the exported items in zoo, provided it is attached. You can abbreviate that to the number in the search list, which is usually 2 immediately after you attach the package. So require(zoo) ls(2) will probably do what you want. Use search() to see the search list. Duncan Murdoch Certainly help(zoo) gives me some clues about what zoo does but I'd like a list. Maybe there's a way to query something but in Rgui under Win Vista ls() returns nothing after zoo is loaded. 2) Related to the above, how do I tell what packages are currently loaded at any given time so that I don't waste time loading things that are already loaded? search() tells me what's available, but what's loaded? The best I can find so far goes like this: a<-.packages(all.available = FALSE) a [1] "zoo" "stats" "graphics" "grDevices" "utils" "datasets" [7] "methods" "base" Maybe that's as good as it gets in code and if I want better then I write a function? Thanks, Mark __ R-help@r-project.org 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@r-project.org 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@r-project.org 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] Wiki down?
Yes, it is known. It is a major power supply fealure during all night... and UPS were exhausted. The site is now back again. Sorry for the inconvenience. Best, Philippe Grosjean Mario Valle wrote: From yesterday I cannot connect anymore to wiki.r-project.org Is the problem known? Thanks! mario __ R-help@r-project.org 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] timer in R?
Barry Rowlingson wrote: On Wed, Jul 1, 2009 at 8:41 PM, Michael wrote: Hi all, How could I set a timer in R, so that at fixed interval, the R program will invoke some other functions to run some tasks? Use timer events in the tcltk package: z=function(){cat("Hello you!\n");tcl("after",1000,z)} tcl("after",1000,z) now every 1000ms it will say "Hello you!". I'm not sure how to stop this without quitting R. There's probably some tcl function that clears it. Maybe. Or not. Just make sure you don't *always* reschedule another event on every event. Barry Here it is: library(tcltk) z <- function () { cat("Hello you!\n"); .id <<- tcl("after", 1000, z)} .id <<- tcl("after", 1000, z) tcl("after", "info", .id) # To get info about this scheduled task tcl("after", "cancel", .id) # To cancel the currently scheduled task Tcl is rather simple :-)... and everything is documented in 'man after'. Best, Philippe Grosjean __ R-help@r-project.org 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] a proposal regarding documentation
Sorry, after a second request, I got the ==Rwiki file not found!== again. Obviously, I have to solve this bug first! PhG Philippe Grosjean wrote: John Sorkin wrote: R 2.8.1, Firefox 3.0.11, windows XP Philippe, I suspect there are more substantial problems with the link to the WIKI then you thought. When I tried your code I got a page that contained nothing more than (excluding the nice graphic header and the index on the left-hand page): Trace: » barplot == Rwiki file not found! == There is a helpful discussion of adding labels to barplots here: https://stat.ethz.ch/pipermail/r-help/2002-October/025879.html This WIKI page is not at all useful,it does not as you suggested it does not contain the help page of ?barplot in wiki format as you suggested int would! John Still the problem with the cache. I refreshed the page, and now it appears as it should. Best, PhG John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Philippe Grosjean 6/15/2009 4:42 AM >>> Ironically, this function is present since the beginning, although a little buggy. If you try this in R on a computer that is connected to the Internet: wikihelp <- function(topic) browseURL(paste("http://wiki.r-project.org/rwiki/rhelp.php?id=";, topic, sep = "")) wikihelp("barplot") You got the help page of ?barplot in wiki format (with a few presentation bugs, but everything is there, basically)... plus a Wiki discussion section where people can add more material, links, etc. The help page is not physically contained in the wiki page, but it is a file stored elsewhere on the R Wiki server, and that is supposed to be updated regularly (but it is not the case for the moment). In the wiki page you see, there is only a ~~RDOC~~ marker indicating where to include the help page. I have a problem with the R Wiki cache: until someone adds comments to such a page, the content is not refreshed, but you just see ~~RDOC~~. Try, for instance: wikihelp("chisq.test") If the engine thinks 'topic' is ambiguous, it displays a list of possibilities (i.e., our wikihelp() function is somehow a mix of help() and of apropos()). For instance: wikihelp("help") This should not be ambiguous, but it is considered as it currently by rhelp.php (a minor bug probably easy to correct). Finally, all wiki pages are spelled with lowercase. It is the same for help pages. So, wikihelp("RSiteSearch") wikihelp("rsitesearch") lead to the same rdoc:utils:rsitesearch wiki page. I have no solutions for that! So, to conclude, most of the required mechanism is already installed on R Wiki. It just needs a little bit of debugging and fine-tuning to become completely operational. A little help here would be very appreciated! ... and, of course, a refined version of the wikihelp() function must be made widely available to "reveal" this function. One could even consider to write a pager that displays local help page and warns if there are comments on this topic posted on the wiki... or that link to a personal wiki engine where everybody could add its own comments to the help pages, with full-text search ability! Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Gabor Grothendieck wrote: In PHP and also in MySQL the manual has a wiki capability so that users can add notes at the end of each page, e.g. http://www.php.net/manual/en/functions.variable-functions.php http://dev.mysql.com/doc/refman/4.1/en/update.html That would combine documentation and wiki into one. Here it would involve copying the R help pages into the wiki in a readonly mode with the writeable wiki portion at the end of each such page. It would also be necessary to be able to update the help pages in the wiki when new versions became available. No explicit email group or coordination would be needed. It would also address the organization problem as they could be organized as they are now, i.e. into packages: base, stats, utils, ... It would require the development of a program to initially copy the help pages and to update them while keeping the notes in place whenever a new version of R came out. On Sun, Jun 14, 2009 at 5:35 PM, Peter Flom wrote: I certainly don't have anything against the WIKI, but I think that the documentation is where the action is, especially for newbies. It's the natu
Re: [R] a proposal regarding documentation
John Sorkin wrote: R 2.8.1, Firefox 3.0.11, windows XP Philippe, I suspect there are more substantial problems with the link to the WIKI then you thought. When I tried your code I got a page that contained nothing more than (excluding the nice graphic header and the index on the left-hand page): Trace: » barplot == Rwiki file not found! == There is a helpful discussion of adding labels to barplots here: https://stat.ethz.ch/pipermail/r-help/2002-October/025879.html This WIKI page is not at all useful,it does not as you suggested it does not contain the help page of ?barplot in wiki format as you suggested int would! John Still the problem with the cache. I refreshed the page, and now it appears as it should. Best, PhG John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Philippe Grosjean 6/15/2009 4:42 AM >>> Ironically, this function is present since the beginning, although a little buggy. If you try this in R on a computer that is connected to the Internet: wikihelp <- function(topic) browseURL(paste("http://wiki.r-project.org/rwiki/rhelp.php?id=";, topic, sep = "")) wikihelp("barplot") You got the help page of ?barplot in wiki format (with a few presentation bugs, but everything is there, basically)... plus a Wiki discussion section where people can add more material, links, etc. The help page is not physically contained in the wiki page, but it is a file stored elsewhere on the R Wiki server, and that is supposed to be updated regularly (but it is not the case for the moment). In the wiki page you see, there is only a ~~RDOC~~ marker indicating where to include the help page. I have a problem with the R Wiki cache: until someone adds comments to such a page, the content is not refreshed, but you just see ~~RDOC~~. Try, for instance: wikihelp("chisq.test") If the engine thinks 'topic' is ambiguous, it displays a list of possibilities (i.e., our wikihelp() function is somehow a mix of help() and of apropos()). For instance: wikihelp("help") This should not be ambiguous, but it is considered as it currently by rhelp.php (a minor bug probably easy to correct). Finally, all wiki pages are spelled with lowercase. It is the same for help pages. So, wikihelp("RSiteSearch") wikihelp("rsitesearch") lead to the same rdoc:utils:rsitesearch wiki page. I have no solutions for that! So, to conclude, most of the required mechanism is already installed on R Wiki. It just needs a little bit of debugging and fine-tuning to become completely operational. A little help here would be very appreciated! ... and, of course, a refined version of the wikihelp() function must be made widely available to "reveal" this function. One could even consider to write a pager that displays local help page and warns if there are comments on this topic posted on the wiki... or that link to a personal wiki engine where everybody could add its own comments to the help pages, with full-text search ability! Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Gabor Grothendieck wrote: In PHP and also in MySQL the manual has a wiki capability so that users can add notes at the end of each page, e.g. http://www.php.net/manual/en/functions.variable-functions.php http://dev.mysql.com/doc/refman/4.1/en/update.html That would combine documentation and wiki into one. Here it would involve copying the R help pages into the wiki in a readonly mode with the writeable wiki portion at the end of each such page. It would also be necessary to be able to update the help pages in the wiki when new versions became available. No explicit email group or coordination would be needed. It would also address the organization problem as they could be organized as they are now, i.e. into packages: base, stats, utils, ... It would require the development of a program to initially copy the help pages and to update them while keeping the notes in place whenever a new version of R came out. On Sun, Jun 14, 2009 at 5:35 PM, Peter Flom wrote: I certainly don't have anything against the WIKI, but I think that the documentation is where the action is, especially for newbies. It's the natural first step when you want to learn about a function or when you get an error message you don't understand. Peter Peter L.
Re: [R] a proposal regarding documentation
baptiste auguie wrote: I knew I had seen this in action! But as you mention, most pages only display ~~RDOC~~ at the moment. I second the idea of using the wiki for such collaborative work. If the current (r-devel) version of all help pages could be automatically copied to the wiki, users would have a convenient way to propose changes. The coloured diff, user identification, and RSS feed make for a very user-friendly alternative to svn access (unthinkable anyway for non-R core members). Well, the help page itself is read-only, but you can use all this in the Wiki discussion section. PhG Best, baptiste Philippe Grosjean wrote: Ironically, this function is present since the beginning, although a little buggy. If you try this in R on a computer that is connected to the Internet: wikihelp <- function(topic) browseURL(paste("http://wiki.r-project.org/rwiki/rhelp.php?id=";, topic, sep = "")) wikihelp("barplot") You got the help page of ?barplot in wiki format (with a few presentation bugs, but everything is there, basically)... plus a Wiki discussion section where people can add more material, links, etc. The help page is not physically contained in the wiki page, but it is a file stored elsewhere on the R Wiki server, and that is supposed to be updated regularly (but it is not the case for the moment). In the wiki page you see, there is only a ~~RDOC~~ marker indicating where to include the help page. I have a problem with the R Wiki cache: until someone adds comments to such a page, the content is not refreshed, but you just see ~~RDOC~~. Try, for instance: wikihelp("chisq.test") If the engine thinks 'topic' is ambiguous, it displays a list of possibilities (i.e., our wikihelp() function is somehow a mix of help() and of apropos()). For instance: wikihelp("help") This should not be ambiguous, but it is considered as it currently by rhelp.php (a minor bug probably easy to correct). Finally, all wiki pages are spelled with lowercase. It is the same for help pages. So, wikihelp("RSiteSearch") wikihelp("rsitesearch") lead to the same rdoc:utils:rsitesearch wiki page. I have no solutions for that! So, to conclude, most of the required mechanism is already installed on R Wiki. It just needs a little bit of debugging and fine-tuning to become completely operational. A little help here would be very appreciated! ... and, of course, a refined version of the wikihelp() function must be made widely available to "reveal" this function. One could even consider to write a pager that displays local help page and warns if there are comments on this topic posted on the wiki... or that link to a personal wiki engine where everybody could add its own comments to the help pages, with full-text search ability! Best, Philippe Grosjean ......<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. __ R-help@r-project.org 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] a proposal regarding documentation
Oh, I forgot to tell that svMisc package already implements since a long time a full-text search in R Wiki from within R, e.g., install.packages("svMisc") library("svMisc") helpSearchWeb("RSiteSearch", "wiki") ?helpSearchWeb There are parts here that could be merged probably in the RSiteSearch package discussed earlier in this mailing list. Best, Philippe Grosjean Gabor Grothendieck wrote: In PHP and also in MySQL the manual has a wiki capability so that users can add notes at the end of each page, e.g. http://www.php.net/manual/en/functions.variable-functions.php http://dev.mysql.com/doc/refman/4.1/en/update.html That would combine documentation and wiki into one. Here it would involve copying the R help pages into the wiki in a readonly mode with the writeable wiki portion at the end of each such page. It would also be necessary to be able to update the help pages in the wiki when new versions became available. No explicit email group or coordination would be needed. It would also address the organization problem as they could be organized as they are now, i.e. into packages: base, stats, utils, ... It would require the development of a program to initially copy the help pages and to update them while keeping the notes in place whenever a new version of R came out. On Sun, Jun 14, 2009 at 5:35 PM, Peter Flom wrote: I certainly don't have anything against the WIKI, but I think that the documentation is where the action is, especially for newbies. It's the natural first step when you want to learn about a function or when you get an error message you don't understand. Peter Peter L. Flom, PhD Statistical Consultant www DOT peterflomconsulting DOT com __ R-help@r-project.org 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@r-project.org 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] a proposal regarding documentation
Ironically, this function is present since the beginning, although a little buggy. If you try this in R on a computer that is connected to the Internet: wikihelp <- function(topic) browseURL(paste("http://wiki.r-project.org/rwiki/rhelp.php?id=";, topic, sep = "")) wikihelp("barplot") You got the help page of ?barplot in wiki format (with a few presentation bugs, but everything is there, basically)... plus a Wiki discussion section where people can add more material, links, etc. The help page is not physically contained in the wiki page, but it is a file stored elsewhere on the R Wiki server, and that is supposed to be updated regularly (but it is not the case for the moment). In the wiki page you see, there is only a ~~RDOC~~ marker indicating where to include the help page. I have a problem with the R Wiki cache: until someone adds comments to such a page, the content is not refreshed, but you just see ~~RDOC~~. Try, for instance: wikihelp("chisq.test") If the engine thinks 'topic' is ambiguous, it displays a list of possibilities (i.e., our wikihelp() function is somehow a mix of help() and of apropos()). For instance: wikihelp("help") This should not be ambiguous, but it is considered as it currently by rhelp.php (a minor bug probably easy to correct). Finally, all wiki pages are spelled with lowercase. It is the same for help pages. So, wikihelp("RSiteSearch") wikihelp("rsitesearch") lead to the same rdoc:utils:rsitesearch wiki page. I have no solutions for that! So, to conclude, most of the required mechanism is already installed on R Wiki. It just needs a little bit of debugging and fine-tuning to become completely operational. A little help here would be very appreciated! ... and, of course, a refined version of the wikihelp() function must be made widely available to "reveal" this function. One could even consider to write a pager that displays local help page and warns if there are comments on this topic posted on the wiki... or that link to a personal wiki engine where everybody could add its own comments to the help pages, with full-text search ability! Best, Philippe Grosjean ......<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Gabor Grothendieck wrote: In PHP and also in MySQL the manual has a wiki capability so that users can add notes at the end of each page, e.g. http://www.php.net/manual/en/functions.variable-functions.php http://dev.mysql.com/doc/refman/4.1/en/update.html That would combine documentation and wiki into one. Here it would involve copying the R help pages into the wiki in a readonly mode with the writeable wiki portion at the end of each such page. It would also be necessary to be able to update the help pages in the wiki when new versions became available. No explicit email group or coordination would be needed. It would also address the organization problem as they could be organized as they are now, i.e. into packages: base, stats, utils, ... It would require the development of a program to initially copy the help pages and to update them while keeping the notes in place whenever a new version of R came out. On Sun, Jun 14, 2009 at 5:35 PM, Peter Flom wrote: I certainly don't have anything against the WIKI, but I think that the documentation is where the action is, especially for newbies. It's the natural first step when you want to learn about a function or when you get an error message you don't understand. Peter Peter L. Flom, PhD Statistical Consultant www DOT peterflomconsulting DOT com __ R-help@r-project.org 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@r-project.org 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] a proposal regarding documentation
John Sorkin wrote: Perhaps help pages should have links to relevant portions of the WIKI. John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) spencerg 6/14/2009 1:53 PM >>> The documentation for the "nlme" package was improved a few years ago by an informal process of this nature. When I first started following r-help, I answered many questions suggesting in part the the person read some portion of Pinheiro and Bates (2000). At that time, none of the help pages mentioned Pinheiro and Bates, because they were completed before the book and had not been updated. Eventually, I volunteered to add that to some of the help pages. Doug agreed. In the process, I also expanded some of the examples and modified the text in places where I thought I could make it more easily understood. One obvious way to do this would be to provide write access to the main R subversion repository. However, that likely would not be acceptable to the R-core team unless it were limited to a very few individuals they already knew and trusted, and those individuals could process suggestions from others. As mentioned, there would need to be additional ground rules. For example, an inappropriate example might cause "R CMD check" to fail on some platforms but not others. This could expose problems with the core code, which perhaps should be fixed but not necessarily in the time frame desired by this new documentation improvement team. For a second example, Brian Ripley once rejected a suggested change to a help page because it referred to a package outside the core R code. A less threatening alternative might be to direct this energy into improving the R Wiki. I have contributed to other Wiki projects, and I've found them to be quite useful and dynamic. The current R Wiki has not so far lived up to its potential. However, I believe that is just a matter of building a critical mass of R Wiki contributors. Many questions on R help could best be answers by first cheking and perhaps improving the R Wiki and then directing the questioner to the Wiki. I plan to do that "sometime", but not yet. Hope this helps. Spencer Graves I agree. The R Wiki probably needs these steps: 1) To reorganize its general structure in order to find more easily relevant pages, 2) To rework the engine, and in particular the main page template to make it easier and more intuitive for R users, 3) ... most importantly: to move it to a faster server, so that it will be more responsive, and 4) To build a RWiki package with functions to ease access of the wiki pages (direct search in the wiki, retrieve code in R from a given wiki page, etc.). I have started something in this direction, but currently lack time to finalize it. Finally, the most important aspect is to get a group of volunteers to move and reformat nice discussions from R-Help/R-Devel/R-SIG-whatever into refined wiki pages... and with a referee mechanism to double/triple check content on the wiki. This happens erratically and certainly lacks proof-checking and feedback to the corresponding mailing list. Beside this, I am completely open to suggestions. Interested people could contact me directly. We could certainly arrange a dinner in Rennes at User!2009 to discuss evolution of the R Wiki, in particular, targeting collaborative writing of *good quality* documentation. Best, Philippe Grosjean [...] __ R-help@r-project.org 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] Most used R editors
Ronggui Huang wrote: Yes, Tinn-R is great for windows users. However, if you work under different OS, it would be great to have an OS-independent editor. Try SciViews-K (http://www.sciviews.org/SciViews-K). Works the same on Windows, Mac OS X and Linux. Best, Philippe Ronggui 2009/6/2 Bos, Roger : I have not seen Tinn-R mentioned so I will mention it. Its worked great for me. Eclipse is a nice IDE, but its more complicated that what is necessary for R programming. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Martial Sankar Sent: Tuesday, June 02, 2009 3:06 AM To: rhelp Subject: [R] Most used R editors Hi, I am a little lonely as R users in my group. So, I would like to know which editor is the most used in the R community. This post is some kind of survey. Personally, I use Emacs with ESS, It permits to : - open more than one R session - split the emacs editor as many part as you want. - use a lot of keybindings. ... I also tried Rkwards, Scilab (windows), JGR etc... but they are not suitable for what I do. Best, - Martial _ Découvrez toutes les possibilités de communication avec vos proches [[alternative HTML version deleted]] ** * This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No right to confidential or privileged treatment of this message is waived or lost by any error in transmission. If you have received this message in error, please immediately notify the sender by e-mail, delete the message and all copies from your system and destroy any hard copies. You must not, directly or indirectly, use, disclose, distribute, print or copy any part of this message if you are not the intended recipient. __ R-help@r-project.org 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@r-project.org 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] Cross-platforms solution to export R graphs
Liviu Andronic wrote: On Sat, Apr 11, 2009 at 3:20 PM, Philippe Grosjean wrote: format (PDF) to another one (SVG). In Inkscape, you use File -> Open... for the first step, and File -> Save as... for the second. Since it is a vector format, your graph should not look pixelised. Yes, this is what I'm doing, but I still get funny results. I have a PDF graph [1] that renders perfectly on my Linux system (say, using Evince), and the SVG counterpart [2] (converted via Inkscape) that appears with blurry lines at normal zoom level. But I just tried couple of R SVGs in Opera at high zoom-ins (350%), and they render as expected; guess I could only blame my image viewers. It looks nice at all resolution with Firefox on my Mac. Not exactly cross-platform, but there's also pdf2svg [3] for this type of conversion. Than you for the suggestion. PhG Thanks, Liviu [1] http://s000.tinyupload.com/index.php?file_id=02313849491005544965 [2] http://s000.tinyupload.com/index.php?file_id=65971482254693721586 [3] http://www.cityinthesky.co.uk/pdf2svg.html __ R-help@r-project.org 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] Cross-platforms solution to export R graphs
Liviu Andronic wrote: Hello, On Thu, Apr 9, 2009 at 3:04 PM, Philippe Grosjean wrote: "Cross-platforms solution to export R graphs" There is playwith, and latticist, which seem cross-platform (binaries available for both Mac&Win). rattle uses latticist. Yes, right. Rcmdr can be used for saving graphs. It is just a GUI on top of the described R functions. JavaGD (used in JGR) saves PDF and EPS plots, but I was not very happy with the quality of the graphics saved. Yes, I should try. Best, Philippe Liviu __ R-help@r-project.org 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] Cross-platforms solution to export R graphs
..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Liviu Andronic wrote: On Thu, Apr 9, 2009 at 3:04 PM, Philippe Grosjean wrote: The page is at: http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:export. The article suggests to use Inksacpe for PDF -> SVG conversion. I've recently experimented this, but it seems that the graph loses quality in the way. The resulting SVG seems pixelised and doesn't look very well when zoomed. I searched within Inkscape, but found no relevant options (only the resolution for export). Would there be options to look out for in Inkscape (such as antialias, or else)? Liviu ?? I don't understand what you are doing here. It is not a question of exporting the graph at a given resolution, but to convert it from one vector format (PDF) to another one (SVG). In Inkscape, you use File -> Open... for the first step, and File -> Save as... for the second. Since it is a vector format, your graph should not look pixelised. All the best, PhG __ R-help@r-project.org 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] Cross-platforms solution to export R graphs
To further add to this discussion. I would like to propose **cross-platform** solutions, emphasizing that the proposed solutions should work on Windows, Mac OS X and Ubuntu, at least. First of all, inclusion of a simple EPS graphs produced by R 2.9.0 with: > setEPS(); postscript("TestGraph.eps", width = 7, height = 7) > hist(rnorm(500), col = "yellow") > dev.off() systematically crashes native OpenOffice 3.0.1 (build 9379) on my Mac OS X 10.4. When I try to recover the document, it crashes again. The document is lost (impossible to get the rest of it when the EPS file in included)! Further experience is probably needed, but I cannot recommend a solution that does not work on my Mac test machine. Further arguments against EPS: - No support of semi-transparent colors (rarely used, but...) - It is the bitmap version that is displayed in the OOo document => not optimal in comparison with the use of EMF files, or with import into native shapes from PDF. This is particularly important because the PDF documents produced from OOo apparently also display the bitmap version of the EPS. Not nice when the intended result is in PDF form. It is then easier to use PNG files. Obviously, further experimentation is required here. Best, PhG Philippe Grosjean wrote: Emmanuel Charpentier wrote: Le jeudi 09 avril 2009 à 15:04 +0200, Philippe Grosjean a écrit : Hello Rusers, I have worked on a R Wiki page for solutions in exporting R graphs, especially, the often-asked questions: - How can I export R graphs in vectorized format (EMF) for inclusion in MS Word or OpenOffice outside of Windows? - What is the best solution(s) for post-editing/annotating R graphs. The page is at: http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:export. I would be happy to receive your comments and suggestions to improve this document. Well, if you insist ... The PDF import plugin in OpenOffice is still beta, and some report deem it difficult to install correctly an/or flaky. Having checked that both MSWord (>=2000) and OpenOffice (>=2.4) import and display correctly (i. e. vectorially, including fonts) EPS files, I switched to this format, most notably for use with the marvellous Max Kuhn's odfWeave package, which is a *must* for us working in state/administrative/corporate salt mines, where \LaTeX is deemed obscene and plain \TeX causes seizures ... The point is that this format doesn't need any intermediary step, thus allowing for automatisation. Be aware, however, that the embedded EPS images are not editable in-place by OpenOffice nor, as far as I know, by MS Word. But my point was to *avoid* post-production as much as humanly possible (I tend to be inhumanly lazy...). Ok, I understand your point of view. I tend to consider PDF import buggy in early trials, but now, the beta version seems fine and easy to install on all tested platforms. Also, using odfWeave and avoiding post-edition of graphs as much as possible is certainly the best practice. However, when you use EPS, you need a postscript printer to render the graphs. So, this is an additional constraint to consider. I will emphasize a little bit more the qualities of EPS in the document. Thanks. PhG HTH, Emmanuel Charpentier All the best, PhG __ R-help@r-project.org 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@r-project.org 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@r-project.org 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] Cross-platforms solution to export R graphs
Emmanuel Charpentier wrote: Le jeudi 09 avril 2009 à 15:04 +0200, Philippe Grosjean a écrit : Hello Rusers, I have worked on a R Wiki page for solutions in exporting R graphs, especially, the often-asked questions: - How can I export R graphs in vectorized format (EMF) for inclusion in MS Word or OpenOffice outside of Windows? - What is the best solution(s) for post-editing/annotating R graphs. The page is at: http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:export. I would be happy to receive your comments and suggestions to improve this document. Well, if you insist ... The PDF import plugin in OpenOffice is still beta, and some report deem it difficult to install correctly an/or flaky. Having checked that both MSWord (>=2000) and OpenOffice (>=2.4) import and display correctly (i. e. vectorially, including fonts) EPS files, I switched to this format, most notably for use with the marvellous Max Kuhn's odfWeave package, which is a *must* for us working in state/administrative/corporate salt mines, where \LaTeX is deemed obscene and plain \TeX causes seizures ... The point is that this format doesn't need any intermediary step, thus allowing for automatisation. Be aware, however, that the embedded EPS images are not editable in-place by OpenOffice nor, as far as I know, by MS Word. But my point was to *avoid* post-production as much as humanly possible (I tend to be inhumanly lazy...). Ok, I understand your point of view. I tend to consider PDF import buggy in early trials, but now, the beta version seems fine and easy to install on all tested platforms. Also, using odfWeave and avoiding post-edition of graphs as much as possible is certainly the best practice. However, when you use EPS, you need a postscript printer to render the graphs. So, this is an additional constraint to consider. I will emphasize a little bit more the qualities of EPS in the document. Thanks. PhG HTH, Emmanuel Charpentier All the best, PhG __ R-help@r-project.org 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@r-project.org 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] Cross-platforms solution to export R graphs
Hello Rusers, I have worked on a R Wiki page for solutions in exporting R graphs, especially, the often-asked questions: - How can I export R graphs in vectorized format (EMF) for inclusion in MS Word or OpenOffice outside of Windows? - What is the best solution(s) for post-editing/annotating R graphs. The page is at: http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:export. I would be happy to receive your comments and suggestions to improve this document. All the best, PhG -- ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. __ R-help@r-project.org 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 Scviews
Steve Sidney wrote: Many thanks Phillipe I was a little confused with web site and must have missed the fact that Komodo Edit has replaced SciViews. I will try and follow the instructions on your email and if I run into any more problems I will communicate with you. Some additional questions. 1) Is it your intention to continue to develop Komodo - SciViews Yes. 2) What is the IDE package used for. Was mainly for Tinn-R, but now, there is a separate TinnR package. It is kept here because we intend to use it for IDE-specific functions later on. 3) Does it still need Rcmdr to be installed to run/. No. Best, PhG Once again thanks for the help. Regards Steve - Original Message - From: "Philippe Grosjean" To: "Steve Sidney" Cc: Sent: Thursday, March 19, 2009 11:19 AM Subject: Re: [R] Help with Scviews Hello Sidney, If you look at http://www.sciviews.org/SciViews-K, you will notice that the old SciViews R Console application has now been superseded by the SciViews-K plugin in Komodo Edit. Also, the SciViews bundle has now been split into its packages components on CRAN. So, you can install all components (svMisc, svIDE, svGUI, ...), for instance by running install.packages("svMisc") but install.packages("SciViews") does not work anymore. To recall, the old SciViews R Console is not compatible with R > 2.2.1, and we are almost R 2.9.0. The new SciViews-K is compatible with current R version, and also, with Linux and Mac OS X in addition to Windows, the only OS supported by the old version. Please, update. Thanks, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Steve Sidney wrote: Dear all I would appreciate it if someone could help me to install Scviews. 1) I am running Windows XP Service Pack 3 with 1Gb of memory and 120GB HDrive. 2) R is installed and runs fine RCommander is installed and seems to run reasonably well. Some issues where it 'bombs' out for no reason. 3) I cannot run (install.packages:"Scviews") from any CRAN site. 4) What I have done is downlaoded the Install file from the scviews.org site but when I run Scviews it says that it can't find the "Bundle" and then when I try and connect to CRAN (any site) it says it cannot find the package as per the comment above in 3) Any ideas, and has anyone got any experience with this package. Many thanks for any help, Regards Steve [[alternative HTML version deleted]] __ R-help@r-project.org 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. No virus found in this incoming message. Checked by AVG - www.avg.com 20:27:00 __ R-help@r-project.org 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@r-project.org 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 Scviews
Hello Sidney, If you look at http://www.sciviews.org/SciViews-K, you will notice that the old SciViews R Console application has now been superseded by the SciViews-K plugin in Komodo Edit. Also, the SciViews bundle has now been split into its packages components on CRAN. So, you can install all components (svMisc, svIDE, svGUI, ...), for instance by running install.packages("svMisc") but install.packages("SciViews") does not work anymore. To recall, the old SciViews R Console is not compatible with R > 2.2.1, and we are almost R 2.9.0. The new SciViews-K is compatible with current R version, and also, with Linux and Mac OS X in addition to Windows, the only OS supported by the old version. Please, update. Thanks, Philippe Grosjean ..<°}))><.... ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Steve Sidney wrote: Dear all I would appreciate it if someone could help me to install Scviews. 1) I am running Windows XP Service Pack 3 with 1Gb of memory and 120GB HDrive. 2) R is installed and runs fine RCommander is installed and seems to run reasonably well. Some issues where it 'bombs' out for no reason. 3) I cannot run (install.packages:"Scviews") from any CRAN site. 4) What I have done is downlaoded the Install file from the scviews.org site but when I run Scviews it says that it can't find the "Bundle" and then when I try and connect to CRAN (any site) it says it cannot find the package as per the comment above in 3) Any ideas, and has anyone got any experience with this package. Many thanks for any help, Regards Steve [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with lmer and wiki example
James Widman wrote: I am trying to duplicate the example by Spencer Graves in the wiki, using lmer with the Nozzle data. http://wiki.r-project.org/rwiki/doku.php?id=guides:lmer-tests However the Chisq value and the fitAB values that are calculated are different compared to those in the example. I also get a warning message when I attempt the fitAB. Does anyone have any guidance as to why this might happen and how to correct it? I am using R on Kubutu in case that may be helpful. Thanks my code -- [Previously saved workspace restored] > rm(list=ls(all=TRUE)) > list=ls(all=TRUE) > print(list) character(0) > y <- c(6,6,-15, 26,12,5, 11,4,4, 21,14,7, 25,18,25, + 13,6,13, 4,4,11, 17,10,17, -5,2,-5, 15,8,1, + 10,10,-11, -35,0,-14, 11,-10,-17, 12,-2,-16, -4,10,24) > Nozzle <- data.frame(Nozzle=rep(LETTERS[1:3], e=15),Operator=rep(letters[1:5], e=3), flowRate=y) > summary(Nozzle) Nozzle Operator flowRate A:15 a:9 Min. :-35.000 B:15 b:9 1st Qu.: 0.000 C:15 c:9 Median : 7.000 d:9 Mean : 5.511 e:9 3rd Qu.: 13.000 Max. : 26.000 > library(lme4) Loading required package: Matrix Loading required package: lattice > fitAB <- lmer(flowRate~Nozzle+(Nozzle|Operator),data=Nozzle, method="ML") Warning messages: 1: In .local(x, ..., value) : Estimated variance-covariance for factor ‘Operator’ is singular 2: In .local(x, ..., value) : nlminb returned message false convergence (8) > fitB <- lmer(flowRate~1+(1|Operator), data=Nozzle, method="ML") > anova(fitAB, fitB) Data: Nozzle Models: fitB: flowRate ~ 1 + (1 | Operator) fitAB: flowRate ~ Nozzle + (Nozzle | Operator) Df AIC BIC logLik Chisq Chi Df Pr(>Chisq) fitB 2 359.36 362.98 -177.68 fitAB 9 362.13 378.39 -172.06 11.237 7 0.1286 -- Output from Spencer Graves example fitAB 9 359.88 376.14 -170.94 13.479 7 0.06126 Now, on a Mac OS X (using the unstable, development version of R 2.9.0, and recompiled version of lme4_0.999375-28... so caution of course!), I got this: First, the method = "ML" argument is deprecated and replaced by REML = TRUE/FALSE, but the doc at ?lmer does not tell exactly what is the equivalence to method = "ML" (and I don't know enough in this field to determine it by myself). Anyway, I tried both: > fitAB <- lmer(flowRate~Nozzle+(Nozzle|Operator),data=Nozzle, REML = TRUE) #Warning messages: #1: In .local(x, ..., value) : #Estimated variance-covariance for factor Operator is singular #2: In .local(x, ..., value) : #nlminb returned message false convergence (8) > fitB <- lmer(flowRate~1+(1|Operator), data=Nozzle, REML = TRUE) > anova(fitAB, fitB) Data: Nozzle Models: fitB: flowRate ~ 1 + (1 | Operator) fitAB: flowRate ~ Nozzle + (Nozzle | Operator) Df AIC BIC logLik Chisq Chi Df Pr(>Chisq) fitB 3 361.36 366.78 -177.68 fitAB 10 362.10 380.17 -171.05 13.261 70.06601 . --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 > fitAB <- lmer(flowRate~Nozzle+(Nozzle|Operator),data=Nozzle, REML = FALSE) #Warning messages: #1: In .local(x, ..., value) : #Estimated variance-covariance for factor Operator is singular #2: In .local(x, ..., value) : #nlminb returned message false convergence (8) > fitB <- lmer(flowRate~1+(1|Operator), data=Nozzle, REML = FALSE) > anova(fitAB, fitB) Data: Nozzle Models: fitB: flowRate ~ 1 + (1 | Operator) fitAB: flowRate ~ Nozzle + (Nozzle | Operator) Df AIC BIC logLik Chisq Chi Df Pr(>Chisq) fitB 3 361.36 366.78 -177.68 fitAB 10 361.96 380.03 -170.98 13.402 7 0.0629 . --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 So, I got same error messages as you. I got results closer to the one in the wiki page, BUT, I am puzzled by the degrees of freedom that are different 3/10 in my case, against 2/9 in yours and in the wiki page! Could the authors of lmer(), and/or of the wiki page, or the code cited in the wiki page (in CC) provide some explanation to this? Corrections/updates of the wiki page so that it reflects latest lmer() version would be also very much appreciated. All the best, Philippe Grosjean Just in case: > R.Version() $platform [1] "i386-apple-darwin8.11.1" $arch [1] "i386" $os [1] "darwin8.11.1" $system [1] "i386, darwin8.11.1" $status [1] "Under development (unstable)" $major [1] "2" $minor [1] "9.0" $year [1] "2009" $month [1] "01" $day [1] "22" $`svn rev` [1] "47686" $language [1] "R" $version.string [1] "R version 2.9.0 Under development (unstable) (2009-01-22 r47686)" > sessionInfo() R version 2.9.0 Under development (unstable) (2009-01-22 r47686) i386-apple-darwin8.11.1 locale: en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attach
Re: [R] Test Driven Development in R
Hello, As Jose noted, svUnit is fully functional. It is completely written and has recently entered in beta stage. It will be released on CRAN (GPL >= 2) at the end of the beta test, lasting in October 2009. svUnit R package is independent from the SciViews GUI, but it is true there is also a GUI for test-driven development (TDD) in R using svUnit + SciViews-K + Komodo, and it works on Linux/Windows/Mac OS X. It is probably the first one available for R. I am pretty sure other people will release similar tools for Eclipse/StatET and for Emacs/ESS soon. The GUI for TDD on top of svUnit depends on SciViews packages that are in mixed states: some are already on CRAN (svMisc, svSocket, svGUI, svIDE), while others, like svUnit or svTools are still in, respectively, beta and alpha stages. You can install them right now from r-forge only. Use: > install.packages("svUnit", repos="http://R-Forge.R-project.org";) in R to install svUnit. On Mac OS X, if R cannot find the binaries, make: > install.packages("svUnit", repos="http://R-Forge.R-project.org";, + type = "source") I want to remind also that svUnit is "test code compatible" with RUnit. Understand: you can use the same test units both with RUnit and with svUnit (but not simultaneously, of course). I think both packages have strengths. RUnit has (experimental) functions to check code coverage of the tests, while svUnit is much more flexible to define the tests: they can be attached to R objects, on memory, or on a .R file, they can be independent objects, and of course, they can also be contained in test suite on disk files, like for Runit. Also, svUnit proposes a mechanism to automatically locate tests, test units and test suites. It also proposes a central logging feature collecting test results from different test runs, and it fully integrates with the R CMD check mechanism of R for packages checking. Finally, svUnit reports can be pretty formatted using creole wiki language and be integrated in wikis (like http://wiki.r-project.org), say for automatic nightly test of your code. See page 9 of the svUnit vignette for an example. It is this additional flexibility that is exploited in the GUI part for TDD in SciViews-K. There is a vignette associated with the svUnit package detailing all its features. Just make: library(svUnit) vignette("svUnit") once the svUnit package is installed in R. We will be happy to receive comments, bug reports and other suggestions during this beta test. Use the bug and suggestions tracker on: https://r-forge.r-project.org/tracker/?group_id=194 Otherwise, I plan to submit an abstract about svUnit to User!2009 soon. All the best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Tobias Verbeke wrote: Jose Quesada wrote: Hi, I wonder what kind of interest there is on Test Driven Development (TDD) in R. Test Driven Development consists of writing the test before the function, and iteratively build the function until it passes the test. Python and Ruby (specially Ruby) have very strong test-oriented cultures. In fact, in Ruby at least the custom is to do TDD and lately Behavior-driven development (BDD). In BDD, one writes a story of what one would want the code to do. This story is almost native English, and then the test suite converts it into something that the language understand as tests. There are some posts on the list about this, but they are about testing in general (Runit), not TDD. Example: http://thread.gmane.org/gmane.comp.lang.r.general/85047 Recently, I found there is an alpha, but working implementation of TDD for Komodo edit: www.sciviews.org/SciViews-K/index.html The editor has a green bar that becomes red as soon as one edits a function, and that edit breaks the tests. This is tremendously useful. Using Gmane search, the only mention I could find on svUnit was: http://thread.gmane.org/gmane.comp.lang.r.general/136632/focus=136662 I think this could make a great UseR 2009 talk. Ideally, by someone with more R experience than me, and even more ideally by Philippe Grosjean :), but it push comes to shove, I could prepare such a talk. Would this be interesting at all? Are there any resources that I have missed? There is the RUnit package which is a mature xUnit implementation for R. I don't know of a tight integration into an editor (apart from that it is _planned_ for StatET, the Eclipse R plug-in), but as such it is very useful already. http://cran.r-project.org/web/packages/RUnit/index.html HTH, Tobias __ R-help@r-project.org mailing lis
Re: [R] R package tests
There is a mechanism for testing code in R packages (R CMD check), see the Writing R extensions manual. If you need more flexibility for your tests, you could look at RUnit on CRAN, or svUnit on R-Forge (http://r-forge.r-project.org, on CRAN soon). For the later one, you install it by: install.packages("svUnit", repos="http://R-Forge.R-project.org";) These is a vignette associated with svUnit: vignette("svUnit") Note that RUnit and svUnit are "test suite code" compatible, but they use very different mechanisms internally. Best, Philippe Grosjean ..<°}))><.... ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Nathan S. Watson-Haigh wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I was wondering if anyone could point me in the right direction for reading up on writing tests in R. I'm writing some functions for inclusion into a package and would like to test them to ensure they're doing what I expect them to do. Are these approaches used for testing packages in CRAN? Cheers, Nathan - -- - Dr. Nathan S. Watson-Haigh OCE Post Doctoral Fellow CSIRO Livestock Industries Queensland Bioscience Precinct St Lucia, QLD 4067 Australia Tel: +61 (0)7 3214 2922 Fax: +61 (0)7 3214 2900 Web: http://www.csiro.au/people/Nathan.Watson-Haigh.html - -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkluio8ACgkQ9gTv6QYzVL5X9QCgwvg5xjwZW2A2Z5G41iADu1Kz hIkAoI5ISuAtHyQ+JwJSRBAc9q/oyeEt =cqm4 -END PGP SIGNATURE- __ R-help@r-project.org 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@r-project.org 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] Interface to open source Reporting tools
Dieter Menne wrote: srinivasa raghavan gmail.com> writes: I am interested to generate dashboard and reports based on data from MS Access. These reports need to be posted on a weekly basis to the web. The reporting interface should provide facilities for "what if" scenarios. Is it possible to interface R analysis results to good open source reporting tools like Jasper Reports. what is the appropriate system requirements for carrying out real time reporting using R. You could use package XML to produce jrxml output; or, probably easier for not too complex reports, HTML could be generated by RHTML directly, including images. You probably mean R2HTML? Best, Philippe Dieter __ R-help@r-project.org 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R badly lags matlab on performance?
I wrote once the benchmark mentioned in Stefan's post (based on initial work by Stephan Steinhaus), and it is still available for those who would like to update it. Note that it is lacking some checking of the results to make sure that calculation is not only faster, but correct! Now, I'll tell why I haven't update it, and you'll see it is connected with the current topic. First, lack of time, for sure. Second, this benchmark has always been very criticized by several people including from the R Core Team. Basically, this is just toy examples, disconnected from the reality. Even with better cases, benchmarks do not take into account the time needed to write your code for your particular application (from the question to the results). I wrote this benchmark at a time when I overemphasized on the pure performances of the software, at a time I was looking for the best software I would choose as a tool for my future career. Now, what's my choice, ten years later? Not two, not three software... but just ONE: R. I tend to do 95% of my calculations with R (the rest is ImageJ/Java). Indeed, this benchmark results (and the toy example of Ajay Shah, a <- a + 1) should be only considered very marginally, because what is important is how your software tool is performing in real application, not in simplistic toy examples. R lays behind Matlab for pure arithmetic calculation... right! But R has a better object oriented approach, features more variable types (factor, for instance), and has a richer mechanism for metadata handling (col/row names, various other attributes, ...) that makes it richer to instanciate complex datasets or analyzes than Matlab. Of course, this has a small cost in performance. As soon as you think your problem in a vectorized way, R is one of the best tool, I think, to go "from the question to the answer" in real situations. How could we quantify this? I would only see big contests where experts of each language would be presented real problems and one would measure the time needed to solve the problem,... Also, one should measure: the robustness, reusability, flexibility, "elegance" of the code produced (how to quantify these?). Such kind of contest between R, Matlab, Octave, Scilab, etc. is very unlikely to happen. At the end, it is really a matter of personal feeling: you can make your own little contest by yourself: trying to solve a given problem in several software... and then decide which one you prefer. I think many people do/did this, and the still exponential growth of R use (at least, as it can be observed by the increasing number of CRAN R packages) is probably a good sign that R is probably one of the top performers when it comes to efficiency "from the question to the answer" in real problems, not just on toy little examples! (sorry for been so long, I think I miss some interaction with the R community this time ;-) Best, Philippe ......<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Stefan Grosse wrote: I don't have octave (on the same machine) to compare these with. And I don't have MatLab at all. So I can't provide a comparison on that front, I'm afraid. Ted. Just to add some timings, I was running 1000 repetitions (adding up to a=1001) on a notebook with core 2 duo T7200 R 2.8.1 on Fedora 10: mean 0.10967, st.dev 0.005238 R 2.8.1 on Windows Vista: mean 0.13245, st.dev 0.00943 Octave 3.0.3 on Fedora 10: mean 0.097276, st.dev 0.0041296 Matlab 2008b on Windows Vista: 0.0626 st.dev 0.005 But I am not sure how representative this is with that very simple example. To compare Matlab speed with R a kind of benchmark suite is necessary. Like: http://www.sciviews.org/benchmark/index.html but that one is very old. I would guess that there did not change much: sometimes R is faster, sometimes not. This difference between the Windows and Linux timing is probably not really relevant: when I was comparing the timings of my usual analysis there was no difference between the two operating systems. (count data and time series stuff) Cheers Stefan __ R-help@r-project.org 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@r-project.org 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] editor for MacOS X
Hello, There is also Komodo Edit + SciViews-K (http://www.sciviews.org/SciViews-K), rather close to Tinn-R functionnalities. Please; note that SciViews-K is not compatible yet with Komodo 5.0 and you must install version 4.4. Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Mike Lawrence wrote: I personally have found the built-in editor rather buggy and have switched to TextMate (which I also use for my python programming). On Fri, Nov 28, 2008 at 7:17 AM, Michael Zak <[EMAIL PROTECTED]> wrote: Why don't you use the bult-in editor from R under OS X? It's much better as the windows pendant. Take care, Michael On 28.11.2008, at 12:15, Bunny, lautloscrew.com wrote: Hi all, just wondered again, if there is some R editor for Mac OS X comparable to TINN-R on windows. thx in advance.. __ R-help@r-project.org 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@r-project.org 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@r-project.org 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] is there any way to run R method as a background process from R interface
Hello, Two approaches depending when you want to trigger this background calculation: 1) It is enough to trigger the background computation after each top-level instruction entered at the command line: use ?addTaskCallback 2) You want to trigger the background calculation at a given time, or redo it every xxx ms. This is a little bit more complicate. I have success using the tcltk package and the 'after' Tcl function. Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Kurapati, Ravichandra (Ravichandra) wrote: Hi , can some body tell to me "how to run a R method /function as a background process from R interface" Thanks K.Ravichandra [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] Including graphics files in MS office / open office
Hello Hadley, I have started this: http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:export. One solution that works not too bad in OpenOffice is to output the graph in XFig format, and then use fig2dev from transfig to get an EMF file. That one is rather well readable by OpenOffice. There are some limitations of XFig with R graphs, see ?xfig. Best, Philippe ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. hadley wickham wrote: Hi all, I'm trying to write up some recommendations for what graphics formats are most useful for inclusion into ms office and openoffice. There have been a few discussions on the list in the past, but I haven't seen a summary. These are the options I've seen so far, along with there costs and benefits: * high-resolution (600-dpi) png output (or tiff or jpg or other raster format). The main disadvantage is that it's a raster format, so you need to know the eventual output size. * windows metafile: works well in MS office, but does not support transparency. Can only be produced on windows, and openoffice support isn't great * encapsulated postscript: supported by both MS office and open office, but won't display a preview image unless you add one with an external program. Prints fine. * svg: R output devices still experimental and open office import still experimental. No support in ms office. Have I missed anything? Is the information correct? Hadley __ R-help@r-project.org 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] What editors can I get R in Mac OS X to talk to?
... and Komodo Edit with the SciViews-K plugin installed (http://www.sciviews.org/SciViews-K). Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Dr Eberhard Lisse wrote: AlphaX 8.0.2 of Course!! :-)-O el on 10/23/08 11:08 AM baptiste auguie said the following: Hi, I use Textmate, but every now and then I like to try out aquamacs. I've just downloaded it from < http://aquamacs.org/ >, where ESS is part of the package. It runs flawlessly for me, out of the box. I just opened a r file, clicked the big R icon, then simply highlighted part of the code and Cc-Cr to evaluate it. For some reason the default graphics device turned out to be x11() but that's a minor detail to configure. Baptiste (R7.2, MBP, Leopard) __ R-help@r-project.org 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] Dream of a wiki GUI for R
Xiaoxu LI wrote: I should have read the following page on R_Extension_for_MediaWiki http://mars.wiwi.hu-berlin.de/mediawiki/sk/index.php/R_Extension_for_MediaWiki_v0.06#New_tags_and_attributes Has anybody seen an ... online example page in English? I really wish wiki.r-project.org be equipped with parameter input interfaces and convenient R codes submit choices. Any donated Rweb, Rcgi or other R server can be the redirected server-side and the professional security burden can be avoided for wiki.r-project.org Yes. Another option that was considered was to write a Sweave driver for the wiki pages. However, in any cases, there are serious security issues. Unless I am helped by an expert in this field, I don't feel confident enough to add that functionality in http://wiki.r-project.org. One solution I could provide is a wiki R package with various utility functions. One of them would be a function to extract R code from given wiki pages in a text editor. Then, the user could run this code while keeping full control of the way the code is executed (locally, on his machine). Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. LI Xiaoxu School of Arts and Social Sciences, Shenzhen Graduate School, Peking Univ.(Shenzhen Campus) China On Mon, Sep 29, 2008 at 7:12 PM, Philippe Grosjean <[EMAIL PROTECTED]> wrote: Hello, Just to add to what Ajay said: the http://wiki.r-project.org does not execute R code from within wiki pages. This is a choice for security reasons. However, there are ways to get R code from R wiki pages and run it in R: http://wiki.r-project.org/rwiki/doku.php?id=tips:misc:wikicode Also, there is a discussion about integrating Sweave in wiki pages: http://wiki.r-project.org/rwiki/doku.php?id=developers:latex2wiki. If someone would like to start a "teaching stats with R" topic on the R wiki and organize a section for this, he is more than welcome to make a proposal (send it to me). Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Ajay ohri wrote: Hi Tobias, It makes sense from a practical view point. SAS Institute funds its own wiki at www.sascommunity.org The catch is they have editorial influence and can use offerings there for commercial purposes. The surprising thing is you can actually create a wiki in wikipedia itself. Just adopt a convention lets say Rproj for beginning of each wiki page. Note this would mean volunteers parsing the back and forth of messages into structure ( maybe it exists already) However wikis are a bit outdated. The latest is knol.google.com as it gives you the right to make document editable, or allow comments, or even what kind of license you want content to be shared. The catch again is its owned by Google , the big company. Other options from Google include Google Docs as well as Google Sites.You can even create bulk Google Docs from a writely email that your docs.google.com account gives you, and just last week someone created a Google Docs plugin for sending R output directly to the Docs. As you may have noticed and I have pointed out once the R -project website itself is badly outdated compared to the software itself. The official R wiki of course is here http://wiki.r-project.org/rwiki/doku.php So these are the options - noting that email groups are more easy to use and addictive , though not the best for collobrative knowledge storage over a period of time. Regards, Ajay www.decisionstats.com On Sun, Sep 28, 2008 at 3:19 PM, Tobias Verbeke <[EMAIL PROTECTED]>wrote: Hi, I am just writing a draft to introduce confidence intervals of various "effect sizes" to my students. Surely, I'll recommend the package MBESS in R. Currently, it means I have to recommend R's interface at first. As a statistics teacher in a dept of psychology, I often have to reply why not to teach SPSS. Psychologists and their students hate to memorize codes, or even to call any function with a list of parameters. I know if I have an online R platform with a wiki html-form design, I can bypass the function calls and headache parameters to expose the power of R. Rcmdr and its plugins help some, but students like to remember just one menu structure in the SPSS textbook. A wiki interface means they can search and find a complete example in psychology, with self-explained parameter inputs and outputs. Do I actually dream a wikipedia with front forms and back R? Mo
Re: [R] TINN-R's "R Explores" - Available for other editors?
Hello, The R explorer in Tinn-R is similar and derived from the one in SciViews R Console. However, SciViews R Console is not maintained any more, because our energy is spend in a cross-platform replacement project: SciViews-K. The R explorer in SciViews-K is not complete yet, and is in alpha stage, but you can have a look at it (and at the other nice features in preparation): http://www.sciviews.org/SciViews-K. We plan to release the first version of SciViews-K around next September. Currently, we finalize the core code and have started a beta test program on the modules that are already finalized in two Universities. The priority is also on the documentation that is still lacking currently. All the best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. [EMAIL PROTECTED] wrote: Hello, I am using TINN-R for working with R and for that purpose it is a very handy editor, in particular the R-Explorer that shows the existing objects and their properties is worth money. But I want to move to a more flexible editor (in particular for Latex) and was thinking of WinEdt (or maybe Eclipse, because of Java). I know they have capabilities to work directly with R, but has any other editor the same capabilities when it comes down to the R-Explorer? Best, Stefan __ R-help@r-project.org 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@r-project.org 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] R 2.7.2 upgrade in Ubuntu, tcltk does not work any more
Hello, I had no problems running R with tcltk until the recent upgrade to R-2.7.2-2gustsy1 (I use Ubuntu 7.10 Gutsy Gibbon). Since the upgrade from R-2.7.2-1, I got this error (see hereunder). Obviously, I have now a problem with tcltk-related .so files. What should I do? Thanks. Philippe [EMAIL PROTECTED]:~$ R R version 2.7.2 (2008-08-25) Copyright (C) 2008 The R Foundation for Statistical Computing 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. Natural language support but running in an English locale 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. > library(tcltk) Loading Tcl/Tk interface ... Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/usr/lib/R/library/tcltk/libs/tcltk.so': libtcl8.5.so.0: cannot open shared object file: No such file or directory Error : .onLoad failed in 'loadNamespace' for 'tcltk' Error: package/namespace load failed for 'tcltk' > > R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 7.2 year 2008 month 08 day25 svn rev46428 language R version.string R version 2.7.2 (2008-08-25) > __ R-help@r-project.org 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] Graph in vector format to OpenOffice
Hello, I know this topic has been discussed already several times. Is it a workable solution that emerged? I would like to place R graph in vector format in an OpenOffice Writer document (solution working in Linux AND Mac OS X AND Windows). I have tried to play with pstoedit to convert .ps file produced by R into .svm, .dxf, etc... but without success. PhG -- ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. __ R-help@r-project.org 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] Dream of a wiki GUI for R
Hello, Just to add to what Ajay said: the http://wiki.r-project.org does not execute R code from within wiki pages. This is a choice for security reasons. However, there are ways to get R code from R wiki pages and run it in R: http://wiki.r-project.org/rwiki/doku.php?id=tips:misc:wikicode Also, there is a discussion about integrating Sweave in wiki pages: http://wiki.r-project.org/rwiki/doku.php?id=developers:latex2wiki. If someone would like to start a "teaching stats with R" topic on the R wiki and organize a section for this, he is more than welcome to make a proposal (send it to me). Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Ajay ohri wrote: Hi Tobias, It makes sense from a practical view point. SAS Institute funds its own wiki at www.sascommunity.org The catch is they have editorial influence and can use offerings there for commercial purposes. The surprising thing is you can actually create a wiki in wikipedia itself. Just adopt a convention lets say Rproj for beginning of each wiki page. Note this would mean volunteers parsing the back and forth of messages into structure ( maybe it exists already) However wikis are a bit outdated. The latest is knol.google.com as it gives you the right to make document editable, or allow comments, or even what kind of license you want content to be shared. The catch again is its owned by Google , the big company. Other options from Google include Google Docs as well as Google Sites.You can even create bulk Google Docs from a writely email that your docs.google.com account gives you, and just last week someone created a Google Docs plugin for sending R output directly to the Docs. As you may have noticed and I have pointed out once the R -project website itself is badly outdated compared to the software itself. The official R wiki of course is here http://wiki.r-project.org/rwiki/doku.php So these are the options - noting that email groups are more easy to use and addictive , though not the best for collobrative knowledge storage over a period of time. Regards, Ajay www.decisionstats.com On Sun, Sep 28, 2008 at 3:19 PM, Tobias Verbeke <[EMAIL PROTECTED]>wrote: Hi, I am just writing a draft to introduce confidence intervals of various "effect sizes" to my students. Surely, I'll recommend the package MBESS in R. Currently, it means I have to recommend R's interface at first. As a statistics teacher in a dept of psychology, I often have to reply why not to teach SPSS. Psychologists and their students hate to memorize codes, or even to call any function with a list of parameters. I know if I have an online R platform with a wiki html-form design, I can bypass the function calls and headache parameters to expose the power of R. Rcmdr and its plugins help some, but students like to remember just one menu structure in the SPSS textbook. A wiki interface means they can search and find a complete example in psychology, with self-explained parameter inputs and outputs. Do I actually dream a wikipedia with front forms and back R? Most R fans are wiki fans, but not vice verse. So, I think I should talk my dream here rather than at wikipedia. If you know it had been a practice rather than an idea, please tell me where to write my teaching interface. Some have had similar dreams: http://ideas.repec.org/p/hum/wpaper/sfb649dp2008-030.html http://www.r-project.org/user-2006/Slides/Klinke.pdf http://www.r-project.org/user-2006/Abstracts/Klinke+Schmerbach+Troitschanskaia.pdf HTH, Tobias LI, Xiaoxu School of Arts and Social Sciences, Shenzhen Graduate School, Peking Univ.(Shenzhen Campus) China __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org 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] Opening R from Tinn without setting directory each time
Paul Chatfield wrote: Hi - someone has just e-mailed me direct with the answer which it'd be helpful to paste just so future users who have the same issue can see. Just follow the advice below and it works perfectly. Open a command window (Run;cmd) and cd to the bin directory of your R installation (cd C:/Program Files). Run the program RSetReg.exe and that's it, Tinn-R should be able to start R. When you update R repeat the process. This shouldn't be needed if you activate the option to register the installed/upgraded version of R in the registry (somewhere at the end of the installer's questions). Best, Philippe Grosjean Paul Chatfield wrote: Hi - I can access R from Tinn-R by going to Options->Main->Application/R and setting the search path, but each time I exit Tinn-R I have to redefine the search path. Is there no way of fixing that directory as default? I have installed R under its default directory C:/Program Files/R/R-2.7.1 and Tinn under a variety of different places to try to rectify the problem though currently under C:/Program Files/Tinn-R. Any ideas what I'm missing? Thanks Paul __ R-help@r-project.org 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] viewing data in something similar to 'R Data Editor'
Erich Neuwirth wrote: On Windows, this could be done with rcom and Excel. rcom can use Excel as a server and put matrices into Excel ranges. The code you run in R could have a statement resending matrices so the current version is displayed. I could set up more conveniently what yo want if RGui had a way of automatically running a function each time code is run from the command line. So here is a question to the masters: Can I have code automatically run each time some code is run from the command line? This is something I have already asked. It seems this is not possible currently. Something like ?addTaskCallback, but registering an R function that is to be called *before* a top-level task is run would be wonderful (???addTaskStart). Best, Philippe Grosjean P.S.: this would solve also another problem we have for some GUIs: to know if R is busy processing commands issued at the command line or not (just set a busy flag to TRUE with a function registered with "addTaskStart", and set it to FALSE with a function registered with addTaskCallback). Of course, a R function that provides this information more directly would be much, much better. On Aug 1, 2008, at 7:29 PM, Rachel Schwartz wrote: Hi, I would like to view matrices I am working with in a clean, easy to read, separate window. A friend showed me how to do something like I want with edit(). I can view the matrix in the 'R Data Editor': For a sample matrix: mat=matrix(1:15,ncol=3) mat [,1] [,2] [,3] [1,]16 11 [2,]27 12 [3,]38 13 [4,]49 14 [5,]5 10 15 look=function(x) invisible(edit(x)) look(mat) That opens the 'R Data Editor' with mat loaded. But I am not able to do any other actions in R while this 'R Data Editor' is open. I want to keep this open while I do other work. Is there a way to view my data in something like the 'R Data Editor' that still allows me to do work at the same time? I am looking for something other than str(), head(), and tail() which just allow me a quick peak at the object. I do not want to edit the object in the table, but be able to watch the object change while I run anything that would manipulate it. Thank you for your help. Best, Rachel Schwartz Graduate Student Researcher UCSD; Scripps Institution of Oceanography [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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@r-project.org 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] Change language in Rcmdr
Hello, As far as I know, Rcmdr is already translated in French. It is thus just a question of switching R to French. Best, Philippe Grosjean Duncan Murdoch wrote: Schleuh wrote: Hello every R-User, I would like to translate Rcmdr menu items to French (by example). How can I do it ? The web page http://developer.r-project.org/Translations.html describes what needs to be done. You should definitely contact the package author (John Fox) first, because you'll need to make changes throughout the package in order to accomplish this; it's probably also a good idea to contact the R French translation team (led by Philippe Grosjean) for advice. Duncan Murdoch __ R-help@r-project.org 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@r-project.org 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] SciViews GUI
Hello, We need a little more information (which platform? which R version?). Also, the GUI is NOT provided with the SciViews package. The version on CRAN is quite outdated and is designed to communicate with the old SciViews R Console GUI for Windows only. We are currently working on a new version that uses a new platform-independent GUI based on Komodo Edit. It will be uploaded to CRAN as soon as it will be finished, but for the moment, you can install alpha version from R-Forge. See detailed instructions on http://www.sciviews.org/SciViews-K. Note that alpha version is unsupported. Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Felipe Carrillo wrote: HI: After following all the instructions on how to install the SciViews package from CRAN I still can't make the GUI show. Can someone give me a hint on how to do this? I have tried library(svGUI), library(svDialogs) and so on with the rest of the packages. I have also placed all the 'sv' packages in my Rprofile but nothing works. Any help would be appreciated. Thanks Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish & Wildlife Service California, USA __ R-help@r-project.org 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R perfomance question !!!
Hello, Do you really need to read these data that often? What's the amount of data you read at each iteration? What's the buffer capacity of your system for sending these data? Couldn't you read data every 1/10 second (or another, better suited interval)? For instance, something like: x <- GiveNextDataPortion() while (!is.null(x)) { Sys.sleep(0.1) x <- GiveNextDataPortion() } If not, consider using C code, or the embedded Tcl (with the tcltk package) that has a very nice mechanism for I/O management in situations like this (google a little bit to find examples of use, or look at the svSocket or Rpad packages for examples of use in R). Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. diver495 wrote: The main task is computing of consistently received data. I have a function named "GiveNextDataPortion()" that returns the list object. The number of function's calls is about 5 millions and thus, I encountered a problem of perfomance. I use this script: x<-GiveNextDataPortion() while(is.null(x)==FALSE) { x<-GiveNextDataPortion() } 5 millions iterations of "while" loop takes about 20 seconds on my computer, it is very quickly, but adding some simple extra operators increases the time of test a lot. For example: x<-GiveNextDataPortion() i=0 j=1 while(is.null(x)==FALSE) { x<-GiveNextDataPortion() i=i+1 j= j*i } It will already take more than 10 minutes. Have you any ideas about the optimization of this test? Roland Rau-3 wrote: Hi, diver495 wrote: Using Visual Basic I can complete the same script (simple loop of 500 itterations) in 0.1 sec. Is it realy R not suitable for huge computing. If you are happy with Visual Basic, then there is no need for you to use R. In case your message was not a flamebait, it is well known that loops like these are often bottlenecks for R. There are many resources how to easily avoid them. See, for example, "S Programming by Venables and Ripley or John Chambers' book: Programming with data. Even searching the mail archive for subject like "avoid loops" might be helpful. You might also consider checking functions like apply, tapply, ... Best, Roland P.S. It seems there is also a good book available for scientific computing with Visual Basic: http://www.ibiblio.org/Dave/Dr-Fun/df22/df2210.jpg __ R-help@r-project.org 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R perfomance question !!!
Hello, Do you really need to read these data that often? What's the amount of data you read at each iteration? What's the buffer capacity of your system for sending these data? Couldn't you read data every 1/10 second (or another, better suited interval)? For instance, something like: x <- GiveNextDataPortion() while (!is.null(x)) { Sys.sleep(0.1) x <- GiveNextDataPortion() } If not, consider using C code, or the embedded Tcl (with the tcltk package) that has a very nice mechanism for I/O management in situations like this (google a little bit to find examples of use, or look at the svSocket or Rpad packages for examples of use in R). Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. diver495 wrote: The main task is computing of consistently received data. I have a function named "GiveNextDataPortion()" that returns the list object. The number of function's calls is about 5 millions and thus, I encountered a problem of perfomance. I use this script: x<-GiveNextDataPortion() while(is.null(x)==FALSE) { x<-GiveNextDataPortion() } 5 millions iterations of "while" loop takes about 20 seconds on my computer, it is very quickly, but adding some simple extra operators increases the time of test a lot. For example: x<-GiveNextDataPortion() i=0 j=1 while(is.null(x)==FALSE) { x<-GiveNextDataPortion() i=i+1 j= j*i } It will already take more than 10 minutes. Have you any ideas about the optimization of this test? Roland Rau-3 wrote: Hi, diver495 wrote: Using Visual Basic I can complete the same script (simple loop of 500 itterations) in 0.1 sec. Is it realy R not suitable for huge computing. If you are happy with Visual Basic, then there is no need for you to use R. In case your message was not a flamebait, it is well known that loops like these are often bottlenecks for R. There are many resources how to easily avoid them. See, for example, "S Programming by Venables and Ripley or John Chambers' book: Programming with data. Even searching the mail archive for subject like "avoid loops" might be helpful. You might also consider checking functions like apply, tapply, ... Best, Roland P.S. It seems there is also a good book available for scientific computing with Visual Basic: http://www.ibiblio.org/Dave/Dr-Fun/df22/df2210.jpg __ R-help@r-project.org 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@r-project.org 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] Quartile regression question
Hello, Look at package quantreg. Philippe Grosjean Ranney, Steven wrote: I have data that looks like lake,loglength,logweight 1,2.369215857,1.929418926 1,2.426511261,2.230448921 1,2.434568904,2.298853076 1,2.437750563,2.298853076 1,2.442479769,2.230448921 1,2.445604203,2.356025857 ... 102,2.722633923,3.310268367 102,2.781755375,3.502153893 102,2.836324116,3.683407299 102,2.802773725,3.583312152 102,2.790285164,3.546419267 102,2.806179974,3.599118565 102,2.716837723,3.316180099 I can regress log weight on log length simply enough, but how would I model the third quartile of log weights? In other words, rather than finding a 2nd quartile (or 50th percentile) regression line, e.g., mod=lm(logweight~loglength) can R find a 75th percentile line? Further, since my data is lake>1, is there a way to run 3rd quartile regressions on each lake? I would imagine that regressing each population would require some call of the subset function, but I cannot figure out how to call it. Thanks in advance, SR Steven H. Ranney Graduate Research Assistant (Ph.D) USGS Montana Cooperative Fishery Research Unit Montana State University PO Box 173460 Bozeman, MT 59717-3460 phone: (406) 994-6643 fax: (406) 994-7479 [[alternative HTML version deleted]] __ R-help@r-project.org 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@r-project.org 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] svIDE and Tinn-R
Hello, This does not seem to be something in the svIDE package, but something send by Tinn-R to R through the DDE connection for the first two warnings. I'll eliminate the last one for next version of the package. Best, Philippe Grosjean Patrick Giraudoux wrote: Probably an old moon since evoqued one year ago in this link: http://tolstoy.newcastle.edu.au/R/e2/help/07/04/15738.html but I have recently re-installed Tinn-R with R 2.7.0 and forgot to insert options(warn=-1) library(svIDE) ... options(warn=0) in Rprofile.site... and could see that we have still the same warning launching R: Warning messages: 1: '\A' is an unrecognized escape in a character string 2: unrecognized escape removed from ";for Options\AutoIndent: 0=Off, 1=follow language scoping and 2=copy from previous line\n" 3: In grep(paste("[{]TclEval ", topic, "[}]", sep = ""), tclvalue(.Tcl("dde services TclEval {}")), : argument 'useBytes = TRUE' will be ignored I wonder how far it may be problematical ? Patrick __ R-help@r-project.org 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@r-project.org 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] R is a virus, spyware or malware (gasp!)
After a search session in Google, I found this page: http://www.prevx.com/filenames/X1993788672854780728-0/RGUI.EXE.html which classifies Rgui.exe (clearly stated as "R for Windows GUI front-end") in a database of virus, spyware and malware! No comments! Philippe Grosjean __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R benchmarking program
Martin Maechler wrote: "PhGr" == Philippe Grosjean <[EMAIL PROTECTED]> on Tue, 13 May 2008 16:10:15 +0200 writes: PhGr> Hello, PhGr> I did this bechmark test. Perhaps is it a good oppotunity to rewrite it PhGr> and make it compatible with R 2.7.0, David? I'll not really rewrite it (to make it "nice" in my eyes), but I'm fixing the problems with the fact that the 'Matrix' package you were using back then has been much changed in the mean time. Expect a corrected benchmark R script within a day or so. Thank you, Martin. Martin Maechler, ETH Zurich PhGr> Best, PhGr> Philippe Grosjean PhGr> ..<°}))><.... PhGr> ) ) ) ) ) PhGr> ( ( ( ( (Prof. Philippe Grosjean PhGr> ) ) ) ) ) PhGr> ( ( ( ( (Numerical Ecology of Aquatic Systems PhGr> ) ) ) ) ) Mons-Hainaut University, Belgium PhGr> ( ( ( ( ( PhGr> .. PhGr> Baker D.J. wrote: >> Hi All, >> >> I've just rebuild the latest R with the Goto BLAS on our new Intel quad core machines. I did a few basic matrix calculations, and I was very impressed by the performance I saw. I wonder if anyone has a more rigorous benchmarking program for R. I downloaded a old R test/benchmarking program (see below), and this didn't work with the current R, and so I wondered if anyone could please direct me to a more recent program that does a good all round test of R. >> >> Regards -- David. >> >> >> # R Benchmark 2.3 (21 April 2004) >> # Warning: changes are not carefully checked yet! >> # version 2.3 adapted to R 1.9.0 >> # Many thanks to Douglas Bates ([EMAIL PROTECTED]) for improvements! >> # version 2.2 adapted to R 1.8.0 >> # version 2.1 adapted to R 1.7.0 >> # version 2, scaled to get 1 +/- 0.1 sec with R 1.6.2 >> # using the standard ATLAS library (Rblas.dll) >> # on a Pentium IV 1.6 Ghz with 1 Gb Ram on Win XP pro >> >> # revised and optimized for R v. 1.5.x, 8 June 2002 >> # Requires additionnal libraries: Matrix, SuppDists >> # Author : Philippe Grosjean >> # eMail : [EMAIL PROTECTED] >> # Web: http://www.sciviews.org >> # License: GPL 2 or above at your convenience (see: http://www.gnu.org) >> # >> # Several tests are adapted from the Splus Benchmark Test V. 2 >> # by Stephan Steinhaus ([EMAIL PROTECTED]) >> # Reference for Escoufier's equivalents vectors (test III.5): >> # Escoufier Y., 1970. Echantillonnage dans une population de variables >> # aleatoires réles. Publ. Inst. Statis. Univ. Paris 19 Fasc 4, 1-47. >> >> ... >> Error in getClass(Class, where = topenv(parent.frame())) : >> "geMatrix" is not a defined class >> Calls: new -> getClass >> Execution halted __ R-help@r-project.org 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R benchmarking program
Hello, I did this bechmark test. Perhaps is it a good oppotunity to rewrite it and make it compatible with R 2.7.0, David? Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( ( Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Baker D.J. wrote: Hi All, I've just rebuild the latest R with the Goto BLAS on our new Intel quad core machines. I did a few basic matrix calculations, and I was very impressed by the performance I saw. I wonder if anyone has a more rigorous benchmarking program for R. I downloaded a old R test/benchmarking program (see below), and this didn't work with the current R, and so I wondered if anyone could please direct me to a more recent program that does a good all round test of R. Regards -- David. # R Benchmark 2.3 (21 April 2004) # Warning: changes are not carefully checked yet! # version 2.3 adapted to R 1.9.0 # Many thanks to Douglas Bates ([EMAIL PROTECTED]) for improvements! # version 2.2 adapted to R 1.8.0 # version 2.1 adapted to R 1.7.0 # version 2, scaled to get 1 +/- 0.1 sec with R 1.6.2 # using the standard ATLAS library (Rblas.dll) # on a Pentium IV 1.6 Ghz with 1 Gb Ram on Win XP pro # revised and optimized for R v. 1.5.x, 8 June 2002 # Requires additionnal libraries: Matrix, SuppDists # Author : Philippe Grosjean # eMail : [EMAIL PROTECTED] # Web: http://www.sciviews.org # License: GPL 2 or above at your convenience (see: http://www.gnu.org) # # Several tests are adapted from the Splus Benchmark Test V. 2 # by Stephan Steinhaus ([EMAIL PROTECTED]) # Reference for Escoufier's equivalents vectors (test III.5): # Escoufier Y., 1970. Echantillonnage dans une population de variables # aleatoires réles. Publ. Inst. Statis. Univ. Paris 19 Fasc 4, 1-47. ... Error in getClass(Class, where = topenv(parent.frame())) : "geMatrix" is not a defined class Calls: new -> getClass Execution halted __ R-help@r-project.org 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@r-project.org 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] Vector format importation from R to OpenOffice
Hello Agustin, hi all, There was a recent discussion about how to import R graphs in vector format into OpenOffice. For Microsoft Word under Windows, there is no problems: the EMF format (Windows Enhanced Metafile) is completely supported. However, importing the same .emf file into OpenOffice leads to very poor results. Here is a workaround, until OpenOffice will support PDF format (in next release): - Install ghostscript and pstoedit (http://www.pstoedit.net/pstoedit). - From R, create a graph in PDF format, or export it in PDF. This is very convenient format to store all your graphs because you can easily view, zoom in/out, etc. you graph in your favorite PDF viewer on any platform. It is much more portable than EMF. - Convert your PDF files into a "OpenOffice-compatible" Windows Metafile at the command line: > pstoedit -f "wmf:-OO" graph.pdf graph.wmf - Import graph.wmf into OpenOffice. I just did a few trials with graphs from demo(graphics). The results are much, much better that the original EMF version generated by R, and it is also more compact. For reasons, I ignore, WMF generated by pstoedit seems better than EMF, and even, than SVM (the OpenOffice vector format)! Yet, some experimentation with pstoedit numerous formats and options before getting the best import of R graph into OpenOffice remains to be done... Best, Philippe Grosjean P.S.: if someone got time, it would be nice to put this on the R Wiki... Agustin Lobo wrote: > Just in case you did not see this thread: > > from > https://stat.ethz.ch/pipermail/r-help/2008-April/160141.html > > ... > As there is no real solution to this problem, I wonder if > developers of R graphic GUIs could consider adding > SVG format as one of the available formats to the "Save As" tab of R > graphic GUIs > (according to my web search, problems at importing emf files by OpenOffice > have been reported since so long ago that there is little hope that this > problem will > ever be solved within Open Office). > > Thank you all. > > Agus > __ R-help@r-project.org 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] read variable global in R tcltk
Read ?tclvalue. For instance, you can do: > tclvalue("tcl_library") # Read the content of a Tcl variable [1] "/usr/local/lib/tcl8.4" > .Tcl("set myvar 1") # Create a variable inside Tcl 1 > tclvalue("myvar")# Read its value [1] "1" To make sure you create global variables in Tcl, start their names with '::', like '::myglobalvar', if you like. Best, Philippe Grosjean Handayani Situmorang wrote: > I have any problem with my code. I build a small GUI in R with tcltk > package. the proolem is I don't understand how to make a variable value can > be read by R from a function. the variable value can only read if it's called > via tcltk widgets and pass it to another function. i think the point is the > variable must be set as global variable. but i don't have any idea? is anyone > can help me, please? Thank you very much. > > > - > Bergabunglah dengan orang-orang yang berwawasan, di bidang Anda di Yahoo! > Answers > [[alternative HTML version deleted]] > > __ > R-help@r-project.org 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@r-project.org 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] Stopping a function execution automatically after a given time
You should look at AutoIt or Autohotkey for this. Best, Philippe Grosjean Duncan Murdoch wrote: > On 4/2/2008 12:00 PM, Lukas Rode wrote: >> Dear Bert and Mel, >> >> thanks for your help, but I'm afraid this doesn't solve my problem. >> >> As I wrote in my previous mail (cf quote below) in most cases I will not be >> able to modify the code of the function that I want to run. This is why I >> was asking for a wrapper solution similar to what tryCatch does. I have >> hinted at a very inelegant version that generates a new R process for each >> function run and kills the process after a given time. But I'm sure there >> must be something more elegant. I hope I have been clear enough in my >> problem description. > > On some systems (not Windows) you could ask some external process to > send a signal after a certain time interval, and I believe you can write > you code to recover afterwards. I don't know any reasonable way to do > this on Windows. > > Duncan Murdoch > >> Thanks again, >> Lukas >> >> Here is what I wrote before: >> Note that mostly these functions are not written by me and not R code (like >> nlme for example), so it is not feasible to adapt the function itself. >> Rather, it needs to be a wrapper around the function, similar to tryCatch. >> >> >> >> On Wed, Apr 2, 2008 at 5:23 PM, mel <[EMAIL PROTECTED]> wrote: >> >>> Lukas Rode a écrit : >>> >>>> Nowever, with regard to #2, I am lost. I would like to set a maximum >>> time >>>> limit (say, 1 minute) and if my procedure is still running then, I would >>>> like to move on to the next model. >>> >>> begin_time = as.difftime(format(Sys.time(), '%H:%M:%S'), units='secs'); >>> for(...) >>> { >>> ... >>> current_time = as.difftime(format(Sys.time(), '%H:%M:%S'), units='secs'); >>> delay = current_time - begin_time; >>> if (delay>60) return(); >>> } >>> >>> a counter may also be enough >>> >>> __ >>> R-help@r-project.org 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@r-project.org 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@r-project.org 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@r-project.org 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 can I reorder a dendrogram?
Hello, Perhaps, you should chose another toy example closer to the reality. Cases with exactly same distance rarely occur "in the field". You should, at least, add some random error: datamatrix <- matrix(c(2,2,2.5,2,1.5,2,2,1.5,2,2.5, 6,2,6.5,2,5.5,2,6,1.5,6,2.5, 4,4,4.5,4,3.5,4,4,3.5,4,4.5) + rnorm(30, sd = 0.1), ncol = 2, byrow = TRUE) distmatrix <- dist(datamatrix, method = "manhattan") hc <- hclust(distmatrix, method = "single") dendro <- as.dendrogram(hc) plot(dendro) #Now, I want to impose an order: weights <- c(2.0, 2.0, 2.0, 2.0, 2.0, 6.0, 6.0, 6.0, 6.0, 6.0, 4.0, 4.0, 4.0, 4.0, 4.0) ddd <- reorder(dendro, weights, agglo.FUN=mean) plot(ddd) unlist(ddd) # [1] 4 2 3 1 5 13 14 15 11 12 10 7 9 6 8 unlist(dendro) # [1] 10 7 9 6 8 13 14 15 11 12 4 2 3 1 5 Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Thomas Walter wrote: > Hi! > > I am trying to reorder a dendrogram via reorder.dendrogram. However, I > observed some problems with this, and I will illustrate them with an > example. > > Take the following clustering problem: > > datamatrix <- matrix(c(2,2,2.5,2,1.5,2,2,1.5,2,2.5, > 6,2,6.5,2,5.5,2,6,1.5,6,2.5, 4,4,4.5,4,3.5,4,4,3.5,4,4.5), ncol=2, > byrow=TRUE) > distmatrix <- dist(datamatrix, method="manhattan") > hc <- hclust(distmatrix, method="single") > dendro <- as.dendrogram(hc) > > The datamatrix contains three equidistant (for manhattan distance) > clusters, each of which contains 5 points. > Now, I want to impose an order: > > weights <- c(2.0, 2.0, 2.0, 2.0, 2.0, 6.0, 6.0, 6.0, 6.0, 6.0, 4.0, 4.0, > 4.0, 4.0, 4.0) > ddd <- reorder(dendro, weights, agglo.FUN=mean) > > but if you compare the order of ddd with dendro, you see no change: > > unlist(ddd) > [1] 15 14 13 11 12 5 4 3 1 2 10 9 8 6 7 > > unlist(dendro) > [1] 15 14 13 11 12 5 4 3 1 2 10 9 8 6 7 > > I would have expected something like: > 5 4 3 1 2 15 14 13 11 12 10 9 8 6 7 > > or something of the sort. (I still do not know, if the order should be > ascending or descending, but in the obtained result, it is neither nor). > I do not see, where my mistake is ... > > Thanks for your advice! > > Thomas. > > __ > R-help@r-project.org 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@r-project.org 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] Table of basic descriptive statistics like SPSS
Jim Lemon wrote: > [EMAIL PROTECTED] wrote: >> Dear list readers, >> I want to: >> >> 1. Get a table of basic descriptive statistics for my variables >> with the variable names one below the other >> like SPSS descriptive statistics: >> >> Varname N Min Max Mean SD >> x x xx x >> xxx x x xx x >> >> > This looks very much like the output of the "describe" function in the > prettyR package. You can specify which summary stats you want (even roll > your own). And if that's not enough: library(pastecs) data(trees) t(stat.desc(trees)) ?stat.desc >> 2. Delete some variables from a data frame or exclude variables >> from beeing analyzed. df2 <- df[ , -c(1, 3), drop = FALSE] for instance to eliminate variables in columns 1 and 3, but there are many other ways to select variables to use in an analysis, beginning with the formula interface, see, e.g., ?lm. >> 3. Create a text file / redirect the terminal output to a >> file (it is supposed to be easy, but I could not find a solution)? >> > sink("myoutputfile.txt") > do.your.stuff(...) > sink() > OR > maybe you would enjoy "htmlize" or "R2html" in the prettyR package. ... or the R2html package! >> 4. Create a latex/dvi file >> > You do this with Sweave, I think. See also functions in the Hmisc package. >> 5. Create a PDF file (can that be done within R?) >> > For plots, the pdf device. See ?pdf Please, note first search commands: apropos("pdf") RSiteSearch("latex") Using these, you would have found by yourself the various corresponding functions. Philippe > Jim > > __ > R-help@r-project.org 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@r-project.org 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] Transfer Crosstable to Word-Document
bartjoosen wrote: > > > Greg Snow-2 wrote: >> >>> write.table(my.data, 'clipboard', sep="\t") >> Then in Excel just do a paste and the data is there, this saves a couple >> of steps from saving as a .csv file and importing that into excel. This >> would probably be fine for a few tables. >> >> >> > > Just to inform: > > if you use write.table(my.data,'whateverfile.xls',sep="\t", quote=FALSE), > you can open this file right from the windows explorer as a normal excel > file. > If you're already running excel and choose file>open, you will get a dialog > box, where you have to click complete or OK. > > > Bart Yes, but it is a very bad practice to name a file with .xls extension that is not in Excel file format (here, a tab-separated ASCII file)! Best, Philippe Grosjean __ R-help@r-project.org 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] Tinn-R not working well with latest R
Hello, These are *warnings*. So, the functions should still work. However, there are changes made in R that probably need some lifting in the svIDE package. The whole SciViews bundle is currently reworked. Unfortunately, I now work on Mac OS X, and it is a little bit more difficult for me to test this with Tinn-R. Could you give me more infos about the "great features in Tinn-R" that stop working in R 2.6.2, please? Best, Philippe Grosjean ..<°}))>< ) ) ) ) ) ( ( ( ( (Prof. Philippe Grosjean ) ) ) ) ) ( ( ( ( (Numerical Ecology of Aquatic Systems ) ) ) ) ) Mons-Hainaut University, Belgium ( ( ( ( ( .. Farrel Buchinsky wrote: > I recently installed R 2.6.2 and am getting errors on startup that > relate to svIDE being loaded by Tinn-R. > > > Loading required package: tcltk > Loading Tcl/Tk interface ... done > Warning messages: > 1: '\A' is an unrecognized escape in a character string > 2: unrecognized escape removed from ";for Options\AutoIndent: 0=Off, > 1=follow language scoping and 2=copy from previous line\n" > 3: In grep(paste("[{]TclEval ", topic, "[}]", sep = ""), > tclvalue(.Tcl("dde services TclEval {}")), : > argument 'useBytes = TRUE' will be ignored > Loading required package: svMisc > Loading required package: R2HTML > > > Any idea what is going on. > I use R 2.6.2 on windows xp > > I also started R without the profile that Tinn-R made. > If I manualy enter library(svIDE) then I get. > > library(svIDE) > Warning messages: > 1: '\A' is an unrecognized escape in a character string > 2: unrecognized escape removed from ";for Options\AutoIndent: 0=Off, > 1=follow language scoping and 2=copy from previous line\n" > > So the underlying problem may be svIDE > see: http://tolstoy.newcastle.edu.au/R/e2/help/07/04/15738.html > > Apparently, because of this error, several great features in Tinn-R are > not working properly. > Any solutions or workarounds? > > > -- > Farrel __ R-help@r-project.org 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.