R Plot: Basics: Difference between revisions

From OnnoCenterWiki
Jump to navigationJump to search
Onnowpurbo (talk | contribs)
No edit summary
Onnowpurbo (talk | contribs)
No edit summary
 
Line 11: Line 11:
  ggplot(data = ss, aes(x = date, y = pop)) +  
  ggplot(data = ss, aes(x = date, y = pop)) +  
   geom_line(color = "#FC4E07", size = 2)
   geom_line(color = "#FC4E07", size = 2)
 
  #  Control line size by the value of a continuous variable:
  #  Control line size by the value of a continuous variable:
  ggplot(data = economics, aes(x = date, y = pop)) +
  ggplot(data = economics, aes(x = date, y = pop)) +
   geom_line(aes(size = unemploy/pop), color = "#FC4E07")
   geom_line(aes(size = unemploy/pop), color = "#FC4E07")
==Referensi==
* http://www.sthda.com/english/articles/32-r-graphics-essentials/128-plot-time-series-data-using-ggplot/


==Pranala Menarik==
==Pranala Menarik==


* [[R]]
* [[R]]

Latest revision as of 03:52, 28 November 2019

library(ggplot2)
theme_set(theme_minimal())
# Demo dataset
head(economics)
# Basic line plot
ggplot(data = economics, aes(x = date, y = pop))+
  geom_line(color = "#00AFBB", size = 2)
# Plot a subset of the data
ss <- subset(economics, date > as.Date("2006-1-1"))
ggplot(data = ss, aes(x = date, y = pop)) + 
  geom_line(color = "#FC4E07", size = 2)

#  Control line size by the value of a continuous variable:
ggplot(data = economics, aes(x = date, y = pop)) +
  geom_line(aes(size = unemploy/pop), color = "#FC4E07")


Referensi

Pranala Menarik