Max*_*ian 4 format r dataframe
我有处理一些数据的函数,我想在函数(循环)进行时打印中间步骤.我可以在1点处完成,其中更新的数据都在一个中data.frame().我正在考虑一些简单的表格,例如我作为Rapporter工具箱的一部分看到的.
所以问题是如何或是否可以将具有数值的表打印到控制台中.
谢谢.
编辑:print()不是我想要的解决方案,这就是为什么:
函数print()将数值打印到控制台,但它是一堆乱七八糟的数字.我希望有一种表可以在函数进行时轻松检查值.所以我可以更好地定位数值.
像这样的东西?
require(knitr)
for(i in 1:2){
#some calculation
x<-runif(runif(1,1,5))
y<-length(x)
#dataframe output
df <- cbind(x,y)
#pretty table
print(kable(df))
}
#output
# | x| y|
# |---------:|--:|
# | 0.4872941| 3|
# | 0.8014921| 3|
# | 0.7023384| 3|
#
#
# | x| y|
# |---------:|--:|
# | 0.9214315| 4|
# | 0.7119830| 4|
# | 0.0354769| 4|
# | 0.1049139| 4|
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5460 次 |
| 最近记录: |