Connect with us

Hi, what are you looking for?

Data Science

Str And Summary Functions In R

In this tutorial, we going to look helper functions (str and summary function). These functions are so helpful for your R projects. With these functions, you can control and examine almost every structure in R projects.

Summary Function Syntax

the summary function syntax is so simple according to other functions, just you need to object for use summary function. The summary function will print general information on the screen.

summary(object)
Str Function Syntax

You can use the str function to get more compact and fragmented printouts than the summary function. The syntax is the same as for the summary function, in the same way, a nail is entered and the values are displayed on the screen.

str(object)
Summary Function Definition

The summary function is more difficult to read than the str function, but it contains more data. For example, if you want both the data and the sum of a list then it is better to use the summary function. This function is not practical but provides you with more information.

Str Function Definition

Str function is a concept that you use more often. This function prints the object information on the screen in a compact way, and there is simple and clear information without any complex information.

Comparison Example

Let’s make an example and compare the outputs to see the obvious difference between them. In this example, we’ll use a matrix with numbers from 1 to 10.

r$> summary(matrix(1:10 , ncol = 2 , nrow = 5))

|V1          |V2
|Min:1       |Min:6
|1st Qu:2    |1st Qu:7
|Median:3    |Median:3
|Mean:3      |Mean:8
|3rd Qu:4    |3rd Qu:9
|Max:5       |Max:10

Yes, we used the summary function in the example above, the output looks long and confusing, but if you examine it for 1-2 minutes, you can understand the features. Let’s write the values of the 1 by 16 matrix object with the str function now.

r$> str(matrix(1:10 , ncol = 2 , nrow = 5))
int [1:5, 1:2] 1 2 3 4 5 6 7 8 9 10

There is a simpler and compact output here, the data type of the data, column and row values, and all values in the matrix, printing in order. We often use this function to examine a variable.

 

CONGRATULATIONS, YOU FINISHED STR AND SUMMARY FUNCTION IN R

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Programming

This article was created for those who want to use functional programming in their career or who are learning new programming paradigms. We will...

Programming

Functions are pieces of code that combine the integrity of the code used to perform a task into a single structure. If you are...

Programming

Computers can solve an event in different ways, we call these ways algorithms, each algorithm works differently from the others and has different processing...

Data Science

SQL (Structured Query Language) is one of the most used tools by data scientists, data analysts, and data engineers. Almost all companies use a...