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.

You May Also Like

News

What is LaMDA? The LaMDA is an AI (neural network) developed to realize natural conversations with humans by extracting information from a large amount...

Programming

In this article, we will create a simple timer app for beginners with Swift and SwiftUI. Step 1: Create a Header First, we will...

Programming

Swift optionals can be a bit confusing, in this article we’ll go into detail about optionals. We will look at how they can be...

News

According to a study from Dartmouth College, Dartmouth’s Tuck School of Business, and Indiana University, artificial intelligence systems can be trained to produce human-like...