1

I have a dataframe called data which contains 5 columns and approximately 181 rows.

I'm trying to run some algorithm on this dataframe, but I have to do some pre-processing beforehand and normalize the columns to have zero and 1. I am using R and the problem that i have columns whit not numeric data like this:

Name       ZwaveType ProprietesName Value                Date
Switcher19         0              2     1 2014-03-01 06:45:00
Switcher5          0              2     1 2014-03-01 07:00:00
Switcher15         0              2     1 2014-03-01 07:15:00
Switcher4          0              2     1 2014-03-01 07:14:30
Switcher15         0              2     0 2014-03-01 07:25:00
Switcher19         0              2     0 2014-03-01 07:45:00

I'd like to ask how can I achieve normalization with R for this case?

4

1 回答 1

1

大概是这样的

col.classes <- sapply(mydata,class)
num.cols <- (col.classes=="numeric")
mydata[,num.cols] <- scale(mydata[,num.cols])
于 2014-05-19T12:38:33.730 回答