약 50개 관측소에서 시간별로 측정된 데이터가 포함된 JMP 테이블이 있습니다.각 관측소에서 데이터는 때때로ppm으로 보고되고, 어떤 때는 ppb로 보고되고, 때로는 두 단위로 보고되고, 때로는 측정값이 전혀 없는 경우도 있습니다.꽤 큰 데이터세트인데 각 스테이션에 관련된 열을 하나의 단위 시스템에서 단일 열로 자동 결합하려면 어떻게 해야 하는지 궁금합니다.아니면 각 스테이션에 대해 새 열을 수동으로 만들고 변환을 수행하는 공식을 입력해야 합니까? Excel을 사용하지 않고 이 데이터 준비 단계의 속도를 높이려고 합니다.
감사합니다.성공했어요!이제 모든 것이 ppm 단위이므로 분석을 계속할 수 있습니다.
다음은 표시된 구조를 고려하여 모든 데이터를 ppm으로 변환하고 ppb 열을 삭제하는 스크립트입니다.
이는 단지 시작점일 뿐이며, 좀 더 구체적으로 계산이 변경되면 논리에 포함될 수 있습니다.
Names Default To Here( 1 );
dt = Current Data Table();
For( i = 1, i <= N Cols( dt ), i++,
If( Trim( Word( -1, Column( dt, i ) << get name, ":" ) ) == "ppm",
ppbCol = Trim( Substr( Column( dt, i ) << get name, 1, Contains( Column( dt, i ) << get name, "ppm" ) - 1 ) || "ppb" );
For( k = 1, k <= N Rows( dt ), k++,
Column( dt, i )[k] = Sum( Column( dt, i )[k], Column( dt, ppbCol )[k]/1000 )
);
)
);
// Get rid of ppb columns
For( i = N Cols( dt ), i >= 1, i--,
If( Trim( Word( -1, Column( dt, i ) << get name, ":" ) ) == "ppb",
dt << delete columns( i )
)
);
의심할 바 없이 이를 수행하는 방법은 여러 가지가 있습니다. 예제의 열 형식이 일관적이라고 가정할 때 가장 먼저 떠오르는 방법은 다음과 같습니다. 게시물 하단에 있는 스크립트를 실행하여 전체 예제를 보거나 스크립트의 녹색 댓글과 아래 스크린샷을 따라갈 수 있습니다.
스택을 사용하여 모든 스테이션 데이터를 단일 열로 가져옵니다.

관측소 공식('예쁜' 형식과 공식을 두 번 클릭하면 얻을 수 있는 코드로 표시됨:

단위 공식은 비슷합니다.

각 잠재적 단위에 대한 데이터 계정 공식:

Tabulate는 간격 및 측점에 대한 순서 또는 명목 데이터 유형을 사용합니다.

그런 다음 표 메뉴에서 Make Into Data 테이블을 사용합니다.
예제를 다시 만드는 스크립트:
//To see a full example you can copy this this into a new script window and press Run, or just following along
//with the green comments
Names default to here(1);
//Recreate part of your sample data table, you could skip this part and open your original data instead
//Note that the times are ordinal or nominal data types, this will be imporant in the tabulate platform later
dt = New Table( "Raw Data",
Add Rows( 2 ),
New Column( "IntervalStart", Numeric, "Ordinal", Format( "m/d/y h:m", 19 ), Input Format( "m/d/y" ),
Set Values( [3503606400, 3503610000] ),
),
New Column( "IntervalEnd", Numeric, "Ordinal", Format( "m/d/y h:m", 19 ), Input Format( "m/d/y h:m" ),
Set Values( [3503609940, 3503613540] )
),
New Column( "StationName: Anzac-Unit:ppb", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2] ) ),
New Column( "StationName: Anzac-Unit:ppm", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., .] ) ),
New Column( "StationName: Ardrossan-Unit: ppb", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., .] ) ),
New Column( "StationName: Ardrossan-Unit: ppm", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [11, 12] ) )
);
//Get a reference to your current data table
dt = Current data table();
//Stack all of the columns - use Tables > Stack and include all of the columns except the first two which are times
dtStacked = dt << Stack(
columns(
(dt << Get Column Names())[3::n col(dt)]
),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
);
//Now add three new columns to find the station and units, and calculate the concentration based on the units
//you should be able to copy and paste the part inside the 'Formula' function below into the formulas of your new columns
dtStacked << New Column("Station", Character, "Nominal", Formula(Words(:Label, "-")[1]));
dtStacked << New Column("Unit", Character, "Nominal", Formula(Words(:Label, "-")[2]), Set Display Width(65));
dtStacked << New Column("Data (ppm)", Numeric, "Continuous", Format("Best", 12), Formula(If(Contains(:Unit, "ppm"), :Data, Contains(:Unit, "ppb"), :Data / 1000)));
//Put back in standard format using the tabulate platform. Drag times and the station into
//columns on the left and add the mean and N as data fields. Note that in the resulting table anything
//with a N(Data) greater than 1 might have a problem!
(dtStacked << Tabulate(
Show Control Panel( 0 ),
Add Table(
Column Table( Analysis Columns( :Data ), Statistics( Mean, N ) ),
Row Table( Grouping Columns( :IntervalStart, :IntervalEnd, :Station ) )
)
)) << Make Into Data Table;
안녕하세요 짐,
귀하의 질문에 대한 답변으로 데이터의 사진을 게시했습니다.데이터를 제자리에서 변경하는 단계를 알려주세요.
감사합니다.
안녕,
이것이 데이터의 모습입니다.열 이름은 관측소와 측정 단위를 나타냅니다.
친절하게 도움을 주셔서 감사합니다.
데이터가 숫자(단위 없이 또는 별도의 필드에 있음)로 표시됩니까, 아니면 단위가 숫자와 함께 표시되는 문자 데이터(예: 13ppm)로 표시됩니까?데이터가 어떻게 나타나는지에 대한 예를 제공할 수 있다면 더 쉬울 것입니다.수식은 원하는 변환을 수행해야 하지만 정확히 어떤 수식은 데이터의 모양에 따라 달라집니다.
매우 간단한 스크립트를 사용하여 입력된 열의 값을 직접 변경할 수 있습니다.또는 Recode 도구를 사용하여 대화형 형식으로 동일한 작업을 수행할 수 있습니다.측정 단위가 무엇인지 어떻게 결정합니까?이를 나타내는 별도의 열이 있습니까?