(1) If you need to install R go to the R website http://www.r-project.org/,
and follow the links to download the R base package and install it. It will take
only a few minutes if you have a fast internet connection.
For an overview of the R package and its survey functions and links to further sources of help click here.
If you have already used R go to next section
This introduction uses the data from exemplar 1, but is relevant to any exemplar.
(2 ) Double click on the link to the R data set (e.g. ex1.Rdata) in the exemplar you want to try to start the R program. In a few seconds you will get a welcome screen with a message to tell you that you have opened an existing workspace and a red prompt where you can type commands.
(3) You are now in the R workspace for this project, and (although you might not
know it) in this workspace you are surrounded by R objects and you can make and
store new objects there too. Each object knows what its classes are. For example
my name is of class character and TotalTable
is both a table and an xtabs (crosstabs). TotalTable
To list all the objects in your local workspace try either of the two commands, ls( ) or objects( )
To view individual objects try just typing their names at the prompt, e.g.TotalTable (R is case sensitive)
As well as your own workspace, you have access to a whole set of other workspaces within the R package. To see what they are do search() at the R prompt (>). In one of these workspaces ( "package:datasets", number 7 in the search list) there is an object called attitudes. To view it type attitude by itself at the R prompt. To find out about it type help(attitude) and to get a graphical display of it type plot(attitude).
(4) GETTING HELP
Go to the help menu and click on html help. This will open a browser where
there are links to various guides. These are NOT AS USEFUL as some of
the contributed guides ones on the R web site http://www.r-project.org/). More useful is the index to packages.
Follow links packages, and for the main R functions (base) and you will get help on all the base functions. You can minimise this
until you need it.
(5) THE FAMILY RESOURCES SURVEY DATA
The family resources survey is in an object of class.data.frame
in your local workspace called frs.
To find out about it try:
> summary (frs) #Gives details of variables.
> dim (frs) #Gives its dimensions
To get number of rows and columns You should find that it has 7007 rows and
9 columns. To visualise some of the columns of the data try:
> plot(frs$HHINC)
> hist(frs$HHINC)
> plot(frss$ADULTH,fam.resources$HHINC)
To look at individual rows of the data frame > frs[1:5,]
and to look individual columns of some rows
> frs[1:10,3:6]
(6) So for you have been typing commands at the R prompt (>) but you can also use a script file. Go to the PEAS web site and download the script file (.R extension) to your computer and then open it from the >> file >> open script menu. You can tile the two windows. Highlight the code from the script file and >>edit >>run selection or ^ctrl-R will run it for you,
(7) CONGRATULATIONS you are no longer a complete beginner and you
are ready to try the survey package.
But first a few handy hints: TRY THEM NOW
If you are new to Splus or R go back to beginners section.
(1 )OPEN THE R WORKSPACE IF YOU HAVE NOT DONE THIS ALREADY Double click on the link to the R data set (e.g. exp1.Rdata) in the exemplar you want to try.
(2) DOWNLOAD AND INSTALL THE SURVEY PACKAGE (you need to be connected to the internet,
but you will only need to do this once)
Go to ->packages ->install
package(s) from CRAN. You will get a list of packages,
scroll down and click on survey (OK) and the package will install
in your system.
ALLOW R TO ACCESS THE OBJECTS IN THE SURVEY PACKAGE WORKSPACE (you will
need to do this every time you want to use the survey package)
type the command: library(survey)
(4) DOCUMENTATION To get a list of all the survey functions and data sets and help
on each one, go to the help menu ->html help->packages and find the survey
package.
(5) USING THE PRE_PREPARED CODE FOR EACH EXEMPLAR The commands for analysing
each exemplar in R are in R source files. You should download the one you want and open it from >> file >> open script menu. You can tile the two windows. Highlight the code from the script file and >>edit >>run selection or ^ctrl-R will run it for you,
(6) Follow the commands in the script file lines starting with # are comments.
GOOD LUCK