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.
我通常使用数据框,并且可以轻松地为数据框执行此操作,但在我当前的项目中,我需要用表结构中的 NA 替换所有零。对于以下两个表(一个使用 table,另一个使用 ftable),我如何用 NA 替换所有零计数?
x <- with(mtcars,table(am, gear, cyl, vs)) x2 <- with(mtcars,ftable(am, gear, cyl, vs))
这应该有效:
x[x==0] <- NA