
괜찮아. 선택한 영역 만 볼 때. 나는 원할 것이다 :
Nback # = 1, 기간 = 14303912, 누적 기간 = 0
Nback # = 2 , 기간 = 14305914, 누적 기간 = 2002
Nback # = 3 , 기간 = 14307916, 누적 기간 = 4004
Nback # = 4 , 기간 = 14309965, 누적 기간 = 6053
Nback # = 5 , 기간 = 14312015, 누적 기간 = 8103
Nback # = 6 , 기간 = 14314051, 누적 기간 = 10139
이 마지막 칼럼을 시간의 척도로 사용해야합니다. 모든 지침은 크게 감사하겠습니다.
따라서,이 작은 변화를 만드는 것은 새로운 변수에 대해 같은 종류의 산출물을 만듭니다.
어쩌면 각 기간의 첫 번째 행의 종료 시간부터 계산을 시작 하시겠습니까?

그러나 기간을 합산 할 수는 있지만 행 사이의 시간을 놓칠 수 있습니다. 내 의견으로는 Start and End Times (Nback Start와 Nback Stop과 summary_image_end)를 사용하는 것은 상당히 간결합니다. 수식은 아래에 표시된 것과 같아야합니다. 파란색 열 (summary_image_end를 신경 쓰는 경우) 또는 빨간색 열 (Lag1을 신경 쓰는 경우) 중 하나를 사용합니다.

그래서 내가 가지고있는 데이터를 보면서 나는 'Nback Duration'컬럼이 있음을 깨달았습니다. 이 열과 lag1 열을 사용하여 원하는 최종 결과를 얻는 쉬운 방법이 있는지 궁금합니다.
다음은 열 수식으로이 작업을 수행하는 방법입니다. 시간 재설정을 나타내는 데 사용하는 열이 확실하지 않으므로 포함 시켰습니다.
- 새 그룹마다 값이 변경되는 열에서이 작업을 수행하는 방법
- 시간의 리셋을 나타내는 열을 기반으로 한 메소드입니다.
Names default to here ( 1 );
//Table with data similar to yours
dt = New Table( "Data",
Add Rows( 40 ),
New Column( "Space", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( Round( Random Uniform( 1, 5 ), 0 ) )
),
New Column( "Duration", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( Round( Random Uniform( 1998, 2002 ), 0 ) )
),
New Column( "Start", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( If( Row() == 1, :Space, :Space + Lag( :Start, 1 ) + Lag( :Duration, 1 ) ) )
),
New Column( "End", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( :Start + :Duration )
),
New Column( "Period Indication", Character, "Nominal",
Formula( If( Row() < 15, "One", "Two" ) )
),
New Column( "Indication of Time Reset Pulse", Numeric, "Nominal",
Formula( If( Row() == 10, 1, . ) )
)
);
//New Column - subtract the current end time from the first end time in
//the group. Use this if the column :summary_image_end" tells you when
//to start a new group
dt << New Column( "Time In Group", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( :End - Col Min( :Start, :Period Indication ) )
);
//Make a New Column indicating the period for a pulse signal, use this if
//the column Lag1 tells you when to start a new group
dt << New Column( "Period Indication from Pulse", Numeric, "Nominal",
Format( "Best", 12 ),
Formula(
If(
Row() == 1,
1,
Lag( :Period Indication from Pulse, 1 ) +
If(
Is Missing( :Indication of Time Reset Pulse ),
0,
1
)
)
)
);
//Once the group column is made then calculate the duration
dt << New Column( "Time In Group - Pulse", Numeric, "Continuous",
Format( "Best", 12 ),
Formula( :End - Col Min( :Start, :Period Indication from Pulse ) )
);이 스크립트는 필요한 스크립트 일 수 있습니다. 데이터가 attchment로 설정됩니다.
dt = Current Data Table();
//dt << New Column( "Delta", numeric );
dt << New Column( "Cumulative", numeric );
dt << Sort( By( :Category, :Time ), Order( Ascending, Ascending ), Replace table );
For( i = 1, i <= N Rows( dt ), i++,
If( :Time[i] == Min( :Time[dt << get rows where( :Category == :Category[i] )] ),
//dt:Delta[i] = 0;
dt:Cumulative[i] = 0;
,
//dt:Delta[i] = dt:Time[i] - dt:Time[i - 1];
dt:Cumulative[i] = dt:Cumulative[i-1]+ (dt:Time[i] - dt:Time[i - 1]);
)
);