I'm doing some very basic sentiment analysis on a pretty large set of data that continues to grow every day. I need to feed this data into a shiny app where I can adjust the date range. Rather than running the analysis over and over again, what I'd like to do is create a new CSV with the sum of each sentiment score by date. I'm having trouble iterating over the date though. Here's some sample data and the `lapply()` statement I tried that is not working.

```
library(tidyverse)
library(syuzhet)
library(data.table)

df <- data.frame(date = c("2021-01-18", "2021-01-18", "2021-01-18", "2021-01-17","2021-01-17", "2021-01-16", "2021-01-15", "2021-01-15", "2021-01-15"),
                 text = c("Some text here", "More text", "Some other words", "Just making this up", "as I go along", "hope the example helps", "thank you in advance", "I appreciate the help", "the end"))

> df
        date                   text
1 2021-01-18         Some text here
2 2021-01-18              More text
3 2021-01-18       Some other words
4 2021-01-17    Just making this up
5 2021-01-17          as I go along
6 2021-01-16 hope the example helps
7 2021-01-15   thank you in advance
8 2021-01-15  I appreciate the help
9 2021-01-15                the end

dates_scores_df <- lapply(df, function(i){
  data <- df %>% 
    # Filter to the unique date
    filter(date == unique(df$date[i]))

  # Sentiment Analysis for each date
  sentiment_data <- get_nrc_sentiment(df$text)

  # Convert to df
  score_df <- data.frame(sentiment_data[,])

  # Transpose the data frame and adjust column names
  daily_sentiment_data <- transpose(score_df)
  colnames(daily_sentiment_data) <- rownames(score_df)

 # Add a date column
  daily_sentiment_data$date <- df$date[i]

})

sentiment_scores_by_date <- do.call("rbind.data.frame", dates_scores_df)

```

What I'd like to get to is something like this (data here is made up and will not match the example above)

```
      date anger anticipation disgust fear joy sadness surprise trust negative positive
2021-01-18     1            2       0    1   2       0        2     1        1        2
2021-01-17     1            2       0    2   3       3        1     2        0        1   

```