Data frames - Creating a data frame

Опубликовано: 20 Октябрь 2024
на канале: 365 Data Science
4,669
67

👉🏻 Download Our Free Data Science Career Guide: https://bit.ly/3iI5QD2
👉🏻 Sign up for Our Complete Data Science Training with 57% OFF: https://bit.ly/2Csmabz

Data frames are one of R’s best structures for dealing with sets of data. Let's learn how to create them from scratch (data.frame, str, names).

The common limitation of vectors and matrices is that they can only store elements of a single basic type. If we try to assign objects of different kinds to either, R’s coercion takes place. That’s mighty inconvenient for storing any type of real data, which often include both numerical and string variables, as well as, although less often, logical values. Lists are very cumbersome as structures, which makes them extremely difficult to operate on directly.

Think of data frames as an Excel spreadsheet: they store different types of data, simultaneously, in a functional way.

Data frames combine vectors of the same length into the columns of a table. Data types can differ between columns, but not within columns. That said, a row can be constructed by cells with different data types, but columns can only contain cells of one type.

To create a data frame, you need two things: vectors of equal length to bind into the columns of a table, and the data.frame() function.

Data.frame binds the vectors as columns and infers that the names of the vector correspond to column names.

You can reassign names with the names() function, or do it directly in the initial call.

► Consider hitting the SUBSCRIBE button if you LIKE the content: https://www.youtube.com/c/365DataScie...

► VISIT our website: https://bit.ly/365ds

🤝 Connect with us LinkedIn:   / 365datascience  

365 Data Science is an online educational career website that offers the incredible opportunity to find your way into the data science world no matter your previous knowledge and experience. We have prepared numerous courses that suit the needs of aspiring BI analysts, Data analysts and Data scientists.

We at 365 Data Science are committed educators who believe that curiosity should not be hindered by inability to access good learning resources. This is why we focus all our efforts on creating high-quality educational content which anyone can access online.

Check out our Data Science Career guides:    • How to Become a... (Data and AI Caree...  

#RProgramming #DataScience #Statistics