Royal Statistical Society professional awards (Data Analyst, GradStat, CStat) · United Kingdom · Royal Statistical Society
Original practice questions written to the published syllabus · not past papersWriting correct, readable programs for data work: R and Python as the working languages, with the control structures, functions, data frames, vectorisation and debugging habits that later computing subjects assume. C and SAS are covered where agricultural universities still teach them.
In the exams: GATE DA 'Programming, Data Structures and Algorithms' (heavy: Python named); AICE-JRF Computer Application Unit 2 programming (heavy); AIEEA-PG Group 07 computer programming (present)
How our questions for Royal Statistical Society professional awards spread across the units of Programming for Statistics & Data (R and Python). Difficulty: 3 easy, 16 medium, 2 hard.
| R: vectors, data frames, factors and lists | 4 | |
| Reading, cleaning and reshaping data | 4 | |
| Graphics in R (base and ggplot2) and Python (matplotlib) | 4 | |
| Debugging, testing and code style | 3 | |
| R: functions, control flow and vectorisation | 2 | |
| Python: core types, NumPy arrays and pandas data frames | 2 | |
| Writing functions and simple packages | 2 |
Choose an answer, then open the working. Each explanation says why the right answer is right and why the others are not.
In R, what does c(1, 2, 3, 4) + c(10, 20) return?
A. 11 22 13 24
The shorter vector is recycled: 10, 20, 10, 20.
Further reading: Wickham and Grolemund, R for Data Science; McKinney, Python for Data Analysis (2022); Kernighan and Ritchie, The C Programming Language (1988); Delwiche and Slaughter, The Little SAS Book (2019)
In R, 0.1 + 0.2 == 0.3 evaluates to FALSE. The correct way to compare is:
A. isTRUE(all.equal(0.1 + 0.2, 0.3))
Floating-point values are inexact; all.equal compares within a tolerance.
Further reading: Wickham and Grolemund, R for Data Science; McKinney, Python for Data Analysis (2022); Kernighan and Ritchie, The C Programming Language (1988); Delwiche and Slaughter, The Little SAS Book (2019)
Which R function computes the mean yield for each variety, given vectors yield and variety?
D. tapply(yield, variety, mean)
tapply applies a function within groups defined by a factor.
Further reading: Wickham and Grolemund, R for Data Science; McKinney, Python for Data Analysis (2022); Kernighan and Ritchie, The C Programming Language (1988); Delwiche and Slaughter, The Little SAS Book (2019)
A left join of a yield table (100 plots) to a treatment table by plot identifier gives 112 rows. The most likely cause is:
B. Duplicated plot keys in the treatment table
Duplicate keys multiply matching rows.
Further reading: Wickham and Grolemund, R for Data Science; McKinney, Python for Data Analysis (2022); Kernighan and Ritchie, The C Programming Language (1988); Delwiche and Slaughter, The Little SAS Book (2019)
Before analysing a newly read data set, which check is least informative?
C. Printing the first value of each column only
One value reveals little; missing counts, ranges and categories find most problems.
Further reading: Wickham and Grolemund, R for Data Science; McKinney, Python for Data Analysis (2022); Kernighan and Ritchie, The C Programming Language (1988); Delwiche and Slaughter, The Little SAS Book (2019)
In ggplot2, writing colour = "red" inside aes() instead of outside it:
C. It makes a legend entry 'red', not red points
Inside aes() the string is treated as a data value; outside it sets a fixed colour.
Further reading: Wickham and Grolemund, R for Data Science; McKinney, Python for Data Analysis (2022); Kernighan and Ritchie, The C Programming Language (1988); Delwiche and Slaughter, The Little SAS Book (2019)
Why do ggplot2 plots usually need data in long (tidy) form?
D. Each aesthetic maps to one column
Mapping colour to year needs a year column, not one column per year.
Further reading: Wickham and Grolemund, R for Data Science; McKinney, Python for Data Analysis (2022); Kernighan and Ritchie, The C Programming Language (1988); Delwiche and Slaughter, The Little SAS Book (2019)
A unit test for a variance function might check that the values 1, 2, 3, 4, 5 give:
B. 2.5
Σ(x − 3)² = 10; 10/(5 − 1) = 2.5; 2 divides by n.
Further reading: Wickham and Grolemund, R for Data Science; McKinney, Python for Data Analysis (2022); Kernighan and Ritchie, The C Programming Language (1988); Delwiche and Slaughter, The Little SAS Book (2019)
A minimal reproducible example helps debugging mainly because it:
B. It isolates the cause in minimal code
Stripping away the irrelevant often reveals the bug.
Further reading: Wickham and Grolemund, R for Data Science; McKinney, Python for Data Analysis (2022); Kernighan and Ritchie, The C Programming Language (1988); Delwiche and Slaughter, The Little SAS Book (2019)
Replacing the number 12.5 in several formulas with a named constant plot_area_m2 mainly:
C. Clearer, easier-to-change code
Magic numbers hide meaning and invite inconsistent edits.
Further reading: Wickham and Grolemund, R for Data Science; McKinney, Python for Data Analysis (2022); Kernighan and Ritchie, The C Programming Language (1988); Delwiche and Slaughter, The Little SAS Book (2019)
Ten here, 21 in the app. The Laisha app has every practice question we have written to Royal Statistical Society professional awards in this subject, marked as you go, with timed papers, a jump-to-unanswered list and a certificate when you pass at 70 per cent.
Free for ten days, then one subscription of US$10 a month. We would rather say so here than have you find it later.
An AI operating system for agriculture: free guides, manuals and tools written for every country.