Introduction to S-PLUS version 4.5 (WIN95/NT)

Download Report

Transcript Introduction to S-PLUS version 4.5 (WIN95/NT)

Introduction to S-PLUS
(Win2000/NT)
「統計計算與模擬」
第二週補充教材
2015/7/21
Preliminaries
History of S-Plus
Open Source, Public Domain version of
the “S” language
Example of using “R” in a teaching
context
Useful resources
2015/7/21
The History of S-Plus
The S Language is developed by AT&T Bell Labs
1980’s
The commercial value-added version marketed
by Stat-Sci Inc.
MathSoft acquires Statsci in 1992 (markets
MathCad software)
S-Plus 4.0 released in 1997
S-Plus 4.5 released in 1998 (WIN95/NT)
S-Plus 2000 released in 2000 (marketed by
Insightful Corp: http://www.insightful.com)
S-Plus 6.0 released in fall 2001
2015/7/21
Open Source Version of
the “S” language
“R” is an open source version of the “S”
language (http://www.cran.r-project.org)
Implemented for Linux, Windows,
Macintosh
No GUI, only command interface
Has many libraries available covering
almost all areas of modern statistics
2015/7/21
An Example of Using R through a
Web Application Server
http://www.unt.edu/benchmarks/october0
1/rss.htm
Programs can be submitted through a
web browser interface
Programs can be modified and
resubmitted to get new results
Useful as a teaching aid
2015/7/21
Useful Resources
http://www.insightful.com/
 The Basics of S and S-PLUS (second edition)
Andreas Krause and Melvin Olson
Springer-Verlag, New York (2000)
 An introduction to S-PLUS and the Hmisc and Design
libraries C.F. Alzola and F.E. Harrell, Freely available
document
 Regression Modeling Strategies with Applications to
Linear Models, Logistic Regression, and Survival
Analysis F.E. Harrell, Springer (2001)
2015/7/21
Use Resources (cont.)
 Modern Applied Biostatistical Methods Using S-PLUS
S. Selvin, Oxford University Press (1998)
ISBN 0-19-512025-6
 Introduction to Robust Estimation and Hypothesis
TestingRand Wilcox, Academic Press (1997)
ISBN 0-12-751545-3
 WebLinks (S-news listserve, and Software archive)
http://lib.stat.cmu.edu/s-news/
http://lib.stat.cmu.edu/S/
2015/7/21
Features of S-Plus
S-Plus is an objected oriented
programming language
Version 2000 has a GUI which is
extensible
S-Plus has over 3,000 functions which
allow total control of data and graphics
S-Plus 2000 accommodates data analysts
from novice to expert
There is a very active S-Plus user group
(S-news)
2015/7/21
Getting Help in S-Plus
Help for general tasks, S-Plus functions, etc.
Can use the Help index from GUI interface
Alternatively can use help function in the
Command Window
Example: In the command window at the “>”
prompt type,
> help(help)
> help(scan)
**help on help**
**help on scan() function**
General Help: Help Menu from GUI
Function index, keyword search, on-line manuals (user
manual, programmer manual, statistics manual, visual
2015/7/21demo
How to stop computations
or quit an S-Plus session
To cancel an ongoing computation, press ESC
Cancels long outputs
Aborts long computations
To quit from S-Plus
From GUI use “File-Exit”
From Command Window use
>q()
2015/7/21
Getting Data into S-Plus
Dialog box starts
up as a default
Select existing data
or import data from
a file
For existing data,
enter the name of
an S-Plus object in
the Name box
2015/7/21
Data Import Options
Select the Options tab for import options
By default, ASCII files are assumed to have:
column labels on row 1 (blank rows ignored)
data from row 2 on
columns are seperated by whitespace or comma
Can change defaults with import options
First data line, separators, column specifications
Note: *.dat files are assumed to be GAUSS files
2015/7/21
Data Objects
When data are imported, the data are
displayed in a data window and a new
object is created
The name of the data object is chosen
from the file name, or can be specified in
the import dialog
2015/7/21
Data Window
The data appears in a spreadsheet
This includes row names and column
names
Can click on a column name to select a
column
Use shift-click to select a block of columns
Use ctrl-click to select non-adjacent
columns
2015/7/21
Data Window (cont.)
The order of selection is important
(selected columns will be used in graphs
and analyses)
2015/7/21
Object Browser
2015/7/21
S-Plus is object
oriented
All data, functions,
results from analyses,
plots, etc., are objects
The object browser
organizes all the
objects you create
Left half - object type;
Right half - list of
objects
Command Window
2015/7/21
Every menu and toolbar
generates the S-Plus
command language
S-Plus is a complete
programming language
This language has loops,
functions, expressions,
and is object oriented
Most of the functionality
and flexibility of S-Plus is
accessed through the
language
Creating Graphs
Open “GRAPH - 2D
Plot”, or “GRAPH 3D Plot” menu option
Select column(s) for
plotting from the
Data Window
ctrl-click the column
for the x-axis
ctrl-click the column
for the y-axis
2015/7/21
Creating Graphs (cont.)
ctrl-click the column
for the z-axis if
needed
click on the palette
button for the desired
plot
2015/7/21
Creating Trellis Graphics
2015/7/21
Any plot can be
conditioned by the
value of any other
variable in the data
First create a plot,
then select the
conditioning column
in the data window
Drag the column
(grabbing a cell) to
the title area of plot
Creating Trellis Graphics
(cont.)
The cursor will
change to a “+” when
ready to drop
The plot is redrawn
with panels for
subranges of the
conditioning variable
2015/7/21
The S-Plus Language
Expressions are
entered at the
prompt: “>”
S-Plus prints out the
result
2015/7/21
> 3+3
[1] 6
> sin(pi)
[1] 1.224606e-016
> sqrt(100)
[1] 10
Additional prompt
An incomplete
expression leads to a
second prompt: “+”
Can continue at the
second prompt
2015/7/21
> sqrt(
+ 100)
[1] 10
Getting stuck at “+”
prompt
If the “+” prompt
continues after hitting
return, then enter
many “)” to get the
“>” prompt
Then start your
expression again
2015/7/21
> sqrt(
+
+ )))))
Error in parse(text = txt): Syntax error: No
opening parenthesis, before ")" at this
point:
sqrt(
))
Dumped
> sqrt(100)
Scalars and Assignments
Read this as “weight”
gets 190
This assigns the value
190 to the scalar
named weight
The assignment
operator is the
sequence of
characters: “<-”
2015/7/21
> weight<-190
> weight
[1] 190
Character Assignments
Character values are
inserted in quotes
If the quotes are
omitted, S-Plus will
look for a data object
called, Jim , to assign
to person
The result is not
printed until you enter
the object name
2015/7/21
> person<-"Jim"
> person
[1] "Jim"
Vectors
The function: rnorm( ),
returns a vector of
random deviates from
the normal distribution
The [n] on the left
shows where the row
starts
2015/7/21
> rnorm(10)
[1] 0.3037020
[2] -0.5248669
[3] 1.4674553
[4] 0.4536315
[5] 0.4077797
[6] 0.5362221
[7] 0.0759569
[8] 0.3239556
[9] -1.3531665
[10] -2.4226150
Vectors (cont.)
A single number is a
vector of length 1
We can make vectors
using the
concatenation
function: c( )
We assign the
integers 1,2,3 to the
vector x
2015/7/21
> mean(rnorm(10))
[1] 0.5807564
> x<-c(1,2,3)
>x
[1] 1 2 3
Vectors (cont.)
We can create a
vector of names
We can create a
vector of sequential
integers using the
function: a:b , where
a is the starting
integer and b is the
ending integer
2015/7/21
> people<-c("Jim", "Sue", "Dave")
> people
[1] "Jim" "Sue" "Dave"
> 5:10
[1] 5 6 7 8 9 10
Object Names
Object names may
contain,
Letters: abcDEF
Numbers: 0123456789
Dot: .
2015/7/21
Examples of valid
names:
height
weight
x.var
.yvar
x.y.var
x110
Object names (cont.)
Objects names
cannot use an
underscore, a
hyphen, begin with a
number, or use
reserved symbols
2015/7/21
Examples of invalid
object names
_xvar
y_var
x-yvar
120xvar
T
F
NA
Handling Objects
We can list out all of the objects
> objects()
[1] ".Last.value" ".Random.seed" "Cars"
[5] "last.warning" "people"
"person"
[9] "weights"
"x"
"last.dump"
"weight"
Objects remain until removed, even if one quits S-Plus
> rm(x)
>x
Error: Object "x" not found
Dumped
Equivalently, you can use the object browser
2015/7/21
Objects as variables
Objects can be used
in expressions
2015/7/21
> x<-1:10
> mean(x)
[1] 5.5
> y<-c(x,10)
> length(y)
[1] 11
> 2*y
[1] 2 4 6 8 10 12 14 16 18 20 20
Vector Arithmetic
Scalar Functions work
on elementwise basis
Can perform scalar
and vector arithmetic
2015/7/21
> x<-1:5
> x^2
[1] 1 4 9 16 25
> 2*x
[1] 2 4 6 8 10
> 2*x+sqrt(x)
[1] 3.000000 5.414214
[3] 7.732051 10.000000
[5] 12.236068
Logical Vectors
Expressions with
relational operators
return logical vectors
T is True, F is False
2015/7/21
> x<-rnorm(5)
>x
[1] 1.2698616 -1.1080517
[3] 0.5627334 0.2454234
[5] 0.2919052
> x<0
[1] F T F F F
Missing values
A missing value is
represented by NA
Operations on NA
return NA
The function is.na( )
checks for missing
values
2015/7/21
> x<-c(1, NA, 3)
>x
[1] 1 NA 3
> x+1
[1] 2 NA 4
> sum(x)
[1] NA
> is.na(x)
[1] F T F
Vector indexing
Use brackets, [ ] to
select elements of a
vector
Negative indices
remove elements
2015/7/21
> x<-c(2,4,6,8,10)
>x
[1] 2 4 6 8 10
> x[1]
[1] 2
> x[3:5]
[1] 6 8 10
> x[c(1,3,5)]
[1] 2 6 10
> x[-(1:3)]
[1] 8 10
Logical Indices
A logical index selects
elements
Symbols for logical
operators:
<
>
<=
>=
==
!
!=
2015/7/21
Less than
Greater than
Less than or equal to
Greater than or equal to
Equal to
Negation operator
Not equal to
> x<-rnorm(5)
>x
[1] -2.4592950 0.9074605
[3] 0.5088648 -1.1184415
[5] 0.5137160
> x[x<=0]
[1] -2.459295 -1.118441
> log.x<-log(x)
Warning messages:
NAs generated in: log(x)
> x[is.na(log.x)]
[1] -2.459295 -1.118441
> log.x[!is.na(log.x)]
[1] -0.09710521 -0.67557299
[3] -0.66608473
Replacement
You can use [ ] on
the left hand side of
an assignment, <-
2015/7/21
> x<-sample(1:8)
>x
[1] 2 6 8 3 1 5 7 4
> x[6]<-NA
>x
[1] 2 6 8 3 1 NA 7 4
> x[is.na(x)]<-0
>x
[1] 2 6 8 3 1 0 7 4
Functions
Functions are called
like this:
function.name(argument, argument, ….)
Functions always
return a value
 NULL represents no
value
Example:
seq(from=1, to=end, by=1,
length=inferred, along=NULL)
2015/7/21
> seq(1,5)
[1] 1 2 3 4 5
> seq(10, 20, length=6)
[1] 10 12 14 16 18 20
> seq(to=100, by=15, length=7)
[1] 10 25 40 55 70 85 100
> seq(length=10)
[1] 1 2 3 4 5 6 7 8
[9] 9 10
Functions (cont.)
Function arguments have:
position(first, second, ….)
function name
default values for function
options (sometimes)
Examples:
rnorm(n, mean=0, sd=1)
rep(x, times=inferrred,
length.out=inferred)
2015/7/21
> rep(1:3,2)
[1] 1 2 3 1 2 3
> rep(1:3, length=8)
[1] 1 2 3 1 2 3 1 2
> rep(1:3, c(3,2,1))
[1] 1 1 1 2 2 3
> rep()
Error in rep: Argument "x" is
missing, with no default:
rep() Dumped
> rep(1:3, c(3,2,1), 5)
[1] 1 2 3 1 2
Matrices
matrix(data=NA, nrow=inferred,
ncol=inferred, byrow=F,
dimnames=NULL)
The function matrix( )
reads data into a matrix
The number of columns is
specified by using the
argument ncol=#
And/Or the number of
rows can be specified by
the argument, nrow=#
2015/7/21
> x<-matrix(1:10, nrow=2)
>x
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
> dim(x)
[1] 2 5
> x.matrix<-matrix(c(20,10,3,1,7,4),
ncol=2)
> x.matrix
[,1] [,2]
[1,] 20 1
[2,] 10 7
[3,] 3 4
Matrices (cont.)
We can attach names to columns with the
dimnames option:
> x<-matrix(c(1:20), ncol=4, byrow=T, dimnames=list(NULL, c("col1", "col2", "col3",
"col4")))
>x
col1 col2 col3 col4
[1,]
1 2
3
4
[2,]
5 6
7
8
[3,]
9 10 11 12
[4,] 13 14 15 16
[5,] 17 18 19 20
2015/7/21
Matrices (cont.)
Specifying byrow=T
forces S-Plus to read
the data in row by
row
When the argument is
not specified, or
specified as byrow=F ,
S-Plus assumes the
data is written in
column by column
2015/7/21
> x.matrix<-matrix(c(20,10,3,1,7,4),
ncol=2, byrow=T)
> x.matrix
[,1] [,2]
[1,] 20 10
[2,] 3 1
[3,] 7 4
Matrices (cont.) - Indexing
> x<-matrix(1:15, nrow=3,
byrow=T)
To extract a value from a
matrix, use two elements
in the subscript
The first element applies to
rows
The second element
applies to columns
If one dimension is not
specified, all elements for
that dimension are
extracted
2015/7/21
>x
[,1] [,2] [,3] [,4] [,5]
[1,] 1 2 3 4 5
[2,] 6 7 8 9 10
[3,] 11 12 13 14 15
> x[2,3]
[1] 8
> x[2:3, 3:5]
[,1] [,2] [,3]
[1,] 8 9 10
[2,] 13 14 15
> x[,1]
[1] 1 6 11
> x[1,]
[1] 1 2 3 4 5
Constructing Matrices from vectors
Matrices can be constructed
from row vectors and column
vectors using cbind and rbind
Binding together vectors of
different attributes (character
and numeric for example), is
not allowed - vectors will be
coerced to a similar attribute
Numeric and character vectors
will be coerced to character
2015/7/21
> x <- c(3,4,5)
> y <- c(6,7,8)
> x.y<-cbind(x,y)
> x.y
xy
[1,] 3 6
[2,] 4 7
[3,] 5 8
> x <- c(3,4,5)
> x <- c(6,7,8)
> x.y<-rbind(x,y)
> x.y
[,1] [,2] [,3]
x 3 4 5
y 6 7 8
Constructing Matrices from vectors
(cont.)
Example: binding
together a character
vector and a numeric
vector coerces to a
character matrix
What is need is a
data object called a
data frame (similar to
SPSS or SAS
datasets)
2015/7/21
>
>
>
>
x <- c(3,4,5)
y <- c("Three","Four","Five")
x.y<-rbind(x,y)
x.y
[,1] [,2] [,3]
x "3"
"4" "5"
y "Three" "Four" "Five"
Converting Matrices to
Data Frames
Data Frames are a data
object that allows one to
bind data vectors of
different types together,
such that the data can be
accessed like a matrix
Most of the dialog boxes in
the GUI operate on Data
Frames
2015/7/21
>
>
>
>
x <- c(3,4,5)
y <- c("Three","Four","Five")
x.y<-data.frame(x, y)
x.y
x
y
1 3 Three
2 4 Four
3 5 Five
Arrays
An array is a data
construct that can be
thought of as a multidimensional (up to
eight dimensions)
An array is defined as
array(data, dim)
If we fix second index
at 2 we get a 3x2
matrix
2015/7/21
> x<-array(1:24, c(3, 4, 2))
>x
,,1
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
[,4]
10
11
12
,,2
[,1] [,2] [,3] [,4]
[1,] 13 16 19 22
[2,] 14 17 20 23
[3,] 15 18 21 24
> x[,2,]
[,1] [,2]
[1,] 4 16
[2,] 5 17
[3,] 6 18
The apply( ) function
> x<-matrix(c(1:10), ncol=2, byrow=T)
The apply function
successively applies a
function of your
choice to each row,
each column, and
each level of a higher
dimension of a matrix
or array:
apply(data, dim, function)
2015/7/21
>x
[,1] [,2]
[1,] 1 2
[2,] 3 4
[3,] 5 6
[4,] 7 8
[5,] 9 10
> x.log<-apply(x, 2, log)
> x.log
[,1]
[,2]
[1,] 0.000000 0.6931472
[2,] 1.098612 1.3862944
[3,] 1.609438 1.7917595
[4,] 1.945910 2.0794415
[5,] 2.197225 2.3025851
Lists
A List is an ordered
collection of arbitrary
objects
A list can be indexed
like a matrix or array
Index an element of
a list by using:
listname$elementname
listname[[index]]
listname$elementname[index]
2015/7/21
> xlist<-list(dat=1:5, name="John", y=c(32, 45))
> xlist
$dat:
[1] 1 2 3 4 5
$name:
[1] "John"
$y:
[1] 32 45
> xlist$dat
[1] 1 2 3 4 5
> xlist$name
[1] "John"
> xlist$y
[1] 32 45
> xlist[[3]]
[1] 32 45
> names(xlist)
[1] "dat" "name" "y"
> xlist$dat[2]
[1] 2
lapply( ) function
> L<-list(vec=1:10, mat=matrix(99:88, 3,4))
The tool lapply ( ) is
designed for working
on all elements of a
list using the same
function
Example: Calculate
the mean of every list
element
>L
$vec:
[1] 1 2 3 4 5 6 7 8 9 10
$mat:
[,1] [,2] [,3] [,4]
[1,] 99 96 93 90
[2,] 98 95 92 89
[3,] 97 94 91 88
> lapply(L, mean)
$vec:
[1] 5.5
$mat:
[1] 93.5
2015/7/21
lapply () function (cont.)
 Can use the lapply to
apply an arbitrary
function to the
corresponding elements
of two lists
 Example: Take the
mean of elements in
first list position, and
add the mean of
elements in the first
position of a second list
2015/7/21
> list1 <- list(c(2,4,6,8), c(10,12,14,16))
> list2 <- list(c(18,20,22,24),
c(26,28,30,32))
> lapply(1:2, function(i, x, y) mean(x[[i]]) +
mean(y[[i]]), x = list1, y = list2)
[[1]]:
[1] 26
[[2]]:
[1] 42
unlist() function
Simplifies the
recursive structure of
a list
Usage:
unlist(data,
recursive=T,
use.names=T)
Example: Create a
vector from a list with
two elements
2015/7/21
> x.list<-list(c(2,4,6,8), c(10,12,14,16),
c(18,20,22,24))
> x.list
[[1]]:
[1] 2 4 6 8
[[2]]:
[1] 10 12 14 16
[[3]]:
[1] 18 20 22 24
> unlist(x.list)
[1] 2 4 6 8 10 12 14 16 18 20 22 24
Creating Functions
Functions allow
modular
programming
Functions can “call”
other functions
Functions have calling
parameters enclosed
in parenthesis with
the main body
inclosed in braces
2015/7/21
> x.power<-function(x, power){
x<-x^power
x}
> x<-c(2,4,6,8)
> x.power(x, 2)
[1] 4 16 36 64
> x.power(x, 3)
[1] 8 64 216 512
Looping
Looping can allow
iteration over indices
of a scalar, vector,
matrix, or list
Looping is slow in
S-Plus: vector
operations are
encouraged
2015/7/21
> temp<-0
> for (i in 1:4){
temp<-i+temp}
> temp
[1] 10
ifelse() function
Compares the
elements of two
objects according to
some boolean
statement
Can return scalar or
vector values for a
true condition, and a
different set of values
for a false condition
2015/7/21
> x<-c(1,3,5)
> y<-c(6,4,2)
> z<-ifelse(x<y, 1, 0)
>z
[1] 1 1 0
Matrix Algebra
Transpose: t( )
Matrix Multiply: %*%
> x<-cbind(rep(1,5), 1:5)
>x
[,1] [,2]
[1,] 1 1
[2,] 1 2
[3,] 1 3
[4,] 1 4
[5,] 1 5
> t(x)
[,1] [,2] [,3] [,4] [,5]
[1,] 1 1 1 1 1
[2,] 1 2 3 4 5
>
> t(x)%*%x
[,1] [,2]
[1,] 5 15
[2,] 15 55
>
2015/7/21
Matrix Algebra (cont.)
Matrix Inverse: solve ()
> solve(t(x)%*%x)
[,1] [,2]
[1,] 1.1 -0.3
[2,] -0.3 0.1
>
Matrix Decompositions
Eigenvector: eigen ( )
Singular Value: svd ( )
Cholesky: chol ( )
> eigen(solve(t(x)%*%x))
$values:
[1] 1.18309519 0.01690481
$vectors:
[,1]
[,2]
[1,] 0.9637149 0.2669336
[2,] -0.2669336 0.9637149
2015/7/21
Exercises (a)
Create the following
matrix called marks
and put in the
appropriate label
names
2015/7/21
> marks
Test1 Test2
[1,] 20 23
[2,] 16 15
[3,] 25 20
[4,] 14 19
Test3
18
18
22
18
Final
48
40
40
42
Solutions (a)
> marks<-matrix(c(20,23,18,48,16,15,18,40,25,20,22,40,14,19,18,42),byrow=T,
+ nrow=4,dimnames=list(NULL,c("Test1","Test2","Test3","Final")))
2015/7/21
Exercises (b)
Add the following row to the bottom of
the matrix:
10
2015/7/21
15
14
30
Solutions (b)
> marks<-rbind(marks,c(10,15,14,30))
> marks
Test1 Test2 Test3 Final
[1,] 20 23 18 48
[2,] 16 15 18 40
[3,] 25 20 22 40
[4,] 14 19 18 42
[5,] 10 15 14 30
2015/7/21
Exercises (c)
Change the fifth mark for test #2 from a
15 to a 17
2015/7/21
Solutions (c)
> marks[5,2]<-17
> marks
Test1 Test2 Test3
[1,] 20 23 18
[2,] 16 15 18
[3,] 25 20 22
[4,] 14 19 18
[5,] 10 17 14
2015/7/21
Final
48
40
40
42
30
Exercises (d)
Print all the marks for test #3
2015/7/21
Solutions (d)
> marks[, 3]
[1] 18 18 22 18 14
2015/7/21
Exercises (e)
Print the final marks for those people with
marks greater than 16 on test #1
2015/7/21
Solutions (e)
> marks[marks[,1]>16,1]
[1] 20 25
2015/7/21
Exercises (f)
Print the marks matrix without the column
for test #3
2015/7/21
Solutions (f)
> marks[,-3]
Test1 Test2
[1,] 20 23
[2,] 16 15
[3,] 25 20
[4,] 14 19
[5,] 10 17
2015/7/21
Final
48
40
40
42
30
Exercises (g)
Print the number of rows in the matrix
2015/7/21
Solutions (g)
> nrow(marks)
[1] 5
2015/7/21
Additional Exercises
Create a vector INTS containing the integers
from 1 to 50
Create a vector X which is 2 to the power of
INTS
Create a vector Y which is INTS raised to the
second power
Create a T/F vector which contains a T when
elements of x and y are equal and an F when
they are not equal
2015/7/21
Solutions to additonal
exercises
> X<-2^INTS
> Y<-INTS^2
>X
[1] 2.000000e+000 4.000000e+000 8.000000e+000 1.600000e+001 3.200000e+001 6.400000e+001 1.280000e+002
[8] 2.560000e+002 5.120000e+002 1.024000e+003 2.048000e+003 4.096000e+003 8.192000e+003 1.638400e+004
[15] 3.276800e+004 6.553600e+004 1.310720e+005 2.621440e+005 5.242880e+005 1.048576e+006 2.097152e+006
[22] 4.194304e+006 8.388608e+006 1.677722e+007 3.355443e+007 6.710886e+007 1.342177e+008 2.684355e+008
[29] 5.368709e+008 1.073742e+009 2.147484e+009 4.294967e+009 8.589935e+009 1.717987e+010 3.435974e+010
[36] 6.871948e+010 1.374390e+011 2.748779e+011 5.497558e+011 1.099512e+012 2.199023e+012 4.398047e+012
[43] 8.796093e+012 1.759219e+013 3.518437e+013 7.036874e+013 1.407375e+014 2.814750e+014 5.629500e+014
[50] 1.125900e+015
>Y
[1] 1 4 9 16 25 36 49 64 81 100 121 144 169 196 225 256 289 324 361 400 441
[22] 484 529 576 625 676 729 784 841 900 961 1024 1089 1156 1225 1296 1369 1444 1521 1600 1681 1764
[43] 1849 1936 2025 2116 2209 2304 2401 2500
> equal<-(X==Y)
> equal
[1] F T F T F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F F
2015/7/21