corr_analys {WeatherSentiment} | R Documentation |
Calculate Correlation between Sentiment and Weather Variable
Description
This function calculates the Pearson correlation coefficient between sentiment scores extracted from tweets and a weather variable (e.g., temperature) in a merged dataset.
Usage
corr_analys(t, w, com_var = "Date", var1 = "T1", var2 = "T2")
Arguments
t |
A data.frame containing tweets with a 'text' column |
w |
A data.frame containing weather data with a column matching the 'com_var' |
com_var |
The name of the common variable for merging the tweet and weather data. Defaults to "Date". |
var1 |
The name of the column in 't' containing the tweet text. Defaults to "T1". |
var2 |
The name of the column in 'w' containing the weather variable. Defaults to "T2". |
Value
The Pearson correlation coefficient between sentiment scores and the weather variable.
Author(s)
Leila Marvian Mashhad and Andriette Bekker and Mohammad Arashi and Priyanka Nagar.
Examples
Date1 <- c('2024-01-01', '2024-01-02')
T1 <- c('I love sunny days', 'Rainy days are the worst')
tweet <- data.frame(Date = Date1 , T1 = T1)
weather <- data.frame(Date = Date1, T2 = c(25, 15))
cor1 <- corr_analys(tweet, weather, com_var = "Date", var1 = "T1", var2 = "T2")
print(cor1)
[Package WeatherSentiment version 1.0 Index]