.


:




:

































 

 

 

 





R , (ASCII) . : read.table() ( : read.csv() read.csv2()), scan() read.fwf().

, data.dat, :

> mydata <-read.table ("data.dat")

mydata data.frame, , , V1, V2... mydata$V1, mydata$V2..., mydata["V1"], mydata["V2"]..., mydata[,1], mydata[,2],

, : mydata$V1 mydata[,1] , mydata["V1"] - data.frame.

read.table() :

read.table(, header=FALSE, sep = "", quote = "\"", dec = ".", row.names =, col.names =, as.is=FALSE, na.strings = "NA", skip=0, fill =! blank.lines.skip, check.names=TRUE, strip.white=FALSE, blank.lines.skip = TRUE)

:

( " "), ( \ , /).
header ( ) , .
sep , sep = "\t", - .
quote , .
dec , .
row.names , , ( ) ( : 1, 2, 3...).
col.names ( : V1, V2, V3...).
as.is ( ) ().
na.strings ( - NA). .
skip ,
fill = TRUE .
check.names , , R
strip.white ( sep), ,
blank.lines.skip TRUE TRUE FALSE, fill = TRUE

read.csv read.csv2 :

read.csv (, header = , sep =,"", quote = " \ "", dec = ". "...)

read.csv2 (, header = , sep = ";", quote = " \ "", dec = ", "...)

scan() , read.table() . , , , :

> mydata <-scan("data.dat", what=list (" ", 0,0))

data.dat , - .

scan():

> 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, strip.white=FALSE, quiet=FALSE)

:

file ( " "), ( \ , /), file = " ", .
what
nmax , , what , ( , scan )
n , ( )
sep
quote ,
dec , .
skip ,
nlines
na.strings , ( NA)
flush , TRUE, scan ,
strip.white ( sep), TRUE,
quiet , FALSE, scan , ,

read.fwf() , :

read.fwf (, widths, sep = "\t ", as is=FALSE, skip=0, row.names, col.names)

, data.txt :

A1    
A1    
B1    
B1    
C1    
C1    

:

> mydata <-read.fwf("data.txt", widths=c(1,4,3))

> mydata

V1 V2 V3

1 1.50 1.2

2 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





:


: 2017-02-28; !; : 288 |


:

:

. .
==> ...

1438 - | 1404 -


© 2015-2024 lektsii.org - -

: 0.011 .