Re: [R] Double condition

2013-03-25 Thread zuzana zajkova
Hi, To Mason: I like your idea with reshaping the dataframe. I've read the paper and checked the help for the cast function, but I wasn't able to reshape it to wanted form, which as you mentioned would be (column names): jul timedtime ddawn.noon ddawn.midnight ddusk.noon ddusk.midnight

[R] Double condition

2013-03-25 Thread zuzana zajkova
Hi Rui, thank you for your code, but unfortunately it doesn't work correctly. What I got is this: subz jultimedtime fixddawnddusk day 101608 15006 2011-02-01 19:14:49 19.24694 noon 7.916667 19.88333 1 101609 15006 2011-02-01 19:24:49 19.41361

Re: [R] Double condition

2013-03-25 Thread Rui Barradas
Hello, I believe the following solves your problem. It's a bit more complicated but with the sample dataset you've provided the result is as wished. tmp - lapply(split(subz, subz$time), function(x) { i1 - which(as.character(x$fix) == noon)[1] i2 - which(as.character(x$fix)

Re: [R] Double condition

2013-03-25 Thread zuzana zajkova
Hi, although it takes some 10 minutes to do the calculation (the original dataframe has more than 100 000 rows..), it seems to work ok. Thanks for your time and help, Zuzana On 25 March 2013 15:37, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, I believe the following solves your problem.

[R] Double condition

2013-03-22 Thread zuzana zajkova
Hi, I would appreciate if somebody could help me with this small issue... I have a dataframe like this (originaly has more than 100 000 rows): subz jultimedtime fixddawnddusk day 101608 15006 2011-02-01 19:14:49 19.24694 noon 7.916667 19.88333 1

Re: [R] Double condition

2013-03-22 Thread Rui Barradas
Hello, Try the following. idx - which(subz$fix == noon) if(idx[length(idx)] == nrow(subz)) idx - idx[-length(idx)] subz$day[idx + 1] - subz$day[idx] Hope this helps, Rui Barradas Em 22-03-2013 18:18, zuzana zajkova escreveu: Hi, I would appreciate if somebody could help me with this

Re: [R] Double condition

2013-03-22 Thread Mason
It sounds like, although your noon and midnight data are separate rows, they are not fully independent. If I understand correctly, the operation you want to perform would be simple if you had (at least temporarily) a single row with columns ddawn.midnight, ddusk.midnight, ddawn.noon, ddusk.noon,