The str()
function returns the structure of an R object and the overall information about it, the exact contents of which depend on the data structure of that object. For example, for a vector, it returns the data type of its items, the range of item indices, and the item values (or several first values, if the vector is too long). For a data frame, it returns its class (data.frame), the number of observations and variables, the column names, the data type of each column, and several first values of each column.
The summary()
function returns the summary statistics for an R object. It’s mostly applied to data frames and matrices, for which it returns the minimum, maximum, mean, and median values, and the 1st and 3rd quartiles for each numeric column, while for the factor columns, it returns the count of each level.
Leave a Reply