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

Cyber Security

In this article, we are going to examine real-world logic bombs. Also, we are going to create one with Python for seeing how to...

Cyber Security

Welcome to the second tutorial on networks for hackers. We are going to learn network types and weaknesses and strengths of networks in this...

Programming

In this tutorial, we going to learn file handling with Python. At the end of the article, you will be ready to work with...

Cyber Security

In this article, we going to learn how networking works and simple terms in networking. Also, we are going to learn simple network attacks....