Re: [程式] R中的if條件

看板Statistics作者 (讓你喜歡這世界~)時間13年前 (2013/03/21 02:58), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串4/5 (看更多)
try this ### rm(list=ls()) v <- matrix(rnorm(176000*20), 176000, 20) v[,1] <- sample(1:10, 176000, TRUE) a <- 3 t.start <- Sys.time() s1 <- which(v[,1] == a) s2 <- which(v[,1] != a) v[s1,1] <- v[s1,1] - a v[s2,1] <- 12 - a + v[s2,1] t.end <- Sys.time() t.end - t.start -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.45.45.48

03/21 20:18, , 1F
感謝建議^^
03/21 20:18, 1F
文章代碼(AID): #1HIWRfDB (Statistics)
文章代碼(AID): #1HIWRfDB (Statistics)