I have this data with 4000 observations, so this is head(both)
:
kön gdk age fbkurs pers stterm
1 man FALSE 69 FALSE 1941-12-23 2011-01-19
2 man NA 70 FALSE 1942-02-11 2012-01-19
3 kvinna NA 65 FALSE 1942-06-04 2007-09-01
4 kvinna TRUE 68 FALSE 1943-04-04 2011-09-01
5 kvinna NA 65 FALSE 1943-10-30 2008-09-01
6 man FALSE 70 TRUE 1944-01-27 2013-09-01
I I want to create a new column based on the column named 'stterm'.
In stterm I have different dates that I would rather name for example. VT10, VT11, etc. I like to call the new column regyear
.
I have tried to enter:
regyear <- factor(both$stterm, levels = c("2007-09-01"="HT07" "2008-09-01"="HT09" "2009-01-19"="VT09" "2009-09-01"="HT09" "2010-01-19"="VT10" "2010-09-01"="HT10" "2011-01-19"="VT11"
"2011-09-01"="HT11" "2012-01-19"="VT12" "2012-09-01"="HT12" "2013-01-19"="VT13" "2013-09-01"="HT13" "2014-01-19"="VT14"))
but when I do, I get the following error message:
Error: unexpected string constant in "regyear<- factor(both$stterm, levels = c("2007-09-01"='HT07' "2008-09-01""
What should I do to make them right?