《r使用方法》由会员分享,可在线阅读,更多相关《r使用方法(51页珍藏版)》请在金锄头文库上搜索。
1、R: Statistics? Programme? and Who are You?,- An ABC introduction to R,Presented by Guohui Ding R&D, SIBS, CAS,For Fudan University,Main Topics Today,What is R? How to administrate R? How does R work? How to apply R for statistical problem? How to program your R function? ,What is R?,A brief history
2、of R,The legend of R,R started in the early 1990s as a project by Ross Ihaka and Robert Gentleman at the University of Auckland, New Zealand, intended to provide a statistical environment in their teaching lab. The lab had Macintosh computers, for which no suitable commercial environment was availab
3、le.,Robert Gentleman,Ross Ihaka,Rs Parents(1),The S language S: an interactive environment for data analysis developed at Bell Laboratories since 1976 Exclusively licensed by AT&T/Lucent to Insightful Corporation, Seattle WA. Product name: “S-plus”.,You can learn more from: http:/cm.bell- father is
4、S, mother is Scheme, but why my name is “R”?,The Scheme language Scheme is a statically scoped and properly tail-recursive dialect of the Lisp programming language invented by Guy Lewis Steele Jr. and Gerald Jay Sussman. Learn more: http:/swiss.csail.mit.edu/projects/scheme/ Schemes underlying seman
5、tics + Ssyntax = R,Rs Parents(2),“ We have named our language R in part to acknowledge the influence of S and in part to celebrate our own efforts.” - R. Ihaka R. Gentleman,R Now,Since mid-1997 there has been a core group who can modify the R source code CVS archive. The R package system CRAN (the C
6、omprehensive R Archive Network ),http:/www.r-project.org,The characters of R,R is “GNU S” A language and environment for data manipula-tion, calculation and graphical display. That is R is a Free Software (or Open source software). (Here, Free refers to freedom, not price, although R is free in that
7、 sense as well.) The core of R is an interpreted computer language. A mosaic of procedure-based programming and object-oriented programming Good interface to procedures written in C, C+, FORTRAN and other languages A flexible data exchange mechanism accessing relational databases -ODBC, PostgreSQL,
8、MySQL and so on.,小偷与强盗的谈判,R and Statistics,Most packages deal with statistics and data analysis. Powerful statistical graphics. Well crosstalking with other statistical softwares. Most R user are statistical experts. You can learn more modern analysis method from they by email. You can do it when yo
9、u come across a thing no body do it before.,Install and administrate R,Focus on Windows(MS),How do I get R?,The informational web site http:/www.r-project.org/ CRAN - the Comprehensive R Archive Network. The primary site is http:/cran.r-project.org/ .Mirror sites are available for many countries. CR
10、AN sites have binary distributions for Windows 95, 98, ME, NT4, 2000 and XP on Intel, for the Macintosh (System 8.6 to 9.1 and MacOS X), and for several Linux distributions. New releases occur frequently about every 3 months. Be prepared to re-install frequently. Also you can get it from your friend
11、s, teachers, etc.,Down it! It is about 20.6M in size.,Using Precompiled Binary Distributions,Installing R,Double click “rw1091.exe” using your mouse. That is OK. You can install it as all other standard MS softwares.,R Console/RGui in Windows(MS),Command box,Graphics box,Menu,Icons,Several concepts
12、in Administrating R,Workspace xxx.RData History xxx.Rhistory Package Object Session Console,Run your R codes,Load/save workspace,Load/save History,Change your working directory,Add a new package,Commands: library() add a package in the library detach(package : xxx) detach a package All can do in the
13、 GUI (except detach(),Load a local package,Install packages from internet or local,Update the local package from internet,Packages in R Environment,Basic packages “package:methods“ “package:stats“ “package:graphics“ “package:utils“ “package:base“ Recommanded packages grid; lattice;e1071 Contributed
14、packages (more than 366 packages nowadays) ,You can see what packages loaded now by the command search().,Dont lose your way!,Three useful system command getwd() Get Working Directory setwd() Set Working Directory list.files() List the Files in a Directory/Folder,Show the Demonstrations of the Packa
15、ges/Functions,Commands demo() Demonstrations of R Functionality example() Run an Examples Section from the Online Help,Getting Helps,Several commands help.start() help() or ?() help.search() apropos() Internet searching I like it very much. It seems omnipotence.,Quit R,Command q() Terminate an R Ses
16、sion,How does R work?,Basic R Structure and data manipulation,Basic R working flow(Object orientation),package,- R for Beginners. Emmanuel Paradis,Object orientation,Object: a collection of atomic variables and/or other objects that belong together Parlance: class: the “abstract” definition of it object: a concrete instance method: other word for function slot: a component of an object,Types of