当我将数据上传到 R 时,它从数字类更改为字符类
当我在 Excel 中设置数据集时,我已将其设置为数字格式,并且所有数据点都是数字。然后我将其转换为 txt 并上传到 R。不知何故,当它在 R 中时,它读取到一些数据点是字符,一些是数字。我不确定上传时如何确保所有数据点均为数字格式。
我需要它们全部采用数字格式,因为稍后我使用 cTree,如果数据是字符,它就不起作用。
谢谢
When I have my data set in excel, I have set it to numeric format and all data points are numbers. I then convert it to a txt and upload to R. Somehow when it is then in R, it reads that some data points are character and some are numeric. I am unsure how to make sure that all data points are numeric format when I upload them.
I need them all to be in numeric format as at a later date I use cTree which does not work if the data is characters.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你用什么函数来上传?如果是
read_csv()
,则可以使用col_types
参数来控制每列的读取方式。例如
What r function are you using to upload? if it is
read_csv()
, you can use thecol_types
argument to control how each column is read.For example