Write text files and code to read them jan de leeuw

Info icon This preview shows pages 6–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Write Text Files and Code to Read Them Jan de Leeuw 102A_2 UCLA Department of Statistics Devices Each R session has a list of graphics devices available. Sessions start with the null device, but as soon as you use graphics R open the default device, which you can see using getOptions ( "device" ) . On MacOS X, using R.app, the default device is "quartz", a native graphics window. From the terminal (or Xterm, or Emacs) the null device is "X11". Jan de Leeuw 102A_2 UCLA Department of Statistics
Image of page 6

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
The list of devices can be controlled by functions dev . cur () , dev . list () , dev . off () , dev . set () which are pretty self-explanatory. You can change the current device by using functions such as pdf ( "foo" ) or postscript ( "foo" ) , which open files, or quartz () and x11 () , which open graphics windows to write to. There are also file devices for xfig, jpeg, png, pictex, and bitmap. Jan de Leeuw 102A_2 UCLA Department of Statistics 1 > dev . cur () 2 null device 3 1 4 > plot (1:10) 5 > dev . cur () 6 X11 7 2 8 > pdf( "boromir.pdf" ) 9 > plot (1:10) 10 > pdf( "faramir.pdf" ) 11 > plot (1:10) 12 > dev . list () 13 X11 pdf pdf 14 2 3 4 15 > dev . off () 16 X11 17 2 18 > dev . list () 19 X11 pdf 20 2 3 21 > dev . set (3) 22 pdf 23 3 Jan de Leeuw 102A_2 UCLA Department of Statistics R packages Add-on packages are the lifeblood of R . There are packages for many statistical and mathematical techniques, packages that interface to database and parallel computing libraries, packages that interface with different graphics systems and different computer languages, and packages that give convenient access to useful external applications. Jan de Leeuw 102A_2 UCLA Department of Statistics You can have libraries of R packages in different locations in the file system. There is a default location for system wide installation, and one for user level installation. You can see which packages are available on your system (in the default locations) by using library () or installed . packages () . The help system for available packages works as expected. You can say help ( package = "foo" ) or library ( help = "foo" ) to get general information, and help ( "bar" , package = "foo" ) to see help for the name "bar" . Jan de Leeuw 102A_2 UCLA Department of Statistics
Image of page 7
Initially R loads the packages defined by getOption ( "defaultPackages" ) . You can change the option in your startup file, if you want. If you want to load additional packages, use library ( "foo" ) , where "foo" is the package name. If that package is available on your machine, then loading it will make all functions, all data, and all help files from that package available in your workspace. To see which packages are loaded, use search () . Jan de Leeuw 102A_2 UCLA Department of Statistics The function data () lists all data files available in the packages on your system. You can make the more specific request data ( package = "foo" ) , and if one of the datasets in "foo" is "bar", you can load it by saying data (bar, package = "foo" ) , even without loading the package first. There is also help available for datasets, same as for other objects in packages. Jan de Leeuw 102A_2 UCLA Department of Statistics For example, we can say data ( package = "datasets" ) . This gives a very long list of datasets that are available in this package. One of them is called "Nile". And since the package is loaded by default these data are immediately available.
Image of page 8

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '10
  • JandeLeeuw
  • Binary file, Executable, UCLA Department of Statistics, Comparison of statistical packages, Jan de Leeuw, Leeuw 102A_2 UCLA

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern