In R, the ______ function can be used to create a scatter plot with a smooth line fitted to the data.

  • scatterplot()
  • smoothplot()
  • lines()
  • loess()
The loess() function in R can be used to fit a smooth line to a scatter plot. It uses the locally weighted scatterplot smoothing technique to estimate a smooth curve that captures the general trend in the data.

Imagine you need to create a predictive model in R. Can you walk me through the steps you would take and the packages you might use?

  • Buy more computing power, Choose any model, Ignore understanding the problem
  • None of the above
  • Start by choosing a model, Ignore data preprocessing, Use any package randomly
  • Understand the problem, Preprocess the data, Choose an appropriate model, Use caret or equivalent package for modeling
The first step in building a predictive model should be understanding the problem at hand and the data available. Preprocessing of the data would come next. Then, choosing an appropriate model based on the problem and data is crucial. The caret package in R provides functions to streamline the model building process.

What is a global variable in R?

  • A variable defined outside of any function that can be accessed from anywhere in the program
  • A variable defined inside a function that can be accessed only within that function
  • A variable defined in the global environment that is read-only
  • A variable that is used for global configuration settings in R
A global variable in R is a variable that is defined outside of any function and can be accessed from anywhere in the program. It is stored in the global environment and is accessible to all functions and code segments within the R session. Global variables can hold data or configuration settings that need to be accessed and modified across multiple functions or code blocks.

What function in R is used to calculate the square root of a number?

  • root()
  • sqr()
  • sqrt()
  • squareroot()
The sqrt() function in R is used to calculate the square root of a number. For example, sqrt(4) would return 2.

How would you calculate a running median in R?

  • Use the runMedian() function from the caTools package
  • Use the rollapply() function from the zoo package
  • Use the cummedian() function from the stats package
  • Use the median() function with a sliding window approach
To calculate a running median in R, you can use the rollapply() function from the zoo package. The rollapply() function allows you to specify a window size and apply a function (such as median()) to a rolling window of values. This can be useful for analyzing time series or other sequential data.

The ________ function in R is used to split a string into components based on a specific character or string.

  • divide()
  • separate()
  • split()
  • strsplit()
The strsplit() function in R is used to split a string into components based on a specific character or string. For example, strsplit("Hello World", " ") would return a list with two components: "Hello" and "World".

In R, a basic pie chart is created using the ______ function.

  • pie()
  • barplot()
  • plot()
  • scatterplot()
In R, a basic pie chart is created using the pie() function. It takes a vector of non-negative numeric values as input and creates a pie chart where each segment represents a proportion of the whole.

Can you describe a scenario where you would need to conduct a statistical test in R?

  • Comparing the means of two groups
  • Testing the independence of categorical variables
  • Determining the correlation between two variables
  • All of the above
All of the mentioned scenarios may require conducting a statistical test in R. Statistical tests are used to assess hypotheses, make inferences about populations, and analyze relationships between variables. Some common scenarios include comparing the means of two groups using t-tests, testing the independence of categorical variables using chi-square tests, and determining the correlation between two variables using correlation tests.

Can you explain the use of global and local variables in R?

  • Global variables can be accessed anywhere in the code, while local variables can only be accessed within the function they were defined
  • Global variables can only be accessed within the function they were defined, while local variables can be accessed anywhere in the code
  • None of the above
  • There's no such thing as global and local variables in R
In R, a variable that is defined outside of any function is known as a global variable and it can be accessed from anywhere in the code. On the other hand, a variable that is defined inside a function is known as a local variable, and it can only be accessed within that function.

In R, a basic scatter plot is created using the ______ function.

  • scatterplot()
  • plot()
  • points()
  • scatter()
In R, a basic scatter plot is created using the plot() function. It allows you to visualize the relationship between two numeric variables by plotting the data points as individual points on the graph.