I want to write some long tables in R and would like to be able to control the number of digits and formatting of each column.
Controlling digits in R have earlier been discussed here, but I want some columns with two digits, and other columns written as exponents of e.
What I have is:
> tab = format(round(Ind_B, 2), nsmall = 2)
logFC AveExpr t P.Value adj.P.Val B
PCL1 -1.50 7.90 -7.78 0.00 0.05 3.11
CYB5 -1.33 9.48 -7.29 0.00 0.05 2.66
YPL272C -1.14 9.84 -6.75 0.00 0.05 2.12
...
write.table(tab,file="table.txt")
What I want is something that looks like
logFC AveExpr t P.Value adj.P.Val B
PCL1 -1.50 7.90 -7.78 2.02e-05 4.66e-2 3.11
CYB5 -1.33 9.48 -7.29 3.46e-05 4.66e-2 2.66
YPL272C -1.14 9.84 -6.75 6.44e-05 4.66e-2 2.12
...
Input data:
> dput(Ind_B[1:2,])
structure(list(logFC = c(-1.49824500263345, -1.33422303887252,
-1.13608497712886), AveExpr = c(7.89908829447163, 9.47578470147621,
9.83832131029262), t = c(-7.77827558246803, -7.29052621516572,
-6.75274781106625), P.Value = c(2.0278944567463e-05, 3.46076798843179e-05,
6.43472955950628e-05), adj.P.Val = c(0.0466525340114348, 0.0466525340114348,
0.0466525340114348), B = c(3.11252319339325, 2.65697661688921,
2.11618901483842)), .Names = c("logFC", "AveExpr", "t", "P.Value",
"adj.P.Val", "B"), row.names = c("PCL1", "CYB5", "YPL272C"), class = "data.frame")