R language Read file data
?? 1.read.table () function
2. Default for other functions
Read.csv (file, Header = TRUE, Sep = ",", quote= "\" ", dec=". ",
Fill = TRUE, ...)
Read.csv2 (file, Header = TRUE, Sep = ";", quote= "\" ", dec=", ",
Fill = TRUE, ...)
Read.delim (file, Header = TRUE, Sep = "\ t", quote= "\" ", dec=". ",
Fill = TRUE, ...)
READ.DELIM2 (file, Header = TRUE, Sep = "\ t", quote= "\" ", dec=", ",
Fill = TRUE, ...)
3.scan function can change parameter type
> MyData <-Scan ("Data.dat", what = List ("", 0, 0))
Scan (File = "", what = Double (0), Nmax =-1, n =-1, Sep = "",
Quote = if (sep== "\ n") "" Else "\" ", Dec =". ",
Skip = 0, Nlines = 0, na.strings = "NA",
Flush = false, fill = false, Strip.white = False, Quiet = False,
Blank.lines.skip = True, Multi.line = true, Comment.char = "")
4.READ.FWF () can read data with a certain width in the file
READ.FWF (file, widths, sep= "\ t", as.is = FALSE,
Skip = 0, row.names, col.names, n =-1, ...)
Widths can set the width
> MyData <-read.fwf ("Data.txt", Widths=c (1, 4, 3))
> MyData
V1 V2 V3
1 A 1.50 1.2
2 A 1.55 1.3
3 B 1.60 1.4
4 B 1.65 1.5
5 C 1.70 1.6
6 C 1.75 1.7
5. Writing Data write.table ()
Write.table (x, File = "", append = FALSE, quote = TRUE, Sep = "",
EOL = "\ n", na = "na", Dec = ".", Row.names = TRUE,
Col.names = TRUE, Qmethod = C ("Escape", "double"))
??????????
????
??????????
????
??
R language Read file data