Select Page
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. Which of the following would print the following output ?

```foo bar
1 1 TRUE
2 2 TRUE
3 3 FALSE
4 4 FALSE```

a)

```> x <- data.frame(foo = 1:4, bar = c(F, T, F, F))
> x```

b)

```> x <- data.frame(foo = 1:6, bar = c(F, T, F, F))
> x```

c)

```> x <- data.frame(foo = 1:4, bar = c(T, T, F, F))
> x```

d) None of the mentioned

Answer: c [Reason:] Data frames are used to store tabular data in R.

2. Point out the wrong statement :
a) is.nan() is used to test objects if they are NA
b) is.nan() is used to test for NaN
c) NA values have a class also, so there are integer NA, character NA, etc
d) All of the mentioned

Answer: a [Reason:] A NaN value is also NA but the converse is not true.

3. Data frames can be converted to a matrix by calling data._______
a) matr()
b) mat()
c) matrix()
d) all of the mentioned

Answer: c [Reason:] as.matrix() function should be used to coerce a data frame to a matrix.

4. What would the following code print ?

```> x <- data.frame(foo = 1:4, bar = c(T, T, F, F))
> ncol(x)```

a) 2
b) 4
c) 7
d) All of the mentioned

Answer: a [Reason:] Data frames are represented as a special type of list where every element of the list has to have the same length.

5. Point out the correct statement :
a) Using factors with labels is better than using integers because factors are self-describing
b) Factors are used to represent categorical data and can be unordered or ordered
c) Factors are important in statistical modeling and are treated specially by modelling functions like lm() and glm()
d) All of the mentioned

Answer: d [Reason:] Having a variable that has values “Male” and “Female” is better than a variable that has values 1 and 2.

6. Which of the following is invalid assignment ?
a)

` > x <- list("Los Angeles" = 1, Boston = 2, London = 3)`

b)

` > names(x) <- c("New York", "Seattle", "Los Angeles")`

c)

` > name(x) <- c("New York", "Seattle", "Los Angeles")`

d) None of the mentioned

Answer: c [Reason:] Lists can also have names, which is often very useful.

7. What would be the output of the following code ?

```> x <- 1:3
> names(x)```

a) NULL
b) 1
c) 2
d) None of the mentioned

Answer: a [Reason:] R objects can have names, which is very useful for writing readable code and self-describing objects.

8. What would be the output of the following code ?

```> m <- matrix(1:4, nrow = 2, ncol = 2)
> dimnames(m) <- list(c("a", "b"), c("c", "d"))
> m```

a)

```c d
a 1 3
b 2 4```

b)

```c d
a 1 2
b 2 3```

c)

```c d
a 1 3
b 4 2```

d) All of the mentioned

Answer: a [Reason:] Matrices can have both column and row names.

9. Which of the following statement changes column name to h and f ?
a) colnames(m) <- c(“h”, “f”)
b) columnnames(m) <- c(“h”, “f”)
c) rownames(m) <- c(“h”, “f”)
d) none of the mentioned

Answer: a [Reason:] Column names and row names can be set separately using the colnames() and rownames() functions.

10.Which of the following is used for reading tabular data ?
b) dget
d) none of the mentioned

### Synopsis and Project Report

You can buy synopsis and project from distpub.com. Just visit https://distpub.com/product-category/projects/ and buy your university/institute project from distpub.com