简体   繁体   English

用R加载csv文件

[英]Load csv file with R

I am trying to load a csv file with R This csv file contains only one column. 我正在尝试使用R加载一个csv文件。此csv文件仅包含一列。 When I try to do : 当我尝试做时:

Data <- read.csv ("file.csv", header = FALSE) 

It loads also the id-row : 1, 2, ... 它还加载id行:1、2,...

How can I do to load only the value? 如何只加载值?

Thank you 谢谢

the csv file : csv文件:

123

11 

24 

122 

133

I would like to load 123, 11 ,24, 122 and 133 in one variable when I try to do a histogram with : hist(X, xlim = c(-10, 20)) it indicates 当我尝试使用hist(X,xlim = c(-10,20))做直方图时,我想在一个变量中加载123、11、24、122和133

x must be numeric

Print ' head(Data) ' and str(Data) . 打印' head(Data) '和str(Data) Have you id-row now? 你现在行吗?

You need to access the column with the variables, because x is a dataframe. 您需要使用变量访问该列,因为x是一个数据框。

hist(x$V1,xlim=c(-10,20))

or just take the column as a vector 或者只是将列作为向量

x <- read.csv("file.csv",header=FALSE)[,1]
hist(x,xlim=c(-10,20))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM