Re: [R] How do I find the index for a value in an array

2009-01-03 Thread Jorge Ivan Velez
Dear George, Try this: mat<-matrix(1:9,1,9) which(mat==5,arr.ind=TRUE) row col [1,] 1 5 HTH, Jorge On Sun, Jan 4, 2009 at 1:21 AM, George Chen wrote: > Hello, > Could anybody tell me how to find the index for a value which I define in > an array? > > ie. > > c<-matrix(1:9,1,9) #A

[R] How do I find the index for a value in an array

2009-01-03 Thread George Chen
Hello, Could anybody tell me how to find the index for a value which I define in an array? ie. c<-matrix(1:9,1,9) #A 1x9 matrix filled with numbers 1 - 9 in order I want to know the index for the value 5. Thanks in advance, George Chen __ R-help@r

Re: [R] Newbie question

2009-01-03 Thread cruz
abntest[abntest$abntesr > 90,] On Sun, Jan 4, 2009 at 11:55 AM, wrote: > Hi: > > I'm loading in students test scores with: > >> abntest <- read.table("scores.txt") > > if I type: > >>abntest > > I get ALL the values. I want to be able to filter it by various things such > as: > > > if( abntes

[R] Newbie question

2009-01-03 Thread greggallen
Hi: I'm loading in students test scores with: > abntest <- read.table("scores.txt") if I type: >abntest I get ALL the values. I want to be able to filter it by various things such as: if( abntesr > 90) Print abntest; and other logical operators. I'm sure this is simple for someone experie

[R] example of using loess()

2009-01-03 Thread cruz
Hi, I have read ?loess help page and did some google on loess, however there are insufficient information on weighted variance. I am wondering that if any of you know of an example or document on weighted variance using loess (), especially for the cases when more than one explanatory variable is

Re: [R] hexbin plot

2009-01-03 Thread jim holtman
Have you considered using the lattice-style panel functions that hexbin provides: mixdata <- data.frame(x = c(rnorm(5000),rnorm(5000,4,1.5)), y = c(rnorm(5000),rnorm(5000,2,3)), a = gl(2, 5000)) hexbinplot(y ~ x, mixdata, aspect = 1, panel=function(x, y

Re: [R] POSIXct and chron issues with tz

2009-01-03 Thread Gabor Grothendieck
There seems to be no reason to use POSIXct in the first place. Just use chron everywhere and read R News 4/1. Suppose we just want month 9 from the merged object: z2 <- zoo(data.matrix(DF), tt) m <- merge(z, z2, all = c(FALSE, TRUE)) m[ m$mon %in% 9 ] On Sat, Jan 3, 2009 at 7:57 PM, Sherri Heck

Re: [R] R: passing parameters to an R script

2009-01-03 Thread jim holtman
?commandArgs On Sat, Jan 3, 2009 at 4:17 PM, wrote: > Thank you. > You're right. I come from C and C++ programming. > I wonder whether to pass parameters to an R script I have to set environment > variables ... ? > > Best regards, > Maura > > > -Messaggio originale- > Da: jim holtman [ma

[R] POSIXct and chron issues with tz

2009-01-03 Thread Sherri Heck
Dear All- I am trying to merge two data files - they have different date formats and different times zones. I need to match up the date/time of the datasets and then invoke a conditional statement, such as: if dataC$mph is >= 12 then keep dataM$co23 for the corresponding time/date stamp. sn

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Dirk Eddelbuettel
On 3 January 2009 at 18:02, l...@stat.uiowa.edu wrote: | The current byte code compiler available from my web site speeds this | (highly artificial) example by about a factor of 4. The experimental | byte code engine I am currently working on (and that can't yet do much | more than an example lik

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread luke
On Sat, 3 Jan 2009, Duncan Murdoch wrote: On 03/01/2009 1:37 PM, Ajay Shah wrote: As for jit and Ra, that was immediate reaction too but I found that jit does not help on your example. But I concur fully with what Ben said --- use the tool that is appropriate for the task at hand. If your ta

[R] [R-pkgs] RQDA-0.1-6 is on CRAN

2009-01-03 Thread ronggui
Major new features of RQDA-0.1-6: GUI: * GUI for file-organization (e.g searching, categorization etc.). * GUI for settings (e.g. colors for ) Functions: * Import a batch of files * Calculate the relation between two codings, given the coding index * Gives a summary of coding and inter-code relati

Re: [R] Linux words file

2009-01-03 Thread Ted Harding
On 03-Jan-09 21:39:55, Erin Hodgess wrote: > Dear R People: > > I have a small function that solves the "Jumble" puzzle from the > newspaper (I know...big deal). It uses the the Linux "words" file. > > My question is: is there a similar words file for Windows, please? > > Thanks, > Happy New (

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Duncan Murdoch
On 03/01/2009 1:37 PM, Ajay Shah wrote: As for jit and Ra, that was immediate reaction too but I found that jit does not help on your example. But I concur fully with what Ben said --- use the tool that is appropriate for the task at hand. If your task is running for loops, Matlab does it faste

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Wacek Kusnierczyk
Ajay Shah wrote: >> As for jit and Ra, that was immediate reaction too but I found that jit does >> not help on your example. But I concur fully with what Ben said --- use the >> tool that is appropriate for the task at hand. If your task is running for >> loops, Matlab does it faster and you hav

Re: [R] Power functions?

2009-01-03 Thread Wacek Kusnierczyk
rkevinbur...@charter.net wrote: > I had a question about the basic power functions in R. > > For example from the R console I enter: > > -1 ^ 2 > [1] -1 > > but also > > -1^3 > [1] -1 > > -0.1^2 > [1] -0.01 > > Normally pow(-1, 2) return either -Infinity or NaN. Has R taken over the math > functi

Re: [R] Power functions?

2009-01-03 Thread Marc Schwartz
on 01/03/2009 02:32 PM rkevinbur...@charter.net wrote: > I had a question about the basic power functions in R. > > For example from the R console I enter: > > -1 ^ 2 [1] -1 > > but also > > -1^3 [1] -1 > > -0.1^2 [1] -0.01 > > Normally pow(-1, 2) return either -Infinity or NaN. Has R taken

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Wacek Kusnierczyk
(Ted Harding) wrote: > On 03-Jan-09 18:28:03, Ben Bolker wrote: > >> Ajay Shah mayin.org> writes: >> >>> On Sat, Jan 03, 2009 at 06:59:29PM +0100, Stefan Grosse wrote: >>> On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah mayin.org> wrote: AS> system.time(for (i in 1:

Re: [R] Power functions?

2009-01-03 Thread YH Deng
(-1)^2 Or a <- -1 a^2 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of rkevinbur...@charter.net Sent: January 3, 2009 3:33 PM To: r-help@r-project.org; r-h...@stat.math.ethz.ch Subject: [R] Power functions? I had a question about the

Re: [R] Power functions?

2009-01-03 Thread Stavros Macrakis
Watch the operator precedences. In R (and many other languages) -1^2 == -(1^2) == -1 Perhaps you intended: (-1)^2 == 1 On Sat, Jan 3, 2009 at 3:32 PM, wrote: > I had a question about the basic power functions in R. > > For example from the R console I enter: > > -1 ^ 2 > [1] -1 > > b

Re: [R] Linux words file

2009-01-03 Thread Duncan Murdoch
On 03/01/2009 4:39 PM, Erin Hodgess wrote: Dear R People: I have a small function that solves the "Jumble" puzzle from the newspaper (I know...big deal). It uses the the Linux "words" file. My question is: is there a similar words file for Windows, please? As far as I know Windows doesn't i

Re: [R] Power functions?

2009-01-03 Thread Prof Brian Ripley
Please post to only one of r-help@r-project.org r-h...@stat.math.ethz.ch not to both, as the same list then got two copies. On Sat, 3 Jan 2009, rkevinbur...@charter.net wrote: I had a question about the basic power functions in R. For example from the R console I enter: -1 ^ 2 [1] -1 but a

[R] Linux words file

2009-01-03 Thread Erin Hodgess
Dear R People: I have a small function that solves the "Jumble" puzzle from the newspaper (I know...big deal). It uses the the Linux "words" file. My question is: is there a similar words file for Windows, please? Thanks, Happy New (Gnu) Year. Sincerely, Erin -- Erin Hodgess Associate Profe

[R] Power functions?

2009-01-03 Thread rkevinburton
I had a question about the basic power functions in R. For example from the R console I enter: -1 ^ 2 [1] -1 but also -1^3 [1] -1 -0.1^2 [1] -0.01 Normally pow(-1, 2) return either -Infinity or NaN. Has R taken over the math functions? If so I would think that -1^2 is 1 not -1 and -0.1^2 is

[R] R: passing parameters to an R script

2009-01-03 Thread mauede
Thank you. You're right. I come from C and C++ programming. I wonder whether to pass parameters to an R script I have to set environment variables ... ? Best regards, Maura -Messaggio originale- Da: jim holtman [mailto:jholt...@gmail.com] Inviato: sab 03/01/2009 21.12 A: mau...@alice.i

Re: [R] passing parameters to an R script

2009-01-03 Thread Stavros Macrakis
R's variable passing mechanism is not call by value, but a mixture of unevaluated arguments (like the obsolete Lisp FEXPR) and call-by-need. It is like FEXPR in that the function can capture the unevaluated argument (using 'substitute'). But it is like call-by-need in that normal use of the argum

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Stefan Grosse
> 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

Re: [R] passing parameters to an R script

2009-01-03 Thread jim holtman
No you can not pass an address to a function. If you want to change the value of something, then return it as a value and assign it to the object so you can see what is going on. Must be coming from the "C" environment where such things are allowed and lead to a number of problems. If you really

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread hadley wickham
On Sat, Jan 3, 2009 at 12:37 PM, Ajay Shah wrote: >> As for jit and Ra, that was immediate reaction too but I found that jit does >> not help on your example. But I concur fully with what Ben said --- use the >> tool that is appropriate for the task at hand. If your task is running for >> loops,

Re: [R] extend summary.lm for hccm?

2009-01-03 Thread John Fox
Dear Achim, I suspect that the problem, involving a fifth-degree raw polynomial, is very ill-conditioned, and that the computation in linear.hypothesis() fails because it is not as stable as lm() and summary.lm(). (BTW, one would not normally call summary.lm() directly, but rather use the generic

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ted Harding
On 03-Jan-09 18:28:03, Ben Bolker wrote: > Ajay Shah mayin.org> writes: >> On Sat, Jan 03, 2009 at 06:59:29PM +0100, Stefan Grosse wrote: >> > On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah >> > mayin.org> wrote: >> > >> > AS> system.time(for (i in 1:1000) {a[i] <- a[i] + 1}) >> > >> > AS> I w

[R] Non-Latin labels in identify

2009-01-03 Thread Aleksandr Andreev
Greetings. I'm trying to label some points using the identify() command. The labels and the coordinates are coming from a csv file. The file encoding is UTF-8. If I use labels in Latin characters, everything comes out OK. But when I switch to using labels in Cyrillic, I get garbage. To check tha

[R] how specify lme() with multiple within-subject factors?

2009-01-03 Thread Ben Meijering
I have some questions about the use of lme(). Below, I constructed a minimal dataset to explain what difficulties I experience: # two participants subj <- factor(c(1, 1, 1, 1, 2, 2, 2, 2)) # within-subjects factor Word Type wtype <- factor(c("nw", "w", "nw", "w", "nw", "w", "nw", "w")) # withi

[R] passing parameters to an R script

2009-01-03 Thread mauede
I knowf R functions ca be called passing some parameters. My first question is: how are parameters passed to R functions ? Browsing through R archives I found an answer confirming taht parameters can be passed to the called function by value. I wonder whether passing the parameter address is po

[R] hexbin plot

2009-01-03 Thread Rodrigo Fernandes Ramalho
Hello, I would like some help to plot a vertical line on a scatterplot build with hexbin package. I just need to plot a vertical line on the graph to mark a threshold value on x axis. It would be better if the parameter of the plot line function respect the x axis scale. Thanks, Rodrigo

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ajay Shah
> As for jit and Ra, that was immediate reaction too but I found that jit does > not help on your example. But I concur fully with what Ben said --- use the > tool that is appropriate for the task at hand. If your task is running for > loops, Matlab does it faster and you have Matlab, well then y

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Dirk Eddelbuettel
On 3 January 2009 at 23:40, Ajay Shah wrote: | On Sat, Jan 03, 2009 at 06:59:29PM +0100, Stefan Grosse wrote: | > On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah wrote: | > | > AS> system.time(for (i in 1:1000) {a[i] <- a[i] + 1}) | > | > AS> I wonder what we're doing wrong! | > | > it is no s

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ben Bolker
Ajay Shah mayin.org> writes: > > On Sat, Jan 03, 2009 at 06:59:29PM +0100, Stefan Grosse wrote: > > On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah mayin.org> wrote: > > > > AS> system.time(for (i in 1:1000) {a[i] <- a[i] + 1}) > > > > AS> I wonder what we're doing wrong! > > > > it is no se

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ajay Shah
On Sat, Jan 03, 2009 at 06:59:29PM +0100, Stefan Grosse wrote: > On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah wrote: > > AS> system.time(for (i in 1:1000) {a[i] <- a[i] + 1}) > > AS> I wonder what we're doing wrong! > > it is no secret that R does badly with loops. Thats why it is > recommen

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Ben Bolker
Ajay Shah mayin.org> writes: > > Here's a small R program: > > --- > a <- rep(1,1000) > > system.time(a <- a + 1) > > system.time(for (i in 1:1000) {a[i] <- a[i] + 1}) > ---

Re: [R] R badly lags matlab on performance?

2009-01-03 Thread Stefan Grosse
On Sat, 3 Jan 2009 22:25:38 +0530 Ajay Shah wrote: AS> system.time(for (i in 1:1000) {a[i] <- a[i] + 1}) AS> I wonder what we're doing wrong! it is no secret that R does badly with loops. Thats why it is recommended to use vectorized operations. Another approach is just in time compilation

Re: [R] Calculating signicance value

2009-01-03 Thread Ben Bolker
Moumita Das gmail.com> writes: [snip snip snip] > But how do i get significance of > e say:-- > recmeanC1&recmeanC2 or say recmeanC1 & i1. > I can add this in my corr function shown above but: > > #Finding out significance of the two items whose correlations are being > found > sig_value<-

Re: [R] runif (and other generator) "precision" / man pages

2009-01-03 Thread Ben Bolker
John C Nash uottawa.ca> writes: > > I'm inclined to agree with the view that the "precision" of a generator > should be highlighted better in the manual pages. When I do > > ?runif > > I don't see a mention, but ?.Random.seed DOES give the info, as Duncan > points out, and it is suggested to

[R] R badly lags matlab on performance?

2009-01-03 Thread Ajay Shah
Here's a small R program: --- a <- rep(1,1000) system.time(a <- a + 1) system.time(for (i in 1:1000) {a[i] <- a[i] + 1}) --- and here's its mat

Re: [R] How to capture multiple graph pages to .png ?

2009-01-03 Thread Mike Williamson
Jim, Thanks so much! I feel kinda stupid now. I read that part, but I didn't really get what it was talking about... despite the fact that I am fairly familiar with the %d syntax when setting up formatting. Regards,

Re: [R] How to capture multiple graph pages to .png ?

2009-01-03 Thread jim holtman
W.R.T. multiple pages, the HELP page says to use a filename like this: png(filename = "Rplot%03d.png", where %03d is an incremented value for each page. On Fri, Jan 2, 2009 at 2:23 PM, Mike Williamson wrote: > Hello all and thanks in advance for any help, > >There are really two issues that

Re: [R] runif (and other generator) "precision" / man pages

2009-01-03 Thread John C Nash
I'm inclined to agree with the view that the "precision" of a generator should be highlighted better in the manual pages. When I do ?runif I don't see a mention, but ?.Random.seed DOES give the info, as Duncan points out, and it is suggested to look there. A 1-liner with each random number g

Re: [R] R Stacked Histogram

2009-01-03 Thread John Kane
Is this of any help? http://www.cse.unsw.edu.au/~mike/myrlibrary/geneplotter/html/histStack.html --- On Sat, 1/3/09, Jason Rupert wrote: > From: Jason Rupert > Subject: [R] R Stacked Histogram > To: r-help@r-project.org > Received: Saturday, January 3, 2009, 12:00 AM > I've seen this asked, b

Re: [R] R Stacked Histogram

2009-01-03 Thread hadley wickham
On Fri, Jan 2, 2009 at 11:00 PM, Jason Rupert wrote: > I've seen this asked, but never fully answered. > > Is it possible to plot stacked histograms in R? > > I have four data sets that I would like to show combined vertically in > histogram format. > > Is this possible? Yes, but it's generally

Re: [R] Equivalent of match for data.frame

2009-01-03 Thread Prof Brian Ripley
On Sat, 3 Jan 2009, Carlos J. Gil Bellosta wrote: Why not something like lapply(mydf, function(x) match(myarg, x) ) I don't think that is what is intended (it does not give the quoted result in 'S'), but I don't actually know (and we were not told what 'S' this is). My guess is that the wh

Re: [R] Equivalent of match for data.frame

2009-01-03 Thread Carlos J. Gil Bellosta
Hello, Why not something like lapply(mydf, function(x) match(myarg, x) ) ? Best regards, Carlos J. Gil Bellosta http://www.datanalytics.com On Sat, 2009-01-03 at 07:24 -0500, Sébastien wrote: > Dear R-users, > > I am translating a S script into R and having some troubles with the > match f

[R] Equivalent of match for data.frame

2009-01-03 Thread Sébastien
Dear R-users, I am translating a S script into R and having some troubles with the match function. This function appears to work with vector and data.frame in S, but not in R, e.g.: a <- rep((1:4), each = 10) b <- rep((1:10), times = 4) mydf <- data.frame(a,b) myarg <- mydf[1,] match(myarg, my

[R] How to capture multiple graph pages to .png ?

2009-01-03 Thread Mike Williamson
Hello all and thanks in advance for any help, There are really two issues that I am having, both related to saving graphs: 1) It seems that the "dev...()" functions are unstable when using higher level graphs (specifically I was using levelplot) 2) I have a large grid of levelplot graphs that

Re: [R] segfault while running an R script

2009-01-03 Thread mauede
I have installed R-2.8.1 right now and will proceed with my tests. So far I haven't used it. The fault is presumably caused by a sort of misuse of the memory on my part. The attached R script (whose last Step is not debugged yet) implements the algorithm for signal features extraction described in

[R] R help and finishing an excel project

2009-01-03 Thread Ray Mota
Hi Yuzhi...I'm not sure if you company gets involve with small project-but I figure I send the e-mail and maybe you could point me in the right direction. We are a small technology research firm and we do market shares and market sizing. We wanted to automate teh process better. We had hi

[R] R Stacked Histogram

2009-01-03 Thread Jason Rupert
I've seen this asked, but never fully answered.  Is it possible to plot stacked histograms in R? I have four data sets that I would like to show combined vertically in histogram format.  Is this possible?  Thank you for any feedback you can provide. P.S. I know I can show the four sets s

Re: [R] A mistake in garchFit()? {fGarch}

2009-01-03 Thread Yohan Chalabi
"TY" == Ted Young on Tue, 30 Dec 2008 11:53:23 -0800 (PST) TY> TY> Hello, TY> TY> I was using garchFit {fGarch} to fit some GARCH processes. TY> I noticed that the result contains Log Likelihood value TY> (right above TY> Description), but when I use @fit to ret