R 學習筆記《四》 R語言初學者指南--載入數據

解壓下載的數據到:E:\R\R-beginer-guide\data\RBook數據庫

在R控制檯執行:ide

Squid <- read.table(file = "E:/R/R-beginer-guide/data/RBook/squid.txt",header=TRUE)
Squid
     Sample Year Month Location Sex     GSI
1         1    1     1        1   2 10.4432
2         2    1     1        3   2  9.8331
3         3    1     1        1   2  9.7356
4         4    1     1        1   2  9.3107
5         5    1     1        1   2  8.9926
6         6    1     1        1   2  8.7707
7         7    1     1        1   2  8.2576
8         8    1     1        3   2  7.4045
9         9    1     1        3   2  7.2156
10       10    1     2        1   2  6.8372
11       11    1     1        1   2  6.3882
12       12    1     6        1   2  6.3672
13       13    1     2        1   2  6.2998
14       14    1     1        1   2  6.0726

..................

..................

..................

省略其他數據函數

 

這個命令實現了把數據從squid.txt文件中讀取出來以數據框的形式存儲到Squid中ui

Squid <- read.table(file = "E:/R/R-beginer-guide/data/RBook/squid.txt",header=TRUE) #命令真正內容:

Squid <- read.table(file = "E:/R/R-beginer-guide/data/RBook/squid.txt",header=TRUE,dec=".")

 

dec指定小數點是什麼。blog

技巧:io

經過setwd設置工做目錄執行read.table函數事就不須要指定目錄了。table

scan也能夠導入數據不過read.table是將數據導入到數據框中,而scan是將數據導入到矩陣中。class

從其餘統計軟件中導入和從數據庫導入數據省略。沒條件實驗。gui

相關文章
相關標籤/搜索