This experiment aimed to perform data visualization in R using various libraries. It loaded Uber trip data from multiple months, combined the data, and transformed variables like date/time and weekday. It then created visualizations to show total trips by hour, trips by hour and month in bar plots, and a heatmap of trips by day and hour. The conclusions were that various R libraries were used to analyze and visualize the Uber dataset for predictive purposes and industrial applications.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
43 views3 pages
DAV Practical 7
This experiment aimed to perform data visualization in R using various libraries. It loaded Uber trip data from multiple months, combined the data, and transformed variables like date/time and weekday. It then created visualizations to show total trips by hour, trips by hour and month in bar plots, and a heatmap of trips by day and hour. The conclusions were that various R libraries were used to analyze and visualize the Uber dataset for predictive purposes and industrial applications.
may <- read.csv("../input/uberdataset/uber-raw-data-may14.csv") june <- read.csv("../input/uberdataset/uber-raw-data-jun14.csv") july <- read.csv("../input/uberdataset/uber-raw-data-jul14.csv") aug <- read.csv("../input/uberdataset/uber-raw-data-aug14.csv") sept <- read.csv("../input/uberdataset/uber-raw-data-sep14.csv")
data <- rbind(apr, may, june, july, aug, sept)
cat("The dimensions of the data are:", dim(data)) The dimensions of the data are: 4534327 4 head(data)
month_hour_data <- data %>% group_by(month, hour) %>% dplyr::summarize(Total
= n()) ggplot(month_hour_data, aes(hour, Total, fill=month)) + geom_bar(stat = "identity") + ggtitle("Trips by Hour and Month") + scale_y_continuous(labels = comma)
day_month_data <- data %>% group_by(dayofweek, month) %>%
dplyr::summarize(Trips = n()) day_month_data ggplot(day_month_data, aes(dayofweek, Trips, fill = month)) + geom_bar(stat = "identity", aes(fill = month), position = "dodge") + ggtitle("Trias by Day and Month") + scale_y_continuous(labels = comma) + scale_fill_manual(values = colors)
ggplot(day_hour_data, aes(day, hour, fill = Total)) +
geom_tile(color = "white") + ggtitle("Heat Map by Hour and Day")
OUTPUT :- CONCLUSION :- We studied about the data visualization as well as how to use R libraries in data analysis for predicting and analyzing the given dataset also know that work of it in industrial companies.