Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将 max() 函数应用于多个列,忽略 NULL 值
(在这种情况下,NULL 被命名为 NA)。
我的数据:
# data df <- data.frame( a = sample(5), b = sample(5) ) df[2:3,1] <- NA dbWriteTable(db1, "df", df, overwrite = TRUE )
我试过的
我想要的是:
(注意 max1 列不包含 NA)
我希望在 SQLite 中有一种简单的方法可以做到这一点,但可能没有吗?
df$max<-apply(X=df, MARGIN=1, FUN=max,na.rm=T)