如果缺少資料則插入 0你好社區,
我搜尋過,但在社區中找不到跳過的內容。
我正在尋找一個腳本,它只需將我的資料表中所有遺失的資料設為“0”(零)。
先致謝
安德里亞
自動化和腳本編寫基礎資料分析與建模回覆:如果缺少資料則插入 0社區裡有很多關於這方面的帖子,這裡有一些(我建議按順序查看)
- 將缺失值替換為 0
- 如何將點更改為數字零
- 您是否應該循環遍歷資料表或使用重新編碼,或使用獲取行位置來更改資料表中的值
Names Default To Here(1);
dt = Current Data Table();
nc = dt << get column names(Numeric);
mat = dt[0, nc];
mat[Loc(mat, .)] = 0;
dt[0, nc] = mat;
Write();
回覆:如果缺少資料則插入 0早安,
你有兩種方法可以實現這種目標。
第一種是使用這樣的腳本(考慮數字列):
dt = current data table();
nc = dt << get column names( Numeric );
For( i = 1, i <= 18, i++,
Column( nc[i] )[dt << get rows where( Is Missing( As Column( nc[i] ) ) )] = 0
);
//the end of the loop is the number of your numeric columns
或者,如果您想對特定列執行此操作:
Names default to here(1);
// Ouvrir la table de données : Missing Data Pattern.jmp
dt = Open( "$SAMPLE_DATA/Missing Data Pattern.jmp" );
// Nouvelle colonne : Colonne 5
dt << New Column( "TEST",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Formula( If( Is Missing( :Trial 4 ), :TEST = 0, :TEST = :Trial 4 ) );
);
回覆:如果缺少資料則插入 0這是處理它的一種方法

Names Default To Here( 1 );
dt = Current Data Table();
For( i = 1, i <= N Cols( dt ), i++,
If( Column( dt, i ) << get data type == "Numeric",
Column( dt, i )[Loc( dt[0, i], . )] = 0
)
);

這個例子可行,但 Jarmo 的回應是最好的。
回覆:如果缺少資料則插入 0不考慮將JMP 資料表中的缺失值從「缺失」變更為數字零的機制,您確實意識到,此變更將對您在JMP 中對錶中的任何變數所使用的任何分析或資料視覺化技術產生巨大影響。我可以想到很多情況,將值從“缺失”更改為數字零是非常不合適的事情。如果沒有您想要進行此更改的原因,我只是想提醒您或其他閱讀此帖子的人,這種類型的更改可能是一個非常糟糕的主意。