2014-09-04 58 views
1
da=read.table("m-ibm6708.txt",header=T) #<== Load data with header 

#<== Check dimension of the data (row = sample size, col = variables) 
###############502 rows, col 1 = date, col 2 = ibm, col 3 = sprtn 
#<== Print out the first 6 rows of the data object "da". 
printrows <- da[1:6] 
printrows  

打印行不起作用。我嘗試了一堆東西。我認爲它可能會使用cbind。 da是一張大桌子,但我只需要顯示前6行。如何在R Studio中的read.table中打印一定數量的行

+0

你可以使用'head'函數:'head(da,6)' – jdharrison 2014-09-04 00:22:20

+0

謝謝你們的幫助! – user3553260 2014-09-04 03:28:35

回答

2

正如jdharrison說,head(da,6)將工作 - 或者你可以使用索引打印前6行da[1:6,]

當使用索引符號記住它的[rows,columns],你必須包括逗號,如果你有一個data.framematrix - 前六列的[1:6,]或前六列的[,1:6]