[英]Problem with export data from excel to R (not interpreting data as numbers)
I have the following problem with exporting data from excel, and importing them into R.我在从 excel 导出数据并将它们导入 R 时遇到以下问题。
My data in excel contains "," so excel interprets them as numbers.我在 excel 中的数据包含“,”,因此 excel 将它们解释为数字。
But when I have this data in RI have "."但是当我在 RI 中有这些数据时有“。” so R interprets them as text instead of numbers.
所以 R 将它们解释为文本而不是数字。
For example,例如,
In excel I have 12,765 and in RI have 12.765在 excel 中我有 12,765,在 RI 中有 12.765
Do you have any idea how can I fix this ?你知道我该如何解决这个问题吗?
I use the following code to import the data file into R:我使用以下代码将数据文件导入 R:
library(openxlsx)
read.xlsx("pk.xlsx")
I suggest using the nice package readxl
from the tidyverse ( https://readxl.tidyverse.org/ ) :我建议使用 tidyverse ( https://readxl.tidyverse.org/ ) 中的好包
readxl
:
library(readxl)
read_excel("pk.xlsx")
Your should find everything you need with the tidyverse
to import different format of files ( readr
for all csv, tsv and so on... ).您应该使用
tidyverse
找到导入不同格式文件readr
的一切(所有 csv、tsv 等的readr
...)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.