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
Run Code Online (Sandbox Code Playgroud)
打印行不起作用。我尝试了很多事情。我认为可能会使用cbind。da 是一个大表,但我只需要显示前 6 行。
正如 jdarrison 所说,head(da,6)会起作用 - 或者你可以使用索引来打印前 6 行da[1:6,]
使用索引表示法时,请记住它是,并且如果有or - 即表示前六行或前六列,[rows,columns]则必须包含逗号。data.framematrix[1:6,][,1:6]