The usage of functions in R is a solid tool to build quantitative analysis and payment traceability of a wide variety of financial databases. From payments and costs reports up to general financial statements, the development of functions in R could be a powerful strategy to automatize and to replicate numeric analysis, especially, in scenarios in which the construction of audit-executive reports is needed.
A set of functions in R could be designed to automatize the treatment and quantitative analysis of numeric-financial databases, through which an executive report could be built and shared within organization´s authorities every quarter, containing crucial numeric insights related with such information. Then, a web-based Data Warehouse published online could be capable to ingest such analysis results, in order to put a wide variety of dashboards within the reach of managers, board members, citizens, customers, providers, partners or local supervision institutions, in order to comply with demanding transparency standards.
In addition, using specific functions, some numeric variables of input-databases could be converted into vectors, in order to build and apply other functions to develop the quantitative analysis of them.
The application of technical data science procedures to databases deployed and developed by any internal or external source, is an excellent tool to strengthen and improve administrative management and market intelligence, in order to improve organization´s decision-making.
Project‘s general structure
The development of the project, in general, has the following stages:
- Identification of strategic input-databases.
- Database secure download and storage.
- Database upload into R.
- Design and execution of code related with functions.
- Result´s analysis.
- Executive report construction.
- Executive report sharing with proper authorities.
- Web-based Data Warehouse update with the insights obtained.
Project’s stages in R
The development of the project, in R, has the following stages:
1. Data ingest or import:
Input databases are imported into R using the read.csv() function:

2. Data preliminary analysis:
The imported data is subjected to a preliminary analysis, in order to know clearly the format of the variables, the length of the database and a numeric summary. In this stage the functions summary(), head(), str() and length() are used.
Additionally, in this stage, a new variable is defined as MONTO_PAGADO, which is the column MONTO of the original database. This task is executed in order to let R define, as a separate variable, the one related with the amounts paid.

3. Database column transformed into a vector
In order to design specific functions applied to the variable MONTO (amounts paid), such a column was transformed into a vector due to the usage of AS.VECTOR() function.

4. Functions developed to automatize analysis process.
Functions developed
1. FUNCTION 1:

This function allows to calculate the summation of the values of the new vector that has been created: vector.monto.pagado.
2. FUNCTION 2:

This function allows to calculate the average of the values of the new vector that has been created: vector.monto.pagado.
3. FUNCTION 3:

This function allows to calculate the standard deviation of the values of the new vector that has been created: vector.monto.pagado.
4. FUNCTION 4:

This function allows to calculate the minimum value of the new vector that has been created: vector.monto.pagado.
5. FUNCTION 5:

This function allows to calculate the maximum value of the new vector that has been created: vector.monto.pagado.
6. FUNCTION 6:

This function allows to calculate the maximum value of the new vector that has been created: vector.monto.pagado.
7. FUNCTION 7:

This function allows to determine the quartiles of the new vector that has been created: vector.monto.pagado.
8. FUNCTION 8:

This function allows to determine the percentiles of the new vector that has been created: vector.monto.pagado.
- High quality executive reports.
- Strategic audit insights from payments and financial databases.
- Replicability of the code in R for future analysis of different databases.
- Automation of quantitative analysis for future projects.
See below for other R programming articles from Roberto Delgado Castro:
Disclosure: Interactive Brokers Third Party
Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.
This material is from Roberto Delgado Castro and is being posted with its permission. The views expressed in this material are solely those of the author and/or Roberto Delgado Castro and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.