I am trying to use the structure() function to create a data frame in R.
I saw something like this
structure(mydataframe, class="data.frame")
Where did class come from? I saw someone using it, but it is not listed in the R document.
Is this something programmers learned in another language and carries it over? And it works. I am very confused.
Edit: I realized dput(), is what actually created a data frame looking like this. I got it figured out, cheers!
You probably saw someone using
dput.dputis used to post (usually short) data. But normally you would not create a data frame like that. You would normally create it with thedata.framefunction. See belowThen, if someone wants to “copy” your
data.frame, he just has to run the following:I put “copy” in quotes because note the following:
identicalyields false because when you post yourdputoutput, often the numbers get rounded to a certain decimal point.