-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror_code_result.R
More file actions
70 lines (49 loc) · 1.06 KB
/
error_code_result.R
File metadata and controls
70 lines (49 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
title: "Webinar 2 tasks"
output: html_document
---
## Code with lots of errors
```{r, eval=FALSE}
# Start with a clean environment (you can use the broom image on
# RStudio or run rm(list=ls())
# can you as a team figure out what went wrong in each of these?
# Q1
x < 1
# Q2
y <- 'a"
x <- y
# Q3
y * 5
# Q4
vect1 <- c(1,2,3 1)
# Q5
vectl[1]
# Q6
vect2 <- rnorm(20, mean=0, st.dev=5)
# Q7
for(i in 1:5{
print("The number is", l)
}
```
## Mystery code
```{r pressure, eval=FALSE}
# Can you (together with your group) figure out what
# this code does? Can you find ways to make the code shorter?
data1 <- rnorm(100)
data2 <- rnorm(100)
data3 <- rnorm(100)
data <- c(data1, data2)
data <- c(data, data3)
x <- sum(is.na(data))
y <- data < 0
z <- data > 0
hist(data)
hist(data, col='red')
hist(data, col='red', breaks=15)
hist(data, col='red', breaks=15, main='Histogram of normally distributed data')
```
```{r}
# You can get the same output with just
data <- rnorm(300)
hist(data, col='red', breaks=15, main='Histogram of normally distributed data')
```