What is R?
R is a free softwareenvironment for data analysis and graphics(visualization)
- programming language
- data visualization tool
Why learning R?
1.data analysis/datascientist
perform comprehensive dataanalytics than can not be achieved using spreadsheet-based tools alone
R for data analysts
R- as an interactive dataanalysis tool
-classical statisticaltests
-linear and nonlinearmodeling
-time-series analysis
-classification
-clustering
-more
2.software developer
fulfill the user demandsfor improved data analysis features in new or existing applications
R for developers
R- as a programminglanguage
-expressions
-built-in functions
-data structures
- vectors, metrics, lists, data frames
-external libraries - packages
-user-defined functions
-user-defined classes
Getting started with Rconsole
TaomatoMacBook-Air:testRMars$ R
R version 3.0.3(2014-03-06) -- "Warm Puppy"
Copyright (C) 2014 The RFoundation for Statistical Computing
Platform:x86_64-apple-darwin10.8.0 (64-bit)
R是自由软件,不带任何担保。
在某些条件下你可以将其自由散布。
用'license()'或'licence()'来看散布的详细条件。
R是个合作计划,有许多人为之做出了贡献.
用'contributors()'来看合作者的详细情况
用'citation()'会告诉你如何在出版物中正确地引用R或R程序包。
用'demo()'来看一些示范程序,用'help()'来阅读在线帮助文件,或
用'help.start()'通过HTML浏览器来看帮助文件。
用'q()'退出R.
TaomatoMacBook-Air:testRMars$ ls -al
total 16
drwxr-xr-x 4Mars staff 136 4 2 22:35 .
drwxr-xr-x+ 60 Mars staff 2040 4 2 22:33 ..
-rw-r--r-- 1Mars staff 59 4 2 22:35 .RData
-rw------- 1Mars staff 23 4 2 22:35 .Rhistory
> library()
图书馆‘/Library/Frameworks/R.framework/Versions/3.0/Resources/library’里有个程辑包:
base The R Base Package
boot Bootstrap Functions(originally by Angelo Canty
for S)
class Functions for Classification
cluster Cluster Analysis Extended Rousseeuwet al.
codetools Code Analysis Tools for R
compiler The R Compiler Package
datasets The R Datasets Package
foreign Read Data Stored by Minitab, S, SAS,SPSS,
Stata, Systat, Weka,dBase, ...
graphics The R Graphics Package
grDevices The R Graphics Devices and Support forColours
and Fonts
grid The Grid Graphics Package
KernSmooth Functions for kernel smoothing for Wand& Jones
(1995)
lattice Lattice Graphics
MASS Support Functions and Datasetsfor Venables and
Ripley's MASS
Matrix Sparse and Dense Matrix Classes andMethods
methods Formal Methods and Classes
mgcv Mixed GAM Computation Vehiclewith GCV/AIC/REML
smoothness estimation
nlme Linear and Nonlinear MixedEffects Models
nnet Feed-forward Neural Networksand Multinomial
Log-Linear Models
parallel Support for Parallel computation in R
rpart Recursive Partitioning and RegressionTrees
spatial Functions for Kriging and PointPattern
Analysis
splines Regression Spline Functions andClasses
stats The R Stats Package
stats4 Statistical Functions using S4Classes
survival Survival Analysis
tcltk Tcl/Tk Interface
tools Tools for Package Development
utils The R Utils Package
> demo(graphics::graphics)
demo(graphics)
---- ~~~~~~~~
Type <Return> tostart :
Determine which package are currently loaded into memory?
We have determined whichpackages have been installed on our system by using ( install.packages() ), butto use the packages we need to load them to the memory.
> search()
[1]".GlobalEnv" "package:stats" "package:graphics"
[4] "package:grDevices""package:utils" "package:datasets"
[7]"package:methods" "Autoloads" "package:base"
Above is an order list ofpackages that are currently in memory and available for our R scripts. Noticethat the base packages is the final package in the search path. As we extend Rby loading new packages into memory.
Loading a package intomemory
> require(package)
BD801EN_Lab_1