Tuesday, 8 August 2017

Data Science Tutorial Part 3 Vectors

  1. Creating Vectors
  1. Vector: 1D array of data elements with same datatype
  2. The c() function can be used to create vectors of objects by concatenating things together.
  1. Note that in the above example, T and F are short-hand ways to specify TRUE and FALSE. However,in general one should try to use the explicit TRUE and FALSE values when indicating logical values.
  2. You can also use the vector() function to initialize vectors.
  1. There are occasions when different classes of R objects get mixed together then R will convert implicitly  into some class.
  1. Objects can be explicitly coerced from one class to another using the as.* functions, if available

  2. Sometimes, R can’t figure out how to coerce an object and this can result in NAs being produced.

  3. Single value variable also vector
  4. Create a named vector for playing cards
  5. Method 1:
  6. Method 2:
  7. Method 3:
  8. One more example : let us say you played cards Monday to Friday and record profit and loss as vector.
For more please refer https://cran.r-project.org/doc/manuals/R-intro.html#Simple-manipulations-numbers-and-vectors or http://www.r-tutor.com/r-introduction/vector

No comments:

Post a Comment