To create a dataframe in R, we can use the data.frame()
function.
Here's an example:
main.r196 chars10 lines
In this example, we create a dataframe with three columns (Name, Age, and Is_Student) and four rows. We pass the values for each column as vectors to the data.frame()
function.
Note that we assign the resulting dataframe to a variable df
so that we can use it later in our code. We then print the dataframe using the print()
function.
Output:
main.r120 chars6 lines
This is how we can create a simple dataframe in R using data.frame()
.
gistlibby LogSnag