• Mauvais document ? Échangez-le gratuitement
  • Rédigé par des étudiants ayant réussi
  • Disponible immédiatement après paiement
  • Lire en ligne ou en PDF
Vendre
Où étudie-tu ?
La langue
Document preview thumbnail
Aperçu 3 sur 24 pages
Resume

Summary Solutions Exercises R lab sessions

Document preview thumbnail
Aperçu 3 sur 24 pages

In this document you can find all the solutions of the lab sessions in R for Business Engineer second bachelor.

Aperçu du contenu

Exercises: solutions: Introduction
Google is your best friend:

max(1,20,15,13,17,18,12,5)

2.3.1 Som van integers 1,…,100

100*(100+1)/2

2.3.2 Som van integers 1,…,1000

1000*(1000+1)/2

2.3.3 Interpreteer code

2

Functions

x <- c(5,6,1,2)

Geneste functies

log10(sqrt(100))

Variables in a dataframe

2

Variables names

# Load package and data

library(ISLR2)

data(Hitters)

names(Hitters)

# Use the function names to extract the variable names

Examining variables

# Load package and data

library(ISLR2)

data(Hitters)



# Use the accessor to extract Hits and assign it to the object a

a <- Hitters$Hits

# Determine the class of a

class(a)

Multiple ways to access variables

, # Load package and data

library(ISLR2)

data(Hitters)



# Use the accessor to extract Hits and assign it to a

a <- Hitters$Hits

# Use the square brackets to extract Hits and assign it to b

b <- Hitters[["Hits"]]

# Check if a and b are identical

identical(a,b)

Factors

# Load package and data

library(ISLR2)

data(Hitters)



# Determine the number of Leagues included in this variable

a <- Hitters$League

b <- levels(a)

length(b)

Tables

# Load package and data

library(ISLR2)

data(Hitters)

# Calculate the number of players per League using the table() function

table(Hitters$League)

Matrices 1

x <- matrix(c(7,8,5,3), 2, 2)

Matrices 2

x <- matrix(data= c(1,2,3,4), nrow =2, ncol = 2, byrow = TRUE)

Matrices 3

x <- matrix(data = c(1, 2, 3, 4), nrow = 2, ncol = 2)

, x.sqrt <- sqrt(x)

x.squared <- x^2

Indexing matrices 1

A <- matrix (1:16, 4, 4)

A1 <- A[1:3, 1:3]

A2 <- A[c(1,3),c(2,4)]

A3 <- A[2,4]

A4 <- A[,4]

A5 <- A[1,]+A[2,]

Indexing matrices 2

B <- matrix(1:8, 4, 2)

dim(B)

2.8.1-5. Vectoren

temp <- c(35,88,42,84,81,30)

city <- c("Beijing","Lagos","Paris","Rio de Janeiro","San Juan","Toronto")

named_temp <- temp

names(named_temp) <- city

temp_13 <- named_temp[1:3]

temp_ps <- named_temp[c("Paris","San Juan")]

2.8.6. Vector van getallen 12..73

12:73

Sequencing

x1 <- seq(5,10)

x2 <- seq(1,10, length = 4)

x3 <- seq(10,25,5)

2.8.7. Oneven getallen

seq(1,100,2)

Adding vectors and vector length

x <- c(1, 6, 2)

y <- c(1, 4, 3)

x.length <- length(x)

Infos sur le Document

Cours
Publié le
22 décembre 2023
Nombre de pages
24
Écrit en
2023/2024
Type
Resume
$7.26

Mauvais document ? Échangez-le gratuitement Dans les 14 jours suivant votre achat et avant le téléchargement, vous pouvez choisir un autre document. Vous pouvez simplement dépenser le montant à nouveau.
Rédigé par des étudiants ayant réussi
Disponible immédiatement après paiement
Lire en ligne ou en PDF

Seller avatar
Worstje2021
5.0
(1)
Vendu
7
Abonnés
5
Éléments
13
Dernière vente
2 année de cela



Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Vous travaillez sur vos références ?

Créez des citations précises en APA, MLA et Harvard avec notre générateur de sources gratuit.

Vous travaillez sur vos références ?

Foire aux questions