background preloader

R

Facebook Twitter

Kickstarting R. Kickstarting R - Writing R scripts So what is an R script?

Kickstarting R

An R script is simply a text file containing (almost) the same commands that you would enter on the command line of R. (almost) refers to the fact that if you are using sink() to send the output to a file, you will have to enclose some commands in print() to get the same output as on the command line. To run a script, let's say one with the name: /home/jim/psych/adoldrug/partyuse1.R you may either use: source("/home/jim/psych/adoldrug/partyuse1.R") on the command line of R OR R CMD BATCH /home/jim/psych/adoldrug/partyuse1.R Let's pause to note a little historical bifurcation that has caused almost as much strife as the question of exactly what the <Delete> key should do.

I would have to refer to it as: in an R script. Using the script to determine where things happen Managing the various objects used in R can be challenging. First, choose your directory. Annotating the output file R's output can often be terse. Viewing and saving plots. Concatenate and Print. Description Outputs the objects, concatenating the representations. cat performs much less conversion than print.

Concatenate and Print

Usage cat(... , file = "", sep = " ", fill = FALSE, labels = NULL, append = FALSE) Arguments Details cat is useful for producing output in user-defined functions. No linefeeds are output unless explicitly requested by "\n" or if generated by filling (if argument fill is TRUE or numeric). If file is a connection and open for writing it is written from its current position. Currently only atomic vectors and names are handled, together with NULL and other zero-length objects (which produce no output). Cat converts numeric/complex elements in the same way as print (and not in the same way as as.character which is used by the S equivalent), so options"digits" and "scipen" are relevant. Value None (invisible NULL). Note References Becker, R. See Also print, format, and paste which concatenates into a string. Examples. An Introduction to R. Table of Contents This is an introduction to R (“GNU S”), a language and environment for statistical computing and graphics.

An Introduction to R

R is similar to the award-winning1 S system, which was developed at Bell Laboratories by John Chambers et al. It provides a wide variety of statistical and graphical techniques (linear and nonlinear modelling, statistical tests, time series analysis, classification, clustering, ...). This manual provides information on data types, programming elements, statistical modelling and graphics. This manual is for R, version 3.1.0 (2014-04-10). Copyright © 1990 W. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Preface This introduction to R is derived from an original set of notes describing the S and S-PLUS environments written in 1990–2 by Bill Venables and David M. Comments and corrections are always welcome. Suggestions to the reader 1.1 The R environment Try ?