# (a) Create the Data Frame
country <- c("India", "China", "USA", "Brazil", "Germany")
gdp_growth <- c(6.8, 5.5, 2.4, 2.2, 0.2)
inflation_rate <- c(5.2, 2.3, 1.7, 5.1, 2.3)
is_developing <- c(TRUE, TRUE, FALSE, TRUE, FALSE)
econ_data <- data.frame(country, gdp_growth, inflation_rate, is_developing)
econ_data
## country gdp_growth inflation_rate is_developing
## 1 India 6.8 5.2 TRUE
## 2 China 5.5 2.3 TRUE
## 3 USA 2.4 1.7 FALSE
## 4 Brazil 2.2 5.1 TRUE
## 5 Germany 0.2 2.3 FALSE
# (b) Display the Structure and First Few Entries
str(econ_data)
## 'data.frame': 5 obs. of 4 variables:
## $ country : chr "India" "China" "USA" "Brazil" ...
## $ gdp_growth : num 6.8 5.5 2.4 2.2 0.2
## $ inflation_rate: num 5.2 2.3 1.7 5.1 2.3
## $ is_developing : logi TRUE TRUE FALSE TRUE FALSE
head(econ_data, 3)
## country gdp_growth inflation_rate is_developing
## 1 India 6.8 5.2 TRUE
## 2 China 5.5 2.3 TRUE
## 3 USA 2.4 1.7 FALSE
# (c) Identify Data Types and Explain
## 1. country: Character type — because names of countries are textual.
## 2. gdp_growth: Numeric type — growth rates are numerical values.
## 3. inflation_rate: Numeric type — inflation is measured as a number.
## 4. is_developing: Logical type — represents TRUE/FALSE values indicating development status.