Chapter-9-exporting-out-of-r.pdf

  • Uploaded by: Crithian Holguin
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Chapter-9-exporting-out-of-r.pdf as PDF for free.

More details

  • Words: 485
  • Pages: 9
Chapter 9: Exporting out of R

R output ✓

Different kinds of files!



Text!



Graphics!

-

Table data! R console output! Vector, matrix data!

-

PDF! Jpeg, bmp, tiff, png! Postscript! pictex! xfig

Text Files ✓

Function sink()!



To send the output of R to a file, instead of the console, use function sink()!

-

Usage: Type sink(file = , append = , split = …) at the command line. Parameter append adds output to the file specified in file if TRUE, else it replaces the contents. Parameter split if TRUE sends output to the file as well as the console, and if FALSE, sends output only to the file.! Files gets created in the working directory! Example:

Text Files ✓

Function cat()!



To create a text file with values, separated by a character [ex., comma, space etc] function cat() may be used!

-

Usage: Type cat(x, file = , sep = ,…) at the command line. Parameter sep specifies the separating character! Files gets created in the working directory! Example:

Text Files ✓

Function write.table()!



To create a data file from a matrix or data frame, use function write.table()!

-

-

Usage: Type write.table(x, file = , append = , quote = , sep = ,dec =, row.names = , col.names = …) at the command line. Parameter append adds output to the file specified in file if TRUE, else it replaces the contents. Parameter quote if TRUE encloses any character values in “”. Parameter sep specifies the separating character (examples: “,”, “ ”, “/t”). Parameter dec specifies the decimal character. Parameters row.names/col.names specify whether row and column names are to be included. ! Files gets created in the working directory! Example:

Exercise

Graphics ✓

Function jpeg()!



To open a graphical device that will create a jpeg file from a plot, use function jpeg()!

-

Usage: Type jpeg(file = , width = , height = , units = , pointsize =, bg = , …) at the command line. Parameter width/height define dimensions of the device [output file] in units specified by parameter units. Parameter pointsize specifies default pointsize of plotted text. Parameter bg specifies background color. ! Files gets created in the working directory! Once complete, use function dev.off() [no parameters] to close the device! Example:

Graphics ✓

Function pdf()!



To open a graphical device that will create a pdf file from a (series of) plot(s), use function pdf()!

-

Usage: Type pdf(file = , width = , height = , onefile = , family =, title = , paper = ,…) at the command line. Parameter width/height define dimensions of the plot area in inches. Parameter onefile specifies whether multiple plots need to be output in the same file. Parameter family specifies font family. ! Files gets created in the working directory! Once complete, use function dev.off() [no parameters] to close the device! Example:

Exercise

More Documents from "Crithian Holguin"

June 2020 14
June 2020 10
Contrapartida791.docx
June 2020 2
Alfredo Vargas.pdf
June 2020 3