Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
13 changes: 13 additions & 0 deletions twitter-data.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
59 changes: 59 additions & 0 deletions twitter_data.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: "twitter"
author: "Jing"
date: "October 11, 2016"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r}
twitter_data <- read.csv("HUDK4050-twitter-10-06-16.csv", header=TRUE,sep=",")
View(twitter_data)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
#plots
plot(twitter_data) #too overwhelming
plot(twitter_data$screenName,twitter_data$time)

#create subset
D1<-twitter_data$screenName
D2<-twitter_data$time

#barplot
table<-table(D2,D1)
barplot(table)

#lineplot
plot(twitter_data$screenName, twitter_data$time, type = "l",lty = "dashed")
#why it is not a line plot, but a boxplot instead???

#boxplot
boxplot(twitter_data$time,twitter_data$screenName)

#use of "aggregate": example of "last day of the month"
dates <- data.frame(date = as.Date("2001-01-01", format = "%Y-%m-%d") + 0:729)
last.day <- aggregate(x = dates["date"], by = list(month = substr(dates$date, 1, 7)), FUN = max)

#create a table about how many times each person tweet:) or AKA frequency table
library(plyr)
table1<-data.frame(name=twitter_data$screenName,tweet=twitter_data$text)
table2<-count(table1,"name")

```


Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.