On Tue, Jul 24, 2018 at 11:41 AM, Ista Zahn wrote:
> I don't think it has much to do with transform in particular:
>
>> BOD <- data.frame(Time = 1:6, demand = runif(6))
>> BOD[["X"]] <- BOD[1:2] * seq(6); BOD
> Timedemand X.Time X.demand
> 11 0.8649628 1 0.8649628
> 22
I don't think it has much to do with transform in particular:
> BOD <- data.frame(Time = 1:6, demand = runif(6))
> BOD[["X"]] <- BOD[1:2] * seq(6); BOD
Timedemand X.Time X.demand
11 0.8649628 1 0.8649628
22 0.5895380 4 1.1790761
33 0.6854635 9 2.0563906
44
The idea is that one wants to write the line of code below
in a general way which works the same
whether you specify ix as one column or multiple columns but the naming entirely
changes when you do this and BOD[, 1] and transform(BOD, X=..., Y=...) or
other hard coding solutions still require
I think you meant to call BOD[,1]
From ?transform, the ... arguments are supposed to be vectors, and BOD[1] is
still a data.frame (with one column). So I don't think it's surprising
transform gets confused by which name to use (X, or Time?), and kind of
compromises on the name "Time". It's also
Note the inconsistency in the names in these two examples. X.Time in
the first case and Time.1 in the second case.
> transform(BOD, X = BOD[1:2] * seq(6))
Time demand X.Time X.demand
118.3 1 8.3
22 10.3 4 20.6
33 19.0 9 57.0
44