R Programming

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

How to create a matrix from vector?

Using vector function. dim(m) <- vector (c(rows, columns))

Rows and columns in a Matrix are like which object?

Vector

Scope

When you use a variable, either in an expression or for assignment, it should be in scope. For an existing variable, scope defines when such variable is available. For a newly assigned variable, the scope is established at assignment.

Get working directory

getwd()

How many values in a vector?

length(vetor)

Set working directory

setcwd()

See structure of an object (data structure)

str() Function

Function

A logical unit of processing code. Usually represents some work that is encapsulated to be reused. Returns the result of processing to the caller.

variables are references to?

Data structures (data objects) and functions (code objects)

Class of object

Data type of the object. E.g. Character, Integer, Logical

How do you see the dimensions of a matrix?

Dim(matrix object)

How is list related to vector?

Each element of a list is a vector. So, a list can be considered a collection of vectors.

Text editor

Editor to create and work with plain text files. Text files are saved with .txt extension by convention.

Two parenthesis after function name

Executes the function

What is a working directory?

If you don't explicitly specify one, a folder on your computer where R will look for files - both to read and write.

Coercion

Implicit or explicit conversion of one data type (class) to another

Arguments

Parameters values passed in between parenthesis, to the function

Clearing workspace does what?

Removes all the variable references to data structures and functions

Clear console

Rstudio: Ctrl+L R GUI: Alt+Ctrl+L

Symbol for: Multiplication Division Exponent

Symbol for: Multiplication: * Division: / Exponent: ^

Get Help

?Command help(command) To start searchable help page: help.start()

Data Structure

A complex data type, typically composed of more than one value. In R, the main data structures are: Vector, Factor, Matrix, List, Data Frame

Variable

A symbol to which we assign a value. This can be a simple value, or a complex data structure that consists of many individual values. The symbol then can be used elsewhere instead of the value. The value is typically assigned as a result of an expression. An expression may use other variables that have been previously assigned.

What is a matrix?

A two dimensional vector which has values of the same class

Vector

An object that can store one or more values of the same class (data type)

Parameters

Arguments expected by a function

How do you explicitly coerce a class/datatype to another?

By using the *. function

y <- c("a", TRUE) is coerced to?

Character

Assignment operator

Conventionally, <- is used. e.g., below statement assigns value 5 to a variable x, x <- 5

What happens when you have numbers in a character vector?

It gets stored as a character

What is a list?

List is a collection of vectors

How is matrix related to vector?

Matrices are vectors in either dimension. Each Row and column represents a vector

What are attributes of R objects (data structures)

Metadata that describes other properties of an object. E.g. class, length etc.

What does dim(matrix object) produce?

Number of rows,columns in the matrix

y <- c(TRUE, 2) is coerced to?

Numeric

Type of object

The data structure of object. E.g. Vector, Matrix

Encapsulation

The packing of data and functions into a single component.

y <- c(1.7, "a") is coerced to?

character

Class or datatype of a vector?

class(vector)


Set pelajaran terkait

Interpersonal Communications - Chapter 10: Intimate Relationships

View Set

ch 4 labs 4-1 through 4-6 server 2019

View Set

Chapter 31. Paint Application: ASE Type Questions

View Set

RESPIRATION - Check for understanding

View Set