简体   繁体   中英

Load csv file with R

I am trying to load a csv file with R This csv file contains only one column. When I try to do :

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

It loads also the id-row : 1, 2, ...

How can I do to load only the value?

Thank you

the csv file :

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

x must be numeric

Print ' head(Data) ' and str(Data) . Have you id-row now?

You need to access the column with the variables, because x is a dataframe.

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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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