November 2018
Beginner to intermediate
354 pages
6h 59m
English
Data frames are like matrices, except for the one additional advantage that we can now have a mix of different element types in a data frame. For example, we can now store both numeric and character elements in this data structure. Now, we can also put the names of different food items along with their prices in different months to be stored in a data frame. First, define a variable with the names of different food items:
items = c("potato", "rice", "oil")
We can define a data frame using data.frame as follows:
all_prices3 = data.frame(items, jan_price, mar_price, june_price) all_prices3
The data frame all_prices3 looks like the following:
Accessing elements in a data frame can be done by using either [[]] or $. To select all ...
Read now
Unlock full access