A Few R Data Types
Every computer programming environment (i.e. R, SAS, SPSS, Python, Perl, etc.) offers various data types. Data types are variables that are used during the run time (when a computer program is running) to hold a value or obtain the current value from the variable. For example let's say we are wanting to run an analysis for a farm which grows apples, peaches, strawberries and raspberries. In the analysis, we may want to hold an integer value in a computer program where this integer value signifies the number of fruits we packed in the last box (i.e. how many apples, etc.); similarly we may want to hold a string value in the same computer program that signifies the name of the fruit we packed in the last box (i.e. apples), etc. Accordingly an integer and a string are two of the common data types offered in many programming environments such as Python and Perl. Every programming environment offers multitude data types, in this topic we will review the three most common data types offered by R: vectors, list and tables.
We have found it to be much easier to learn these concepts if you have the opportunity to practice with some data. Let's start with some simple exercises to help you practice.
Write a script in which you have defined a vector with 5 cells having values 2,4,8,16, and 32. Next write an instruction with a new variable that will calculate the value of the sum of all the integer values of the defined vector. Finally print the sum from the variable.
Answer: You must get an output of 62 on the R console i.e. the lower left frame of RStudio.
Modify the input data file for the Vector Table (from the data file link above the video tutorial) and change the column names to GroupingVariable, Att1, Att2 instead of GroupOn,Attribute1,Attribute2 respectively. Now print the vector form for the column 1 of the table.