```{library(tidyverse)}
SwiftData <- read.csv(“https://onedrive.live.com/download?resid=7F10935B0125F211!1716&authkey=!ACxaGGi_sDuDO9U”, skip=6) datatoadd <- read.csv(“https://onedrive.live.com/download?resid=7F10935B0125F211!1714&authkey=!AAUZnwCxPOsxo8U”, skip=6) SwiftData <- rbind(SwiftData,datatoadd) rm(datatoadd)
datatoadd <- read.csv(“https://onedrive.live.com/download?resid=7F10935B0125F211!1715&authkey=!ABSa7q8TyCfA9q0”, skip=6) SwiftData <- rbind(SwiftData,datatoadd) rm(datatoadd)
datatoadd <- read.csv(“https://onedrive.live.com/download?resid=7F10935B0125F211!1717&authkey=!AJFMjDiVckD2bgk”, skip=6) SwiftData <- rbind(SwiftData,datatoadd) rm(datatoadd)
write.csv(SwiftData, “SwiftData.csv”)
```r
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.3 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.0
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
# Read from local file
SwiftData <- read.csv("SwiftData.csv")
# Getting all column names
ColumnNames <- as.data.frame(colnames(SwiftData))
# Keeping columns of interest after making a copy
# of the full dataset for reference
FullSwiftData <- SwiftData
SwiftData <- select(SwiftData,
Date,
Url,
Domain,
Page.Type,
Account.Type,
Author,
Full.Text,
X.Replies,
X.Reposts,
X.Likes,
Reach..new.)
#Formatting "Date" as POSIXct object
SwiftData$Date <- as.POSIXct(SwiftData$Date, tz = "America/Chicago")
#Sorting by Date
SwiftData <- arrange(SwiftData,Date)
#Categorizing by source type
PageType <- SwiftData %>%
group_by(Page.Type,
Account.Type) %>%
summarize(
PageTypeCount = n())
## `summarise()` has grouped output by 'Page.Type'. You can override using the
## `.groups` argument.
PageType <- arrange(PageType,desc(PageTypeCount))
# Re-expressing "Date" as "Day," the day from "Date."
SwiftData <- SwiftData %>%
mutate(Day = floor_date(Date,
unit = "day"))
# Counting posts per day
PostsByDay <- SwiftData %>%
group_by(Day) %>%
summarize(
PostsByDay = n())