<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type='text/css' href='../rootCSS/css1.css'?>
<html xmlns='http://www.w3.org/1999/xhtml'>
	<head>
		<title>R Notes Basic</title>
	</head>
	<body>
		<ctitle>R Notes Basic</ctitle>
		<section>
			<ctitle class='list'>Aphorisms</ctitle>
			<ol>
				<li>incompletely initialized arrays</li>
				<li>The best reason to build your own binaries is to get better performance out of R.</li>
				<li><code>sudo yum install R.i386</code></li>
				<li><code>R -g Tk</code></li>
				<li><code>R --quiet</code> or <code>R -q</code></li>
				<li>The commands that you type into the console are called <em>expressions</em>. A part of the R system called the <em>interpreter</em> will read the expressions and respond with a result or an error message.</li>
				<li>Incidentally, <console>R</console> has quite a bit in common with <console>LISP</console>: both languages allow you to compute expressions on the language itself, both languages use similar internal structures to hold data, and both languages use lots of parentheses.</li>
				<li><code>R CMD BATCH generate_graphs.R</code></li>
				<li><code>R CMD BATCH generate_graphs.R generate_graphs_'date "+%y%m%d"'.log</code></li>
				<li>On Linux and Mac OS X systems, the command line uses the GNU <code>readline</code> and includes a large set of editing commands.</li>
				<li>RExcel, <a href="http://rcom.univie.ac.at">http://rcom.univie.ac.at</a></li>
				<li>Rapache, <a href="http://biostat.mc.vanderbilt.edu/rapache/">http://biostat.mc.vanderbilt.edu/rapache/</a></li>
				<li>Rserve, <a href="http://www.rforge.net/Rserve/index.html">http://www.rforge.net/Rserve/index.html</a></li>
				<li>ESS, <a href="http://ess.r-project.org/">http://ess.r-project.org/</a></li>
				<li>Preallocate Memory by setting the length, nrow, ncol, or dim attributes for an object. 
				    <code class='block'>v = c(NA)</code>
				    <code class='block'>length(v) = 100000</code>
				    <code class='block'>for(i in 1:100000){v[i] = i;}</code>
				</li>
				<li><code>gc()</code> performs garbage collection and displays memory statistics.</li>
				<li><code>object.size(<plh>obj</plh>)</code> returns the approximate size of the object <plh>obj</plh></li>
				<li><code>memory.profile()</code> displays information on memory usage by object type</li>
				<li>(MS Windows only) <code>memory.size()</code> returns how much memory in MB R is using on Windows OS.</li>
				<li>(MS Windows only) <code>memory.limit(size=1280)</code> sets the memory limit to 1280MB on Windows OS.</li>
				<li><code>mem.limits(nsize=NA, vsize=NA)</code> is used to get or set memory limits on Linux and Mac OS. </li>
				<li><code>library()</code> # list installed libraries in a separate window</li>
				<li><code>installed.packages()</code> # return a char vector composed of names of installed libraries</li>
				<li><code>search()</code> # return a char array of search paths, begin with <code>.GlobalEnv</code>. Packages in the search path are prefixed with <code>package:</code>.</li>
				<li><code>isLoaded = paste("package", myPackageNames, sep=":") %in% search()</code> # return a bool array of whether a package is loaded.</li>
				<li><code>loadedPackages = unique(installed.packages()[paste("package",installed.packages(),sep=":") %in% search()])</code> # return a char vector of currently loaded packages, which must be a subset of installed packages.</li>
				<li><code>with(myTable,subset(myTable, sex == "male", select=c("height","weight")))</code> # this code emulates SQL's select statement <code>SELECT height,weight FROM myTable WHERE sex='male';</code></li>
				<li><code>merge(table1, table2, by=commonField)</code> # this code emulates SQL's join statement <code>SELECT * FROM table1, table2 WHERE table1.commonField = table2.commonField;</code></li>
				<li><code>myTable[c(T,F),]</code> # retrieves the odd rows of myTable. Boolean values in index are recycled to match the dimension.</li>
				<li><code>stop("someErrorMessage");</code> # Error: someErrorMessage and programming halts at the line</li>
				<li><code>options(warn=1);warning("someWarningMessage");</code> # warn=1 => print waring message immediately; warn=0 => print warning message when returned to top level control; warn &lt; 0 => ignore warning; warn > 1 => same as <code>stop("someErrorMessage")</code></li>
				<li><code>options()$warn</code> # to view the specific option item</li>
				<li><code>.Machine</code> # a list of machine constants. e.g. <code>.Machine$double.eps</code></li>


			</ol>
		</section>
	</body>
</html>

