[R] Formatted output with alternating format at different rows

Ray Laymon ray.laymon064 at gmail.com
Wed Jan 12 17:54:58 CET 2011


thx a lot Jim. sprintf solved my problem.

Ray


On Mon, Jan 3, 2011 at 3:40 PM, jim holtman <jholtman at gmail.com> wrote:
> 'sprintf' if your friend:
>
>> dummy3 = c(1.1, 2.2, 3.3)
>> dummy4 = c(4.4, 5.5, 6.6, 7.7)
>> dummy2 = c(8.8, 9.9)
>>
>> cat(sprintf("%5.1f%6.2f%7.3f\n", dummy3[1], dummy3[2], dummy3[3]))
>  1.1  2.20  3.300
>> cat(sprintf("%5.2f%6.3f%7.4f%8.5f\n", dummy4[1], dummy4[2], dummy4[3], dummy4[4]))
>  4.40 5.500 6.6000 7.70000
>> cat(sprintf("%5.3f%6.4f\n", dummy2[1], dummy2[2]))
> 8.8009.9000
>>
>>
>



More information about the R-help mailing list