R Programming Data frame: Exercises, Practice, Solution

1. Write a R program to create an empty data frame.

d <- data.frame(nombre = character(), edad = integer(), boolean = logical())
d
## [1] nombre  edad    boolean
## <0 rows> (o 0- extensión row.names)

2. Write a R program to create a data frame from four given vectors.

## Warning: package 'kableExtra' was built under R version 4.4.3
Nombre Carrera Semestre
Andreina Ing. Industrial 4
Daniela Ing. Industrial 5
Carlos Ing. Industrial 4

3. Write a R program to get the structure of a given data frame.

## [1] "Original dataframe:"
##         name score attempts qualify
## 1  Anastasia  12.5        1     yes
## 2       Dima   9.0        3      no
## 3  Katherine  16.5        2     yes
## 4      James  12.0        3      no
## 5      Emily   9.0        2      no
## 6    Michael  20.0        3     yes
## 7    Matthew  14.5        1     yes
## 8      Laura  13.5        1      no
## 9      Kevin   8.0        2      no
## 10     Jonas  19.0        1     yes
## [1] "Structure of the said data frame:"
## 'data.frame':    10 obs. of  4 variables:
##  $ name    : chr  "Anastasia" "Dima" "Katherine" "James" ...
##  $ score   : num  12.5 9 16.5 12 9 20 14.5 13.5 8 19
##  $ attempts: num  1 3 2 3 2 3 1 1 2 1
##  $ qualify : chr  "yes" "no" "yes" "no" ...
## NULL

4. Write a R program to get the statistical summary and nature of the data of a given data frame.