I have a data.frame (df):
Mês SpreadMensal
1 jan2006 -3.04045769
2 fev2006 -3.39026284
3 mar2006 -2.52839603
4 abr2006 -1.52792341
5 mai2006 -0.08979180
6 jun2006 1.02865488
7 jul2006 0.54515613
8 ago2006 0.13076121
9 set2006 0.07423530
10 out2006 -0.10478629
11 nov2006 -0.04161989
12 dez2006 -0.40504212
13 jan2007 -0.51056142
14 fev2007 -0.69200513
15 mar2007 -0.73608848
...
50 fev2010 4.37919039
51 mar2010 3.96563441
52 abr2010 3.55914902
53 mai2010 2.85757135
54 jun2010 2.03576435
55 jul2010 1.41129808
56 ago2010 0.80415571
57 set2010 0.90434619
58 out2010 0.97753435
59 nov2010 1.30446466
60 dez2010 1.34682208
61 jan2011 1.19608226
62 fev2011 1.07001901
63 mar2011 0.80556310
64 abr2011 0.65837218
65 mai2011 0.30898661
66 jun2011 -0.03946940
67 jul2011 -0.05902839
68 ago2011 -0.55409805
69 set2011 -0.36402331
70 out2011 -0.21302781
71 nov2011 -0.15414390
72 dez2011 0.29072412
73 jan2012 0.89794991
74 fev2012 1.19541625
75 mar2012 1.89563925
76 abr2012 1.98807663
77 mai2012 1.89189602
78 jun2012 2.24721387
79 jul2012 2.00140636
80 ago2012 2.33372249
81 set2012 2.59733963
82 out2012 2.42408844
83 nov2012 2.40611260
84 dez2012 2.35786991
85 jan2013 2.53196473
86 fev2013 2.82097624
87 mar2013 2.84742861
88 abr2013 2.61528861
89 mai2013 2.53958494
90 jun2013 3.15504505
91 jul2013 2.91702023
92 ago2013 3.26063617
93 set2013 3.12586325
94 out2013 2.55812363
95 nov2013 3.02603774
96 dez2013 3.21191655
97 jan2014 3.13692051
98 fev2014 2.71665822
99 mar2014 2.50222843
100 abr2014 2.08358406
101 mai2014 1.67663242
102 jun2014 1.38021497
103 jul2014 1.15440685
104 ago2014 0.99317141
105 set2014 0.66278156
106 out2014 0.87560496
107 nov2014 0.97597018
108 dez2014 0.45712044
I'm trying to make a simple plot with ggplot, but it does not:
ggplot(data = df, aes(x = Mês, y = SpreadMensal)) + geom_line()
class(df)
[1] "data.frame"
class(df$Mês)
[1] "factor"
One suggestion I saw was to turn the Month column into date:
df$Mês<-as.Date(df$Mês, format="%m%Y")
class(df$Mês)
[1] "Date"
But this command gives me this:
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[32] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[63] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[94] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
My data.frame looks like this:
Mês SpreadMensal
1 <NA> -3.04045769
2 <NA> -3.39026284
3 <NA> -2.52839603
4 <NA> -1.52792341
5 <NA> -0.08979180
6 <NA> 1.02865488
7 <NA> 0.54515613
8 <NA> 0.13076121
9 <NA> 0.07423530
10 <NA> -0.10478629
11 <NA> -0.04161989
...