Last active
November 6, 2016 09:11
-
-
Save messefor/9db068f2f32dbae6f9a3a21da7e0b5aa to your computer and use it in GitHub Desktop.
how to convert each column data type in data.frame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set function with which convert data into named vector | |
col.type.f <- c(vane=as.factor, | |
prefecture=as.factor, | |
date=as.Date, | |
time=as.factor, | |
ts=as.POSIXct) | |
# convert data type | |
for (col in names(col.type.f)) { | |
f.conv <- col.type.f[col][[1]] | |
dt[col] <- f.conv(dt[,col]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment