7
I have a date.frame, I changed the data class of the date column and later I separated the other three column through the Separate command, whose names became %Y, %m and %d, I would like to change these names to year, month and day. However, when trying to rename columns, using the Rename command gives error.
> as.data <- as.Date(dados$data)
> meus.dados <- separate(data = dados, col = data, into = c("%Y", "%m","%d"), sep = "-")
> meus.dados[1:5, 1:9]
Source: local data frame [5 x 9]
posicao %Y %m %d especie BF CA2 CB CP
(chr) (chr) (chr) (chr) (chr) (dbl) (dbl) (dbl) (dbl)
1 direita 2012 05 22 Canis familiaris 0 0 0 0
2 direita 2012 05 22 Canis familiaris 0 0 0 0
3 esquerda 2012 05 24 Dasypus novemcinctus 0 0 0 1
4 esquerda 2012 05 25 Canis familiaris 1 0 0 0
5 esquerda 2012 05 26 Dasypus novemcinctus 0 0 0 1
> rename(meus.dados, ano=" %Y", mes="%m", dia="%d")
Error: Arguments to rename must be unquoted variable names. Arguments ano, mes, dia are not.
I don’t know what to do!!
Why not already create with the definitive names in the function
separate
?meus.dados <- separate(data = dados, col = data, into = c("ano", "mes","dia"), sep = "-")
– Molx
Thank you!!! It worked!!!!
– Fabiane Pereira