Skip to main content

Posts

Showing posts with the label head()

head() and tail() functions in R

head()  and  tail()  functions: head()  function displays the first values from a data frame, matrix or vector, while   tail()  function displays the last values. Parameters:   x :object to display the values from   n :number of values to be displayed, default values is 6. #head() and tail() functions with a vector head ( 1 : 20 ) ## [1] 1 2 3 4 5 6 head ( 1 : 20 , n = 10 ) #10 first rows in the vector ## [1] 1 2 3 4 5 6 7 8 9 10 head ( 1 : 20 , n = - 10 ) #all the rows in the vector but the LAST 10!! ## [1] 1 2 3 4 5 6 7 8 9 10 tail ( 1 : 20 ) ## [1] 15 16 17 18 19 20 tail ( 1 : 20 , n = 10 ) #10 first rows ## [1] 11 12 13 14 15 16 17 18 19 20 tail ( 1 : 20 , n = - 5 ) ##all the rows in the vector but the FIRST 10!! ## [1] 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 #head() and tail() functions with a matrix A = head ( matrix ( 1 : 50 , ncol = 5 ) , n = 3 ) #assign...