SlideShare una empresa de Scribd logo
1 de 23
Introduction TO S+(S-plus)
S-PLUS
• S-PLUS is a commercial implementation of the S programming language sold
by TIBCO Software Inc..
• It features object-oriented programming capabilities and advanced analytical
algorithms.
• S-plus is an object-oriented programming and statistical analysis language
developed primarily at AT&T research labs during the 1980's. Data in Splus is
aggregated into "objects", which are of different types.
S (programming language)
• S is a statistical programming language developed primarily by John Chambers and (in earlier versions) Rick
Becker and Allan Wilks of Bell Laboratories. The aim of the language, as expressed by John Chambers, is "to
turn ideas into software, quickly and faithfully."
• The two modern implementations of S are R, part of the GNU free software project, and S-PLUS.
• History
• "Old S“: S is one of several statistical computing languages that were designed at Bell Laboratories, and first
took form between 1975–1976.[1] Up to that time, much of the statistical computing was done by directly
calling Fortran subroutines; however, S was designed to offer an alternate and more interactive approach.
Early design decisions that hold even today include interactive graphics devices (printers and character
terminals at the time), and providing easily accessible documentation for the functions.
• "New S“:The New S Language[4] (1988 Blue Book) was published to introduce the new features, such as the
transition from macros to functions and how functions can be passed to other functionsMany other changes
to the S language were to extend the concept of "objects", and to make the syntax more consistent (and
strict). However, many users found the transition to New S difficult, since their macros needed to be
rewritten. Many other changes to S took hold, such as the use of X11 and PostScript graphics devices,
rewriting many internal functions from Fortran to C, and the use of double precision (only) arithmetic. The
New S language is very similar to that used in modern versions of S-PLUS and R.
• S4:Version 4 of S, often abbreviated S4, provides advanced object-oriented features. S4 classes differ
markedly from S3 classes.
Historical timeline
• 1988: S-PLUS is first produced by a Seattle-based start-up company called Statistical Sciences, Inc. The
founder and sole owner is R. Douglas Martin, professor of statistics at the University of Washington, Seattle.
• 1993: Statistical Sciences acquires the exclusive license to distribute S and merges with MathSoft, becoming
the firm's Data Analysis Products Division (DAPD).
• 1995: S-PLUS 3.3 for Windows 95/NT. Matrix library, command history, Trellis graphics
• 1996: S-PLUS 3.4 for UNIX. Trellis graphics, nlme library, hexagonal binning, cluster methods.
• 1997: S-PLUS 4 for Windows. New GUI, integration with Excel, editable graphics.
• 1998: S-PLUS 4.5 for Windows. Scatterplot brushing, create S-PLUS graphs from within Excel & SPSS.
• 1998: S-PLUS is available for Linux & Solaris.
• 1999: S-PLUS 5 for Solaris, Linux, HP-UX, IBM AIX, SGI Irix, and DEC Alpha. S-PLUS 2000 for Windows. nlme
3.3, quality control charting, new commands for data manipulation.
• 2000: S-PLUS 6 for Linux/UNIX. Java-based GUI, Graphlets, survival5, missing data library, robust library.
• 2001: MathSoft sells its Cambridge-based Engineering and Education Products Division (EEPD), changes
name to Insightful Corporation, and moves headquarters to Seattle. This move is basically an "Undo" of the
previous merger between MathSoft and Statistical Sciences, Inc.
Historical timeline
• 2001: S-PLUS Analytic Server 2.0. S-PLUS 6 for Windows (Excel integration, C++ classes/libraries for
connectivity, Graphlets, S version 4, missing data library, robust library).
• 2002: StatServer 6. Student edition of S-PLUS now free.
• 2003: S-PLUS 6.2 New reporting, database integration, improved Graphlets, ported to AIX, libraries for
correlated data, Bayesian methods, multivariate regressions.
• 2004: Insightful purchases the S language from Lucent Technologies for $2 million.
• 2004: S+ArrayAnalyzer 2.0 released.
• 2005: S-PLUS 7.0 released. BigData library for working with larger-than-memory data sets, S-PLUS
Workbench (Eclipse development tool). Insightful Miner 7.0 released.
• 2007: S-PLUS 8 released. New package system, language extensions for R package compatibility, Workbench
debugger.
• 2008: TIBCO acquires Insightful Corporation [1
Historical timeline
• Data in S-plus is aggregated into "objects", which are of different types. The most common
object types are:
• vectors: ordered strings of data values (having no row or column orientation). All data
must be of the same mode (e.g., all numeric, all character, all logical, etc.).
• matrices: rectangular arrays, with rows and columns, of like-mode data.
• data frames: rectangular arrays similar to SAS data sets. Columns and rows have
identifying names. Columns (variables) may be of different modes.
• lists: ordered collections of objects of possibly different types and modes. For
example, a data frame, several matrices, and a vector or two can be joined to form a
list.
• There are many other kinds of objects, including time series objects, array objects, and
factor objects.
Installation
• System requirements
• A PC with Pentium processor
• 32 MB internal memory (64 MB recommended)
• 75 MB of free hard disk space
• CD-ROM drive
• Microsoft Windows 95/98/Me, Windows NT (4.0 or higher) or Windows 2000
INTRODUCTION
• Simple arithmetical ,Don't forget a RETURN after each statement. The first > on each line is the Splus prompt
• 3+5
• 4*5
• 8*(3+6)
• The colon operator is used to obtain sequences
• 1:7
• Vectors can be made with the function c() (c for 'combine')
• c(3, 4, 1, 6)
• MISTAKES
• 32 1+1
• 0.5(2+4)
• SPACES AND RETURN
• 31+
4
• 31 + 4 ok
• 3 1 +4 Error
• UPPER AND LOWER CASE: case sensitive
• sex <- 'female‘ Different from SEX<-’female’
INTRODUCTION
• Comment ##, or #
• CONTINUATION:continuation prompt +
• 3 *
+ 6
• c(3, 4, 1, 6
+ )
•?log
•sqrt(x)
•exp(x)
• ONLINE HELP:on-line help on all functions, operators or data sets
• help('c')
• Help(seq)
• Help()
• Types of data objects include vectors, matrices, lists, data frames, arrays, categories, time series and functions.
• Vectors have the attributes length and mode
• mode(c(-2.0, 3.1, 4.7, 6.9))
• length(c(-2.0, 3.1, 4.7, 6.9))
• mode(c(T, T, F, T, T, F, F, F, F))
• mode(c('orc', 'troll', 'gnome', 'elf', 'hobbit'))
• mode(c('hello', 1, T))
ASSIGNMENT
• the assignment operator <-
• x <- c(4, 2, 8, 7), x+10,x+y,x/*+y
• Print(x) or x or length(x)
• We can overwrite with x<-199
• To remove x write:rm(x)
• Be careful with minus signs when assigning objects
• x <-- 4 or x <- -4
• y <- 1:10
• Y1<-seq(1,5,1)
• everything get stored
• objects()
• OPERATORS:+ - * / ^ (exponentiation)
• 2^3*4
• 2^(3*4)
• x <- 5
• 1:(x-1)
• 1:x-1
• 1:3^2
• x <- c(2, 1, 4, 5) => x+1 Ex:2*x, x^2, sin(x)
ASSIGNMENT
• EX: y <- c(1, 2, 1, 2)
• x+y, x*y , x/y , z <- c(2, 4, 6), x + z
• y==6:10, x=2:9, z=c(x,y)
• MATRIX DATA OBJECTS
• A matrix in S-PLUS is a two-way array
• x <- matrix(1:12, nrow=3, ncol=4)
• Show length of row and column: dim(x)
• length(x) show length of number
• mode(x) show data type
• S-PLUS is clever enough not to need both the number of rows and the number of columns
• matrix(1:12, nrow=3)
• Notice that the matrix has been filled down the columns first. This is the DEFAULT.
• matrix(1:12, nrow=3, byrow=T)
• DATA FRAME OBJECTS :A data frame consists of rows and columns of data, just like a matrix object, except that the
COLUMNS can be different modes.
• firstnames <- c('Kate', 'Linda', 'Edgar', 'Chelsea')
• lastnames <- c('Beatty', 'Colpoys', 'Gonzales', 'Miller')
• height <- c(165, 170, 180, 168)
• class.height <- data.frame(firstnames,lastnames,height)
ASSIGNMENT
• seq1 <- seq(1:6)
mat1 <- matrix(seq1, 2)
mat1
• mat2 <- matrix(seq1, 2, byrow = T)
• matrix(rnorm(20), 4)
• #appending v1 to mat5
v1 <- c(1, 1, 2, 2)
mat6 <- cbind(mat5, v1)
• v2 <- c(1:6)
mat7 <- rbind(mat6, v2)
• #determining the dimensions of a mat7
dim(mat7)
• matrix_name[row#, col#]
mat7[1, 6]
• #to access an entire row leave the column number blank
mat7[1, ]
•#to access an entire column leave the row number
blank
mat7[, 6]
•#Creating mat8 and mat9
mat8 <- matrix(1:6, 2)
•mat9 <- matrix(c(rep(1, 3), rep(2, 3)), 2, byrow = T)
•#addition mat9 + mat8
•mat9 + 3
•#subtraction mat8 - mat9
•#inverse
•solve(mat8[, 2:3])
#transpose t(mat9)
•cbind(B, C)
•D = matrix(
+ c(6, 2),
+ nrow=1,
+ ncol=2)
•Deconstruction:We can deconstruct a matrix by
applying the c function, which combines all column
vectors into one.
•c(B)
ASSIGNMENT
• seq1<-seq(1:6)
mat1<-matrix(seq1,2,3,byrow=F)
v1<-c(9,8)
mat2<-cbind(mat1,v1)
mat2
• seq1<-seq(1:6)
mat1<-matrix(seq1,2,3,byrow=F)
v1<-c(9,8,0)
mat2<-rbind(mat1,v1)
mat2
mat2[3,3]
• mat1<-matrix(rep(1,16),4,4)
mat2<-matrix(rep(4,16),4)
mat3<-mat1+mat2
mat3
•mat9 <- matrix(c(rep(1, 3), rep(2, 3)), 2, byrow = T)
Mat9
•#transpose
t(mat9)
• B = matrix(
+ c(2, 4, 3, 1, 5, 7),
+ nrow=3,
+ ncol=2)
•> c(B)
[1] 2 4 3 1 5 7
• use of the function data.frame()
• class.height
• LIST OBJECTS: They are even more general than data frames
• junklist <- list(x=firstnames,y=height,z=X)
• junklist
• ?
• ADDING NAMES: it is useful to add names to vectors
• x <- (1:5)^2
• x
• days <- c('Mon', 'Tue', 'Wed', 'Thu', 'Fri')
• names(x) <- days
• X
• REP AND SEQ
• repeat function rep() and the sequence function seq() are useful functions which can be used to make
vectors and matrices.
• seq(from=0.3, to=1, by=0.1)
• Note that S-PLUS doesn't care about the order the arguments of a function when they are given names,
as above.
• seq(to=1, by=0.1, from=0.3)
• But if you leave out the names, you must keep to a standard order: from,to, by
• seq(0.3, 1, 0.1)
• seq(f=0.3, b=0.1, t=1)
• rep() makes a repeat of an input either a certain number of times, or to a certain length.
• rep(1, length=4)
• rep(1:4, l=12)
• rep(1:4, l=9)
• rep() just fills in until it runs out of length. Another use of times is when times is a vector.
• rep(c(4, 6, 5), t=c(1, 2, 3))
• SUBSETS OF DATA
• x <- c(5, 14, 8, 9, 10)
• To display a single element we use square brackets x[1]
• To display more than one element at a time, use the c() function within the [] characters.
• Eg. to get the 3rd and 5th characters use x[c(3, 5)]
• Negation is useful to display all elements except those that are specified. Try
• x[-4]
• x[-c(1, 3)]
• Logical expressions are a more sophisticated and VERY USEFUL tool.
• x[x>8]
• we can assign this to another vector of length 3 with
• biguns <- x[x>8]
• it is convenient to define a vector with logical entries as in
• Data Frame Object
• row and columns of data, like matrix but columns
• can be different mode.
• Syntax function: mydata<-data.frame(col1,col2,col3...)
• ls() : show all variable
• class(varName): show mode of varName
• remove(varName): remove variable
• names(varObject): show variale in varObject
• village$age=age
EX1:
patientID<-c(1,2,3,4)
age<-c(25,34,38,52)
diabetes<-c("Type1","Type2","Type1","Type1")
status<-c("Poor","Improved","Excelent","Poor")
patientData<-data.frame(patientID,age,diabetes,status)
print(patientData)
EX2:
#patientData[1:3]
#patientData[c("status","age")]
• Data Frame Object
• attach: make variable in dataframe to work space
• plot(age,height) : show linear regression activity
• List
• x<-list(name='Chan chav',sex='M',salary=200,age=25)
• y<-list(name='Tav minsour',sex='F',salary=100,age=20)
• z<-c(x,y)
• z
• #x[[2]]
• #x["name"]
• x[["name"]]
Control Structures
• x == y "x is equal to y"
• x != y "x is not equal to y"
• x > y "x is greater than y"
• x < y "x is less than y"
• x <= y "x is less than or equal to y"
• x >= y "x is greater than or equal to y"
• if(1==0){
print(1)}
else{
print(2)}
• + Ifelse Statements
• Syntax:
• ifelse(test,true_value,false_value)
• Ex:
x<-1:10
ifelse(x<5 | x>8,x,0)
•EX:
score<-10
if(score<5)
{
print("FAIL");
}
else
{
print("Pass");}
•EX2:
score<-1;
ifelse(score<5,"FAIL","PASS");
•EX3:
x <- 1:10
ifelse(x<5 | x>8, x, 0)
•EX4:
•x <- 1
while(x < 5) {x <- x+1; print(x);}
•next can skip one step of the loop.
•break will end the loop abruptly.
•which() function gives the TRUE indices
of a logical object, allowing for array
indices.
•which(letters=="a")
•LOOP
x <- 1
while(x < 5) {x <- x+1; if (x == 3) break;
print(x); }
•EX6:
x <- 1
while(x < 5) {x <- x+1; if (x == 3) next;
print(x);}
Control Structures
• Loops
• for (k in 1:5){
print(k)
}
• while (g < 1)
{
g <- rnorm(1) + cat(g,"n")
}
• repeat is similar to while and for loop,
it will execute a block of commands
repeatly till break.
• sum <- 1
repeat
{ sum <- sum + 2;
print(sum);
if (sum > 11)
break; }
• The break statement can be used to terminate the loop abruptly
•EX:
samples <- c(rep(1:10))
samples
•EX1:
x<-0;
while (x < 10) {
x<- x+4;
print (x);
}
EX2:
x<-0;
while (x < 10)
{
x <- x + 4;
print (x);
if ( x = 8)
{
break;
}
}
•EX3:
samples<-c(1:10)
for (thissample in samples)
{
str <- paste(thissample,"is
current sample",sep=" ")
print(str)
}
EX4:
end <- length(samples)
begin <- end - 2
for (thissample in begin:end)
{
str <- paste(thissample,"is
current sample",sep=" ")
print(str)
}
array
• R Array:
• + syntax:
• array(data,dim)
• Note: data: vector fill the array
• dim: row and col number
• EX:
• x <- array(1:6,c(2,3))
• x
• Ex:
• x <- 1:64#declare vector(1->64)
• dim(x)<- c(2,4,8)#convert vector x to array row=2
• #col=4 number eleement=8
• is.array(x)#test wheter array or not
• x#show element of array
EX: show all event of array
x[1,,]
EX: x[2,2,] # show row 2 column 2

Más contenido relacionado

La actualidad más candente

R Spatial Analysis using SP
R Spatial Analysis using SPR Spatial Analysis using SP
R Spatial Analysis using SPtjagger
 
MapInfo Professional 12.0 and SQL Server 2008
MapInfo Professional 12.0 and SQL Server 2008MapInfo Professional 12.0 and SQL Server 2008
MapInfo Professional 12.0 and SQL Server 2008Peter Horsbøll Møller
 
Automating Repetitive Tasks with MapBasic
Automating Repetitive Tasks with MapBasicAutomating Repetitive Tasks with MapBasic
Automating Repetitive Tasks with MapBasicPeter Horsbøll Møller
 
Monad presentation scala as a category
Monad presentation   scala as a categoryMonad presentation   scala as a category
Monad presentation scala as a categorysamthemonad
 
2014 11 lucene spatial temporal update
2014 11 lucene spatial temporal update2014 11 lucene spatial temporal update
2014 11 lucene spatial temporal updateDavid Smiley
 
The Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David SmileyThe Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David SmileyLucidworks
 
peRm R group. Review of packages for r for market data downloading and analysis
peRm R group. Review of packages for r for market data downloading and analysispeRm R group. Review of packages for r for market data downloading and analysis
peRm R group. Review of packages for r for market data downloading and analysisVyacheslav Arbuzov
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1blessyboban92
 
Towards typesafe deep learning in scala
Towards typesafe deep learning in scalaTowards typesafe deep learning in scala
Towards typesafe deep learning in scalaTongfei Chen
 
Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)Robert Metzger
 
Spatial Data Science with R
Spatial Data Science with RSpatial Data Science with R
Spatial Data Science with Ramsantac
 
Enhancing Spark SQL Optimizer with Reliable Statistics
Enhancing Spark SQL Optimizer with Reliable StatisticsEnhancing Spark SQL Optimizer with Reliable Statistics
Enhancing Spark SQL Optimizer with Reliable StatisticsJen Aman
 

La actualidad más candente (20)

matlab
matlabmatlab
matlab
 
R Spatial Analysis using SP
R Spatial Analysis using SPR Spatial Analysis using SP
R Spatial Analysis using SP
 
MapInfo Professional 12.0 and SQL Server 2008
MapInfo Professional 12.0 and SQL Server 2008MapInfo Professional 12.0 and SQL Server 2008
MapInfo Professional 12.0 and SQL Server 2008
 
Automating Repetitive Tasks with MapBasic
Automating Repetitive Tasks with MapBasicAutomating Repetitive Tasks with MapBasic
Automating Repetitive Tasks with MapBasic
 
Monad presentation scala as a category
Monad presentation   scala as a categoryMonad presentation   scala as a category
Monad presentation scala as a category
 
Programming with matlab session 6
Programming with matlab session 6Programming with matlab session 6
Programming with matlab session 6
 
Introduction2R
Introduction2RIntroduction2R
Introduction2R
 
2014 11 lucene spatial temporal update
2014 11 lucene spatial temporal update2014 11 lucene spatial temporal update
2014 11 lucene spatial temporal update
 
The Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David SmileyThe Latest in Spatial & Temporal Search: Presented by David Smiley
The Latest in Spatial & Temporal Search: Presented by David Smiley
 
What is matlab
What is matlabWhat is matlab
What is matlab
 
Enter The Matrix
Enter The MatrixEnter The Matrix
Enter The Matrix
 
peRm R group. Review of packages for r for market data downloading and analysis
peRm R group. Review of packages for r for market data downloading and analysispeRm R group. Review of packages for r for market data downloading and analysis
peRm R group. Review of packages for r for market data downloading and analysis
 
R - the language
R - the languageR - the language
R - the language
 
Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1Ist year Msc,2nd sem module1
Ist year Msc,2nd sem module1
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Towards typesafe deep learning in scala
Towards typesafe deep learning in scalaTowards typesafe deep learning in scala
Towards typesafe deep learning in scala
 
Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)Stratosphere Intro (Java and Scala Interface)
Stratosphere Intro (Java and Scala Interface)
 
Precisely MapInfo Pro v2019 and Roadmap
Precisely MapInfo Pro v2019 and RoadmapPrecisely MapInfo Pro v2019 and Roadmap
Precisely MapInfo Pro v2019 and Roadmap
 
Spatial Data Science with R
Spatial Data Science with RSpatial Data Science with R
Spatial Data Science with R
 
Enhancing Spark SQL Optimizer with Reliable Statistics
Enhancing Spark SQL Optimizer with Reliable StatisticsEnhancing Spark SQL Optimizer with Reliable Statistics
Enhancing Spark SQL Optimizer with Reliable Statistics
 

Destacado

ARCHIVO GENERAL DE LA NACION
ARCHIVO GENERAL DE LA NACIONARCHIVO GENERAL DE LA NACION
ARCHIVO GENERAL DE LA NACIONbordaangela
 
Sistemas operativos
Sistemas operativosSistemas operativos
Sistemas operativosotamiel
 
Presentation of transport tracking system
Presentation of transport tracking systemPresentation of transport tracking system
Presentation of transport tracking systemArchana Negi
 
Workshop Google Adwords
Workshop Google AdwordsWorkshop Google Adwords
Workshop Google Adwordswilph
 
Владимир Кочетков. Как разработать защищенное веб-приложение и не сойти при э...
Владимир Кочетков. Как разработать защищенное веб-приложение и не сойти при э...Владимир Кочетков. Как разработать защищенное веб-приложение и не сойти при э...
Владимир Кочетков. Как разработать защищенное веб-приложение и не сойти при э...Positive Hack Days
 
Informativo n° 14 2º básico a- viernes 07 de junio.
Informativo n° 14  2º básico a- viernes 07 de junio.Informativo n° 14  2º básico a- viernes 07 de junio.
Informativo n° 14 2º básico a- viernes 07 de junio.Colegio Camilo Henríquez
 
Iuris leave colour
Iuris leave colourIuris leave colour
Iuris leave colourCrickh10
 
Palabras compuestas judith
Palabras compuestas judithPalabras compuestas judith
Palabras compuestas judithfrancalamaslinda
 
NUCCA Case Study Presentation - Post Concussion Syndrome
NUCCA Case Study Presentation - Post Concussion SyndromeNUCCA Case Study Presentation - Post Concussion Syndrome
NUCCA Case Study Presentation - Post Concussion SyndromeJon Chung
 
Chapter i(flash basic)
Chapter i(flash basic)Chapter i(flash basic)
Chapter i(flash basic)Chhom Karath
 
Cervical Arthritis / Cervical Spondylotic Myelopathy / Cervical Stenosis by P...
Cervical Arthritis / Cervical Spondylotic Myelopathy / Cervical Stenosis by P...Cervical Arthritis / Cervical Spondylotic Myelopathy / Cervical Stenosis by P...
Cervical Arthritis / Cervical Spondylotic Myelopathy / Cervical Stenosis by P...Pablo Pazmino
 
6 сценариев взаимодействия с потребителем
6 сценариев взаимодействия с потребителем6 сценариев взаимодействия с потребителем
6 сценариев взаимодействия с потребителемNimax
 

Destacado (18)

Bhakti Vedanta Darshana
Bhakti Vedanta DarshanaBhakti Vedanta Darshana
Bhakti Vedanta Darshana
 
ARCHIVO GENERAL DE LA NACION
ARCHIVO GENERAL DE LA NACIONARCHIVO GENERAL DE LA NACION
ARCHIVO GENERAL DE LA NACION
 
Sistemas operativos
Sistemas operativosSistemas operativos
Sistemas operativos
 
Presentation of transport tracking system
Presentation of transport tracking systemPresentation of transport tracking system
Presentation of transport tracking system
 
Workshop Google Adwords
Workshop Google AdwordsWorkshop Google Adwords
Workshop Google Adwords
 
Владимир Кочетков. Как разработать защищенное веб-приложение и не сойти при э...
Владимир Кочетков. Как разработать защищенное веб-приложение и не сойти при э...Владимир Кочетков. Как разработать защищенное веб-приложение и не сойти при э...
Владимир Кочетков. Как разработать защищенное веб-приложение и не сойти при э...
 
07 06 lesson-02
07 06 lesson-0207 06 lesson-02
07 06 lesson-02
 
Plan de comunicación 2.0
Plan de comunicación 2.0 Plan de comunicación 2.0
Plan de comunicación 2.0
 
Informativo n° 14 2º básico a- viernes 07 de junio.
Informativo n° 14  2º básico a- viernes 07 de junio.Informativo n° 14  2º básico a- viernes 07 de junio.
Informativo n° 14 2º básico a- viernes 07 de junio.
 
JoseOVazquez03
JoseOVazquez03JoseOVazquez03
JoseOVazquez03
 
Iuris leave colour
Iuris leave colourIuris leave colour
Iuris leave colour
 
Palabras compuestas judith
Palabras compuestas judithPalabras compuestas judith
Palabras compuestas judith
 
Winter DDS & Cut Plus - Esite
Winter DDS & Cut Plus - EsiteWinter DDS & Cut Plus - Esite
Winter DDS & Cut Plus - Esite
 
NUCCA Case Study Presentation - Post Concussion Syndrome
NUCCA Case Study Presentation - Post Concussion SyndromeNUCCA Case Study Presentation - Post Concussion Syndrome
NUCCA Case Study Presentation - Post Concussion Syndrome
 
FF style guide
FF style guideFF style guide
FF style guide
 
Chapter i(flash basic)
Chapter i(flash basic)Chapter i(flash basic)
Chapter i(flash basic)
 
Cervical Arthritis / Cervical Spondylotic Myelopathy / Cervical Stenosis by P...
Cervical Arthritis / Cervical Spondylotic Myelopathy / Cervical Stenosis by P...Cervical Arthritis / Cervical Spondylotic Myelopathy / Cervical Stenosis by P...
Cervical Arthritis / Cervical Spondylotic Myelopathy / Cervical Stenosis by P...
 
6 сценариев взаимодействия с потребителем
6 сценариев взаимодействия с потребителем6 сценариев взаимодействия с потребителем
6 сценариев взаимодействия с потребителем
 

Similar a Ch1

Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to pythonActiveState
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine LearningAmanBhalla14
 
R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011Mandi Walls
 
Programming with R in Big Data Analytics
Programming with R in Big Data AnalyticsProgramming with R in Big Data Analytics
Programming with R in Big Data AnalyticsArchana Gopinath
 
Advanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAdvanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAnshika865276
 
Introduction to R.pptx
Introduction to R.pptxIntroduction to R.pptx
Introduction to R.pptxkarthikks82
 
Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSonaCharles2
 
Introduction to R for data science
Introduction to R for data scienceIntroduction to R for data science
Introduction to R for data scienceLong Nguyen
 
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...HendraPurnama31
 
Data Analytics with R and SQL Server
Data Analytics with R and SQL ServerData Analytics with R and SQL Server
Data Analytics with R and SQL ServerStéphane Fréchette
 
Algorithmic techniques-for-big-data-analysis
Algorithmic techniques-for-big-data-analysisAlgorithmic techniques-for-big-data-analysis
Algorithmic techniques-for-big-data-analysisAtner Yegorov
 

Similar a Ch1 (20)

Migrating from matlab to python
Migrating from matlab to pythonMigrating from matlab to python
Migrating from matlab to python
 
R programming by ganesh kavhar
R programming by ganesh kavharR programming by ganesh kavhar
R programming by ganesh kavhar
 
R Introduction
R IntroductionR Introduction
R Introduction
 
R programmingmilano
R programmingmilanoR programmingmilano
R programmingmilano
 
Matlab_Harshal.pptx
Matlab_Harshal.pptxMatlab_Harshal.pptx
Matlab_Harshal.pptx
 
R programming & Machine Learning
R programming & Machine LearningR programming & Machine Learning
R programming & Machine Learning
 
R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011R for Pirates. ESCCONF October 27, 2011
R for Pirates. ESCCONF October 27, 2011
 
Programming with R in Big Data Analytics
Programming with R in Big Data AnalyticsProgramming with R in Big Data Analytics
Programming with R in Big Data Analytics
 
Advanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.pptAdvanced Data Analytics with R Programming.ppt
Advanced Data Analytics with R Programming.ppt
 
R language, an introduction
R language, an introductionR language, an introduction
R language, an introduction
 
Introduction to R.pptx
Introduction to R.pptxIntroduction to R.pptx
Introduction to R.pptx
 
MATLAB & Image Processing
MATLAB & Image ProcessingMATLAB & Image Processing
MATLAB & Image Processing
 
Mit6 094 iap10_lec05
Mit6 094 iap10_lec05Mit6 094 iap10_lec05
Mit6 094 iap10_lec05
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Slides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MDSlides on introduction to R by ArinBasu MD
Slides on introduction to R by ArinBasu MD
 
17641.ppt
17641.ppt17641.ppt
17641.ppt
 
Introduction to R for data science
Introduction to R for data scienceIntroduction to R for data science
Introduction to R for data science
 
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
Matplotlib adalah pustaka plotting 2D Python yang menghasilkan gambar berkual...
 
Data Analytics with R and SQL Server
Data Analytics with R and SQL ServerData Analytics with R and SQL Server
Data Analytics with R and SQL Server
 
Algorithmic techniques-for-big-data-analysis
Algorithmic techniques-for-big-data-analysisAlgorithmic techniques-for-big-data-analysis
Algorithmic techniques-for-big-data-analysis
 

Más de Chhom Karath

Más de Chhom Karath (20)

set1.pdf
set1.pdfset1.pdf
set1.pdf
 
Set1.pptx
Set1.pptxSet1.pptx
Set1.pptx
 
orthodontic patient education.pdf
orthodontic patient education.pdforthodontic patient education.pdf
orthodontic patient education.pdf
 
New ton 3.pdf
New ton 3.pdfNew ton 3.pdf
New ton 3.pdf
 
ច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptxច្បាប់ញូតុនទី៣.pptx
ច្បាប់ញូតុនទី៣.pptx
 
Control tipping.pptx
Control tipping.pptxControl tipping.pptx
Control tipping.pptx
 
Bulbous loop.pptx
Bulbous loop.pptxBulbous loop.pptx
Bulbous loop.pptx
 
brush teeth.pptx
brush teeth.pptxbrush teeth.pptx
brush teeth.pptx
 
bracket size.pptx
bracket size.pptxbracket size.pptx
bracket size.pptx
 
arch form KORI copy.pptx
arch form KORI copy.pptxarch form KORI copy.pptx
arch form KORI copy.pptx
 
Bracket size
Bracket sizeBracket size
Bracket size
 
Couple
CoupleCouple
Couple
 
ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣ច្បាប់ញូតុនទី៣
ច្បាប់ញូតុនទី៣
 
Game1
Game1Game1
Game1
 
Shoe horn loop
Shoe horn loopShoe horn loop
Shoe horn loop
 
Opus loop
Opus loopOpus loop
Opus loop
 
V bend
V bendV bend
V bend
 
Closing loop
Closing loopClosing loop
Closing loop
 
Maxillary arch form
Maxillary arch formMaxillary arch form
Maxillary arch form
 
Front face analysis
Front face analysisFront face analysis
Front face analysis
 

Último

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 

Último (20)

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Ch1

  • 2. S-PLUS • S-PLUS is a commercial implementation of the S programming language sold by TIBCO Software Inc.. • It features object-oriented programming capabilities and advanced analytical algorithms. • S-plus is an object-oriented programming and statistical analysis language developed primarily at AT&T research labs during the 1980's. Data in Splus is aggregated into "objects", which are of different types.
  • 3. S (programming language) • S is a statistical programming language developed primarily by John Chambers and (in earlier versions) Rick Becker and Allan Wilks of Bell Laboratories. The aim of the language, as expressed by John Chambers, is "to turn ideas into software, quickly and faithfully." • The two modern implementations of S are R, part of the GNU free software project, and S-PLUS. • History • "Old S“: S is one of several statistical computing languages that were designed at Bell Laboratories, and first took form between 1975–1976.[1] Up to that time, much of the statistical computing was done by directly calling Fortran subroutines; however, S was designed to offer an alternate and more interactive approach. Early design decisions that hold even today include interactive graphics devices (printers and character terminals at the time), and providing easily accessible documentation for the functions. • "New S“:The New S Language[4] (1988 Blue Book) was published to introduce the new features, such as the transition from macros to functions and how functions can be passed to other functionsMany other changes to the S language were to extend the concept of "objects", and to make the syntax more consistent (and strict). However, many users found the transition to New S difficult, since their macros needed to be rewritten. Many other changes to S took hold, such as the use of X11 and PostScript graphics devices, rewriting many internal functions from Fortran to C, and the use of double precision (only) arithmetic. The New S language is very similar to that used in modern versions of S-PLUS and R. • S4:Version 4 of S, often abbreviated S4, provides advanced object-oriented features. S4 classes differ markedly from S3 classes.
  • 4. Historical timeline • 1988: S-PLUS is first produced by a Seattle-based start-up company called Statistical Sciences, Inc. The founder and sole owner is R. Douglas Martin, professor of statistics at the University of Washington, Seattle. • 1993: Statistical Sciences acquires the exclusive license to distribute S and merges with MathSoft, becoming the firm's Data Analysis Products Division (DAPD). • 1995: S-PLUS 3.3 for Windows 95/NT. Matrix library, command history, Trellis graphics • 1996: S-PLUS 3.4 for UNIX. Trellis graphics, nlme library, hexagonal binning, cluster methods. • 1997: S-PLUS 4 for Windows. New GUI, integration with Excel, editable graphics. • 1998: S-PLUS 4.5 for Windows. Scatterplot brushing, create S-PLUS graphs from within Excel & SPSS. • 1998: S-PLUS is available for Linux & Solaris. • 1999: S-PLUS 5 for Solaris, Linux, HP-UX, IBM AIX, SGI Irix, and DEC Alpha. S-PLUS 2000 for Windows. nlme 3.3, quality control charting, new commands for data manipulation. • 2000: S-PLUS 6 for Linux/UNIX. Java-based GUI, Graphlets, survival5, missing data library, robust library. • 2001: MathSoft sells its Cambridge-based Engineering and Education Products Division (EEPD), changes name to Insightful Corporation, and moves headquarters to Seattle. This move is basically an "Undo" of the previous merger between MathSoft and Statistical Sciences, Inc.
  • 5. Historical timeline • 2001: S-PLUS Analytic Server 2.0. S-PLUS 6 for Windows (Excel integration, C++ classes/libraries for connectivity, Graphlets, S version 4, missing data library, robust library). • 2002: StatServer 6. Student edition of S-PLUS now free. • 2003: S-PLUS 6.2 New reporting, database integration, improved Graphlets, ported to AIX, libraries for correlated data, Bayesian methods, multivariate regressions. • 2004: Insightful purchases the S language from Lucent Technologies for $2 million. • 2004: S+ArrayAnalyzer 2.0 released. • 2005: S-PLUS 7.0 released. BigData library for working with larger-than-memory data sets, S-PLUS Workbench (Eclipse development tool). Insightful Miner 7.0 released. • 2007: S-PLUS 8 released. New package system, language extensions for R package compatibility, Workbench debugger. • 2008: TIBCO acquires Insightful Corporation [1
  • 6. Historical timeline • Data in S-plus is aggregated into "objects", which are of different types. The most common object types are: • vectors: ordered strings of data values (having no row or column orientation). All data must be of the same mode (e.g., all numeric, all character, all logical, etc.). • matrices: rectangular arrays, with rows and columns, of like-mode data. • data frames: rectangular arrays similar to SAS data sets. Columns and rows have identifying names. Columns (variables) may be of different modes. • lists: ordered collections of objects of possibly different types and modes. For example, a data frame, several matrices, and a vector or two can be joined to form a list. • There are many other kinds of objects, including time series objects, array objects, and factor objects.
  • 7. Installation • System requirements • A PC with Pentium processor • 32 MB internal memory (64 MB recommended) • 75 MB of free hard disk space • CD-ROM drive • Microsoft Windows 95/98/Me, Windows NT (4.0 or higher) or Windows 2000
  • 8. INTRODUCTION • Simple arithmetical ,Don't forget a RETURN after each statement. The first > on each line is the Splus prompt • 3+5 • 4*5 • 8*(3+6) • The colon operator is used to obtain sequences • 1:7 • Vectors can be made with the function c() (c for 'combine') • c(3, 4, 1, 6) • MISTAKES • 32 1+1 • 0.5(2+4) • SPACES AND RETURN • 31+ 4 • 31 + 4 ok • 3 1 +4 Error • UPPER AND LOWER CASE: case sensitive • sex <- 'female‘ Different from SEX<-’female’
  • 9. INTRODUCTION • Comment ##, or # • CONTINUATION:continuation prompt + • 3 * + 6 • c(3, 4, 1, 6 + ) •?log •sqrt(x) •exp(x) • ONLINE HELP:on-line help on all functions, operators or data sets • help('c') • Help(seq) • Help() • Types of data objects include vectors, matrices, lists, data frames, arrays, categories, time series and functions. • Vectors have the attributes length and mode • mode(c(-2.0, 3.1, 4.7, 6.9)) • length(c(-2.0, 3.1, 4.7, 6.9)) • mode(c(T, T, F, T, T, F, F, F, F)) • mode(c('orc', 'troll', 'gnome', 'elf', 'hobbit')) • mode(c('hello', 1, T))
  • 10.
  • 11. ASSIGNMENT • the assignment operator <- • x <- c(4, 2, 8, 7), x+10,x+y,x/*+y • Print(x) or x or length(x) • We can overwrite with x<-199 • To remove x write:rm(x) • Be careful with minus signs when assigning objects • x <-- 4 or x <- -4 • y <- 1:10 • Y1<-seq(1,5,1) • everything get stored • objects() • OPERATORS:+ - * / ^ (exponentiation) • 2^3*4 • 2^(3*4) • x <- 5 • 1:(x-1) • 1:x-1 • 1:3^2 • x <- c(2, 1, 4, 5) => x+1 Ex:2*x, x^2, sin(x)
  • 12. ASSIGNMENT • EX: y <- c(1, 2, 1, 2) • x+y, x*y , x/y , z <- c(2, 4, 6), x + z • y==6:10, x=2:9, z=c(x,y) • MATRIX DATA OBJECTS • A matrix in S-PLUS is a two-way array • x <- matrix(1:12, nrow=3, ncol=4) • Show length of row and column: dim(x) • length(x) show length of number • mode(x) show data type • S-PLUS is clever enough not to need both the number of rows and the number of columns • matrix(1:12, nrow=3) • Notice that the matrix has been filled down the columns first. This is the DEFAULT. • matrix(1:12, nrow=3, byrow=T) • DATA FRAME OBJECTS :A data frame consists of rows and columns of data, just like a matrix object, except that the COLUMNS can be different modes. • firstnames <- c('Kate', 'Linda', 'Edgar', 'Chelsea') • lastnames <- c('Beatty', 'Colpoys', 'Gonzales', 'Miller') • height <- c(165, 170, 180, 168) • class.height <- data.frame(firstnames,lastnames,height)
  • 13. ASSIGNMENT • seq1 <- seq(1:6) mat1 <- matrix(seq1, 2) mat1 • mat2 <- matrix(seq1, 2, byrow = T) • matrix(rnorm(20), 4) • #appending v1 to mat5 v1 <- c(1, 1, 2, 2) mat6 <- cbind(mat5, v1) • v2 <- c(1:6) mat7 <- rbind(mat6, v2) • #determining the dimensions of a mat7 dim(mat7) • matrix_name[row#, col#] mat7[1, 6] • #to access an entire row leave the column number blank mat7[1, ] •#to access an entire column leave the row number blank mat7[, 6] •#Creating mat8 and mat9 mat8 <- matrix(1:6, 2) •mat9 <- matrix(c(rep(1, 3), rep(2, 3)), 2, byrow = T) •#addition mat9 + mat8 •mat9 + 3 •#subtraction mat8 - mat9 •#inverse •solve(mat8[, 2:3]) #transpose t(mat9) •cbind(B, C) •D = matrix( + c(6, 2), + nrow=1, + ncol=2) •Deconstruction:We can deconstruct a matrix by applying the c function, which combines all column vectors into one. •c(B)
  • 14. ASSIGNMENT • seq1<-seq(1:6) mat1<-matrix(seq1,2,3,byrow=F) v1<-c(9,8) mat2<-cbind(mat1,v1) mat2 • seq1<-seq(1:6) mat1<-matrix(seq1,2,3,byrow=F) v1<-c(9,8,0) mat2<-rbind(mat1,v1) mat2 mat2[3,3] • mat1<-matrix(rep(1,16),4,4) mat2<-matrix(rep(4,16),4) mat3<-mat1+mat2 mat3 •mat9 <- matrix(c(rep(1, 3), rep(2, 3)), 2, byrow = T) Mat9 •#transpose t(mat9) • B = matrix( + c(2, 4, 3, 1, 5, 7), + nrow=3, + ncol=2) •> c(B) [1] 2 4 3 1 5 7
  • 15. • use of the function data.frame() • class.height • LIST OBJECTS: They are even more general than data frames • junklist <- list(x=firstnames,y=height,z=X) • junklist • ?
  • 16. • ADDING NAMES: it is useful to add names to vectors • x <- (1:5)^2 • x • days <- c('Mon', 'Tue', 'Wed', 'Thu', 'Fri') • names(x) <- days • X
  • 17. • REP AND SEQ • repeat function rep() and the sequence function seq() are useful functions which can be used to make vectors and matrices. • seq(from=0.3, to=1, by=0.1) • Note that S-PLUS doesn't care about the order the arguments of a function when they are given names, as above. • seq(to=1, by=0.1, from=0.3) • But if you leave out the names, you must keep to a standard order: from,to, by • seq(0.3, 1, 0.1) • seq(f=0.3, b=0.1, t=1) • rep() makes a repeat of an input either a certain number of times, or to a certain length. • rep(1, length=4) • rep(1:4, l=12) • rep(1:4, l=9) • rep() just fills in until it runs out of length. Another use of times is when times is a vector. • rep(c(4, 6, 5), t=c(1, 2, 3))
  • 18. • SUBSETS OF DATA • x <- c(5, 14, 8, 9, 10) • To display a single element we use square brackets x[1] • To display more than one element at a time, use the c() function within the [] characters. • Eg. to get the 3rd and 5th characters use x[c(3, 5)] • Negation is useful to display all elements except those that are specified. Try • x[-4] • x[-c(1, 3)] • Logical expressions are a more sophisticated and VERY USEFUL tool. • x[x>8] • we can assign this to another vector of length 3 with • biguns <- x[x>8] • it is convenient to define a vector with logical entries as in
  • 19. • Data Frame Object • row and columns of data, like matrix but columns • can be different mode. • Syntax function: mydata<-data.frame(col1,col2,col3...) • ls() : show all variable • class(varName): show mode of varName • remove(varName): remove variable • names(varObject): show variale in varObject • village$age=age EX1: patientID<-c(1,2,3,4) age<-c(25,34,38,52) diabetes<-c("Type1","Type2","Type1","Type1") status<-c("Poor","Improved","Excelent","Poor") patientData<-data.frame(patientID,age,diabetes,status) print(patientData) EX2: #patientData[1:3] #patientData[c("status","age")]
  • 20. • Data Frame Object • attach: make variable in dataframe to work space • plot(age,height) : show linear regression activity • List • x<-list(name='Chan chav',sex='M',salary=200,age=25) • y<-list(name='Tav minsour',sex='F',salary=100,age=20) • z<-c(x,y) • z • #x[[2]] • #x["name"] • x[["name"]]
  • 21. Control Structures • x == y "x is equal to y" • x != y "x is not equal to y" • x > y "x is greater than y" • x < y "x is less than y" • x <= y "x is less than or equal to y" • x >= y "x is greater than or equal to y" • if(1==0){ print(1)} else{ print(2)} • + Ifelse Statements • Syntax: • ifelse(test,true_value,false_value) • Ex: x<-1:10 ifelse(x<5 | x>8,x,0) •EX: score<-10 if(score<5) { print("FAIL"); } else { print("Pass");} •EX2: score<-1; ifelse(score<5,"FAIL","PASS"); •EX3: x <- 1:10 ifelse(x<5 | x>8, x, 0) •EX4: •x <- 1 while(x < 5) {x <- x+1; print(x);} •next can skip one step of the loop. •break will end the loop abruptly. •which() function gives the TRUE indices of a logical object, allowing for array indices. •which(letters=="a") •LOOP x <- 1 while(x < 5) {x <- x+1; if (x == 3) break; print(x); } •EX6: x <- 1 while(x < 5) {x <- x+1; if (x == 3) next; print(x);}
  • 22. Control Structures • Loops • for (k in 1:5){ print(k) } • while (g < 1) { g <- rnorm(1) + cat(g,"n") } • repeat is similar to while and for loop, it will execute a block of commands repeatly till break. • sum <- 1 repeat { sum <- sum + 2; print(sum); if (sum > 11) break; } • The break statement can be used to terminate the loop abruptly •EX: samples <- c(rep(1:10)) samples •EX1: x<-0; while (x < 10) { x<- x+4; print (x); } EX2: x<-0; while (x < 10) { x <- x + 4; print (x); if ( x = 8) { break; } } •EX3: samples<-c(1:10) for (thissample in samples) { str <- paste(thissample,"is current sample",sep=" ") print(str) } EX4: end <- length(samples) begin <- end - 2 for (thissample in begin:end) { str <- paste(thissample,"is current sample",sep=" ") print(str) }
  • 23. array • R Array: • + syntax: • array(data,dim) • Note: data: vector fill the array • dim: row and col number • EX: • x <- array(1:6,c(2,3)) • x • Ex: • x <- 1:64#declare vector(1->64) • dim(x)<- c(2,4,8)#convert vector x to array row=2 • #col=4 number eleement=8 • is.array(x)#test wheter array or not • x#show element of array EX: show all event of array x[1,,] EX: x[2,2,] # show row 2 column 2

Notas del editor

  1. v1<-10 v2<-20 v3<-v1+v2 v4<-v1-v2 v5<-v1*v2 v6<-v1/v2 paste(v1,"+",v2,"=",v3) paste(v1,"-",v2,"=",v4) paste(v1,"*",v2,"=",v5) paste(v1,"/",v2,"=",v6)
  2. money<-64 money100<-as.integer(money/100) money<-money%%100 money50<-as.integer(money/50) money<-money%%50 money20<-as.integer(money/20) money<-money%%20 money10<-as.integer(money/10) money<-money%%10 money5<-as.integer(money/5) money<-money%%5 money2<-as.integer(money/2) money<-money%%2 money1<-as.integer(money/1) paste("Money 100$=",money100,"sheet") paste("Money 50$=",money50,"sheet") paste("Money 20$=",money20,"sheet") paste("Money 10$=",money10,"sheet") paste("Money 5$=",money5,"sheet") paste("Money 2$=",money2,"sheet") paste("Money 1$=",money1,"sheet")
  3. v1<-100 v2<-200 if(v1>v2) { min<-v2 max<-v1 } else { min<-v1 max<-v2 } print(min) print (max) gender<-"Male"; ifelse(gender=="Female","Wife","Husband"); EX: i<-0; tmp<-""; while(i<10) { if(i%%2==0) { tmp=cbind(i," is even"); } else { tmp=cbind(i," is odd"); } print(tmp); if(i==5) { break; } i=i+1; }
  4. v1<-100 v2<-200 if(v1>v2) { min<-v2 max<-v1 } else { min<-v1 max<-v2 } print(min) print (max)
  5. v1<-100 v2<-200 if(v1>v2) { min<-v2 max<-v1 } else { min<-v1 max<-v2 } print(min) print (max)