여보세요,
시간 온도 표 1과 작동 시작 및 종료 시간 표 2가 있습니다. 나는 time column에 새로운 컬럼을 추가하고 그것이 작동 시간 peroid에있을 때 cell "operation"에 라벨을 붙이고 싶다. 아무도 그걸하는 법을 압니까?
케빈,
표 2는 혼란 스럽지만 종료 시간은 시작 시간보다 빠릅니다. 온도 표와 일치하는 유일한 시간은 시작 시간입니다. 아래는 스크립트이지만, 종료 시간이 시작 시간보다 늦을 것으로 예상했습니다.
시작 시간과 일치하는 두 테이블을 조인하여 이러한 시작 조작을 찾을 수 있습니다 (JSL의 두 x 째 블록 참조).
시작 시간 만 일치 했으므로 다른 작업을 코드에 추가하고 온도 안정성을 시각적으로 비교하기 위해 기간 열을 만들었습니다.
Names Default to Here(1);
dt1 = Data Table("Table 1 Temperature log");
dt2 = Data Table("Table 2 operation Time");
dt1 << New Column ("Operation", character);
for(i=1, i<=nrows(dt2), i++,
tbeg = dt2:Start Time[i];
tend = dt2:End Time[i];
_idx = dt1 << get rows where( tend <= dt1:Time <= tbeg);
if(nrow(_idx)>0,
dt1:Operation[_idx] = "Operation " || char(i);
); //end if
); //end for
//since there is only one row that matches, copy down
//if End Time column was the end of the operation, this would not be needed
//--copy down and get duration
dt1 << New Column("Duration", Numeric, Continuous, Format("min:s") );
_idx = dt1 << get rows where (:Operation != "");
for(i=1, i<=nrow(_idx), i++,
init = dt1:Time[_idx[i]];
If(i < nrow(_idx),
tbeg = _idx[i];
tend = _idx[i + 1] - 1;
dt1:Operation[tbeg :: tend ] = dt1:Operation[_idx[i] ];
, //else
tbeg = _idx[i];
tend = nrow(dt1);
dt1:Operation[tbeg :: tend ] = dt1:Operation[_idx[i] ];
);
dt1[tbeg :: tend,"Duration"] = Transpose(dt1:Time[tbeg :: tend] - init);
);
//--graph
gb = dt1 << Graph Builder(
Size( 534, 454 ),
Show Control Panel( 0 ),
Variables( X( :Duration ), Y( :RoomTemp ), Overlay( :Operation ) ),
Elements( Points( X, Y, Legend( 9 ) ), Line( X, Y, Legend( 11 ) ) )
);
어울리다
Data Table( "Table 1 Temperature log" ) << Join(
With( Data Table( "Table 2 operation Time" ) ),
By Matching Columns( :Time = :Start Time ),
Drop multiples( 0, 0 ),
Include Nonmatches( 1, 0 ),
Preserve main table order( 1 )
)