Commit cd0b2ddf authored by Weigert, Andreas's avatar Weigert, Andreas
Browse files

Update of Tutorial 1

parent ec7857b8
......@@ -9,25 +9,14 @@ This file is part of the lecture Business Intelligence & Analytics (EESYS-BIA-M)
```{r Exercise: Mathematical calculations}
# Exercise 1
2 + 3*5^2
# Exercise 2
2^3^5
# Exercise 3
1.4e-2
# Exercise 4
1.4*exp(-2)
# Exercise 5
3*exp(1)^5 + 2
# Exercise 6
log2(33554432)
# Exercise 7
sin(pi/2)
```
......@@ -103,60 +92,4 @@ A[1,]
sum(A[,-2])
```
```{r Exercise: Working with lists}
# Exercise 27
list_data <- list(text, u, x, A)
# Exercise 28
list_data[[2]]
# Exercise 29
list_data[[2]][3]
# Exercise 30
names(list_data) <- c("text", "u", "x", "A")
# Exercise 31
list_data
# Exercise 32
list_data$A
```
```{r Exercise: Working with data frames}
# For Exercise 33
ID <- c(876, 563, 345, 939)
Name <- as.character(c("Michael", "Susan", "Hans", "Björn"))
Age <- c(29,23,56,35)
Nationality <- as.factor(c("DE","US","DE","SE"))
# Exercise 33
students <- data.frame(ID=ID,
Name=Name,
Age=Age,
Nationality=Nationality)
# Long command: If you do not use proper datatypes and enhance the data.frame command by "stringsAsFactors = F", data types might not be correct.
students <- data.frame(ID=as.numeric(c(876, 563, 345, 939)),
Name=as.character(c("Michael", "Susan", "Hans", "Björn")),
Age=as.numeric(c(29,23,56,35)),
Nationality=as.factor(c("DE","US","DE","SE")),
stringsAsFactors = F)
# Exercise 34
View(students)
# Exercise 35
students[3,2]
# Exercise 36
students$Age
# Exercise 37
students[students$Age < 30,"Name"] # colum name as identifier
students[students$Age < 30,2] # column index as identifier
students[students$Age < 30,]$Name # get a data.frame and then select the variable by $ operator
```
......@@ -28,7 +28,6 @@ This file is part of the lecture Business Intelligence & Analytics (EESYS-BIA-M)
# Exercise 7
```
......@@ -99,49 +98,5 @@ This file is part of the lecture Business Intelligence & Analytics (EESYS-BIA-M)
```
```{r Exercise: Working with lists}
# Exercise 27
# Exercise 28
# Exercise 29
# Exercise 30
# Exercise 31
# Exercise 32
```
```{r Exercise: Working with data frames}
# For Exercise 33
ID <- c(876, 563, 345, 939)
Name <- as.character(c("Michael", "Susan", "Hans", "Björn"))
Age <- c(29,23,56,35)
Nationality <- as.factor(c("DE","US","DE","SE"))
# Exercise 33
# Exercise 34
# Exercise 35
# Exercise 36
# Exercise 37
```
......@@ -7,6 +7,65 @@ editor_options:
This file is part of the lecture Business Intelligence & Analytics (EESYS-BIA-M), Information Systems and Energy Efficient Systems, University of Bamberg.
```{r Exercise: Working with lists}
# Exercise 27
list_data <- list(text, u, x, A)
# Exercise 28
list_data[[2]]
# Exercise 29
list_data[[2]][3]
# Exercise 30
names(list_data) <- c("text", "u", "x", "A")
# Exercise 31
list_data
# Exercise 32
list_data$A
```
```{r Exercise: Working with data frames}
# For Exercise 33
ID <- c(876, 563, 345, 939)
Name <- as.character(c("Michael", "Susan", "Hans", "Björn"))
Age <- c(29,23,56,35)
Nationality <- as.factor(c("DE","US","DE","SE"))
# Exercise 33
students <- data.frame(ID=ID,
Name=Name,
Age=Age,
Nationality=Nationality)
# Long command: If you do not use proper datatypes and enhance the data.frame command by "stringsAsFactors = F", data types might not be correct.
students <- data.frame(ID=as.numeric(c(876, 563, 345, 939)),
Name=as.character(c("Michael", "Susan", "Hans", "Björn")),
Age=as.numeric(c(29,23,56,35)),
Nationality=as.factor(c("DE","US","DE","SE")),
stringsAsFactors = F)
# Exercise 34
View(students)
# Exercise 35
students[3,2]
# Exercise 36
students$Age
# Exercise 37
students[students$Age < 30,"Name"] # colum name as identifier
students[students$Age < 30,2] # column index as identifier
students[students$Age < 30,]$Name # get a data.frame and then select the variable by $ operator
```
```{r Load and inspect data}
# Task 1 clone git repository
......
......@@ -7,6 +7,52 @@ editor_options:
This file is part of the lecture Business Intelligence & Analytics (EESYS-BIA-M), Information Systems and Energy Efficient Systems, University of Bamberg.
```{r Exercise: Working with lists}
# Exercise 27
# Exercise 28
# Exercise 29
# Exercise 30
# Exercise 31
# Exercise 32
```
```{r Exercise: Working with data frames}
# For Exercise 33
ID <- c(876, 563, 345, 939)
Name <- as.character(c("Michael", "Susan", "Hans", "Björn"))
Age <- c(29,23,56,35)
Nationality <- as.factor(c("DE","US","DE","SE"))
# Exercise 33
# Exercise 34
# Exercise 35
# Exercise 36
# Exercise 37
```
```{r Load and inspect data}
# Task 1 clone git repository
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment