Difference between revisions of "R"
Sudhakarst (Talk | contribs) |
Nancyvarkey (Talk | contribs) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
'''R''' can be used for simple calculations, matrix calculations, differential equations, optimisation, statistical analysis, plotting graphs, etc. Also, it is useful to anybody who wishes to undertake extensive statistical computations and data visualization. | '''R''' can be used for simple calculations, matrix calculations, differential equations, optimisation, statistical analysis, plotting graphs, etc. Also, it is useful to anybody who wishes to undertake extensive statistical computations and data visualization. | ||
− | The | + | The spoken tutorials (ST) for R series was initially created by '''Prof. Kannan Moudgalya, IIT Bombay'''. Later, the domain expert for this series was '''Prof. Radhendushka Srivastava, Maths Dept. IIT Bombay'''. Content for this series was contributed by FOSSEE Fellows 2018 Shaik Sameer and Varshit Dubey and the tutorials were recorded by Sudhakar Kumar, M.Tech student IIT Bombay. Overall coordination for the series was done by Smita Wangikar from FOSSEE project, IIT Bombay. Madhuri Ganapati and Vidhya Iyer from Spoken Tutorial project, IIT Bombay, were the reviewers from ST end. |
+ | |||
+ | '''Learners:''' Analysts, researchers, statistics students | ||
__TOC__ | __TOC__ | ||
Line 12: | Line 14: | ||
'''Note:''' Each numbered topic corresponds to a single spoken tutorial. Each bulleted point corresponds to a command or topic that must be covered in the given spoken tutorial. | '''Note:''' Each numbered topic corresponds to a single spoken tutorial. Each bulleted point corresponds to a command or topic that must be covered in the given spoken tutorial. | ||
− | + | #'''Overview of R and RStudio''' | |
− | + | #*About '''R''' programming language | |
− | * Install R on Linux | + | #*Features of '''R''' |
− | + | #*Applications of '''R''' | |
− | * Use the command-line interface of R | + | #*Discuss the contents available on the '''R''' Project website |
− | + | #*Use the command-line interface of '''R''' | |
− | * Show the value of the exponential function in R | + | #*About '''RStudio''' |
− | + | #*Features of '''RStudio''' | |
− | * Install wget utility | + | #*Discuss the contents available on the '''RStudio''' website |
− | + | #*Explain the interface of '''RStudio''' | |
− | * Install gdebi utility | + | #*Topics covered in this series |
− | + | #'''Installing R and RStudio on Linux''' | |
− | * Install RStudio on Linux | + | #*Install '''R''' on Linux |
− | + | #*Use the command-line interface of '''R''' | |
− | * Launch RStudio on Linux | + | #*Show the value of the exponential function in R |
− | + | #*Install <code>wget</code> utility | |
− | * Run a plot in RStudio | + | #*Install <code>gdebi</code> utility |
− | + | #*Install '''RStudio''' on Linux | |
− | * View packages in RStudio | + | #*Launch '''RStudio''' on Linux |
− | + | #*Run a plot in '''RStudio''' | |
− | * Install packages | + | #*View packages in '''RStudio''' |
− | + | #*Install packages | |
− | + | #'''Installing R and RStudio on Windows''' | |
− | + | #*Install R on Windows 10 | |
− | * Version of '''R''' and '''RStudio''' used | + | #*Launch R |
− | + | #*Use command-line-interface of R | |
− | * Operating systems on which these run | + | #*Run an <code>exp</code> command in R |
− | + | #*Install '''RStudio''' on Windows | |
− | * Quick intro to '''R''' and '''RStudio''' | + | #*Launch '''RStudio''' on Windows |
− | + | #*Run a plot in '''RStudio''' | |
− | * Resizing the font and window size | + | #*Install packages |
− | + | #'''Introduction to basics of R''' | |
− | * Using <code>+</code>, <code>-</code>, <code>^</code>, <code>sqrt</code> | + | #*Version of '''R''' and '''RStudio''' used |
− | + | #*Operating systems on which these run | |
− | * Using <code>exp</code>, <code>log</code>, <code>sin</code> | + | #*Quick intro to '''R''' and '''RStudio''' |
− | + | #*Resizing the font and window size | |
− | * Different ways of invoking <code>log</code> | + | #*Using <code>+</code>, <code>-</code>, <code>^</code>, <code>sqrt</code> |
− | + | #*Using <code>exp</code>, <code>log</code>, <code>sin</code> | |
− | * Vectors using <code>seq</code> and <code>length</code> | + | #*Different ways of invoking <code>log</code> |
− | + | #*Vectors using <code>seq</code> and <code>length</code> | |
− | * Using <code>pi</code> | + | #*Using <code>pi</code> |
− | + | #*Plotting a <code>sine</code> function | |
− | * Plotting a <code>sine</code> function | + | #*Defining more points to get a smooth plot |
− | + | #*Plotting with points and as line | |
− | * Defining more points to get a smooth plot | + | #*Introduction to '''help''' |
− | + | #'''Introduction to data frames in R''' | |
− | * Plotting with points and as line | + | #*Storing captaincy information in '''vectors''' |
− | + | #*Constructing a '''data frame''' using '''vectors''' | |
− | * Introduction to '''help''' | + | #*Plotting one vector of a '''data frame''' vs. another one |
− | + | #*Adding a vector to a '''data frame''' | |
− | + | #*Saving a data frame into a '''csv''' file | |
− | + | #*Preventing the writing of row numbers into the '''csv''' file | |
− | + | #*Changing the contents of a '''csv''' file through a text editor | |
− | * Storing captaincy information in '''vectors''' | + | #*Loading a '''csv''' file into a '''data frame''' |
− | + | #*Accessing the data sets that come with '''R''' | |
− | * Constructing a '''data frame''' using '''vectors''' | + | #'''Introduction to RStudio''' |
− | + | #*Features of '''RStudio''' | |
− | * Plotting one vector of a '''data frame''' vs. another one | + | #*A look at the windows in '''RStudio''' interface: |
− | + | #**'''Source''' and '''Console''' windows | |
− | * Adding a vector to a '''data frame''' | + | #**'''Workspace''' window |
− | + | #**'''Plots''' and '''Files''' window | |
− | * Saving a data frame into a '''csv''' file | + | #*Example to plot a simple data set |
− | + | #*Introduction to packages in '''R''' | |
− | * Preventing the writing of row numbers into the '''csv''' file | + | #*How to find the list of packages installed in '''R''' |
− | + | #*Installation of '''R''' packages in '''RStudio''' | |
− | * Changing the contents of a '''csv''' file through a text editor | + | #*Loading and using '''R''' packages |
− | + | #'''Introduction to R script''' | |
− | * Loading a '''csv''' file into a '''data frame''' | + | #*What is an '''R''' script |
− | + | #*Features of '''R''' script | |
− | * Accessing the data sets that come with '''R''' | + | #*How to create and save an '''R''' script from the user interface (UI) of '''RStudio''' |
− | + | #*Shortcut keys to create an '''R''' script | |
− | + | #*How to use auto-completion of commands | |
− | + | #*How to run an entire script | |
− | + | #*How to run a block of a script | |
− | * Features of '''RStudio''' | + | #*How to add comments |
− | + | #*How to comment an existing line | |
− | * A look at the windows in '''RStudio''' interface: | + | #*How to load one script into another script |
− | ** '''Source''' and '''Console''' windows | + | #'''Working Directories in RStudio''' |
− | ** '''Workspace''' window | + | #*What is working directory in '''R''' |
− | ** '''Plots''' and '''Files''' window | + | #*How to know current working directory |
− | + | #*How to use <code>getwd</code> function | |
− | * Example to plot a simple data set | + | #*How to set a working directory from the user interface of '''RStudio''' |
− | + | #*How to set a working directory from the '''Console''' window of '''RStudio''' | |
− | * Introduction to packages in '''R''' | + | #*How to use <code>setwd</code> function |
− | + | #*How to read and store a '''csv''' file in '''R''' | |
− | * How to find the list of packages installed in '''R''' | + | #*How to use <code>read.csv</code> function |
− | + | #*How to view a stored '''csv''' file in '''R''' | |
− | * Installation of '''R''' packages in '''RStudio''' | + | #*How to use <code>View</code> function |
− | + | #'''Indexing and Slicing Data Frames''' | |
− | * Loading and using '''R''' packages | + | #*Shortcut key for assignment operator (<code><-</code>) |
− | + | #*How to perform numeric indexing | |
− | + | #*How to extract a row or column from a data frame | |
− | + | #*How to retrieve multiple rows from a data frame | |
− | + | #*How to combine objects to form a vector | |
− | * What is an '''R''' script | + | #*How to perform logical indexing on a data frame |
− | + | #*How to perform name indexing on a data frame | |
− | * Features of '''R''' script | + | #*How to slice a data frame using <code>subset</code> function |
− | + | #*How to select required columns (by name) from a data frame | |
− | * How to create and save an '''R''' script from the user interface (UI) of '''RStudio''' | + | #*How to retrieve data using double square brackets |
− | + | #'''Creating Matrices using Data Frames''' | |
− | * Shortcut keys to create an '''R''' script | + | #*Data required in a matrix format |
− | + | #*Convert a data frame into a matrix | |
− | * How to use auto-completion of commands | + | #*Create a matrix with known data |
− | + | #*Add two matrices | |
− | * How to run an entire script | + | #*Subtract two matrices |
− | + | #*Multiply two matrices element wise | |
− | * How to run a block of a script | + | #*Perform true matrix multiplication |
− | + | #*Calculate the transpose of a matrix | |
− | * How to add comments | + | #*Calculate the determinant of a matrix |
− | + | #'''Operations on Matrices and Data Frames''' | |
− | * How to comment an existing line | + | #*How to find the inverse of a matrix |
− | + | #*How to calculate the sum of elements in a matrix using <code>for</code> loop | |
− | * How to load one script into another script | + | #*How to calculate the sum of elements in a matrix using <code>sum</code> function |
− | + | #*How to calculate the time elapsed in an operation | |
− | + | #*How to find out the sum of rows of a matrix | |
− | + | #*How to find out the sum of columns of a matrix | |
− | + | #*How to add a new column or row to an existing data-frame | |
− | * What is working directory in '''R''' | + | #*How to use <code>cbind</code> and <code>rbind</code> function |
− | + | #'''Merging and Importing Data''' | |
− | * How to know current working directory | + | #*Use of built-in functions in '''R''' for exploring a data frame |
− | + | #*Access help in '''RStudio''' | |
− | * How to use <code>getwd</code> function | + | #*Advantages of merging data frames |
− | + | #*Merge two data frames | |
− | * How to set a working directory from the user interface of '''RStudio''' | + | #*Import data from the command line |
− | + | #*Import <code>xml</code> file and <code>txt</code> file in R | |
− | * How to set a working directory from the '''Console''' window of '''RStudio''' | + | #*Import data from the user interface of '''RStudio''' |
− | + | #'''Data Types and Factors''' | |
− | * How to use <code>setwd</code> function | + | #*What is an object in '''R''' |
− | + | #*Types of '''R''' - objects | |
− | * How to read and store a '''csv''' file in '''R''' | + | #*What is an atomic vector in '''R''' |
− | + | #*Types of atomic vectors | |
− | * How to use <code>read.csv</code> function | + | #*How to find types of vectors |
− | + | #*Factors in '''R''' | |
− | * How to view a stored '''csv''' file in '''R''' | + | #*Levels of a factor in '''R''' |
− | + | #*Identification of categorical variables | |
− | * How to use <code>View</code> function | + | #*How to change the type of a vector |
− | + | #*How to change the values of levels | |
− | + | #'''Lists and its Operations''' | |
− | + | #*Lists in '''R''' | |
− | + | #*Atomic vectors in '''R''' | |
− | * Shortcut key for assignment operator (<code><-</code>) | + | #*Difference between atomic vectors and lists in '''R''' |
− | + | #*How to create a list | |
− | * How to perform numeric indexing | + | #*How to assign names to the elements of a list |
− | + | #*Named list in '''R''' | |
− | * How to extract a row or column from a data frame | + | #*How to access elements of a list by its index |
− | + | #*How to access an element of a list by its name | |
− | * How to retrieve multiple rows from a data frame | + | #*How to access an element of an element of a list |
− | + | #*Combine two different lists | |
− | * How to combine objects to form a vector | + | #'''Plotting Histograms and Pie Chart''' |
− | + | #*How to find the dimensions of a data frame | |
− | * How to perform logical indexing on a data frame | + | #*Define a histogram |
− | + | #*Plot a histogram in '''R''' | |
− | * How to perform name indexing on a data frame | + | #*Add labels to the histogram |
− | + | #*Add color to the bins of a histogram | |
− | * How to slice a data frame using <code>subset</code> function | + | #*Change the number of breaks in the histogram |
− | + | #*Define a pie chart | |
− | * How to select required columns (by name) from a data frame | + | #*Plotting a pie chart in '''R''' |
− | + | #*Add a label to the pie chart | |
− | * How to retrieve data using double square brackets | + | #*Saving the plot as an image |
− | + | #'''Plotting Bar Charts and Scatter Plot''' | |
− | + | #*What is a bar chart | |
− | + | #*Draw a bar chart | |
− | + | #*Use the <code>barplot</code> function | |
− | * Data required in a matrix format | + | #*Add labels to the bar chart |
− | + | #*Adjust the labels of the bar chart | |
− | * Convert a data frame into a matrix | + | #*What is a scatter plot |
− | + | #*Draw a scatter plot | |
− | * Create a matrix with known data | + | #*Use <code>plot</code> function with two objects |
− | + | #*Find the correlation coefficient | |
− | * Add two matrices | + | #*Range of correlation coefficient |
− | + | #'''Introduction to ggplot2''' | |
− | * Subtract two matrices | + | #*Define visualization |
− | + | #*About grammar of graphics - '''ggplot2''' | |
− | * Multiply two matrices element wise | + | #*Use of the <code>plot</code> function |
− | + | #*Add labels to a plot | |
− | * Perform true matrix multiplication | + | #*Change the color and type of plot |
− | + | #*Plot two graphs in the same plot | |
− | * Calculate the transpose of a matrix | + | #*Add a legend to the plot |
− | + | #*About '''ggplot2''' package | |
− | * Calculate the determinant of a matrix | + | #*Draw a scatter plot using <code>ggplot</code> function |
− | + | #*Save plots using <code>ggsave</code> function | |
− | + | #'''Aesthetic Mapping in ggplot2''' | |
− | + | #*Define aesthetic | |
− | + | #*Need for aesthetic in plotting | |
− | * How to find the inverse of a matrix | + | #*Draw a scatter plot |
− | + | #*Customize a scatter plot | |
− | * How to calculate the sum of elements in a matrix using <code>for</code> loop | + | #*View the structure of an object |
− | + | #*View the levels of a categorical variable | |
− | * How to calculate the sum of elements in a matrix using <code>sum</code> function | + | #*Draw a bar chart using <code>ggplot</code> |
− | + | #*Add labels to a plot in <code>ggplot</code> | |
− | * How to calculate the time elapsed in an operation | + | #*Use the <code>fill</code> argument in aesthetic mapping |
− | + | #*Draw a histogram using <code>ggplot</code> | |
− | * How to find out the sum of rows of a matrix | + | #'''Data Manipulation using dplyr Package''' |
− | + | #*What is data visualization | |
− | * How to find out the sum of columns of a matrix | + | #*Need for data manipulation |
− | + | #*What is '''dplyr''' package | |
− | * How to add a new column or row to an existing data-frame | + | #*Functions in '''dplyr''' package |
− | + | #*Install '''dplyr''' package | |
− | * How to use <code>cbind</code> and <code>rbind</code> function | + | #*Use <code>filter</code> function |
− | + | #*Use <code>filter</code> function with a logical operator | |
− | + | #*Use '''match''' operator | |
− | + | #*Use <code>arrange</code> function for ascending order | |
− | + | #*Use <code>arrange</code> function for descending order | |
− | *Use of built-in functions in '''R''' for exploring a data frame | + | #'''More functions in the dplyr Package''' |
− | + | #*Functions in the '''dplyr''' package | |
− | *Access help in '''RStudio''' | + | #*Select multiple variables in a data frame |
− | + | #*Remove variables from a data frame | |
− | *Advantages of merging data frames | + | #*Use of <code>select</code> function |
− | + | #*Use of <code>starts_with</code> function | |
− | *Merge two data frames | + | #*Change the name of a variable |
− | + | #*Use of <code>rename</code> function | |
− | *Import data from the command line | + | #*Create a new variable from existing variables |
− | + | #*Use of <code>mutate</code> function | |
− | *Import <code>xml</code> file and <code>txt</code> file in R | + | #*Property of <code>mutate</code> function |
− | + | #'''Pipe Operator''' | |
− | *Import data from the user interface of '''RStudio''' | + | #*About <code>summarise</code> function in '''dplyr''' package |
− | + | #*About <code>group_by</code> function in '''dplyr''' package | |
− | + | #*Difference between <code>summarise</code> and <code>group_by</code> functions | |
− | + | #*Use <code>summarise</code> and <code>group_by</code> functions together | |
− | + | #*About '''pipe''' operator | |
− | * What is an object in '''R''' | + | #*Examples of '''pipe''' operator |
− | + | #*Benefits of using '''pipe''' operator | |
− | * Types of '''R''' - objects | + | #*Use '''ggplot2''' and '''dplyr''' package together using '''pipe''' |
− | + | #*Plot '''boxplot''' | |
− | * What is an atomic vector in '''R''' | + | #*Use <code>count</code> in <code>summarise</code> function |
− | + | #'''Conditional Statements''' | |
− | * Types of atomic vectors | + | #*About conditional statements |
− | + | #*Syntax of <code>if</code>, <code>else</code> and <code>else if</code> statements | |
− | * How to find types of vectors | + | #*Use <code>if</code>, <code>else</code> and <code>else if</code> statements |
− | + | #*Use <code>ifelse</code> function | |
− | * Factors in '''R''' | + | #*Arguments of <code>ifelse</code> function |
− | + | #*Add a new column in an existing data frame | |
− | * Levels of a factor in '''R''' | + | #*Read and store a <code>csv</code> file |
− | + | #*View a data frame | |
− | * Identification of categorical variables | + | #*Count true values in a column |
− | + | #*Use <code>sum</code> function | |
− | * How to change the type of a vector | + | #'''Functions in R''' |
− | + | #*About functions | |
− | * How to change the values of levels | + | #*About '''built-in''' functions and '''user-defined''' functions |
− | + | #*Need for '''user-defined''' functions | |
− | + | #*Syntax of a function | |
− | + | #*Parts of a function | |
− | + | #*Create a '''user-defined''' function with arguments | |
− | * Lists in '''R''' | + | #*Create a '''user-defined''' function without arguments |
− | + | #*About <code>readline</code> function | |
− | * Atomic vectors in '''R''' | + | #*Scope of variables |
− | + | #*Use the <code>return</code> function | |
− | * Difference between atomic vectors and lists in '''R''' | + | |
− | + | ||
− | * How to create a list | + | |
− | + | ||
− | * How to assign names to the elements of a list | + | |
− | + | ||
− | * Named list in '''R''' | + | |
− | + | ||
− | * How to access elements of a list by its index | + | |
− | + | ||
− | * How to access an element of a list by its name | + | |
− | + | ||
− | * How to access an element of an element of a list | + | |
− | + | ||
− | * Combine two different lists | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | * How to find the dimensions of a data frame | + | |
− | + | ||
− | * Define a histogram | + | |
− | + | ||
− | * Plot a histogram in '''R''' | + | |
− | + | ||
− | * Add labels to the histogram | + | |
− | + | ||
− | * Add color to the bins of a histogram | + | |
− | + | ||
− | * Change the number of breaks in the histogram | + | |
− | + | ||
− | * Define a pie chart | + | |
− | + | ||
− | * Plotting a pie chart in '''R''' | + | |
− | + | ||
− | * Add a label to the pie chart | + | |
− | + | ||
− | * Saving the plot as an image | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | * What is a bar chart | + | |
− | + | ||
− | * Draw a bar chart | + | |
− | + | ||
− | * Use the <code>barplot</code> function | + | |
− | + | ||
− | * Add labels to the bar chart | + | |
− | + | ||
− | * Adjust the labels of the bar chart | + | |
− | + | ||
− | * What is a scatter plot | + | |
− | + | ||
− | * Draw a scatter plot | + | |
− | + | ||
− | * Use <code>plot</code> function with two objects | + | |
− | + | ||
− | * Find the correlation coefficient | + | |
− | + | ||
− | * Range of correlation coefficient | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | * Define visualization | + | |
− | + | ||
− | * About grammar of graphics - '''ggplot2''' | + | |
− | + | ||
− | * Use of the <code>plot</code> function | + | |
− | + | ||
− | * Add labels to a plot | + | |
− | + | ||
− | * Change the color and type of plot | + | |
− | + | ||
− | * Plot two graphs in the same plot | + | |
− | + | ||
− | * Add a legend to the plot | + | |
− | + | ||
− | * About '''ggplot2''' package | + | |
− | + | ||
− | * Draw a scatter plot using <code>ggplot</code> function | + | |
− | + | ||
− | * Save plots using <code>ggsave</code> function | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | * Define aesthetic | + | |
− | + | ||
− | * Need for aesthetic in plotting | + | |
− | + | ||
− | * Draw a scatter plot | + | |
− | + | ||
− | * Customize a scatter plot | + | |
− | + | ||
− | * View the structure of an object | + | |
− | + | ||
− | * View the levels of a categorical variable | + | |
− | + | ||
− | * Draw a bar chart using <code>ggplot</code> | + | |
− | + | ||
− | * Add labels to a plot in <code>ggplot</code> | + | |
− | + | ||
− | * Use the <code>fill</code> argument in aesthetic mapping | + | |
− | + | ||
− | * Draw a histogram using <code>ggplot</code> | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | * What is data visualization | + | |
− | + | ||
− | * Need for data manipulation | + | |
− | + | ||
− | * What is '''dplyr''' package | + | |
− | + | ||
− | * Functions in '''dplyr''' package | + | |
− | + | ||
− | * Install '''dplyr''' package | + | |
− | + | ||
− | * Use <code>filter</code> function | + | |
− | + | ||
− | * Use <code>filter</code> function with a logical operator | + | |
− | + | ||
− | * Use '''match''' operator | + | |
− | + | ||
− | * Use <code>arrange</code> function for ascending order | + | |
− | + | ||
− | * Use <code>arrange</code> function for descending order | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | * Functions in the '''dplyr''' package | + | |
− | + | ||
− | * Select multiple variables in a data frame | + | |
− | + | ||
− | * Remove variables from a data frame | + | |
− | + | ||
− | * Use of <code>select</code> function | + | |
− | + | ||
− | * Use of <code>starts_with</code> function | + | |
− | + | ||
− | * Change the name of a variable | + | |
− | + | ||
− | * Use of <code>rename</code> function | + | |
− | + | ||
− | * Create a new variable from existing variables | + | |
− | + | ||
− | * Use of <code>mutate</code> function | + | |
− | + | ||
− | * Property of <code>mutate</code> function | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | * About <code>summarise</code> function in '''dplyr''' package | + | |
− | + | ||
− | * About <code>group_by</code> function in '''dplyr''' package | + | |
− | + | ||
− | * Difference between <code>summarise</code> and <code>group_by</code> functions | + | |
− | + | ||
− | * Use <code>summarise</code> and <code>group_by</code> functions together | + | |
− | + | ||
− | * About '''pipe''' operator | + | |
− | + | ||
− | * Examples of '''pipe''' operator | + | |
− | + | ||
− | * Benefits of using '''pipe''' operator | + | |
− | + | ||
− | * Use '''ggplot2''' and '''dplyr''' package together using '''pipe''' | + | |
− | + | ||
− | * Plot '''boxplot''' | + | |
− | + | ||
− | * Use <code>count</code> in <code>summarise</code> function | + | |
− | + | ||
− | + | ||
− | + | ||
− | * About conditional statements | + | |
− | + | ||
− | * Syntax of <code>if</code>, <code>else</code> and <code>else if</code> statements | + | |
− | + | ||
− | * Use <code>if</code>, <code>else</code> and <code>else if</code> statements | + | |
− | + | ||
− | * Use <code>ifelse</code> function | + | |
− | + | ||
− | * Arguments of <code>ifelse</code> function | + | |
− | + | ||
− | * Add a new column in an existing data frame | + | |
− | + | ||
− | * Read and store a <code>csv</code> file | + | |
− | + | ||
− | * View a data frame | + | |
− | + | ||
− | * Count true values in a column | + | |
− | + | ||
− | * Use <code>sum</code> function | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | * About functions | + | |
− | + | ||
− | * About '''built-in''' functions and '''user-defined''' functions | + | |
− | + | ||
− | * Need for '''user-defined''' functions | + | |
− | + | ||
− | * Syntax of a function | + | |
− | + | ||
− | * Parts of a function | + | |
− | + | ||
− | * Create a '''user-defined''' function with arguments | + | |
− | + | ||
− | * Create a '''user-defined''' function without arguments | + | |
− | + | ||
− | * About <code>readline</code> function | + | |
− | + | ||
− | * Scope of variables | + | |
− | + | ||
− | * Use the <code>return</code> function | + |
Latest revision as of 11:57, 11 October 2021
R ( http://www.r-project.org/) is an open source software - a well organized and sophisticated package - that facilitates data analysis, modeling, inferential testing and forecasting. It is a user friendly software which allows to create new function commands to solve statistical problems. It runs on a variety of UNIX platforms (and similar systems such as LINUX), Windows and Mac OS.
R is the most preferred open-source language for analytics and data science. At Microsoft, R is used by its data scientists, who apply machine learning to data from Bing, Azure, Office, and the Sales, Marketing, and Finance departments. Twitter has been using R for measuring user-experience. On the other hand, the cross-platform compatibility of R and its capacity to handle large and complex data sets make it an ideal tool for academicians to analyze data in their labs.
R can be used for simple calculations, matrix calculations, differential equations, optimisation, statistical analysis, plotting graphs, etc. Also, it is useful to anybody who wishes to undertake extensive statistical computations and data visualization.
The spoken tutorials (ST) for R series was initially created by Prof. Kannan Moudgalya, IIT Bombay. Later, the domain expert for this series was Prof. Radhendushka Srivastava, Maths Dept. IIT Bombay. Content for this series was contributed by FOSSEE Fellows 2018 Shaik Sameer and Varshit Dubey and the tutorials were recorded by Sudhakar Kumar, M.Tech student IIT Bombay. Overall coordination for the series was done by Smita Wangikar from FOSSEE project, IIT Bombay. Madhuri Ganapati and Vidhya Iyer from Spoken Tutorial project, IIT Bombay, were the reviewers from ST end.
Learners: Analysts, researchers, statistics students
Note: Each numbered topic corresponds to a single spoken tutorial. Each bulleted point corresponds to a command or topic that must be covered in the given spoken tutorial.
- Overview of R and RStudio
- About R programming language
- Features of R
- Applications of R
- Discuss the contents available on the R Project website
- Use the command-line interface of R
- About RStudio
- Features of RStudio
- Discuss the contents available on the RStudio website
- Explain the interface of RStudio
- Topics covered in this series
- Installing R and RStudio on Linux
- Install R on Linux
- Use the command-line interface of R
- Show the value of the exponential function in R
- Install
wget
utility - Install
gdebi
utility - Install RStudio on Linux
- Launch RStudio on Linux
- Run a plot in RStudio
- View packages in RStudio
- Install packages
- Installing R and RStudio on Windows
- Install R on Windows 10
- Launch R
- Use command-line-interface of R
- Run an
exp
command in R - Install RStudio on Windows
- Launch RStudio on Windows
- Run a plot in RStudio
- Install packages
- Introduction to basics of R
- Version of R and RStudio used
- Operating systems on which these run
- Quick intro to R and RStudio
- Resizing the font and window size
- Using
+
,-
,^
,sqrt
- Using
exp
,log
,sin
- Different ways of invoking
log
- Vectors using
seq
andlength
- Using
pi
- Plotting a
sine
function - Defining more points to get a smooth plot
- Plotting with points and as line
- Introduction to help
- Introduction to data frames in R
- Storing captaincy information in vectors
- Constructing a data frame using vectors
- Plotting one vector of a data frame vs. another one
- Adding a vector to a data frame
- Saving a data frame into a csv file
- Preventing the writing of row numbers into the csv file
- Changing the contents of a csv file through a text editor
- Loading a csv file into a data frame
- Accessing the data sets that come with R
- Introduction to RStudio
- Features of RStudio
- A look at the windows in RStudio interface:
- Source and Console windows
- Workspace window
- Plots and Files window
- Example to plot a simple data set
- Introduction to packages in R
- How to find the list of packages installed in R
- Installation of R packages in RStudio
- Loading and using R packages
- Introduction to R script
- What is an R script
- Features of R script
- How to create and save an R script from the user interface (UI) of RStudio
- Shortcut keys to create an R script
- How to use auto-completion of commands
- How to run an entire script
- How to run a block of a script
- How to add comments
- How to comment an existing line
- How to load one script into another script
- Working Directories in RStudio
- What is working directory in R
- How to know current working directory
- How to use
getwd
function - How to set a working directory from the user interface of RStudio
- How to set a working directory from the Console window of RStudio
- How to use
setwd
function - How to read and store a csv file in R
- How to use
read.csv
function - How to view a stored csv file in R
- How to use
View
function
- Indexing and Slicing Data Frames
- Shortcut key for assignment operator (
<-
) - How to perform numeric indexing
- How to extract a row or column from a data frame
- How to retrieve multiple rows from a data frame
- How to combine objects to form a vector
- How to perform logical indexing on a data frame
- How to perform name indexing on a data frame
- How to slice a data frame using
subset
function - How to select required columns (by name) from a data frame
- How to retrieve data using double square brackets
- Shortcut key for assignment operator (
- Creating Matrices using Data Frames
- Data required in a matrix format
- Convert a data frame into a matrix
- Create a matrix with known data
- Add two matrices
- Subtract two matrices
- Multiply two matrices element wise
- Perform true matrix multiplication
- Calculate the transpose of a matrix
- Calculate the determinant of a matrix
- Operations on Matrices and Data Frames
- How to find the inverse of a matrix
- How to calculate the sum of elements in a matrix using
for
loop - How to calculate the sum of elements in a matrix using
sum
function - How to calculate the time elapsed in an operation
- How to find out the sum of rows of a matrix
- How to find out the sum of columns of a matrix
- How to add a new column or row to an existing data-frame
- How to use
cbind
andrbind
function
- Merging and Importing Data
- Use of built-in functions in R for exploring a data frame
- Access help in RStudio
- Advantages of merging data frames
- Merge two data frames
- Import data from the command line
- Import
xml
file andtxt
file in R - Import data from the user interface of RStudio
- Data Types and Factors
- What is an object in R
- Types of R - objects
- What is an atomic vector in R
- Types of atomic vectors
- How to find types of vectors
- Factors in R
- Levels of a factor in R
- Identification of categorical variables
- How to change the type of a vector
- How to change the values of levels
- Lists and its Operations
- Lists in R
- Atomic vectors in R
- Difference between atomic vectors and lists in R
- How to create a list
- How to assign names to the elements of a list
- Named list in R
- How to access elements of a list by its index
- How to access an element of a list by its name
- How to access an element of an element of a list
- Combine two different lists
- Plotting Histograms and Pie Chart
- How to find the dimensions of a data frame
- Define a histogram
- Plot a histogram in R
- Add labels to the histogram
- Add color to the bins of a histogram
- Change the number of breaks in the histogram
- Define a pie chart
- Plotting a pie chart in R
- Add a label to the pie chart
- Saving the plot as an image
- Plotting Bar Charts and Scatter Plot
- What is a bar chart
- Draw a bar chart
- Use the
barplot
function - Add labels to the bar chart
- Adjust the labels of the bar chart
- What is a scatter plot
- Draw a scatter plot
- Use
plot
function with two objects - Find the correlation coefficient
- Range of correlation coefficient
- Introduction to ggplot2
- Define visualization
- About grammar of graphics - ggplot2
- Use of the
plot
function - Add labels to a plot
- Change the color and type of plot
- Plot two graphs in the same plot
- Add a legend to the plot
- About ggplot2 package
- Draw a scatter plot using
ggplot
function - Save plots using
ggsave
function
- Aesthetic Mapping in ggplot2
- Define aesthetic
- Need for aesthetic in plotting
- Draw a scatter plot
- Customize a scatter plot
- View the structure of an object
- View the levels of a categorical variable
- Draw a bar chart using
ggplot
- Add labels to a plot in
ggplot
- Use the
fill
argument in aesthetic mapping - Draw a histogram using
ggplot
- Data Manipulation using dplyr Package
- What is data visualization
- Need for data manipulation
- What is dplyr package
- Functions in dplyr package
- Install dplyr package
- Use
filter
function - Use
filter
function with a logical operator - Use match operator
- Use
arrange
function for ascending order - Use
arrange
function for descending order
- More functions in the dplyr Package
- Functions in the dplyr package
- Select multiple variables in a data frame
- Remove variables from a data frame
- Use of
select
function - Use of
starts_with
function - Change the name of a variable
- Use of
rename
function - Create a new variable from existing variables
- Use of
mutate
function - Property of
mutate
function
- Pipe Operator
- About
summarise
function in dplyr package - About
group_by
function in dplyr package - Difference between
summarise
andgroup_by
functions - Use
summarise
andgroup_by
functions together - About pipe operator
- Examples of pipe operator
- Benefits of using pipe operator
- Use ggplot2 and dplyr package together using pipe
- Plot boxplot
- Use
count
insummarise
function
- About
- Conditional Statements
- About conditional statements
- Syntax of
if
,else
andelse if
statements - Use
if
,else
andelse if
statements - Use
ifelse
function - Arguments of
ifelse
function - Add a new column in an existing data frame
- Read and store a
csv
file - View a data frame
- Count true values in a column
- Use
sum
function
- Functions in R
- About functions
- About built-in functions and user-defined functions
- Need for user-defined functions
- Syntax of a function
- Parts of a function
- Create a user-defined function with arguments
- Create a user-defined function without arguments
- About
readline
function - Scope of variables
- Use the
return
function