alperyilmaz / dav-exercises

Exercise questions submitted by Data Analysis and Visualization with R course students at YTU
GNU General Public License v3.0
1 stars 2 forks source link

#Which one is more safety, steering wheel on the left or right ? #90

Open teoxus opened 6 years ago

teoxus commented 6 years ago

Please fill in the form to submit an exercise question. Please state the question under Question section. Please try to be as specific as possible when describing the problem. In hint chunk, you can provide a statement (which function to use, or which columns to join, etc.) or you can provide first 1-2 lines of expected result. Please refer to Github markdown table instructions if you need to include a table. In solution chunk please provide the code to solve the problem. Your solutions should be runnable in anybody's computer. Thus, please don't include file locations in your own computer while importing data. The data should be coming from a R package or from an online source.

Question

In Turkey, 7530trafic accident death per year between 2006 - 2015. I want to researh with United Kingdom stactics to find, is steering wheel's place effects accidents ?

library(gapminder)
library(tidyverse)
library(broom)
library(modelr)
library(purrr) # loaded with tidyverse but still having it here to show map() needs purrr package
library(ggplot2)
accidents_UK <- read.csv("https://raw.githubusercontent.com/curran/data/gh-pages/Rdatasets/csv/datasets/UKDriverDeaths.csv")
accidents_UK %>%

  ggplot(aes(time, UKDriverDeaths))+
 geom_point()

total_death <- 
accidents_UK %>%
  summarise(avg_deaths = mean(UKDriverDeaths))

lmfit <- lm(time ~UKDriverDeaths, accidents_UK)
total_d <- 
data.frame(UKDriverDeaths = c(1670.307, 7530))
total_d$prediction <- predict(lmfit, total_d)
  ggplot(accidents_UK, aes(time, UKDriverDeaths))+
 geom_point() +
    geom_point(data = total_d, aes(prediction, UKDriverDeaths),col ="red")
  #top of the left corner is average of turkey, it is not normal for them its so high.

About images: If your question or solution contains an image, please attach necessary images by dragging them here or copy/pasting from clipboard. After the upload, a markdown style link to image will be generated for you.

Additional information

Originality

Please mark relevant information with x, (ex. [x])

Is this question

If you select Inspired or Paraphrased please provide the links in markdown format ( [link](http://example.com) ). Please provide all relevant links. You can refer to DataCamp course pages if you're inspired by them.

Difficulty Level

According to you, what is the level of difficulty of the question (note: this can be modified by instructor after submission)

Tags (optional)

Please provide comma separated list of dplyr verbs (e.g. summarize, left join) or concepts (e.g. text mining) that you think are relevant with question

Before submitting