테이블 a에서 b로 몇 개의 열/행 이동
Clear Symbols();
// Open a file dialog to choose the text file
txtFilePath = Pick File("Choose a text file", {"Text Files|*.txt"});
// Check if a file was selected
If(txtFilePath != "",
// Convert the file path to ensure it's in the correct format
txtFilePath = Convert File Path(txtFilePath);
// Import the text file into a new JMP table
dt1 = Open(
txtFilePath,
Delimiter("\t") // Change delimiter if necessary
);
// Specify the row to use for column names (e.g., row 1)
columnNamesRow = 16;
// Specify the columns to extract (e.g., columns 1, 2, 3)
columnsToExtract = {1, 17, 18, 22}; // Adjust column indices as needed
// Extract the column names from the specified row and columns
columnNamesList = {};
For(j = 1, j <= N Items(columnsToExtract), j++,
colIndex = columnsToExtract[j];
columnNamesList[j] = :Column(colIndex)[columnNamesRow];
);
// Create a new JMP table with the extracted column names
dt2 = New Table("Converted Table");
For(i = 1, i <= N Items(columnNamesList), i++,
dt2 << New Column(Char(columnNamesList[i]), Character); // Adjust column type as needed
);
// Specify the rows to extract (e.g., rows 2 to 10)
startRow = 17;
endRow = 65;
//
// Loop through the specified rows and add them to the JMP table
For(i = startRow, i <= endRow, i++,
dt2 << Add Rows(1);
For(j = 1, j <= N Items(columnsToExtract), j++,
colIndex = columnsToExtract[j];
dt2:Column(j)[i - startRow + 1] = dt1:Column(colIndex)[i];
);
);
// Close the imported table
Close(dt1);
,
// If no file was selected, show a message
Show Message("No file selected.")
);
동일한 오류 메시지가 나타납니다.
범위가 지정된 데이터 테이블 액세스에는 'dt1:Column' 액세스 또는 평가에서 행 1에 데이터 테이블 열 또는 변수가 필요합니다. dt1:Column( colIndex ) /*###*/
49번째 줄에서
자동화 및 스크립팅기본 데이터 분석 및 모델링Re: 테이블 a에서 b로 몇 개의 열/행 이동열을 참조하는 구문이 잘못되었습니다(Column()과 As Column()을 결합했습니다(table:column 구문)).
작고 보기 어리석은 동물
dt2:Column(j)[i - startRow + 1] = dt1:Column(colIndex)[i];
에게
Column(dt2, j)[i - startRow + 1] = Column(dt1, colIndex)[i];
효과가 있을 수도 있습니다.
또한, 원하는 것을 달성하는 더 쉬운 방법이 있을 수도 있지만, 이를 위해서는 예제 파일과 원하는 결과를 보여줘야 합니다.
Re: 테이블 a에서 b로 몇 개의 열/행 이동Jarmo가 설명한 대로, JMP는 일부 단계에 대해 미리 정의된 모듈을 제공합니다.
이러한 모듈을 사용하면:
- 코드가 더 짧아지고 이해하기 쉬워집니다.
- JMP는 데이터 유형을 자동으로 처리합니다.
- 실행이 훨씬 빠르다
txtFilePath = "$SAMPLE_IMPORT_DATA/Animals_line3.txt";
columnNamesRow = 3;
columnsToExtract = {"species", "miles"};
startRow = 2;
endRow = 10;
dt1 = Open( txtFilePath,
Import Settings( Labels( 0 ) )
);
wait(0); //let JMP relax before it continues with the next steps<BR />
if(columnNamesRow>1, dt1 << delete rows( 1 :: (columnNamesRow - 1) ));<BR />dt1 << move up;
dt2 = dt1 << Subset(
Rows( startRow :: endRow ),
columns( columnsToExtract )
);