如何从r中的列 Dataframe 中删除最后x个零?

tvz2xvvm  于 2022-12-06  发布在  其他
关注(0)|答案(1)|浏览(118)

我的数据框如下所示:

dput(tree)
structure(list(date = c(2.0220409e+13, 2.022041e+13, 2.0220411e+13, 
2.0220412e+13, 2.0220413e+13, 2.0220414e+13, 2.0220415e+13, 2.0220416e+13, 
2.0220417e+13, 2.0220418e+13), N = c(1, 2, 3, 4, 5, 6, 7, 8, 
9, 10), NDVI = c(0.7192, 0.7034, 0.689, 0.6761, 0.6646, 0.6545, 
0.6458, 0.6386, 0.6299, 0.6231)), class = "data.frame", row.names = c(NA, 
-10L))

date列中,我想删除最后6个零(所有条目都重复),如何才能做到这一点?
任何帮助都是非常感谢的。

b4wnujal

b4wnujal1#

也许像这样?

options(scipen = 999)
library(dplyr)
df |> 
  dplyr::mutate(across(date, ~.x/1000000))

相关问题