• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 10 páginas
Examen

Data_Mining_&_Statistical_Modeling_Week1_Introduction_to_R

Document preview thumbnail
Vista previa 2 fuera de 10 páginas

Replicate the textbook's code shown in Chapter 2 (2.3 Lab: Introduction to R). 2.3 Lab: Introduction to R In this lab, we will introduce some simple R commands to understand how R works. 2.3.1 Basic Commands 2.3.2 Graphics 2.3.3 Indexing Data 2.3.4 Loading Data

Vista previa del contenido

Intro_to_R
John Doe

2025-06-05

2.3 Lab: Introduction to R


In this lab, we will introduce some simple R commands to understand
how R works.
2.3.1 Basic Commands
# Creating a numeric vector with 4 elements
x <- c(1, 3, 2, 5)

# Printing the vector x
x

## [1] 1 3 2 5

# Updating x with a new set of values
x = c(1, 6, 2)

# Printing the updated x
x

## [1] 1 6 2

# Creating another numeric vector with 3 elements
y= c(1, 4, 3)


# Checking the number of elements in x
length(x)

## [1] 3

# Trying to find the length of y (this will give an error because y
doesn't exist yet)
length(y)

## [1] 3

# Adding x and y (will also give an error unless y is defined)
x + y

## [1] 2 10 5

, # Listing all current objects in the environment
ls()

## [1] "x" "y"

# Removing objects x and y from the environment
rm(x, y)

# Checking again to confirm they are removed
ls()

## character(0)

# Removing everything from the environment
rm(list = ls())

# Asking for help on the matrix function
?matrix

## starting httpd help server ... done

# Creating a 2x2 matrix using named arguments
x <- matrix(data = c(1, 2, 3, 4), nrow = 2, ncol = 2)
x

## [,1] [,2]
## [1,] 1 3
## [2,] 2 4

# Creating a matrix without naming the arguments (just positional)
x <- matrix(c(1, 2, 3, 4), 2, 2)

# Creating a matrix where values are filled by row instead of column
matrix(c(1, 2, 3, 4), 2, 2, byrow = TRUE)

## [,1] [,2]
## [1,] 1 2
## [2,] 3 4

# Taking square root of each element in x
sqrt(x)

## [,1] [,2]
## [1,] 1.000000 1.732051
## [2,] 1.414214 2.000000

# Squaring each element in x
x^2

## [,1] [,2]
## [1,] 1 9
## [2,] 4 16

Libro relacionado
 image
Gareth James, Daniela Witten, Trevor Hastie, Robert Tibshirani An Introduction to Statistical Learning
Editorial: 2013 ISBN: 9781461471387 Edición: Desconocido

Información del documento

Subido en
5 de junio de 2025
Número de páginas
10
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$10.98

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
datascience24
4.5
(12)
Vendido
87
Seguidores
16
Artículos
159
Última venta
5 meses hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes