Skip to content
ME-705 · MATLAB and R Programming/Important Questions

MATLAB and R Programming (ME-705) - Important Questions

  1. Unit 210 Marks High Priority

    Write an R script that performs the following steps: (a) Create a $m\times n$ matrix filled column-wise with integers from 1 to $mn$ where $m=4$ and $n=5$. (b) Print the matrix to the console. (c) Add a new column which contains the column-wise sums. (d) Extract and print the submatrix consisting of rows 2 to 4 and columns 1 and 3. Provide the exact R commands and the expected output.

    Core practical operations on matrices in R: creation, printing, column addition and slicing. Frequently appears in past papers and tests basic indexing skills.

  2. Unit 210 Marks High Priority

    Using R, create a data frame with the following columns: ID (integer), Name (character), Age (numeric), Gender (factor with levels 'M' and 'F'), Salary (numeric). Append one new row to this data frame. Then subset the data frame to obtain only rows where Age $>$ 30 and Gender == 'F'. Show the R code used and the resulting data frame.

    Data frame creation, appending rows, selection and subsetting — a frequently tested practical topic in Unit 2.

  3. Unit 27 Marks High Priority

    Explain the basic R data types: numeric, integer, logical, character and complex. For each type give a one-line R example. Demonstrate arithmetic operators ($+$, $-$, $*$, $\,$$/$\,$, $^$) and logical operators ($>$, $\ge$, $<$, $\le$, $==$ , $!=$, $\&$, $|$, $!$) with at least two example expressions showing input and R output.

    Core conceptual question on R atomic types and operator usage; tests both knowledge and demonstration ability.

  4. Unit 27 Marks High Priority

    What are factors in R and why are they used? Convert the numeric vector c(1,2,2,3,1) into a factor with labels 'Low', 'Medium', 'High' and show the R command. Explain how to create an ordered factor for the same data and describe one situation where an ordered factor is required for modeling.

    Focused on factors and categorical data handling in R; common in exams for testing categorical encoding and ordering.

  5. Unit 25 Marks High Priority

    Describe the steps to install R and RStudio on a Windows machine. Explain how to install a CRAN package (for example, 'ggplot2') and how to load it in an R session. Also describe how to update all installed packages.

    Practical setup knowledge: installation and package management in R/RStudio — frequently appears as short-answer or procedural question.

  6. Unit 210 Marks Medium Priority

    Write an R function that accepts an $n\times n$ matrix (which may contain complex entries), extracts its main diagonal, and returns the sum of the diagonal elements. Provide the function code and show its output for the example matrix matrix(c(1+2i,2,3,4,5+1i,6,7,8,9), nrow=3, byrow=TRUE).

    Matrix indexing and handling of complex entries in R; analogous to a common MATLAB question but asked in R context to test diagonal extraction and complex arithmetic handling.

  7. Unit 27 Marks Medium Priority

    Explain the differences between R matrices and R data frames. Provide one short R code example where a matrix is preferable and one short R code example where a data frame is preferable. Mention at least two reasons for each choice.

    Conceptual comparison question that tests understanding of data structures in R and when each should be used; appears in global lists and is relevant to Unit 2 topics.

Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in