R使用方法

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
• 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/
Ross Ihaka Robert Gentleman
R‘s 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‖.
Quit R
• Command
– q() Terminate an R Session
How does R work?
Basic R Structure and data manipulation
Basic R working flow(Object orientation)
package
-- R for Beginners. Emmanuel Paradis
• Scheme’s underlying semantics + S’syntax = R
― 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
– That is R is a Free Software (or Open source software). (Here, Free refers to freedom, not price, although R is free in that sense as well.)
• The core of R is an interpreted computer language.
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"
——小偷与强盗的谈判
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 you come across a thing no body do it before.
CRAN (the Comprehensive
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.
OK. You can install it as all other standard MS softwares.
R Console/RGui in Windows(MS)
Graphics box Menu Icons
Command box
Several concepts in Administrating R
My father is S, mother is Scheme, but why my name is ―R‖?
You can learn more from:
http://cm.bell-labs.com/cm/ms/departments/sia/S/history.html
R‘s Parents(2)
Add a new package • Commands:
– library() add a package in the library – detach(package : xxx) detach a package
• All can do in the GUI (except detach())
– 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, MySQL and so on.
• Also you can get it from your friends, teachers, etc.
Using Precompiled Binary Distributions
Installing R • Double click ―rw1091.exe‖ using your mouse. That is
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. – CRAN 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. Down it! • New releases occur frequently It is about 20.6M – about every 3 months. in size. Be prepared to re-install frequently.
Don’t lose your way! • Three useful system command
– getwd() – setwd() – list.files()
Get Working Directory Set Working Directory List the Files in a Directory/Folder
What is R?
A brief history of R
The legend of R
• R started in the early 1990’s 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 available.
Show the Demonstrations of the Packages/Functions
• Commands
– demo() – example()
Demonstrations of R Functionality Run an Examples Section from the Online Help
R: Statistics? Programme? and Who are You?
-- An ABC introduction to R
For Fudan University
Presented by Guohui Ding R&D, SIBS, CAS
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? ………
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
Getting Helps • Several commands
– – – – help.start() help() or ?() help.search() apropos()
• Internet searching
– I like it very much. It seems omnipotence.
-- Ihaka R. & Gentleman R., 1996
R Now • Since mid-1997 there has been a core group who can modify the R source code CVS archive. • The R package system
• Workspace
– xxx.RData
• History
– xxx.Rhistory
-- Ihaka R. & Gentleman R., 1996
• • • •
Run your R codes Package Object Load/save workspace Session Load/save History Console Change your working directory
• Recommanded packages
– grid; lattice;e1071…
• Contributed packages (more than 366 packages
nowadays) – …… You can see what packages loaded now by the command search().
相关文档
最新文档