Category: Interview Questions
-
How to remove columns from a data frame in R?
1. By using the select() function of the dplyr package of the tidyverse collection. The name of each column to delete is passed in with a minus sign before it: If, instead, we have too many columns to delete, it makes more sense to keep the rest of the columns rather than delete the columns in interest. In this…
-
How do you add a new column to a data frame in R?
Output: Output: Output: In each of the three cases, we can assign a single value or a vector or calculate the new column based on the existing columns of that data frame or other data frames.
-
How to create a data frame in R?
1. From one or more vectors of the same length—by using the data.frame() function: 2. From a matrix—by using the data.frame() function: 3. From a list of vectors of the same length—by using the data.frame() function: 4. From other data frames:
-
What is a package in R, and how do you install and load packages?
An R package is a collection of functions, code, data, and documentation, representing an extension of the R programming language and designed for solving specific kinds of tasks. R comes with a bunch of preinstalled packages, and other packages can be installed by users from repositories. The most popular centralized repository storing thousands of various…
-
How to import data in R?
The base R provides essential functions for importing data: In practice, any of these functions can be used to import tabular data with any kind of field and decimal separators: using them for the specified formats of files is only the question of convention and default settings. For example, here is the syntax of the…
-
What is R, and what are its main characteristics?
R is a programming language and environment widely used for solving data science problems and particularly designed for statistical computing and data visualization. Its main characteristics include: