[R] R Square Help (this debate again, i know!)

2011-02-21 Thread surreyj
Hello everyone, I have been using R to do some behavioural economic analysis for my masters thesis, specifically fitting demand curves using nls. E.g. Formula: y ~ c + b * x - a * exp(x) Parameters: Estimate Std. Error t value Pr(>|t|) c -0.445097 0.080823 -5.507 0.005304 ** b -0

Re: [R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-17 Thread surreyj
Thanks so Peter, works great! Surrey -- View this message in context: http://r.789695.n4.nabble.com/Selecting-the-first-occurrence-of-a-value-after-an-occurrence-of-a-different-value-tp3217340p3221271.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-17 Thread surreyj
Hi Freddy, I have a long column of event codes e.g. below (in multiple files) that I am trying to analyse. OutMag FirstResp InMag MagUp OutMag MagDwn Resp Resp Resp InMag MagUp OutMag InMag OutMag InMag OutMag InMag OutMag InMag MagDwn OutMag Resp MagUp InMag MagDwn OutMag Resp MagUp With th

Re: [R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-16 Thread surreyj
Hello, Back again, I thought the problem was solved but I realised that the only reason I was getting the correct answer was because my data set happened to only have two "rfts" to choose from, so it looked correct. I have been using: onlyfirstresponseafterrft<-which(!diff(as.numeric(factor(

Re: [R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-15 Thread surreyj
Thanks so much for your help everyone, got it sorted now :) this is what I used in the end: timeofonlyfirstresponseafterrft<-testdata$Time[test<-which(!diff(as.numeric(factor(Stat, levels = c("MagDwn", "Resp")] timeofonlyfirstresponseafterrft1<-as.POSIXct(timeofonlyfirstresponseafterrft, ori

Re: [R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-14 Thread surreyj
Thanks so much that works, but I just realised I was unclear, I meant I need to select all the "MagDwn" after every "Resp" :) -- View this message in context: http://r.789695.n4.nabble.com/Selecting-the-first-occurrence-of-a-value-after-an-occurrence-of-a-different-value-tp3217340p3217456.html S

[R] Selecting the first occurrence of a value after an occurrence of a different value

2011-01-14 Thread surreyj
Hello everyone, I am currently working with some data where I need to select the first occurrence of a value after the occurrence of another value. The data has two columns, one with a time and one with occurence of certain events. The column of data I want to select from looks like this (a