University of Washington STATZST下IC3 STAT 425 Introduction to Nonparametric Statistics Introduction/Review of R Fritz Scholz Spring Quarter 2009 March 22,2009
STAT 425 Introduction to Nonparametric Statistics Introduction/Review of R Fritz Scholz Spring Quarter 2009 March 22, 2009
Purpose The following slides are intended as review of or as a basic introduction to the statistical analysis platform R.They are by no means exhaustive! The class web page contains links to more extensive introductions and they should be consulted when these slides raise questions. The internal documentation accompanying R via Help on the R toolbar is another resource.More on Help later. Also,it is always useful to experiment with certain command ideas to see and understand/interpret what happens. Start right away as you reread these slides to get a feel. We will be using R extensively throughout this course. 1
Purpose The following slides are intended as review of or as a basic introduction to the statistical analysis platform R. They are by no means exhaustive! The class web page contains links to more extensive introductions and they should be consulted when these slides raise questions. The internal documentation accompanying R via Help on the R toolbar is another resource. More on Help later. Also, it is always useful to experiment with certain command ideas to see and understand/interpret what happens. Start right away as you reread these slides to get a feel. We will be using R extensively throughout this course. 1
Statistical Analysis Platform Freely available from http://cran.r-project.org/ See also http://en.wikipedia.org/wiki/R_(programming-language) For Windows version:at CRAN site→Windows(95 and later))→base Download R-2.8.1-win32.exe or latest version to your desktop. For installation double-click on this executable program R-2.8.1-win32.exe and follow the instructions(use defaults when prompted). This creates a blue R icon on your desktop. Double-clicking this R icon opens up an R session. You close the session by typing q()or quit () This prompts you to save workspace image(with all changes in current session) or not (leave the workspace as it was when starting this session), or cancel(continue working in R). 2
Statistical Analysis Platform Freely available from http://cran.r-project.org/ See also http://en.wikipedia.org/wiki/R (programming language) For Windows version: at CRAN site −→ Windows (95 and later) −→ base Download R-2.8.1-win32.exe or latest version to your desktop. For installation double-click on this executable program R-2.8.1-win32.exe and follow the instructions (use defaults when prompted). This creates a blue R icon on your desktop. Double-clicking this R icon opens up an R session. You close the session by typing q()or quit(). This prompts you to save workspace image (with all changes in current session) or not (leave the workspace as it was when starting this session), or cancel (continue working in R). 2
Workspaces and Directories By default the workspace image is saved in {\tt C:\Program Files\R\R-2.8.1\.RData} It is a good idea to keep separate workspace images for different projects(HW?), otherwise the clutter will become unmanageable. Keep each separate workspace in a separate directory. To save an open workspace in a specific directory,say R-practice,click on File on the tool bar in the R work session,choose Change dir,browse to that directory R-practice and choose OK. When you quit,g(),after that change of directories,the workspace.RData is saved in that new directory. A new icon R with name RData appears in that directory. 3
Workspaces and Directories By default the workspace image is saved in {\tt C:\Program Files\R\R-2.8.1\.RData} It is a good idea to keep separate workspace images for different projects (HW?), otherwise the clutter will become unmanageable. Keep each separate workspace in a separate directory. To save an open workspace in a specific directory, say R-practice, click on File on the tool bar in the R work session, choose Change dir, browse to that directory R-practice and choose OK. When you quit, q(), after that change of directories, the workspace .RData is saved in that new directory. A new icon R with name .RData appears in that directory. 3
Starting a Session from a Directory When you have a directory containing an R icon with name.RData you can open a session using that workspace by double-clicking on that icon. To see the objects in that workspace type 1s()or objects () When there are no objects the response is character(0). If you want to start with a clean(empty)workspace you can remove all those objects by typing the command rm(list=1s ()) If you want to keep every object except specific ones,say myobject and dataset.x, you would remove them by typing rm(myobject,dataset.x) 4
Starting a Session from a Directory When you have a directory containing an R icon with name .RData you can open a session using that workspace by double-clicking on that icon. To see the objects in that workspace type ls() or objects(). When there are no objects the response is character(0). If you want to start with a clean (empty) workspace you can remove all those objects by typing the command rm(list=ls()). If you want to keep every object except specific ones, say myobject and dataset.x, you would remove them by typing rm(myobject,dataset.x). 4