复旦R语言PPT课件.ppt

上传人:资****亨 文档编号:125528428 上传时间:2020-03-18 格式:PPT 页数:52 大小:3.52MB
返回 下载 相关 举报
复旦R语言PPT课件.ppt_第1页
第1页 / 共52页
复旦R语言PPT课件.ppt_第2页
第2页 / 共52页
复旦R语言PPT课件.ppt_第3页
第3页 / 共52页
复旦R语言PPT课件.ppt_第4页
第4页 / 共52页
复旦R语言PPT课件.ppt_第5页
第5页 / 共52页
点击查看更多>>
资源描述

《复旦R语言PPT课件.ppt》由会员分享,可在线阅读,更多相关《复旦R语言PPT课件.ppt(52页珍藏版)》请在金锄头文库上搜索。

1、R Statistics Programme and Who are You An ABC introduction to R Presented by Guohui Ding R lattice e1071 Contributed packages more than 366 packages nowadays You can see what packages loaded now by the command search Don t lose your way Three useful system command getwd Get Working Directory setwd S

2、et Working Directory list files List the Files in a Directory Folder Show the Demonstrations of the Packages 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 s

3、earching I like it very much It seems omnipotence 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 Object orientation Object a collection of atomic variables and or other o

4、bjects 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 Data in R The basic data object is a vector of elements of type numeric numbers either floating point or integer character each el

5、ement is a character string logical each element is TRUE or FALSE list elements can be any type of object including other lists Components of the S language such as functions are also vectors Any vector can include the missing data marker NA as an element All vectors have a length and a mode The fun

6、ctions length and mode return this information as does the str function A structure consists of a data object plus additional information Matrices or arrays in general and time series are examples of structures Operators Vectors Matrices and Arrays Command array data NA dim length data dimnames NULL

7、 matrix data NA nrow 1 ncol 1 byrow FALSE dimnames NULL Lists List vs Vector list an ordered collection of data of arbitrary types vector an ordered collection of data of the same type Typically vector elements are accessed by their index an integer list elements by their name a character string But

8、 both types support both access methods Factors Factors classification variables If the levels of a factor are numeric e g the treatments are labelled 1 2 and 3 it is important to ensure that the data are ctually stored as a factor and not as numeric data Always check this by using summary Data fram

9、es data frame is supposed to represent the typical data table that researchers come up with like a spreadsheet It is a rectangular table with rows and columns data within each column has the same type e g number text logical but different columns may have different types A list actually Subsetting I

10、ndividual elements of a vector matrix array or data frame are accessed with by specifying their index or their name Using R on Windows MS Basic statistical analysis by R Data Input From the keyboard one by one c scan From the file read table read csv read csv2 read dta read spss By a spreadsheet dat

11、a entry edit fix Data Edit Commands edit fix Tips edit can invoke an notepad in the RGui Data Discription Commands summary mean sd hist boxplot Probability Distribution Three useful prefix in Probability Distribution Function dxxx for the density pxxx for the CDF qxxx for the quantile function rxxx

12、for the simulation random deviates They are different The seed is set by the system You can set seed yourself by set seed Statistical Inference Commands qxxx for the quantile function t test wilcox test stats kruskal test stats var test shapiro test qqnorm qqline Analysis of variance and Regression

13、Analysis Commands anova lm Experiment Design Commands sample power t test Save Object Data Every R object can be stored into and restored from a the commands save and load save x file x Rdata load x Rdata Importing and exporting data with rectangular tables in the form of tab delimited text files wr

14、ite table x file x txt sep t Graphics with R A Friendly R Environment Rcmdr If you don t like a command line environment package Rcmdr may be a good choice R programming R Program your R code own Control Flow if cond expr if cond cons expr else alt expr for var in seq expr while cond expr repeat exp

15、r break next Loops The main loop construct in R is for The commonest use as in C and other languages is to count from 1 to n for i in 1 n do something Leaving loops The break and next commands allow the flow of a loop to be altered break jumps out the loop next jumps to the next iteration of the loo

16、p Avoiding Iteration The canonical bad R program looks like this multiply two vectors for i in 1 n d i a i b i compute the inner product s 0 for i in 1 n s s d i The right way to do this is s sum a b apply lapply sapply Write R function A function definition looks like median function x na rm FALSE lots of code a return value More Packages Objects and methods Debugging and optimisation Connecting to other packages Interface to other programme language or DataBase R R Some Resources A Course The

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号