SubjectsSubjects(version: 978)
Course, academic year 2025/2026
   
R for life - MB162P13
Title: R pro život
Czech title: R pro život
Guaranteed by: Department of Botany (31-120)
Faculty: Faculty of Science
Actual: from 2025
Semester: winter
E-Credits: 2
Examination process: winter s.:
Hours per week, examination: winter s.:1/1, C+Ex [HT]
Capacity: 50
Min. number of students: unlimited
4EU+: no
Virtual mobility / capacity: no
State of the course: taught
Language: Czech
Additional information: https://dl2.cuni.cz/course/view.php?id=6117
Note: enabled for web enrollment
priority enrollment if the course is part of the study plan
Guarantor: Mgr. Martin Weiser, Ph.D.
Teacher(s): Mgr. Anna Tószögyová, Ph.D.
Mgr. Martin Weiser, Ph.D.
Incompatibility : MB120P147E
Is incompatible with: MB120P147E, MB120C15E, MB120C15
Annotation -
The main purpose of the course is to teach participants how to program (in R) and effectively use programming for solving common problems. We would like to show that programming is, in principle, easy and anybody can do it (R is very intuitive). Moreover, we would like to demonstrate that R is not just statistics but can be used to work with graphics, databases, simulations or GIS.
We intend to make the course comprehensible for all students, there are no restrictions concerning year, degree or programme. However, we assume that the attendants will be mostly biologists with elementary experience with biological data and with simple graphs. The course is especially suitable for all who spend more than ~3 hours a day working with computer.

If you are interested in the English version of the course, look at the MB120P147E - "R for life", or MB120C15 - "Flash R course" if you are in hurry.


Last update: Weiser Martin, Mgr., Ph.D. (09.08.2024)
Literature -

Grolemund G (2014) Hands-On Programming with R. O'Reilly (https://rstudio-education.github.io/hopr/)
Crawley MJ (2007) The R book. John Wiley & Sons. (second edition exists already)
Venables WN & Smith DM (2008) An introduction to R. R development core team.
http://www.r-project.org

Last update: Weiser Martin, Mgr., Ph.D. (09.08.2024)
Requirements to the exam -

"Zápočet" is based on the test (written exam) score. Extra points are available via tests completed throughout the semester.

"Zkouška" is based on the own code (program) the student makes. The code is supposed to solve a selected problem and the student is supposed to explain its purpose and inner mechanisms in detail. The code is expected to exceed the complexity and functionality of the examples presented during the lectures or in the suggested textbooks. The meeting when a student presents the code ("Zkouška") happens after the students completes "Zápočet", not earlier, but we welcome consultations prior to that.

Last update: Weiser Martin, Mgr., Ph.D. (09.08.2024)
Syllabus -

An interactive lecture (with computers). We will introduce basics of work with data, graphics and programming in R (all the non-statistical tricks). This part roughly corresponds with chapters 1-5 in Crawley (2007).

Topics of the theoretical part:

1. Introduction to R. Help and literature. R environment and specifics of R. R-editor, RStudio; data import and export, basics of syntax, operators, signs and brackets.

2. Basic structures in R. Variables, vectors, matrices, data frames, arrays, strings, characters vs. numbers. Indexes as a crucial concept.

3. Brief "bestiary" of some useful functions. Random number generation. Operations with vectors and matrices (sample, order, sort, diff, max, min, unique, sums, which). Operations with strings. Basic mathematical functions.

4. Scripting and programming (code writing). Most important, we will dedicate extra time to make sure anybody understand this.
Functions, arguments of functions. Control flow & loops (if, else, for, while, repeat). Functions within/inside function.

5. Good programming practice.

6. Data visualisation and graphics in R. Good practice in data visualization. Plot, lines, points, abline, text, image, par etc. as tools to visualize nearly anything. Lattice (Trellis) graphics. Connection of graphics and programming ? drawing and animations in R.

Last update: Weiser Martin, Mgr., Ph.D. (09.08.2024)
Learning outcomes -

The objective of this course is to master R so that you can independently create (simple) applications. The primary learning outcome is the independent creation of an R application that you understand in detail and are therefore able to modify and adapt to new requirements.

Throughout the course, you will achieve the following learning outcomes:

Problem Solving and Resources

  • Identify suitable functions to solve a problem based on their name and description.

  • Read and comprehend documentation for existing functions, locating relevant sections to implement the function effectively.

  • Locate advice and tips for specific problems within documentation, forums, online texts, and through large language model (LLM) outputs.

  • Find, install, and utilize third-party libraries (packages).

Environment and Data Handling

  • Manually start and terminate the R interpreter.

  • Transfer data between individual projects or sessions.

  • Import external data into the interpreter, including various table formats and, in specific cases, text data.

  • Generate portable files containing graphical and data results of your work.

Data Objects and Manipulation

  • Create the following data object types: vector, factor, matrix, list, and dataframe.

  • Determine the properties of previously unknown objects of these types.

  • Merge, rename, delete, and convert object types.

  • Modify individual elements within data objects.

  • Locate elements using their position, value, or attributes.

  • Reorder elements within data objects.

  • Perform set operations (intersections, unions, unique and repeated elements) on object combinations.

  • Apply logical operators (standard, summarizing, and short-circuit) to evaluate element properties.

Numerical Specifics

  • Recognize the specifics of machine processing regarding floating-point numbers, rounding, and special values (non-rational numbers).

Functions and Programming

  • Create custom functions (objects containing a sequence of other functions) to streamline data tasks.

  • Read and adapt existing function code to meet specific requirements.

  • Develop functions that call other functions and work with default or mandatory arguments without affecting objects in the global environment (user space).

  • Perform conditional modifications on vector elements.

  • Design functions with conditional execution of specific components.

  • Apply basic error-handling mechanisms for function inputs (raising exceptions/errors).

Automation and Loops

  • Automate repetitive function calls using program loops.

  • Integrate conditional breaks and skips (next) into loops.

  • Select the appropriate loop type (repeat, while, or for) for a specific programming task.

  • Convert simple loops into concise forms using the apply family of functions and gain familiarity with functional programming tools (vectorize, outer, Reduce, Map, Filter, do.call, etc.).

String Manipulation

  • Concatenate and split text strings.

  • Locate and modify parts of strings based on position or content using regular expressions (regex).

Data Visualization

  • Generate vector and bitmap graphics.

  • Create fully annotated histograms, bar and box plots, scatter and line plots, heatmaps, and contour plots using base R graphics.

  • Select the appropriate plot type based on the data and the intended message.

  • Enhance plots with legends, additional axes, text labels, points, lines, and arrows.

  • Modify aesthetic elements (color, size, symbols), including conditional changes.

  • Adjust color palettes with regard to accessibility and intended use, utilizing projects like ColorBrewer and viridis.

  • Create visualizations using the ggplot2 library, including the use of facets (subplots).

Last update: Weiser Martin, Mgr., Ph.D. (28.01.2026)
 
Charles University | Information system of Charles University | http://www.cuni.cz/UKEN-329.html