daroczig / CEU-R-intro

Data Analysis 1a: Foundation of Data management in R @ CEU
35 stars 62 forks source link

Last exercise in assignment week4 (A complex example) #21

Closed PeterPaziczki closed 6 years ago

PeterPaziczki commented 6 years ago

Dear Gergely Daroczi,

I am struggeling with the last exercise, I have tried it in many ways and I believe it should work now, but it is still not the required solution.

Could you please check it, whether it is a datacamp issue, or I still need to work on the code. Thank you in advance!

Please find my code below:

`library(nycflights13) library(data.table) library(ggplot2) dt <- data.table(flights) dt[,.N, by = dest]

Compute the average air time per destination and store the resulting data.table object in the airtime_by_dest variable. The column names should be dest and air_time

str(dt) dt[, dest := factor(dest)] str(dt) airtime_by_dest <- dt[, list(air_time =mean(air_time, na.rm = TRUE)), by = dest][order(air_time)]

str(airtime_by_dest) airtime_by_dest

Plot the bar plot

ggplot(airtime_by_dest, aes(dest)) + geom_bar()`

daroczig commented 6 years ago

Running your code does not result in the preferred output, which should be something like

screenshot from 2017-10-16 00-00-09

Hints: