Забыли?

?

# How to Use the R Programming Language for Statistical Analyses

код для вставкиСкачать
```R basics
Ahmed RebaГЇ
What Is R?
a programming вЂњenvironmentвЂќ
пЃ° object-oriented
пЃ° similar to S-Plus
пЃ° freeware
пЃ° provides calculations on matrices
пЃ° excellent graphics capabilities
пЃ° supported by a large user network
пЃ°
What is R Not?
a statistics software package
пЃ° quick to learn
пЃ° a program with a complex graphical
interface
пЃ°
Installing R
www.r-project.org/
пЃ°
Tutorials
пЃ°
From R website under вЂњDocumentationвЂќ
пЃ®
вЂњManualвЂќ is the listing of official R
documentation
пЃ°
пЃ°
пЃ°
пЃ°
пЃ°
пЃ°
An Introduction to R
R Language Definition
Writing R Extensions
R Data Import/Export
The R Reference Index
Tutorials cont.
пЃ®
вЂњContributedвЂќ documentation are tutorials and
manuals created by R users
пЃ°
пЃ°
пЃ°
пЃ®
пЃ®
Simple R
R for Beginners
Practical Regression and ANOVA Using R
R FAQ
Mailing Lists (listserv)
пЃ°
r-help
Tutorials cont.
пЃ°
Textbooks
пЃ®
пЃ®
Venables & Ripley (2002) Modern Applied
Statistics with S. New York: Springer-Verlag.
Chambers (1998). Programming With Data: A
guide to the S language. New York: SpringerVerlag.
R Basics
objects
пЃ° naming convention
пЃ° assignment
пЃ° functions
пЃ° workspace
пЃ° history
пЃ°
Objects
names
пЃ° types of objects: vector, factor, array,
matrix, data.frame, ts, list
пЃ° attributes
пЃ°
пЃ®
пЃ®
пЃ°
mode: numeric, character, complex, logical
length: number of elements in object
creation
пЃ®
пЃ®
assign a value
create a blank object
Naming Convention
пЃ° can contain letters, digits (0-9), and/or
periods вЂњ.вЂќ
пЃ° case-sensitive
пЃ°
пЃ®
пЃ°
mydata different from MyData
do not use underscore вЂњ_вЂќ
Assignment
пЃ°
вЂњ<-вЂќ used to indicate assignment
пЃ®
пЃ®
пЃ®
пЃ°
x<-c(1,2,3,4,5,6,7)
x<-c(1:7)
x<-1:4
note: as of version 1.4 вЂњ=вЂњ is also a valid assignment operator
Functions
actions can be performed on objects using
functions (note: a function is itself an
object)
пЃ° have arguments and options, often there
are defaults
пЃ° provide a result
пЃ° parentheses () are used to specify that a
function is being called
пЃ°
LetвЂ™s look at R
R Workspace & History
Workspace
during an R session, all objects are stored
in a temporary, working memory
пЃ° list objects
пЃ°
пЃ®
пЃ°
remove objects
пЃ®
пЃ°
ls()
rm()
objects that you want to access later must
be saved in a вЂњworkspaceвЂќ
пЃ®
пЃ®
from the menu bar: File->save workspace
from the command line:
save(x,file=вЂњMyData.RdataвЂќ)
History
command line history
пЃ° can be saved, loaded, or displayed
пЃ°
пЃ®
пЃ®
пЃ®
пЃ°
savehistory(file=вЂњMyData.Rhistory)
history(max.show=Inf)
during a session you can use the arrow
keys to review the command history
Two most common object types
for statistics:
matrix
data frame
Matrix
a matrix is a vector with an additional
attribute (dim) that defines the number of
columns and rows
пЃ° only one mode (numeric, character,
complex, or logical) allowed
пЃ° can be created using matrix()
пЃ°
x<-matrix(data=0,nr=2,nc=2)
or
x<-matrix(0,2,2)
Data Frame
several modes allowed within a single data
frame
пЃ° can be created using data.frame()
пЃ°
L<-LETTERS[1:4] #A B C D
x<-1:4
#1 2 3 4
data.frame(x,L) #create data frame
пЃ°
attach() and detach()
пЃ®
пЃ®
the database is attached to the R search path so that the database is
searched by R when it is evaluating a variable.
objects in the database can be accessed by simply giving their names
Data Elements
пЃ°
select only one element
пЃ®
пЃ°
select range of elements
пЃ®
пЃ°
x[-3]
slicing: including only part of the object
пЃ®
пЃ°
x[1:3]
select all but one element
пЃ®
пЃ°
x[2]
x[c(1,2,5)]
select elements based on logical operator
пЃ®
x(x>3)
Data Import & Entry
Importing Data
пЃ°
пЃ®
пЃ°
data.entry()
пЃ®
пЃ°
reads in data from an external file
create object first, then enter data
c()
пЃ®
concatenate
пЃ°
scan()
пЃ°
prompted data entry
R has ODBC for connecting to other programs
пЃ®
Data entry & editing
пЃ°
start editor and save changes
пЃ®
пЃ°
start editor, changes not saved
пЃ®
пЃ°
data.entry(x)
de(x)
start text editor
пЃ®
edit(x)
```
###### Документ
Категория
Презентации
Просмотров
9
Размер файла
1 020 Кб
Теги
1/--страниц
Пожаловаться на содержимое документа