Chapter 9 R Console

When iNZight starts, two windows open: one is the main window in which we work, and a second window is an R Console. R code can be directly typed into this window at the prompt >. The datasets that are imported into iNZight are available at the R console. However note that the R installation that comes with iNZight is different from the one you might have installed yourself with Rstudio, so R packages you may have added will not be available.

This manual does not cover the writing of R code, however some simple calculations may be conveniently done at the R Console.

For example, if we have a confidence interval from iNZight, we can compute the margin of error by simply halving the length of the interval. If the confidence interval has been computed by iNZight as, say,

   Lower    Mean   Upper
   529.7   584.6   639.5

(this is the confidence interval for the mean school size in the apisrs dataset), then we can compute the margin of error in R by typing

> (639.5-529.7)/2

at the prompt: i.e. MOE=(Upper-Lower)/2. R responds with the answer:

[1] 54.9

Then the SE = MOE/1.96, and RSE=SE/Estimate are given by

> 54.9/1.96
[1] 28.0102


> 28.0102/584.6
[1] 0.04791345

i.e. an RSE of 4.8%.