[英]How to convert categorical string variables in Excel to numeric variables?
I am trying to analyze road collision data. 我正在尝试分析道路碰撞数据。 I need to convert the categorical data into numeric data in Excel before I import it to RStudio, but I am not able to do it.
在将分类数据导入RStudio之前,我需要在Excel中将分类数据转换为数字数据,但是我无法做到。
Excel file containing the sample data to be used: 包含要使用的示例数据的Excel文件:
Have a look at this, as I don't know which value you want to search with and which you want as the result, I have shown it taking the weather and returning the leftmost column. 看看这个,因为我不知道您要搜索哪个值,以及想要哪个结果,所以我已经显示了天气情况并返回了最左边的列。
You can change that as you need as I have used Index() with match(). 您可以根据需要更改它,因为我已经将Index()与match()一起使用了。
So, based on the comment, all you need is left() to get the number, I have used find() to get the space just in case you have 2 or 3 digit numbers... 因此,基于注释,您只需要left()即可获取数字,我已经使用find()来获取空格,以防万一您拥有2或3位数字...
=LEFT(C3,FIND(" ",C3,1)-1)
C3 is the target cell, drag down as far as... C3是目标单元格,向下拖动到...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.