R Data Frame - r - learn r - r programming



  • A data frame is a very important data type in R.
  • A data frame is more common than a matrix, in that different columns can have different modes such as numeric, character, factor, etc. This is similar to SAS (Statistical Analysis System) and SPSS (Statistical Package for the Social Sciences) datasets.
  • A data frame is used for storing data tables.
 r data frames

Syntax:

Data.frame()

Sample Code:

d1 = 1:3
d2 = c(T,F,T)
wikitechy = data.frame(d1,d2)
print(wikitechy)

Code Explanation:

 r datatypes dataframe structure
  1. A dataframe of two vectors is created, each of three elements. The first vector, d1 is composed of a sequence of the integers 1 through 3 (1:3).
  2. A second vector, d2, is composed of three logical values drawn of type T (TRUE) and F (FALSE).
  3. The dataframe is then created, composed of the vectors d1 and d2.
  4. Here print() is used to print the value, that value stored in wikitechy variable.

Sample Output:

 r datatypes dataframe output
  1. Here in this output we display combine the vectors (d1 and d2) which using to data.frame() function.

Related Searches to R Data Frame