0
I have a date frame with the column below. I would like to turn the years (with 4 digits) into dates (as.Date). The idea would be to keep only the years even. I tried some solutions I’ve seen around, but I haven’t yet. I’m a beginner in R and I’m finding this part of turning into very difficult dates. Any tips? Grateful!
summary(CPU$A0252)
1945 1961 1964 1966 1970
1 1 1 2 1
1971 1972 1973 1980 1981
1 1 1 1 3
1982 1983 1984 1986 1987
1 1 2 3 4
1988 1989 1990 1991 1992
1 4 6 11 5
1993 1994 1995 1996 1997
13 6 11 14 23
1998 1999 2000 2001 2002
7 12 12 20 19
2003 2004 2005 2006 2007
58 30 69 223 201
2008 2009 Ignorado NA Não aplicável
113 71 92 5 4520
You want to do this here: >today <- Sys.Date() >format(today, format = "%Y") [1] "2018"
– alxwca
So in R if you try to generate type Date, setting only the year it will pick a random date. For this you have to use the format that is right.
– alxwca