I generally work with dataframes and could easily do this for a data frame but on my current project I have the need to replace all zeros with NAs in a table structure. For
This should work:
x[x==0] <- NA