n to all three vectors to see what would happen. If the function requires more than one input x, then you just create other objects as needed. sum (x) sum of the elements of x prod (x) product of the elements of x max (x) maximum of the elements of x min(x) minimum of

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Play and practice all the functions that we listed here. 

What I would like you to do is to first create three vectors---a logic vector, a double vector, and a character vector, for example,

x1 = c( TRUE, FALSE, TRUE)

x2 = c( 0, -2.5, 1, 3, 5.9 )

x3 = c( "a1", "a2", "za", "zz", "0", "1")

and apply each function to all three vectors to see what would happen. If the function requires more than one input x, then you just create other objects as needed.

sum (x)

sum of the elements of x

prod (x)

product of the elements of x

max (x)

maximum of the elements of x

min(x)

minimum of the elements of x

which. max (x)

returns the index of the greatest element of x

which. min(x)

returns the index of the smallest element of x

range (x)

id. than c (min(x), max (x))

length (x)

number of elements in x

mean (x)

mean of the elements of x

median (x)

median of the elements of x

 

round (x, n)

rounds the elements of x to n decimals

rev (x)

reverses the elements of x

sort (x)

sorts the elements of x in increasing order; to sort in decreasing order:

rev (sort (x))

rank (x)

ranks of the elements of x

10g(x, base)

computes the logarithm of x with base base

scale (x)

if x is a matrix, centers and reduces the data; to center only use the option center=FALSE, to reduce only scale=FALSE (by default center=TRUE, scale=TRUE)

pmin(x,y,..

a vector which ith element is the minimum of x [1], y [il, ...

pmax (x,y,..

id. for the maximum

cumsum (x)

a vector which ith element is the sum from x [1] to x [i]

cumprod (x)

id. for the product

cummin (x)

id. for the minimum

cummax (x)

id. for the maximum

match(x, y)

returns a vector of the same length than x with the elements of x which are in y (NA otherwise)

which (x == a)

returns a vector of the indices of x if the comparison operation is true (TRUE), in this example the values of i for which x [i] == a (the argument of this function must be a variable of mode logical)

choose (n, k)

computes the combinations of k events among n repetitions = n!/[n-

k)!k!]

na. omit (x)

suppresses the observations with missing data (NA) (suppresses the corresponding line if x is a matrix or a data frame)

na. fail(x)

returns an error message if x contains at least one NA

unique (x)

if x is a vector or a data frame, returns a similar object but with the duplicate elements suppressed

table(x)

returns a table with the numbers of the differents values of x (typically for integers or factors)

table (x, y)

contingency table of x and y

subset (x, ...)

returns a selection of x with respect to criteria (..., typically com-parisons: x$V1 < 10); if x is a data frame, the option select gives the variables to be kept (or dropped using a minus sign)

samplex, size)

resample randomly and without replacement size elements in the

vector x, the option replace = TRUE allows to resample with replace-

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education