[英]How can I plot factor and numbers?
year val
1966 1
1967 22
1968 55
1969 57
在這里,年份是一個有水平的因素
並且 val 是數字
如何用 x 軸上的年份和 y 軸上的 val 繪制它?
ggplot(data=df,aes(x="year",y="val"))+
geom_line()+
ggsave('test.png')
實際數據集
df <- structure(list(year = structure(1:47, .Label = c("1936", "1947",
"1948", "1950", "1952", "1954", "1957", "1959", "1961", "1972",
"1973", "1975", "1979", "1980", "1981", "1982", "1983", "1984",
"1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992",
"1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000",
"2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008",
"2009", "2010", "2011", "2012", "2013"), class = "factor"), val = c(1L,
2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 8L, 2L, 4L, 1L, 1L, 3L, 43L,
146L, 108L, 68L, 200L, 414L, 367L, 977L, 1996L, 1768L, 1875L,
3235L, 1966L, 2244L, 3500L, 2479L, 3536L, 2062L, 1687L, 2563L,
2576L, 3884L, 3969L, 3101L, 2810L, 2941L, 4207L, 3353L, 2596L,
4485L, 1801L, 3286L)), .Names = c("year", "val"), row.names = c(NA,
-47L), class = "data.frame")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.