如何将分类变量转换为R中的连续变量?

问题描述 投票:0回答:1

我有一个DataFrame,其中包含许多变量,例如百分比,年,公顷等,但是我有一个变量,即距离,我正在评估直接影响(直接影响的区域)以及该影响的程度,其范围为km左右的缓冲区直接的影响,我将其与对照进行比较。我有:

至此,我的变量是分类的,即使它们代表距离。

 Distances:"dirImpct",1km","2km","3km","4km","5km","6km","7km","8km","9km","10km","20km","30km","40km","50km","60km","70km", "controle")

我想要这样的东西:

Distances:  dirImpct < km < control
DirImpact= distance  0
km= distances, (1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70)
control= distances > 70
r dataframe variables categorical-data continuous
1个回答
0
投票

您可以转换为factor并重命名levels

© www.soinside.com 2019 - 2024. All rights reserved.