I'm trying to create a graph to show the correlation between Minecraft streams/non Minecraft streams and the day of the week for a given streamer.
- The
minecraft
variable is a dummy variable, with either 0 or 1 for all observations. - The
weekday
variable is categorical, with numbers from 1-7 indicating the day of the week.
This is what I have:
streamerData %>%
ggplot(aes(x=minecraft))
geom_bar(aes(fill=weekday))
theme_ipsum_rc()
CodePudding user response:
Try converting the numerical data for the weekday
variable into categorical data with some code like this. There may be an easier way to do this but it should work.
for (x in 1:high)
{
if (streamerData$weekday[x] == 1)
{
streamerData$weekday[x] = "Sunday"
}
else if (streamerData$weekday[x] == 2)
{
streamerData$weekday[x] = "Monday"
}
else if (streamerData$weekday[x] == 3)
{
streamerData$weekday[x] = "Tuesday"
}
else if (streamerData$weekday[x] == 4)
{
streamerData$weekday[x] = "Wednesday"
}
else if (streamerData$weekday[x] == 5)
{
streamerData$weekday[x] = "Thursday"
}
else if (streamerData$weekday[x] == 6)
{
streamerData$weekday[x] = "Friday"
}
else if (streamerData$weekday[x] == 7)
{
streamerData$weekday[x] = "Saturday"
}
}
high
should be replaced with whatever the length of your data is. After running this, run what you currently have and it should work.