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

Personal Expenditure in USA #102

Open dilakurtul opened 6 years ago

dilakurtul 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

Which expenditure has the most increasing between 1940 - 1960. Draw plot for each expenditure

read.csv("https://raw.githubusercontent.com/curran/data/gh-pages/Rdatasets/csv/datasets/USPersonalExpenditure.csv")
library(ggplot2)
Expendit <- read.csv("https://raw.githubusercontent.com/curran/data/gh-pages/Rdatasets/csv/datasets/USPersonalExpenditure.csv")
difference <- 
Expendit %>%
  mutate(X6055 = X1960 - X1955,
         X5550 = X1955 - X1950,
         X5045 = X1950 - X1945,
         X4540 = X1945 - X1940,
         DIFFERENCE = X4540 + X5045 + X5550 + X6055) %>%
  select(X, DIFFERENCE)
answer <- difference %>%
  arrange(-DIFFERENCE) %>% head(1)

ggplot(difference,aes(X, DIFFERENCE), col = "red") +
geom_jitter()

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