data.frame(..., row.names = NULL, check.rows = FALSE, check.names = TRUE, stringsAsFactors = default.stringsAsFactors())as.data.frame(x, row.names = NULL, optional = FALSE, ...)
is.data.frame(x)
... | the objects to include in the data frame. These can be vectors (numeric, character, or logical), factors, numeric matrices, lists, or other data frames. Matrices, lists, and data frames provide as many variables to the new data frame as they have columns, elements, or variables, respectively. If the objects have different lengths for each of their elements, the value of the length must have a multiple relationship. Otherwise, an error is shown. This argument can be missing, in which case the function produces an empty data frame (0 columns by 0 rows). |
row.names | a (character) vector giving row names for the data frame. If this argument is a single string, and the data frame contains more than one row, this specifies the name of the input object containing the row names (rather than including that object into the data frame). If the vector is a single numeric value, it specifies the index of the input object containing the row names. Neither duplicated nor NA values are allowed in row.names. If this argument is NULL (the default), default row names are used. |
check.rows | a logical flag: if TRUE, and if several arguments imply row names, the function checks that these names are consistent. Usually, this flag is useful only in computations that claim to have selected the same rows from several parallel sources of data. This argument is ignored if row.names is supplied. The default is FALSE. |
check.names | a logical flag: if TRUE (the default), then variable names are changed to legal object names by substituting . for illegal characters such as blanks, parentheses, or commas. (See make.names for details.) |
stringsAsFactors | a logical flag: if TRUE (the default), then it converts character arguments to factors whose levels are the unique strings in the argument. This option can save time and space if the strings contain several repeated values, which in turn can make the statistical modeling functions easier to use. |
x | an object to be coerced to a data frame. This object can be anything representing one or more variables of a data frame. For example, it can be a vector representing a single column or a matrix representing multiple columns. The as.data.frame S3 method for the class of x is called to coerce x to a data frame If there is no S3 method for the class of x, the function exits with an error. |
optional | a logical value: if TRUE, keep the object default column names with no change. If FALSE (the default), try to construct the column names with a specified nm argument (if available) or the names of x (if available). Otherwise, construct the column names as a "X*", "V*", or "c*" format. (* can be 1, 2, 3, or combination of character elements). This argument is not available in the default and character class methods. |
data.frame | returns a data frame consisting of all the variables supplied in the arguments. The variables are required to have the same number of observations. See Details for more information. |
as.data.frame | returns a data frame created from x. The S3 method method for the class of x does the coericion. |
is.data.frame | returns a logical value: TRUE if the object x is a data.frame and FALSE otherwise. |
data.frame(c(1:4), c(4:5), list(c(1), c(2:3)), c(3)) # OK to create a dataframe. For the column c(1),c(2:3),c(3), # it will repeat to meet the length of c(1:4) and c(4:5)as.data.frame(c(1, 2, 3)) # OK to create a dataframe with the column name is "c(1, 2, 3)"
is.data.frame((1:10)) # [1] FALSE
is.data.frame(data.frame(c(1, 2, 3))) # [1] TRUE