# Journal Analysis…Take One!

UPDATE: 6/17/15 – I’ve since realized that a dataframe is not the right format for timeseries analysis. I’ve redone this code and will post an update soon.

In this dataset I go through my 2008 journal and plot it over time. I recorded my mood each day for 15 months; enough to fill one journal.

For now what I have set-up in R is taking concatenated data from my journal. Putting that data into a dataframe after checking each month’s length. Max length is 23 values for one month. So I wrote 23 times that month. Sometimes I just wrote once. In fact my initial system for collecting this data was a line with a dot on it. I had to guess at those from Feb08. :]

# Mood graphed over one entire 14 month journal. Feb2008 - Apr2009.

# Data manually entered right out of my journal from dated entries during
# the month.
feb08 <- c(3, 6, 7, 7, 7.5, 8, 8, 10, 9, -5, -3, 5, 7)
mar08 <- c(5, -7, 7, 7, 10, 10, 7, 6, 6, 5, 6, 4, 6)
apr08 <- c(5, 7)
may08 <- c(7)
jun08 <- c(8, 6)
jul08 <- c(6, 7, 6, 6, 6, 7, 6, 5, 7, 6, 4, 5)
aug08 <- c(3, 8, 6, 6, 6, 6, 5)
sept08 <- c(6, 7, 9, 5, 7, 8, 7)
oct08 <- c(3, 6, 7, 6, 8, 8, 5, 7, 8, 5, 8, 5, 7, 10, 6, 6)
nov08 <- c(5, 6, 7, 7, 7, 7, 5, 7, 7)
dec08 <- c(7, 6, 6, 10, 6, 7, 6, 6, 6, 5, 4, 5, 4, 6, 6, 6)
jan09 <- c(5, 7, 6, 7, 5, 6, 5, 7, 3, 7, 6, 7, 8, 7, 6, 6, 7, 5, 5, 4, 6, 4,
2)
feb09 <- c(7, 7, 8, 7, 8, 6, 7, 7, 6, 7, 5, 8, 6, 7, 6, 7, 8, 7)
mar09 <- c(3, 5, 7, 6, 4, 6, 5, 6, 2, 3, 6, 6, 5, 5, 5, 5, 6, 7, 6, 5)
apr09 <- c(6, 6, 7, 8, 6, 7, 9, 7, 6)

# Data needs put into a dataframe but dataframes require all vectors to be
# the same length. So we need to see which month has the most entries.

maxlength <- (max(length(feb08), length(mar08), length(apr08), length(may08),
length(jun08), length(jul08), length(aug08), length(sept08), length(oct08),
length(nov08), length(dec08), length(jan09), length(feb09), length(mar09),
length(apr09)))

# Now that maxlength contains the most entries, we need to make extend all
# individual entries to this length.

length(feb08) <- maxlength
length(mar08) <- maxlength
length(apr08) <- maxlength
length(may08) <- maxlength
length(jun08) <- maxlength
length(jul08) <- maxlength
length(aug08) <- maxlength
length(sept08) <- maxlength
length(oct08) <- maxlength
length(nov08) <- maxlength
length(dec08) <- maxlength
length(jan09) <- maxlength
length(feb09) <- maxlength
length(apr09) <- maxlength

# Now I'm ready to build the dataframe, mood.

mood <- data.frame(feb08, mar08, apr08, may08, jun08, jul08, aug08, sept08,
oct08, nov08, dec08, jan09, feb09, apr09)

# Fix the NA values to be zero.
mood[is.na(mood)] <- 0

# Results.
mood
##    feb08 mar08 apr08 may08 jun08 jul08 aug08 sept08 oct08 nov08 dec08
## 1    3.0     5     5     7     8     6     3      6     3     5     7
## 2    6.0    -7     7     0     6     7     8      7     6     6     6
## 3    7.0     7     0     0     0     6     6      9     7     7     6
## 4    7.0     7     0     0     0     6     6      5     6     7    10
## 5    7.5    10     0     0     0     6     6      7     8     7     6
## 6    8.0    10     0     0     0     7     6      8     8     7     7
## 7    8.0     7     0     0     0     6     5      7     5     5     6
## 8   10.0     6     0     0     0     5     0      0     7     7     6
## 9    9.0     6     0     0     0     7     0      0     8     7     6
## 10  -5.0     5     0     0     0     6     0      0     5     0     5
## 11  -3.0     6     0     0     0     4     0      0     8     0     4
## 12   5.0     4     0     0     0     5     0      0     5     0     5
## 13   7.0     6     0     0     0     0     0      0     7     0     4
## 14   0.0     0     0     0     0     0     0      0    10     0     6
## 15   0.0     0     0     0     0     0     0      0     6     0     6
## 16   0.0     0     0     0     0     0     0      0     6     0     6
## 17   0.0     0     0     0     0     0     0      0     0     0     0
## 18   0.0     0     0     0     0     0     0      0     0     0     0
## 19   0.0     0     0     0     0     0     0      0     0     0     0
## 20   0.0     0     0     0     0     0     0      0     0     0     0
## 21   0.0     0     0     0     0     0     0      0     0     0     0
## 22   0.0     0     0     0     0     0     0      0     0     0     0
## 23   0.0     0     0     0     0     0     0      0     0     0     0
##    jan09 feb09 apr09
## 1      5     7     6
## 2      7     7     6
## 3      6     8     7
## 4      7     7     8
## 5      5     8     6
## 6      6     6     7
## 7      5     7     9
## 8      7     7     7
## 9      3     6     6
## 10     7     7     0
## 11     6     5     0
## 12     7     8     0
## 13     8     6     0
## 14     7     7     0
## 15     6     6     0
## 16     6     7     0
## 17     7     8     0
## 18     5     7     0
## 19     5     0     0
## 20     4     0     0
## 21     6     0     0
## 22     4     0     0
## 23     2     0     0