I am trying to Bin some (75) continuous variable based on some predefined bins of another data frame. For example, the data frame, G, has all of the bins I want, and the data frame Test is where the continuous variables are that I need to be discreet. For example, the variable, X3975, has bin cut off points .0625, and .1 so I need to write an ifelse statement like the following:
Ifelse((X3975 >=0 & X3975 <=.0625),”0-.0625”,
Ifelse((X3975 >=.0625 & X3975 <=.1),”.0625-.1”,
Ifelse((X3975 >= .1 ),”>.1”,
For each of the variables in the G data set to match with the variables in the Test data set. Is there an efficient way of doing this??
G dataframe data set looks like:
Bins Variable
- .0625 X3975
- .1 X3975
- .01 X3976
- .1 X3976 ...... a total of 75 different variables with different number of bins
Test dataframe dataset
X3001 X3100 X3102 .... X3999
Aucun commentaire:
Enregistrer un commentaire