Better filereading and print formating in R
This should not be a complete review, but the base R function round has an optional second argument digits. It works like this


&gt; round(1.234567, digits=1)
[1] 1.2
&gt; round(1.234567, digits=2)
[1] 1.23



Therefore there is no need for your function f.