read CSV format data
Data source is Southwestern University Siyakin Teacher's course assignment
Method One: Read.csv () function
1 file.choose () 2 read.csv ("c:\\users\\administrator\\desktop\\astocks.csv",3 head=t,sep=','5
Results
file.choose (): reads the file so that we know the specific path to the file.
File parameter : path and filename, Windows uses a backslash \ \
head=t: This is the first line, T indicates that the file has a title, and the first row in the file is the column name. If head=f, the original file is not
Title, add a line v1,v2, ... As the first line of the file, that is, the column name. The Read.csv () function defaults to head=t.
sep= ",": Delimiter problem, here the selection of separators will affect the input of the referenced string.
nrows=200: The number of rows problem, indicating that the first 200 lines of the file are read.
stringsasfactors = False : Character data is automatically converted to a factor when read, prevents conversion to a factor, and the parameter stringsasfactors = False,
Prevents the conversion of any factor in the imported data.
method Two: Read.table () function
1 a<-read.table ('c:\\users\\administrator\\desktop\\astocks.csv', 2 head=t,sep=','5, stringsasfactors = FALSE) 3 A
1 a[1:3,1:3]
Results
Slices: Select the number of rows and columns (choose between 1 and 3 rows and 1 to 3 columns)
R language Learning Note 001--reading CSV format data