1
我想一个data.frame
保存到一个文件中这样说:R:左对齐固定宽度
library(gdata)
write.fwf(mydata,file = "myfile.txt",width = c(12, 7), eol="\r\n", colnames = FALSE, justify = "left")
的数据是非常简单的:
V1 V2
1 foo
2 bar
3 ter
4 four
但是生成的输出把值靠右侧而不是左侧:
1 foo
2 bar
etc
,而不是
1 foo
2 bar
etc
所以它从左侧填充空格而不是从右侧填充。
我该如何解决?
那么不是真的confy :)特别有许多列,但只要你可以用'as.character'或跳过'stringAsFactors'等来转换列就行了 – Randomize