Printing results

Results can be printed in R using print, cat, and other commands:

# print is often used as a means to document code output as 
(function(x){x=10;print ("x is now 10")})() 

print also supports other flags such as digits (number of digits to print), justify (left and right), quote (whether strings should be quoted), for example:

print (1.1234567,digits=3) 

Formatting strings can be done using the format command in R. It is one of the most versatile functions that allows users to present data in a more readable manner. For instance, to add a comma (,) separator to numbers, we can use the big.mark argument in the format as follows:

format(14324234,big.mark=",") 

Other options as specified in the R help page include the following:

# big.mark, big.interval, small.mark, small.interval, decimal.mark, zero.print, drop0trailing 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.4.179