Lab 8
Rmd
keyboard_arrow_up
School
Missouri University of Science & Technology *
*We aren’t endorsed by this school
Course
3420
Subject
Information Systems
Date
Dec 6, 2023
Type
Rmd
Pages
2
Uploaded by DeaconStarSquid34
---
title: "Lab 8"
output: html_document
date: "2022-11-03"
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
rm(list = ls())
```
#1 Read the cleansed data set into R
```{r}
library(jsonlite)
weblog <- stream_in(file("weblog_clean.jsonlines"))
```
#2 Show the structure of the data set
```{r}
str(weblog)
```
#3 Change the data type
```{r}
x <- as.POSIXct(weblog$request.datetime, tz="", format = "%Y-%m-%d %H:%M:%OS")
weblog$request.datetime <- x
```
#4 Show the summary statistics of the data set
```{r}
summary(weblog)
```
#5 Get the frequency distribution of 'weekday'
```{r}
table(weblog$weekday)
#Wednesday has the largest number of visits.
```
#6 Cross tabulate 'weekday' and 'request.uri'
```{r}
table(weblog$weekday, weblog$request.uri)
#There are 4407 visits on the 'faq.html' page on Fridays.
```
#7 Draw a bar plot to show the distribution of visits by 'weekday'
```{r}
weekday.dist <- table(weblog$weekday)
barplot(weekday.dist)
```
#8 Draw a stacked bar plot to show the distribution of visits by 'request.uri' and
'request.method'
```{r}
weblog.stackedbarplot <- table(weblog$request.method, weblog$request.uri)
barplot(weblog.stackedbarplot,
main = "Distribution of Visits",
xlab = "Type of URI Request",
ylab = "Number of Request",
col = rainbow(2),
legend = rownames(weblog.stackedbarplot))
```
#9 Draw a pie chart to present the distribution of visits by 'request.uri' and show
the count of visits for each URI
```{r}
ruri.dist <- table(weblog$request.uri)
lb1 <- paste(names(ruri.dist), ruri.dist,
sep="
")
pie(ruri.dist,
labels = lb1,
main="Pie Chart of 'request.uri' Distribution
(with number of visits)",
col=rainbow(length(lb1)))
```
#10 Draw a pie chart to present the distribution of visits by 'request.uri' and how
the percentage of visits for each URI
```{r}
pct <- round(ruri.dist/sum(ruri.dist)*100, digits = 1)
lb2 <- paste(names(ruri.dist), "visits
", sep=" ", paste(pct,"%"))
pie(ruri.dist,
labels = lb2,
main="Pie Chart of 'request.uri' Distribution
(with percentage)",
col=rainbow(length(lb2)))
```
#11 Calculate 5-number summary for 'reponse.size'
```{r}
quantile(weblog$response.size, type=7)
```
#12 Knit R Markdown file into an HTML file
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help