Summary
Some concepts are common to all programming. Therefore, regardless of whether one uses Python, R, Julia, JavaScript, SQL, etc., there will always be a way to build what is needed by recognizing and using different data/variable types and structures, operators and control/flow structures, and functions/procedures. Of course, each language will have variations that have to be learned in due course, but the essence will lie in the functionality of each of the elements just mentioned.
So, first of all, there are data and/or variables. It is worth reviewing the chapter Data, units and variables of analysis, since once again the data point appears as the smallest unit being worked with. Data, which can be of one type or another, are stored in variables, and those variables can have various structures, depending on the logic by which the information is stored. For example, a very basic structure is a table or matrix, an arrangement of elements in 2 dimensions (horizontal and vertical), which, as noted earlier, can be used as a means of presenting aggregations of data (see Frequency tables). Of course, data can carry relationships as complex as those of the real world, so there are data structures (or combinations of them) able to represent that complexity. Python has lists, tuples, arrays, dictionaries, dataframes and many more, commonly used for data analysis. In R and other languages they may or may not have the same name, and the operations that can be performed on them may also vary.
Operations are the way to relate elements. In practice, one can start from the parallel with mathematical operations (addition, subtraction, multiplication, etc.), which is correct, given that they are present in almost any analysis process. One level below that are Boolean operations, which are the basis of all programming. These are operations with ones and zeros, simple in nature, but just as present in everyday work with data, since they allow the comparison and conditioning of elements and processes, through structures designed in advance for that purpose.
Any operation on data, variables and/or data structures will likely need to be reused (in whatever language); so what is called (almost universally) functions comes into play. Functions are blocks of operations that usually take data as input and output, with some transformation in between. It should be noted that this may not be the case, but they at least make a change (in the code or in the working environment). A set of functions is usually called a library (or module), which will be of vital importance, since it is practically impossible to build anything from scratch. Hence the importance of reuse (and of the concepts of transparency, replicability, interoperability and scalability mentioned in Working environment).
To all of the above should be added a matter related to design patterns in programming, that is, to the way programs are developed, since they can become extremely complex and there must be a common criterion for creating not only functions but any reusable element. In that sense, object-oriented programming has been widely adopted. Its building block is the class, which can be an abstraction of any entity that can be thought of (cars, houses, feelings). From those classes, concrete elements can be generated, which is called an instance of that class (a particular car, house or feeling). Instances will have an associated set of attributes (the color of a car, the height of a house, the fervor of a feeling) and operations, called methods (driving the car, painting the house, making someone laugh), through which they can relate to the rest of the elements and to the programming environment itself.
Further reading
- Python for Everybody. Charles Severance, chapters 3 to 11 and 15.
- Python Tutorial. W3Schools.