On Wed, Feb 23, 2011 at 10:46 AM, mathijsdevaan wrote:
>
> Thanks Matthew that worked great. What a great forum this is: I am learning a
> lot!
>
> PS. I am now running both solutions on two similar computers. Let's see
> which is fastest.
If your data is small its pointless to be concerned with
Thanks Matthew that worked great. What a great forum this is: I am learning a
lot!
PS. I am now running both solutions on two similar computers. Let's see
which is fastest.
--
View this message in context:
http://r.789695.n4.nabble.com/Re-Transforming-relational-data-tp3307449p3321214.html
Se
Thanks. How about this?
DT$B = factor(DT$B)
firststep = DT[,cbind(expand.grid(B,B),v=1/length(B),C=C[1]),by=A][Var1!
=Var2]
setkey(firststep,Var1,Var2,C)
firststep = firststep[,transform(.SD,cv=cumsum(v)),by=list(Var1,Var2)]
setkey(firststep,Var1,Var2,C)
DT[, {x=data.table(expand.grid(B,B),C[1]-1
Gabor, that worked great! I was unaware of the sqldf package, but it is great
for data manipulation. Thanks!
--
View this message in context:
http://r.789695.n4.nabble.com/Re-Transforming-relational-data-tp3307449p3320067.html
Sent from the R help mailing list archive at Nabble.com.
___
On Mon, Feb 14, 2011 at 12:22 PM, mathijsdevaan wrote:
>
> Hi,
>
> I have a large dataset with info on individuals (B) that have been involved
> in projects (A) during multiple years (C). The dataset contains three
> columns: A, B, C. Example:
>
> A B C
> 1 1 a 1999
> 2 1 b 1999
> 3 1 c
The output for the new example should be:
project v
1 0
2 0.5
3 1.5
4 0.5
The output you calculated was correct for the v per year, but the v per
group would be incorrect. I think the problem lies in the fact that
expand.grid(B,B) doesn't take into account that combinations of B can only
be
With the new example, what is the full output, and
what do you need instead? Was it correct for the
previous example?
Matthew
"mathijsdevaan" wrote in message
news:1298372018181-3318939.p...@n4.nabble.com...
>
> Hi Matthew, thanks for your help. There are some things going wrong still.
> Consi
Hi Matthew, thanks for your help. There are some things going wrong still.
Consider this (slightly extended) example:
library(data.table)
DT = data.table(read.table(textConnection("A B C
1 1 a 1999
2 1 b 1999
3 1 c 1999
4 1 d 1999
5 2 c 2001
6 2 d 2001
7 3 a 2004
8 3
Thanks for the attempt and required output. How about this?
firststep = DT[,cbind(expand.grid(B,B),v=1/length(B)),by=C][Var1!=Var2]
setkey(firststep,Var1,Var2,C)
firststep = firststep[,transform(.SD,cv=cumsum(v)),by=list(Var1,Var2)]
setkey(firststep,Var1,Var2,C)
DT[, {x=data.table(expand.grid(B,B
OK, for the last step I have tried this (among other things):
library(data.table)
DT = data.table(read.table(textConnection("A B C
1 1 a 1999
2 1 b 1999
3 1 c 1999
4 1 d 1999
5 2 c 2001
6 2 d 2001
7 3 a 2004
8 3 b 2004
9 3 d 2004"),head=TRUE,stringsAsFactors=FALSE))
Mathijs,
To my eyes you seem to have repeated back what is already done.
More R and less English would help. In other words if it is not 2.5
you need, what is it? Please provide some input and state what the
output should be (and what you tried already).
Matthew
--
View this message in contex
Thanks for helping me out so generously. After reading the vignettes and the
other info I still have a question (sorry I am a R novice):
I am not so much trying to construct time series (although it comes very
close). Rather for each pair (Bi,Bj) in project (An) I am trying to sum up
the values o
Hello. One (of many) solution might be:
require(data.table)
DT = data.table(read.table(textConnection("A B C
1 1 a 1999
2 1 b 1999
3 1 c 1999
4 1 d 1999
5 2 c 2001
6 2 d 2001"),head=TRUE,stringsAsFactors=FALSE))
firststep = DT[,cbind(expand.grid(B,B),v=1/length(B)),by=C][Var1!=
Hi,
I have a large dataset with info on individuals (B) that have been involved
in projects (A) during multiple years (C). The dataset contains three
columns: A, B, C. Example:
A B C
1 1 a 1999
2 1 b 1999
3 1 c 1999
4 1 d 1999
5 2 c 2001
6 2 d 2001
7 3 a 2004
8 3 c 2004
9
14 matches
Mail list logo