嘗試編寫將迴歸分析結果附加到現有 Excel 電子表格的腳本你好 - 我正在嘗試編寫一個 jsl 腳本,它將回歸分析的結果附加到現有的 Excel 文件中。我目前的腳本寫入 Excel 文件,但我希望能夠多次執行該腳本並將每個新結果附加到現有的 Excel 工作表中。 (目前我正在手動附加新結果。)請參閱附加腳本。
先致謝!
ps我使用的是JMP Pro 17
自動化和腳本編寫回覆:嘗試編寫將迴歸分析結果附加到現有 Excel 電子表格的腳本太棒了 - 謝謝你,吉姆!
回覆:嘗試編寫將迴歸分析結果附加到現有 Excel 電子表格的腳本這是一個範例腳本,我希望它能幫助您清楚將新資料連接到主文件所需的操作
names default to here(1);
// Create 2 data tables and save them as excel files
// one will be the master and one will play the role of the new data
dtExample = open("$SAMPLE_DATA/big class.jmp");
theTables =dtExample << Subset(
By( :sex ),
All rows,
Selected columns only( 0 ),
columns( :name, :age, :height, :weight )
);
close( dtExample, nosave );
// Change the names of the first table to Master
theTables[1] << set name("Master");
data table("Master") << bring window to front;
// Add the new columns to the master, like your master file already
// has all of the columns. In this example, I will only add 1 column
data table("Master")<< new column("Ratio", set each value(:height/:weight));
// Wait 5 seconds so you can observe the master table
wait(5);
// save and close the Master table as an excel table
close( data table("Master"), save("$TEMP/master.xlsx"));
// Change the name of the second table to New Data
theTables[2] << set name("New Data");
data table("New Data") << bring to front;
// wait 5 seconds here too, so you can observe the New Data table
wait(5);
// now save and close the New Data table as an excel table
close( data table("New Data"), save("$TEMP/New Data.xlsx"));
// Now that there are a Master and a New Data table that have been
// created we can now illustrate how to read in some new data,
// add the required new columns, save it, then open the master file,
// and concatenate the new data to the master and then save the updated
// master file
// open the new data table. I am using the variable dt as the pointer
// to the file, since that is what you are doing in your script
dt = open("$TEMP/New Data.xlsx");
// Add the new columns (in this example, only 1 column) to the data table
// your syntax is
// new column("ratio", formula(:height/:weight);
// I suggest that you become more precise and point to the specific data table
// by using either
// dt << New Column(......);
// or
// data table("New Data") << New Column( ...... );
data table("New Data") << New Column( "Ratio", formula(:height/:weight));
// Now the data can be saved
// use either
// dt<< save(...........);
// or
// data table("New Data")<< save(................);
dt << save("$TEMP\test1 n=22.xlsx");
// now open the master table
dtMaster = open("$TEMP\master.xlsx");
// concatenate the new data table to the master
dtMaster << concatenate( dt, append to first table(1));
// now save the master
dtMaster << save("$TEMP\master.xlsx");
// uncomment the below code if you want to close the new data and the master tables
// close( dt, nosave );
// close( dtMaster, nosave );
回覆:嘗試編寫將迴歸分析結果附加到現有 Excel 電子表格的腳本不幸的是,這沒有幫助。連接腳本仍然不起作用。 (奇怪的是,如果腳本自動執行該過程,我不確定為什麼每次運行腳本時都需要單擊彈出視窗上的複選框。)
另外(可能與連接腳本不起作用無關),由於某種原因,在運行開始時打開了遺留文件(現已刪除的文件),而不是腳本說要運行的文件。我不明白為什麼會發生這種情況。

然後我運行回歸,根據運行結果添加一些列,然後...

回覆:嘗試編寫將迴歸分析結果附加到現有 Excel 電子表格的腳本嘗試選擇標有“附加到第一個表格”的複選框
回覆:嘗試編寫將迴歸分析結果附加到現有 Excel 電子表格的腳本這是運行後打開的內容。 (奇怪的是,它顯示了我的 jsl 程式碼不使用的遺留檔案名稱(v2n=25....) - 我已經檢查並重新檢查)。無論如何,以下程式碼(如下所示)不會產生連接的行。

dt << save("C:\Users\trcampbell\Desktop\MASTER ECOLI\2024\回歸分析\驗證執行\testtest2 n=258.xls");
///新增附加腳本
Concatenate("C:\Users\trcampbell\Desktop\MASTER ECOLI\2024\回歸分析\驗證執行\masterfile n=258.xls") ;
//儲存包含所有運行的行(附加)的主文件
dt<< save("C:\Users\trcampbell\Desktop\MASTER ECOLI\2024\回歸分析\驗證執行\masterfile n=258.xls");
任何建議將不勝感激。
回覆:嘗試編寫將迴歸分析結果附加到現有 Excel 電子表格的腳本是的
回覆:嘗試編寫將迴歸分析結果附加到現有 Excel 電子表格的腳本謝謝吉姆。如果執行分析並新增表格的腳本產生名為 X 的文件,那麼在串聯之前是否必須先儲存 X?如果是這樣,我的 Concatenate 函數中的表名稱是否是接收所有運行結果的檔案(即 Concatenate (masterfile)?
所以如果以上是正確的,我會說:
保存X
連接(主文件)
儲存主文件
重新運行腳本
我讀得正確嗎?
回覆:嘗試編寫將迴歸分析結果附加到現有 Excel 電子表格的腳本看起來你需要做的是,在資料表中建立新列後,你需要讀入要新增資料的 Excel 表,使用 Tables=>Concatenate 將新表新增到要將資料新增到的表,然後儲存新連接的數據。