What is the use of knowing how to debug a code in R?

Asked

Viewed 1,048 times

15

According to the theory, debugging can be defined as the art and science of correcting unexpected problems in your code.

  • What is the usefulness (for a data analyst) of knowing thresh a code?
  • What functions exist in R to do this?
  • 5

    Fix issues in your code.

  • 2

    Is this important to a data analyst? Many concepts in R has greater relevance for those who develop Packages, as lexical scope and dynamic scope.

  • What do you call "data analyst"? Are you referring to the professional who analyzes and compiles data for decision-making within a company? Or are you referring to the Systems Analyst?

  • "to the professional who analyses and compiles data for decision-making within a company"

5 answers

4

I have no knowledge of the language R.

A data analyst who knows how to debug (or debug) a code does its job in less time, generating less expense and a more efficient product.

Many of the errors are not detected by the programming languages, do not generate exceptions and the code is executed, presenting incorrect data and information. To solve this, it is possible to create functions, small snippets of code or use specialized libraries to signal the problem, forcing an interruption (stop) and showing a message.

In accordance with https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Debugging (in English), follow some useful functions:

traceback()
debugger
debugger.look()
## it turns warnings into errors
options(warn = 2) 

4

For a data analyst, it’s important. Because depending on its function, it is through the data obtained by the system that the value for the company’s business is generated. For example, some companies today do a lot of work with data mining and leads, so it is necessary that the data analyst knows your system well.

I don’t have much knowledge in R, but it is a very used language for statistics, because it has functions such as Rsitesearch(), which allows searching keywords in the parameter passed to it!

4

I don’t know the R language but I’ll talk about the debbug as a whole.

The debbug itself, independent of being for data analysis, as for a web system code, you know how to debug your code, helps in the sense that you can track step by step the path and the changes that the given has in your system, thus facilitating the chance for you to correct errors not observed during development, and even find code failures missing in your system.

Well debbug is a very powerful tool for whatever purpose is development, I encourage everyone who develop any type of system, for any type of solution to use debbug during its development process, so you can save a lot of time trying to find a feature error just by analyzing the code with the naked eye.

I hope I have given an idea of the importance of knowing how to debug a code, regardless of the problem that the code comes to solve.

3

Good afternoon Giovani,

- What is debugging?

Broadly speaking we can say that thresh or debug, in the case of programmes, is the action of removing anomalies and/or bugs that distort the veracity and/or integrity of your data, errors that were not predicted by the developers of it. The compiler or IDE you are working on is able to detect syntax errors, execution or libraries not imported for example, but this does not guarantee that your variables will not assume strange values during execution, the final, shit happens[English].

The debugging is a good practice to ensure the quality of software produced.

When debugging a code you can follow the step by step execution through the breakpoints, checking which functions are being called, what values the variables are assuming, what value their tests return, among other things, all of this in order to search more efficiently at which point of execution their logic is wrong.

- What is the use, for a data analyst, of knowing how to debug a code?

At this point we come to a delicate issue, because from here everything will depend on how is your reality within the business organization, the final, not every data analyst necessarily needs to know how to program since can if it is a function of analyzing data, and not producing it, which is the case for store managers, for example. Through sales reports they can realize what is selling more and what is not, and from that take their business decisions. Note that in the example cited it is not necessary that the manager knows how to program, even if he uses the programming for his work.

On the other hand, if your work includes the production of this data, it is of fundamental importance that you know how to debug the code to ensure the integrity and veracity of the data to make the best decisions for your company. Returning to the example cited: If the information in this report is not true in any way, this manager will make decisions from false information and, consequently, may harm your business.

I don’t know the tools to debugging in R, but I found this link: Debugging code in R, I hope it will be useful to you.

Hugs!

3


What is the utility (for a data analyst) of knowing how to debug a code?

In general "debuggar" or debug a code has the purpose of checking if one or more functionalities of the application when running have the desired behavior, ie, check that all conditions, however implicit they are have been checked, treat possible bugs and failures properly and of course, check whether the business logic of the application is being executed correctly.

Knowing how to use debugging for a professional whose function is to analyze the data is essential to verify the integrity of the collected data and also to check if the functions that generate results that will be taken into account for the analysis are programmed with the correct logic.


What functions exist in R to do this?

Without an IDE

There is the function browser(), it will pause code when code is executed in debug mode.
When this occurs, you can type in names of variables that would be accessible in that scope to verify their value.
To run in console debug mode just type debugSource("<NomeDoArquivo>").

With an IDE (Rstudio)

You can delimit a break point by clicking on the area to the left of the code, when this occurs, a red dot will be marked at the beginning of the line and will have the same behavior as the function browser(), will only pause code execution when code is executed in debug mode.

To run in debug mode in Rstudio just check the option "Source on Save" and save the code, click on "Source" in the upper right of Rstudio or press Ctrl+Shift+S.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.