R Programming: Constructing Data from Data Frame in two ways
Автор: Anita Mendiratta
Загружено: 2025-03-02
Просмотров: 1673
In this tutorial, we’ll explore how to create and manipulate Data Frames in R Studio! Data frames are a fundamental data structure in R, allowing you to organize and analyze data in a tabular form. In this video, we will cover:
---------
CHAPTERS
0:15 How to create a basic data frame using the data.frame() function
2:51 Exploring data structure and summary using functions like str() and summary()
3:04 Renaming columns in a data frame
-------
R Script:
Creating a data structure for the data frame
Months = c(1:6)
Products = c("Laptop", "Mobile", "Desktop", "TV", "Laptop", "TV")
Sales = c(25000, 34567, 78965, 90876, 23453, 67896)
Using data.frame() to create a data frame
AM <- data.frame(Months, Products, Sales, stringsAsFactors = FALSE)
Creating a data frame in one go
AM_new <- data.frame(Months = c(1:6), Products = c("Laptop", "Mobile", "Desktop", "TV", "Laptop", "TV"),
Sales = c(25000, 34567, 78965, 90876, 23453, 67896))
("Please note that YouTube does not allow angled brackets in video descriptions. Therefore, I have used the Unicode large < symbol as a replacement.")
Explore structure and summary of data
AM
AM_new
str(AM)
summary(AM)
Adding a new variable (unique row) to the data
AM$Name_Months <- c("January", "February", "March", "April", "May", "June")
print(AM)
Changing a column name
AM <- data.frame(Months, Products, Revenue = Sales, stringsAsFactors = FALSE)
---------
By the end of this tutorial, you'll understand how to efficiently work with data frames in R, including creating, modifying, and exploring them.
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: