相关疑难解决方法(0)

格式化乳胶的科学记数法

在 RStudio 中,我得到像 1e-2 或 4e-35 这样的科学记数法结果。我正在使用 xtable 将这些数字导出到乳胶,但希望它们看起来像乳胶中的常规格式,即,$1 \times 10^{-2}$$4 \times 10^{-35}$. 如何在 R 中编码以获得像 xtable 输出这样的常规科学记数法格式?

r

5
推荐指数
0
解决办法
6106
查看次数

R:格式化xtable中的数字

我有数据:

transaction <- c(1,2,3);
date <- c("2010-01-31","2010-02-28","2010-03-31");
type <- c("debit", "debit", "credit");
amount <- c(-500, -1000.97, 12500.81);
oldbalance <- c(5000, 4500, 17000.81)
evolution <- data.frame(transaction, date, type, amount, oldbalance, row.names=transaction, stringsAsFactors=FALSE);
evolution$date <- as.Date(evolution$date, "%Y-%m-%d");
evolution <- transform(evolution, newbalance = oldbalance + amount);
evolution
Run Code Online (Sandbox Code Playgroud)

如果我想创建一个数字amount等于1位小数的表,这样的命令是否有效?

> tab.for <- formatC(evolution$amount,digits=1,format="f")
> tab.lat <- xtable(tab.for)
Error in UseMethod("xtable") :
  no applicable method for 'xtable' applied to an object of class "character"
Run Code Online (Sandbox Code Playgroud)

谢谢.

r digits

3
推荐指数
1
解决办法
4230
查看次数

标签 统计

r ×2

digits ×1