Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Assignment 2-2020.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ library(dplyr)

D1 <- read.csv("video-data.csv", header = TRUE)


#Create a data frame that only contains the years 2018
D2 <- filter(D1, year == 2018)
```
Expand All @@ -37,6 +38,7 @@ D2 <- filter(D1, year == 2018)

hist(D2$watch.time)


#Change the number of breaks to 100, do you get the same impression?

hist(D2$watch.time, breaks = 100)
Expand Down Expand Up @@ -92,17 +94,30 @@ pairs(D5)

```{r}
#rnorm(100, 75, 15) creates a random sample with a mean of 75 and standard deviation of 20
score <- rnorm(100, 75, 15)
S1 <- data.frame(score)
#filter() can be used to set a maximum and minimum value
S1 <- filter(S1, score<=100)

#round() rounds numbers to whole number values
#sample() draws a random samples from the groups vector according to a uniform distribution

S2 <- data.frame(rep(100,3))
names(S2) <- "score"
S3 <- bind_rows(S1, S2)
S3$score <- round(S3$score, 0)

interest <- c("sport", "music", "nature", "literature")
S3$interest <- sample(interest, 100, replace = TRUE)
S3$stid <- seq(1, 100, 1)


```

2. Using base R commands, draw a histogram of the scores. Change the breaks in your histogram until you think they best represent your data.

```{r}

hist(score)
```


Expand Down
Loading