statistics_learning
statistics_learning

Reputation: 437

how to interpret data.frame in R

I have problem in interpret the following syntax:

data=data.frame(X,Z[,5])

I check it in R. I konw that X is the dataset that pass to the data.fram, but I don't find the corresoponding argument to Z[,5], so how to interpret this syntax?

data.frame(..., row.names = NULL, check.rows = FALSE,
           check.names = TRUE, fix.empty.names = TRUE,
           stringsAsFactors = default.stringsAsFactors())

Upvotes: 0

Views: 124

Answers (1)

Rich Scriven
Rich Scriven

Reputation: 99331

X and Z[,5] are both being passed as data values through the ... argument. An attempt will be made to make both of them into separate columns of a data frame. Any arguments that follow ... in an argument list must be named. In data.frame(), ... is the first argument. So to pass values to any argument other than ..., you must use names. You haven't named any, and therefore both X and Z[,5] are passed to .... If you had done, for example,

data.frame(X, row.names = Z[,5]) 

where there is a named argument, then Z[,5] would be passed to the row.names argument. See the Introduction to R manual for more.

Upvotes: 4

Related Questions