Hi,
I've created a plot combining 4 plots using ggarrange. Following is the code, it worked perfectly.
sleep_vs_activity <- ggarrange(
ggplot(data=activity_sleep) +
geom_point(mapping = aes(x=avg_TotalMinAsleep, y=avg_VActminutes), color= 'dark blue', alpha= 1/4) +
geom_smooth(method = loess,formula =y ~ x,mapping = aes(x=avg_TotalMinAsleep, y=avg_VActminutes)) +
labs(title = "Very active minutes", x= 'Avg_Sleep (mins)', y= 'Avg_Very Active Minutes'),
ggplot(data=activity_sleep) +
geom_point(mapping = aes(x=avg_TotalMinAsleep, y=avg_FActMinutes), color= '#FFA500', alpha= 1/4) +
geom_smooth(method = loess,formula =y ~ x,mapping = aes(x=avg_TotalMinAsleep, y=avg_FActMinutes)) +
labs(title = "Fairly active minutes", x= 'Avg_Sleep (mins)', y= 'Avg_Fairly Active Minutes'),
ggplot(data=activity_sleep) +
geom_point(mapping = aes(x=avg_TotalMinAsleep, y=avg_LActMinutes), color="#008000", alpha= 1/4) +
geom_smooth(method = loess,formula =y ~ x,mapping = aes(x=avg_TotalMinAsleep, y=avg_LActMinutes)) +
labs(title = "Lightly active minutes", x= 'Avg_Sleep (mins)', y= 'Avg_Lightly Active Minutes'),
ggplot(data=activity_sleep) +
geom_point(mapping = aes(x=avg_TotalMinAsleep, y=avg_SActMinutes), color="#800000", alpha= 1/4) +
geom_smooth(method = loess,formula =y ~ x,mapping = aes(x=avg_TotalMinAsleep, y=avg_SActMinutes)) +
labs(title = "Sedentary minutes", x= 'Avg_Sleep (mins)', y= 'Avg_Sedentary Minutes')
)
sleep_vs_activity
Using the same code, I tried to combine 4 different plots:
inactive_vs_activity <- ggarrange(
ggplot(data=activity_sleep) +
geom_point(mapping = aes(x=avg_InactiveMinBed, y=avg_VActminutes), color= 'dark blue', alpha= 1/4) +
geom_smooth(method = loess,formula =y ~ x,mapping = aes(x=avg_Inactive, y=avg_VActminutes)) +
labs(title = "Very active minutes", x= 'Avg_Inactive (mins)', y= 'Avg_Very Active Minutes'),
ggplot(data=activity_sleep) +
geom_point(mapping = aes(x=avg_InactiveMinBed, y=avg_FActMinutes), color= '#FFA500', alpha= 1/4) +
geom_smooth(method = loess,formula =y ~ x,mapping = aes(x=avg_Inactive, y=avg_FActMinutes)) +
labs(title = "Fairly active minutes", x= 'Avg_Inactive (mins)', y= 'Avg_Fairly Active Minutes'),
ggplot(data=activity_sleep) +
geom_point(mapping = aes(x=avg_InactiveMinBed, y=avg_LActMinutes), color="#008000", alpha= 1/4) +
geom_smooth(method = loess,formula =y ~ x,mapping = aes(x=avg_Inactive, y=avg_LActMinutes)) +
labs(title = "Lightly active minutes", x= 'Avg_Inactive (mins)', y= 'Avg_Lightly Active Minutes'),
ggplot(data=activity_sleep) +
geom_point(mapping = aes(x=avg_InactiveMinBed, y=avg_SActMinutes), color="#800000", alpha= 1/4) +
geom_smooth(method = loess,formula =y ~ x,mapping = aes(x=avg_Inactive, y=avg_SActMinutes)) +
labs(title = "Sedentary minutes", x= 'Avg_Inactive (mins)', y= 'Avg_Sedentary Minutes')
)
inactive_vs_activity
This code says
Error in FUN(X[[i]], ...) : object 'avg_Inactive' not found
inactive_vs_activity
Error: object 'inactive_vs_activity' not found
Any clue why? Any help will be much appreciated.