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

แชร์
ฝัง
  • เผยแพร่เมื่อ 20 ก.ย. 2024
  • 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
    drive.google.c...
    To learn basics of R Programming
    • Basics of R Programing
    Creating objects, vectors or variables in R program
    • Creating Objects and V...
    Performing operations on vectors and objects in R software
    • Performing Operation o...
    #dataframe #rprogramming #rlanguage #rstats #rstudio #animalsciences

ความคิดเห็น • 2