R language: A Quick Reference is about learning R Programming with a short description of the widely used commands. It will help the learner and intermediate user of the R Programming Language to get help with different functions quickly. This Quick Reference is classified into different groups. Let us start with R Language: A Quick Reference – III.

This R Language: A Quick Reference contains R commands about subsetting of vectors, matrices, lists, data frames, arrays, and factors. It also discusses about setting the different properties related to R language data types.

### Subsetting Vectors in R Language

R Command | Short Description |
---|---|

x[1:5] | Select elements of $x$ by index |

x[-(1:5)] | Exclude elements of $x$ by index |

x[c(TRUE, FALSE)] | Select elements of $x$ corresponding to the True value |

x[c(“a”, “b”)] | Select elements of $x$ by name |

### Subsetting Lists in R Language

R Command | Short Description |
---|---|

x[1:5] | Extracts a sublist of the list $x$ |

x[-(1:5)] | Extract a sublist by excluding elements of list $x$ |

x[c(TRUE, FALSE)] | Extract a sublist with logical subscripts |

x[c(“a”, “b”)] | Extract a sublist by name |

x[[2]] | Extract an element of the list $x$ |

x[[“a”]] | Extract the element with the name “a” from list $x$ |

x$a | Extract the element with the name “a” from list $x$ |

### Subsetting Matrices in R Language

R Command | Short Description |
---|---|

x[i, j] | Extracts elements of matrix $x$, specified by row $i$ and column $j$ |

x[i, j] = v | Set or rest the elements of matrix $x$, specified by row $i$ and column $j$ |

x[i, ] | Extracts $i$th row of a matrix $x$ |

x[i, ] = v | Set or resets the $i$th row of a matrix $x$ specified by $i$th row |

x[ , j] | Extracts the $j$ column of a matrix $x$ |

x[ , j] = v | Sets or resets the $j$ column of matrix $x$ |

x[i] | Subets a matrix $x$ as a vector |

x[i] = v | Sets or resets the $i$th elements (treated as a vector operation) |

### Subsetting a Data Frame in R Language

R Command | Short Description |
---|---|

df[i, j] | Matrix subsetting of a data frame, specified by $i$th row and $j$th column |

df[i, j] = dfv | Sets or resets a subset of a data frame |

subset(df, subset = i) | Subset of the $i$ cases/ observations of a data frame |

subset(df, select = i) | Subset of the $i$ variables/ columns of a data frame |

subset(df, subset=i, select=j) | Subset of the $i$ cases and $j$ variables of a data frame |