1 / 57
文档名称:

实验 R语言...ppt

格式:ppt   大小:827KB   页数:57页
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

实验 R语言...ppt

上传人:s1188831 2018/8/13 文件大小:827 KB

下载得到文件列表

实验 R语言...ppt

文档介绍

文档介绍:1 Introduction to R 2 Basic data management 3 Basic graphs 4 Basic Statistics 5 Regression 6 Analysis of variance 7 Analysis of SSSL
R IN ACTION
Why use R?
1 Introduction to R
R is free!
prehensive statistical platform
State-of-the-art graphics capabilities
Interactive platform
Data from multiple sources
Easy and straightforward, extensible
Obtaining and installing R
1 Introduction to R
prehensive R work (CRAN) at:
-
1 Introduction to R
A simple R session
age <- c(1,3,5,2,11,9,3,9,12,3)
weight <- c(,,,,,,,,,)
mean(weight)
[1]
sd(weight)
[1]
cor(age,weight)
[1]
plot(age,weight)
Getting help
1 Introduction to R
( ) # general help
help("mean") or ?mean # help on the function
The workspace
setwd("d:/R")
savehistory( ) # logo in the file .Rhistory
1 Introduction to R
Packages
( ) # a list of CRAN mirror sites
("gclus") # install the gclus package
library( ) # a list of packages
library(gclus) # loading the gclus package
help(package="gclus") # provides a brief description
2 Basic data management
Understanding datasets
Columns: as variables Rows: as observations
Variables:
Numeric: PatientID, AdmDate, and Age
Character: Diabetes and Status
Logical: (TRUE/FALSE)
Data structures
(a) Vectors: One-dimensional arrays
a <- c(1, 2, 5, 3, 6, -2, 4) # numeric data
b <- c("one", "two", "three") # character data
c <- c(TRUE, FALSE, TRUE) # logical
(b) Matrices
x <- matrix(1:10, nrow=2)
x
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
2 Basic data management
Data structures
(c) Data frames: A matrix, contain different modes of data
(numeric, character, etc.)
patientID <- c(1, 2, 3, 4)
age <- c(25, 34, 28, 52)
diabetes <- c("Type1", "Type2", "Type1", "Type1")
status <- c("Poor", "Improved", "Excellent", "Poor")
patientdata <- (patientID, age, diabetes, status)
patientd