Skip to the content

About this set

The Ministry of Statistics and Programme Implementation, the National Statistical Commission and Office, the census and the large sample surveys, the contributions of Indian statisticians, and computing with R and typesetting with LaTeX.

These are model questions written for practice at the standard of the paper; they are not questions from a past paper. Try each one before opening the answer. Every answer gives the working and a link to the section of the Unit X notes that teaches it.

The questions

Q1. The Ministry of Statistics and Programme Implementation (MoSPI) came into being as an independent ministry, by the merger of the Department of Statistics and the Department of Programme Implementation, in:
  1. 1947
  2. 1999
  3. 2005
  4. 2019
Show Answer

Answer: (B) 1999.

MoSPI was formed in 1999 by merging the Department of Statistics and the Department of Programme Implementation. 2005 is the year the National Statistical Commission was constituted, and 2019 the year the National Statistical Office was formed by merging the CSO and the NSSO.

Read this in the notes: Unit X, Ministry of Statistics & Programme Implementation (MoSPI)

Q2. Which of the following is NOT monitored by the Programme Implementation Wing of MoSPI?
  1. The Twenty Point Programme
  2. Central sector infrastructure projects
  3. The Members of Parliament Local Area Development Scheme (MPLADS)
  4. The decennial Census of India
Show Answer

Answer: (D) The decennial Census of India.

The Programme Implementation Wing monitors the Twenty Point Programme, infrastructure projects and MPLADS. The Census of India is conducted by the Office of the Registrar General and Census Commissioner, which is under the Ministry of Home Affairs, not MoSPI.

Read this in the notes: Unit X, Ministry of Statistics & Programme Implementation (MoSPI)

Q3. The Annual Survey of Industries (ASI), the principal source of industrial statistics in India, is conducted under the:
  1. Collection of Statistics Act, 2008
  2. Census Act, 1948
  3. Factories Act, 1948
  4. Industrial Disputes Act, 1947
Show Answer

Answer: (A) Collection of Statistics Act, 2008.

The ASI is conducted under the Collection of Statistics Act, 2008. Its coverage is defined by the Factories Act, 1948 (factories registered under sections 2(m)(i) and 2(m)(ii)), but that Act is not the authority under which the survey is taken. The Census Act, 1948 governs the population census.

Read this in the notes: Unit X, Ministry of Statistics & Programme Implementation (MoSPI)

Q4. Match the official statistical output in List I with what it measures in List II.
List IList II
(a) Index of Industrial Production (IIP)(i) Employment and unemployment indicators
(b) Consumer Price Index (CPI)(ii) Annual data on registered factories
(c) Periodic Labour Force Survey (PLFS)(iii) Short-term changes in the volume of industrial output
(d) Annual Survey of Industries (ASI)(iv) Changes in retail prices paid by households
  1. (a)-(iii), (b)-(iv), (c)-(ii), (d)-(i)
  2. (a)-(ii), (b)-(iv), (c)-(i), (d)-(iii)
  3. (a)-(iii), (b)-(iv), (c)-(i), (d)-(ii)
  4. (a)-(iv), (b)-(iii), (c)-(i), (d)-(ii)
Show Answer

Answer: (C) (a)-(iii), (b)-(iv), (c)-(i), (d)-(ii).

The IIP tracks the volume of industrial production month by month; the CPI measures retail price change and is the measure of inflation; the PLFS gives the labour force participation rate, worker population ratio and unemployment rate; the ASI gives detailed annual data on registered factories.

Read this in the notes: Unit X, Ministry of Statistics & Programme Implementation (MoSPI)

Q5. The National Statistical Commission (NSC) was constituted in 2005 on the recommendation of the commission chaired by:
  1. P. C. Mahalanobis
  2. C. Rangarajan
  3. Suresh Tendulkar
  4. C. R. Rao
Show Answer

Answer: (B) C. Rangarajan.

The Rangarajan Commission (which reported in 2001) reviewed the Indian statistical system and recommended a permanent apex body; the NSC was set up in 2005 to evolve policies, priorities and standards for official statistics.

Read this in the notes: Unit X, National Statistical Commission (NSC)

Q6. The Secretary (Member-Secretary) of the National Statistical Commission is the:
  1. Chief Statistician of India
  2. Chief Executive Officer of NITI Aayog
  3. Registrar General of India
  4. Governor of the Reserve Bank of India
Show Answer

Answer: (A) Chief Statistician of India.

The NSC has a Chairperson, four Members, the Chief Executive Officer of NITI Aayog as an ex-officio Member, and the Chief Statistician of India, who is the Secretary of MoSPI, as its Secretary.

Read this in the notes: Unit X, National Statistical Commission (NSC)

Q7. Consider the following about the National Statistical Commission:(I) It identifies the core statistics that are of national importance.(II) It lays down national quality standards for official statistics.(III) It conducts the decennial population census.(IV) It coordinates the statistical activities of central and state agencies.Which of these are functions of the Commission?
  1. I and II only
  2. II and III only
  3. I, II, III and IV
  4. I, II and IV only
Show Answer

Answer: (D) I, II and IV only.

The NSC is a policy and standards body: it identifies core statistics, sets quality standards, coordinates agencies and monitors major surveys. It does not collect data itself; the census is conducted by the Registrar General and Census Commissioner under the Ministry of Home Affairs.

Read this in the notes: Unit X, National Statistical Commission (NSC)

Q8. Given below are two statements, one labelled Assertion (A) and the other Reason (R).Assertion (A): The National Statistical Commission advises on matters such as the revision of the base year of the national accounts and of price indices.Reason (R): The Commission was set up to evolve policies, priorities and standards for the Indian statistical system.Choose the correct answer.
  1. Both (A) and (R) are true and (R) is the correct explanation of (A)
  2. Both (A) and (R) are true but (R) is not the correct explanation of (A)
  3. (A) is true but (R) is false
  4. (A) is false but (R) is true
Show Answer

Answer: (A) Both (A) and (R) are true and (R) is the correct explanation of (A).

Choosing and revising base years is a question of statistical policy and standards, which is exactly the Commission's mandate. Both statements are true and (R) explains (A). The compilation itself is done by the National Statistical Office.

Read this in the notes: Unit X, National Statistical Commission (NSC)

Q9. The National Statistical Office (NSO) was formed by merging the Central Statistics Office (CSO) and the National Sample Survey Office (NSSO) in:
  1. 1950
  2. 1999
  3. 2019
  4. 2005
Show Answer

Answer: (C) 2019.

The CSO and the NSSO were brought together as the NSO in 2019, to streamline the system under MoSPI. 1950 is the year the National Sample Survey began; 1999 and 2005 are the years of MoSPI and of the NSC.

Read this in the notes: Unit X, National Statistical Office (NSO)

Q10. Within the National Statistical Office, the estimates of gross domestic product, gross value added, saving and capital formation are compiled by the:
  1. Field Operations Division
  2. National Accounts Division
  3. Survey Design and Research Division
  4. Social Statistics Division
Show Answer

Answer: (B) National Accounts Division.

The National Accounts Division compiles GDP, GVA, saving and capital formation. The Survey Design and Research Division plans the sample designs, the Field Operations Division collects the data, and the Social Statistics Division handles the labour force survey and social indicators.

Read this in the notes: Unit X, National Statistical Office (NSO)

Q11. The sampling design generally adopted in the household surveys of the National Sample Survey is:
  1. simple random sampling of households from a national list
  2. systematic sampling of districts only
  3. quota sampling within states
  4. stratified multi-stage sampling, with villages or urban blocks as first-stage units and households as second-stage units
Show Answer

Answer: (D) stratified multi-stage sampling, with villages or urban blocks as first-stage units and households as second-stage units.

The surveys use a stratified multi-stage design: census villages in rural areas and Urban Frame Survey blocks in urban areas are the first-stage units, and households the ultimate units. No national list of households exists, which is what makes a multi-stage design necessary.

Read this in the notes: Unit X, National Statistical Office (NSO)

Q12. In a surveyed population of 1000 persons, 400 are employed and 50 are unemployed (available for and seeking work). The labour force participation rate and the unemployment rate are, respectively:
  1. 45% and 11.1%
  2. 45% and 5%
  3. 40% and 11.1%
  4. 40% and 12.5%
Show Answer

Answer: (A) 45% and 11.1%.

The labour force is the employed plus the unemployed, 450. $\text{LFPR}=\dfrac{450}{1000}=45\%$. The unemployment rate is the unemployed as a proportion of the labour force, not of the population: $\dfrac{50}{450}=11.1\%$. The worker population ratio is $40\%$.

Read this in the notes: Unit X, National Statistical Office (NSO)

Q13. The Census of India is conducted under the Census Act of which year, and by an office under which ministry?
  1. 1948; Ministry of Statistics and Programme Implementation
  2. 1881; Ministry of Home Affairs
  3. 1948; Ministry of Home Affairs
  4. 1951; Ministry of Statistics and Programme Implementation
Show Answer

Answer: (C) 1948; Ministry of Home Affairs.

The Census Act, 1948 provides the legal basis, and the census is conducted by the Office of the Registrar General and Census Commissioner, India, under the Ministry of Home Affairs. It is a complete enumeration taken every ten years.

Read this in the notes: Unit X, Census & Large Sample Surveys

Q14. The two phases in which the Census of India is conducted are:
  1. Sample selection, and Population Enumeration
  2. Houselisting and Housing Census, and Population Enumeration
  3. Population Enumeration, and Economic Census
  4. Pilot survey, and Post-enumeration survey
Show Answer

Answer: (B) Houselisting and Housing Census, and Population Enumeration.

In the first phase every building and household is listed and data on housing, amenities and assets are collected; in the second, each individual is enumerated. The houselisting provides the frame for the enumeration. The Economic Census is a separate count of establishments.

Read this in the notes: Unit X, Census & Large Sample Surveys

Q15. Match the survey or system in List I with its description in List II.
List IList II
(a) National Sample Survey (NSS)(i) Provides birth, death and infant mortality rates
(b) National Family Health Survey (NFHS)(ii) Data on operational holdings, taken every five years
(c) Sample Registration System (SRS)(iii) Begun in 1950 at the initiative of P. C. Mahalanobis
(d) Agriculture Census(iv) Conducted with the International Institute for Population Sciences, Mumbai, as the nodal agency
  1. (a)-(iii), (b)-(i), (c)-(iv), (d)-(ii)
  2. (a)-(iv), (b)-(iii), (c)-(i), (d)-(ii)
  3. (a)-(ii), (b)-(iv), (c)-(i), (d)-(iii)
  4. (a)-(iii), (b)-(iv), (c)-(i), (d)-(ii)
Show Answer

Answer: (D) (a)-(iii), (b)-(iv), (c)-(i), (d)-(ii).

The NSS began in 1950; the NFHS is carried out for the Ministry of Health and Family Welfare with IIPS, Mumbai, as nodal agency; the SRS gives the vital rates between censuses; the Agriculture Census, every five years, counts operational holdings.

Read this in the notes: Unit X, Census & Large Sample Surveys

Q16. Consider the statements about the Census of India, 2011:(I) It enumerated about 1.21 billion persons.(II) The final count put the sex ratio at 943 females per 1000 males.(III) The literacy rate was about 74%.(IV) It was conducted by the National Statistical Office.Which of the statements are correct?
  1. I, II and III only
  2. I and III only
  3. II and III only
  4. I, II, III and IV
Show Answer

Answer: (A) I, II and III only.

The 2011 census counted about 1.21 billion people, with a sex ratio of 943 (the provisional figure was 940) and a literacy rate of 74.04%. It was conducted by the Registrar General and Census Commissioner under the Ministry of Home Affairs, not by the NSO: (IV) is false.

Read this in the notes: Unit X, Census & Large Sample Surveys

Q17. Match the statistician in List I with the contribution in List II.
List IList II
(a) P. C. Mahalanobis(i) The union–intersection principle in multivariate analysis
(b) R. C. Bose(ii) The $D^2$ statistic, a distance between populations
(c) S. N. Roy(iii) Independence of a complete sufficient statistic and an ancillary statistic
(d) D. Basu(iv) Disproof of Euler's conjecture on orthogonal Latin squares
  1. (a)-(ii), (b)-(i), (c)-(iv), (d)-(iii)
  2. (a)-(ii), (b)-(iv), (c)-(i), (d)-(iii)
  3. (a)-(iv), (b)-(ii), (c)-(i), (d)-(iii)
  4. (a)-(ii), (b)-(iv), (c)-(iii), (d)-(i)
Show Answer

Answer: (B) (a)-(ii), (b)-(iv), (c)-(i), (d)-(iii).

Mahalanobis introduced $D^2$; Bose, with Shrikhande and Parker, disproved Euler's conjecture; Roy gave the union–intersection principle and the largest root test; Basu's theorem states the independence of a complete sufficient statistic and any ancillary statistic.

Read this in the notes: Unit X, Contributions of Indian Statisticians

Q18. The Indian Statistical Institute was founded, and the National Sample Survey was started, in the years:
  1. 1931 and 1961
  2. 1950 and 1931
  3. 1931 and 1950
  4. 1947 and 1950
Show Answer

Answer: (C) 1931 and 1950.

P. C. Mahalanobis founded the Indian Statistical Institute in Calcutta in 1931 and started the National Sample Survey in 1950. He also gave the model used for the Second Five Year Plan.

Read this in the notes: Unit X, Contributions of Indian Statisticians

Q19. Euler's conjecture that no pair of orthogonal Latin squares exists for orders of the form $4k+2$ was disproved in 1959 by:
  1. Mahalanobis, Bose and Roy
  2. Rao, Mitra and Mathai
  3. Fisher, Yates and Bose
  4. Bose, Shrikhande and Parker
Show Answer

Answer: (D) Bose, Shrikhande and Parker.

R. C. Bose, S. S. Shrikhande and E. T. Parker showed that pairs of orthogonal Latin squares exist for every order except 2 and 6 (their first counter-example was of order 22). They came to be called ‘Euler's spoilers’.

Read this in the notes: Unit X, Contributions of Indian Statisticians

Q20. Which of the following is NOT a contribution of C. R. Rao?
  1. The largest root test of multivariate analysis
  2. A lower bound for the variance of an unbiased estimator
  3. The score test
  4. Orthogonal arrays
Show Answer

Answer: (A) The largest root test of multivariate analysis.

The largest root test is due to S. N. Roy. C. R. Rao's contributions include the Cramér–Rao inequality, the Rao–Blackwell theorem, the score test and orthogonal arrays; he received the International Prize in Statistics in 2023.

Read this in the notes: Unit X, Contributions of Indian Statisticians

Q21. In R, the values of -7 %/% 2 and -7 %% 2 are, respectively:
  1. -3 and -1
  2. -3 and 1
  3. -4 and 1
  4. -4 and -1
Show Answer

Answer: (C) -4 and 1.

%/% is integer division rounding towards minus infinity (the floor), so -7 %/% 2 is $\lfloor-3.5\rfloor=-4$. %% gives the remainder with the sign of the divisor: $-7-2(-4)=1$. The two always satisfy $x=y\times(x\ \%/\%\ y)+(x\ \%\%\ y)$.

Read this in the notes: Unit X, R as a Calculator

Q22. In R, 0/0 gives NaN. The value of is.na(0/0) is:
  1. FALSE
  2. TRUE
  3. NA
  4. an error
Show Answer

Answer: (B) TRUE.

NaN (not a number) is treated as a kind of missing value: is.na(NaN) is TRUE, while is.nan(NA) is FALSE. Note that 5/0 is Inf, which is neither.

Read this in the notes: Unit X, R as a Calculator

Q23. In R, the result of c(1, 2, 3, 4) + c(10, 20) is:
  1. an error, because the lengths differ
  2. 11 22
  3. 11 22 3 4
  4. 11 22 13 24
Show Answer

Answer: (D) 11 22 13 24.

R recycles the shorter vector: c(10, 20) is used as 10 20 10 20, giving 11 22 13 24. No warning is given here because the longer length is a multiple of the shorter.

Read this in the notes: Unit X, R as a Calculator

Q24. After x <- c(2, 4, 6, 8), the value of sum(x[-1]) is:
  1. 18
  2. 20
  3. 12
  4. 2
Show Answer

Answer: (A) 18.

A negative index drops elements: x[-1] is 4 6 8, whose sum is 18. (In R, unlike some languages, -1 does not mean the last element.)

Read this in the notes: Unit X, R as a Calculator

Q25. After m <- matrix(1:6, nrow = 2), the element m[2, 3] is:
  1. 5
  2. 6
  3. 4
  4. 3
Show Answer

Answer: (B) 6.

By default a matrix is filled column by column, so m has rows 1 3 5 and 2 4 6, and m[2, 3] is 6. With byrow = TRUE the rows would be 1 2 3 and 4 5 6.

Read this in the notes: Unit X, Functions and Matrix Operations

Q26. After A <- matrix(c(2, 1, 1, 3), 2), the values of (A %*% A)[1, 1] and (A * A)[1, 1] are, respectively:
  1. 4 and 4
  2. 4 and 5
  3. 5 and 5
  4. 5 and 4
Show Answer

Answer: (D) 5 and 4.

A is $\begin{pmatrix}2&1\\1&3\end{pmatrix}$. %*% is the matrix product, whose $(1,1)$ element is $2\times2+1\times1=5$; * multiplies element by element, giving $2\times2=4$.

Read this in the notes: Unit X, Functions and Matrix Operations

Q27. After m <- matrix(1:6, nrow = 2), the result of apply(m, 1, sum) is:
  1. 9 12
  2. 3 7 11
  3. 21
  4. 1 2
Show Answer

Answer: (A) 9 12.

The second argument 1 means ‘over rows’ (2 would mean over columns). The rows are 1 3 5 and 2 4 6, with sums 9 and 12. apply(m, 2, sum) gives 3 7 11.

Read this in the notes: Unit X, Functions and Matrix Operations

Q28. In R, mean(c(1, 2, NA, 5)) and mean(c(1, 2, NA, 5), na.rm = TRUE) give, respectively:
  1. 2 and 2.667
  2. 2.667 and 2.667
  3. NA and 2.667
  4. NA and 2
Show Answer

Answer: (C) NA and 2.667.

Any arithmetic involving a missing value is missing, so the first is NA. With na.rm = TRUE the missing value is removed first and the mean of 1, 2, 5 is $\tfrac83=2.667$.

Read this in the notes: Unit X, Built-in Functions, Missing Data & Logical Operators

Q29. In R, the value of var(c(2, 4, 6)) is:
  1. 2.667
  2. 4
  3. 2
  4. 8
Show Answer

Answer: (B) 4.

var uses the divisor $n-1$: $\dfrac{(2-4)^2+0+(6-4)^2}{2}=4$, and sd gives 2. The divisor $n$ would give 2.667.

Read this in the notes: Unit X, Built-in Functions, Missing Data & Logical Operators

Q30. After x <- c(1, 5, 8, 3), the value of sum(x > 2) is:
  1. 16
  2. 17
  3. 4
  4. 3
Show Answer

Answer: (D) 3.

x > 2 is the logical vector FALSE TRUE TRUE TRUE, and in arithmetic TRUE counts as 1 and FALSE as 0. So the sum is 3, the number of elements greater than 2. sum(x[x > 2]) would give 16.

Read this in the notes: Unit X, Built-in Functions, Missing Data & Logical Operators

Q31. Consider the statements about logical values in R:(I) NA & FALSE is FALSE.(II) NA | TRUE is TRUE.(III) NA == NA is TRUE.(IV) is.na(NA) is TRUE.Which of the statements are correct?
  1. I, II and IV only
  2. I and II only
  3. III and IV only
  4. I, II, III and IV
Show Answer

Answer: (A) I, II and IV only.

A logical operation with NA gives a definite answer when the answer does not depend on the missing value: anything AND FALSE is FALSE, anything OR TRUE is TRUE. But a comparison with NA is unknown, so NA == NA is NA; missing values are tested with is.na.

Read this in the notes: Unit X, Built-in Functions, Missing Data & Logical Operators

Q32. What is the value of s after this R code is run?
s <- 0
for (i in 1:5) {
  if (i %% 2 == 0) next
  s <- s + i
}
  1. 15
  2. 6
  3. 9
  4. 5
Show Answer

Answer: (C) 9.

next skips the rest of the loop body for even $i$, so only the odd values are added: $1+3+5=9$. With break in place of next the loop would stop at $i=2$ and s would be 1.

Read this in the notes: Unit X, Conditional Execution & Loops

Q33. What is the value of n after this R code is run?
x <- 100; n <- 0
while (x > 1) {
  x <- x / 2
  n <- n + 1
}
  1. 6
  2. 7
  3. 8
  4. 50
Show Answer

Answer: (B) 7.

The successive values of x are 50, 25, 12.5, 6.25, 3.125, 1.5625, 0.78125. The loop stops when x is no longer greater than 1, after 7 halvings ($2^6=64\lt100\le2^7=128$).

Read this in the notes: Unit X, Conditional Execution & Loops

Q34. In R, the result of ifelse(c(1, 5, 3) > 2, "H", "L") is:
  1. "H"
  2. "L"
  3. "H" "L" "L"
  4. "L" "H" "H"
Show Answer

Answer: (D) "L" "H" "H".

ifelse works element by element on a vector: 1 is not greater than 2, while 5 and 3 are. By contrast if takes a single condition and is not vectorised.

Read this in the notes: Unit X, Conditional Execution & Loops

Q35. In R, the result of seq(2, 10, by = 3) is:
  1. 2 5 8
  2. 2 5 8 11
  3. 2 6 10
  4. 2 4 6 8 10
Show Answer

Answer: (A) 2 5 8.

The sequence starts at 2 and goes up in steps of 3 without passing 10: 2, 5, 8. seq(2, 10, length.out = 3) would give 2 6 10.

Read this in the notes: Unit X, Data Management: Sequences, Repeats, Sorting, Ordering, Strings

Q36. In R, the results of rep(c("a", "b"), each = 2) and rep(c("a", "b"), times = 2) are, respectively:
  1. "a" "b" "a" "b" and "a" "a" "b" "b"
  2. the same vector in both cases
  3. "a" "a" "b" "b" and "a" "b" "a" "b"
  4. "a" "a" and "b" "b"
Show Answer

Answer: (C) "a" "a" "b" "b" and "a" "b" "a" "b".

each repeats every element in turn before moving to the next; times repeats the whole vector.

Read this in the notes: Unit X, Data Management: Sequences, Repeats, Sorting, Ordering, Strings

Q37. After x <- c(30, 10, 20), the results of order(x) and rank(x) are, respectively:
  1. 3 1 2 and 2 3 1
  2. 2 3 1 and 3 1 2
  3. 10 20 30 and 3 1 2
  4. 2 3 1 and 2 3 1
Show Answer

Answer: (B) 2 3 1 and 3 1 2.

order gives the positions of the elements in increasing order: the smallest is in position 2, then 3, then 1. rank gives the rank of each element: 30 is third, 10 first, 20 second. x[order(x)] is the same as sort(x).

Read this in the notes: Unit X, Data Management: Sequences, Repeats, Sorting, Ordering, Strings

Q38. In R, the value of substr("statistics", 3, 6) is:
  1. "stat"
  2. "tati"
  3. "atist"
  4. "atis"
Show Answer

Answer: (D) "atis".

substr(x, start, stop) extracts the characters from position 3 to position 6 inclusive, counting from 1: s-t-a-t-i-s-t-i-c-s, i.e. "atis". nchar("statistics") is 10.

Read this in the notes: Unit X, Data Management: Sequences, Repeats, Sorting, Ordering, Strings

Q39. After f <- factor(c("b", "a", "b", "c")), the result of as.integer(f) is:
  1. 2 1 2 3
  2. 1 2 1 3
  3. 1 2 3 4
  4. an error
Show Answer

Answer: (A) 2 1 2 3.

The levels of a factor are the distinct values in sorted order, "a" "b" "c", coded 1, 2, 3. The data b, a, b, c therefore have codes 2, 1, 2, 3. nlevels(f) is 3 and table(f) gives the counts 1, 2, 1.

Read this in the notes: Unit X, Lists, Factors, Display & Formatting

Q40. After L <- list(a = 1:3, b = "x"), which statement is correct?
  1. L["a"] and L[["a"]] are both integer vectors
  2. L["a"] is an integer vector and L[["a"]] is a list
  3. L["a"] is a list of length 1 and L[["a"]] is the integer vector 1 2 3
  4. length(L) is 4
Show Answer

Answer: (C) L["a"] is a list of length 1 and L[["a"]] is the integer vector 1 2 3.

Single brackets return a sub-list; double brackets (or L$a) return the element itself. So L[["a"]][2] is 2. The list has two components, so length(L) is 2.

Read this in the notes: Unit X, Lists, Factors, Display & Formatting

Q41. In R, the values of round(2.5) and round(3.5) are, respectively:
  1. 3 and 4
  2. 2 and 4
  3. 2 and 3
  4. 3 and 3
Show Answer

Answer: (B) 2 and 4.

R follows the IEC 60559 standard and rounds a value exactly half-way to the even digit: 2.5 goes to 2 and 3.5 goes to 4. This avoids the upward bias of always rounding halves up.

Read this in the notes: Unit X, Lists, Factors, Display & Formatting

Q42. After df <- data.frame(x = c(1, 2, 3), y = c("a", "b", "c")), the results of dim(df) and nrow(df[df$x > 1, ]) are, respectively:
  1. 2 3 and 2
  2. 3 2 and 1
  3. 6 and 2
  4. 3 2 and 2
Show Answer

Answer: (D) 3 2 and 2.

dim gives rows then columns: 3 observations of 2 variables. df[df$x > 1, ] keeps the rows where x exceeds 1 (the second and third) and all columns, so it has 2 rows. The comma is essential: without it R would select columns.

Read this in the notes: Unit X, Data Frames, Data Input and Output

Q43. In R, the result of tapply(c(10, 20, 30, 40), c("a", "b", "a", "b"), mean) is:
  1. a single value, 25
  2. a = 15, b = 35
  3. a = 20, b = 30
  4. a = 40, b = 60
Show Answer

Answer: (C) a = 20, b = 30.

tapply applies a function to the values of a vector within the groups defined by a factor. Group a holds 10 and 30 (mean 20); group b holds 20 and 40 (mean 30). With sum it would give 40 and 60.

Read this in the notes: Unit X, Data Frames, Data Input and Output

Q44. Match the R function in List I with what it does in List II.
List IList II
(a) hist(x)(i) Draws a scatter diagram
(b) boxplot(x)(ii) Draws a histogram
(c) plot(x, y)(iii) Adds the fitted regression line to an existing plot
(d) abline(lm(y ~ x))(iv) Draws a box-and-whisker plot
  1. (a)-(ii), (b)-(iv), (c)-(iii), (d)-(i)
  2. (a)-(ii), (b)-(iv), (c)-(i), (d)-(iii)
  3. (a)-(iv), (b)-(ii), (c)-(i), (d)-(iii)
  4. (a)-(i), (b)-(iv), (c)-(ii), (d)-(iii)
Show Answer

Answer: (B) (a)-(ii), (b)-(iv), (c)-(i), (d)-(iii).

The first three are high-level functions that start a new plot; abline is a low-level function that adds a line to the current plot, here the least-squares line from lm. par(mfrow = c(2, 2)) would arrange four plots on one page.

Read this in the notes: Unit X, Graphics & Plots

Q45. After f <- function(x, y = 2) x^y, the values of f(3) and f(y = 3, x = 2) are, respectively:
  1. 9 and 8
  2. 9 and 9
  3. 6 and 6
  4. an error and 8
Show Answer

Answer: (A) 9 and 8.

When y is not supplied its default 2 is used: $3^2=9$. Arguments given by name are matched by name whatever their order: $x=2$, $y=3$ gives $2^3=8$.

Read this in the notes: Unit X, Scripts, Functions, and Programming Basics

Q46. What does this R code print?
x <- 5
f <- function() {
  x <- 10
  x
}
print(f())
print(x)
  1. 10 and 10
  2. 5 and 5
  3. 10 and 5
  4. 5 and 10
Show Answer

Answer: (C) 10 and 5.

The assignment inside the function creates a local variable x that exists only while the function runs; the function returns 10, and the global x is still 5. Only the super-assignment operator <<- would change the global variable.

Read this in the notes: Unit X, Scripts, Functions, and Programming Basics

Q47. In R, sapply(1:3, function(i) i^2) returns:
  1. a list of three elements
  2. the numeric vector 1 4 9
  3. the single number 14
  4. a 3 × 3 matrix
Show Answer

Answer: (B) the numeric vector 1 4 9.

sapply applies the function to each element and simplifies the result to a vector where it can. lapply does the same but always returns a list. Here the vectorised (1:3)^2 gives the same result without any loop.

Read this in the notes: Unit X, Scripts, Functions, and Programming Basics

Q48. Which LaTeX source produces the formula $\bar x=\dfrac1n\sum_{i=1}^{n}x_i$?
  1. $\mean{x} = 1/n \sum{i=1}{n} x_i$
  2. $\bar{x} = \frac{1}{n} \sum^{i=1}_{n} x_i$
  3. $\bar{x} = \frac{n}{1} \sum_{i=1}^{n} x_i$
  4. $\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i$
Show Answer

Answer: (D) $\bar{x} = \frac{1}{n} \sum_{i=1}^{n} x_i$.

\bar{x} puts a bar over x; \frac{1}{n} takes the numerator first and the denominator second; the lower limit of a sum follows _ and the upper limit follows ^. Option B has the limits interchanged and option C the fraction inverted; \mean is not a LaTeX command.

Read this in the notes: Unit X, LaTeX & Other Word Processing Software

Q49. Match the LaTeX environment in List I with what it produces in List II.
List IList II
(a) equation(i) A numbered displayed equation
(b) equation*(ii) An unnumbered displayed equation
(c) align(iii) Several displayed equations aligned at the & signs
(d) tabular(iv) A table of rows and columns
  1. (a)-(i), (b)-(ii), (c)-(iii), (d)-(iv)
  2. (a)-(ii), (b)-(i), (c)-(iii), (d)-(iv)
  3. (a)-(i), (b)-(ii), (c)-(iv), (d)-(iii)
  4. (a)-(iii), (b)-(ii), (c)-(i), (d)-(iv)
Show Answer

Answer: (A) (a)-(i), (b)-(ii), (c)-(iii), (d)-(iv).

A star after an environment or sectioning command suppresses the number. align (from the amsmath package) sets several equations aligned at &, with lines separated by \\. tabular builds a table, its argument (such as {|c|c|}) describing the columns.

Read this in the notes: Unit X, LaTeX & Other Word Processing Software

Q50. Consider the statements about a LaTeX document:(I) \usepackage commands are placed in the preamble, before \begin{document}.(II) The column specification {lcr} of a tabular environment declares three columns.(III) \includegraphics requires the graphicx package.(IV) \section*{Introduction} produces a numbered section heading.Which of the statements are correct?
  1. I and II only
  2. I, II and III only
  3. II, III and IV only
  4. I, II, III and IV
Show Answer

Answer: (B) I, II and III only.

The preamble, between \documentclass and \begin{document}, is where packages are loaded. {lcr} declares a left-aligned, a centred and a right-aligned column. \includegraphics is defined by graphicx. The starred form \section* gives an unnumbered heading: (IV) is false.

Read this in the notes: Unit X, LaTeX & Other Word Processing Software