Skip to content

How to … R (post in progress)


  • How to round up a number with R?

You can easily round up a number with round() function. Besides, you can select the number of decimals with digits argument:


  • How to convert a decimal number with factor class to numerical class with R?

We obtain a dataframe with a column that contains decimal number and the class of this column is factor, but we need to convert to numerical class because we want to operate with them.

The first idea is to use as.numeric() function:

As you can see, the function as.numeric() round up decimal numbers. We will have to explore other approach:

Finally, we can obtain our desired decimal numbers correctly converting the column to character and then to numerical.

  • How to update R in Ubuntu?

If we want to update R language to the last version we need R’repository. I have recently seen these lines of code that we have to write in our terminal:

In the second step we can customize two elements:

  • If the selected mirror is slow, we can choose another here.
  • We should change “precise” word by other depending of your ubuntu version. For that, you can access this website  and choose the correct name. For example, in my case I have written “xenial” because I’m using Ubuntu 16.04 LTS (e.g., trusty – 14.04 LTS).

  • How to clean up the environment?We can easily eliminate the environment where we are working with the next line:

Published inSin categoría

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *