Tuesday 8 August 2017

Data Science Tutorial Part 6 Data Frames

  1. Data frames
  1. In simple words a data frame is a table
  2. Rows are called as observations
  3. Columns are called as variables
  4. Columns can be different data types
  5. One column should store only one datatype data
  6. Create data frame
    1. Generally we are going to create data frame by importing csv files,relational database,excel ..etc
    2. First let us see how to create manually

  7. Structure of the data frame .Notice that above data frame has 3 observations(rows) and 4 variables(columns)

  8. In create data frame include one more parameter stringsAsFactors = FALSE and observe str(emp.data)
  9. Summary of data in data frame

  10. Exercise : create one more dataframe with the name df and with below data
  11. Extract specific column of a data frame using column name

  12. Extract the first two rows and then all columns
  13. Extract the first two columns and then all rows
  14. Extract specific rows and columns
  1. Add a column to data frame

  2. Add row to data frame



  3. Delete a row from data frame

  4. Delete column from data frame

  5. Head(),tail(),dim() functions
  1. Sort() and order() functions
  2. The number of data rows in the data frame is given by the nrow() function
  3. the number of columns of a data frame is given by the ncol() function
  4. We reference a data frame column with the double square bracket "[[]]" operator.
  5. For example, to retrieve the ninth column vector of the built-in data set mtcars, we write mtcars[[9]] or mtcars[["am"]] or mtcars$am or mtcars[,"am"]
For more refer https://cran.r-project.org/doc/manuals/R-intro.html#Data-frames or http://www.r-tutor.com/r-introduction/data-frame

No comments:

Post a Comment