7. Defining a data frame. In R
, it will often be simpler to work with data in the form of a data frame
, rather than
a collection of vectors. In this exercise, you will combine bond data, which consists of two variables -- rate
,
and company
-- into a data frame object.
You can define a data frame by passing the data.frame()
function column names and associated vectors. For example, the code
below defines a data frame with the columns X
and Y
.
data <- data.frame(X = c(1,2,3), Y = c(4,5,6))