How to Create Data Frames in R | How to Add a New Column to a Data

Published: 25 March 2023
on channel: Animal Sciences
872
15

This video is about creating data frames in R. A data frame contains columns and rows and it is a two dimensional structure. First, we will create 4 objects. The first object is a character vector which contains the names of animals. The second object is a numeric vector which contains the numbers of animals, stored as animal_n. The 3rd object is names of fruits and the fourth object is the numbers of fruits.

To confirm the values stored in these objects, we will simply print the results by typing the names of these objects. Now we will create a data frame from these objects using data.frame function. We will store this data as data1. So we type data.frame and then type each object in a sequence. Run this code. To print the results we will type data1. So here you can see a data frame is created. You can type View(data1) to view it.

You can also check the structure of data using str function. To add a new column to a data frame we use $ sign. You can clear console using Ctrl + L command from the keyboard.

To download R code or Rscript
https://drive.google.com/file/d/1ffOg...

To learn basics of R Programming
   • Basics of R Programing  

Creating objects, vectors or variables in R program
   • Creating Objects and Variables in R |...  

Performing operations on vectors and objects in R software
   • Performing Operation on Vectors and O...  

#dataframe #rprogramming #rlanguage #rstats #rstudio #animalsciences


Watch video How to Create Data Frames in R | How to Add a New Column to a Data online without registration, duration hours minute second in high quality. This video was added by user Animal Sciences 25 March 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 872 once and liked it 15 people.