data science sub

 

Arithmetic with R

In its most basic form, R can be used as a simple calculator. Consider the following arithmetic operators:

  • Addition: +
  • Subtraction: -
  • Multiplication: *
  • Division: /
  • Exponentiation: ^
  • Modulo: %%

The last two might need some explaining:

  • The ^ operator raises the number to its left to the power of the number to its right: for example 3^2 is 9.
  • The modulo returns the remainder of the division of the number to the left by the number on its right, for example 5 modulo 3 or 5 %% 3 is 2.

With this knowledge, follow the instructions to complete the exercise.

Instructions
100 XP
  • Type 2^5 in the editor to calculate 2 to the power 5.
  • Type 28 %% 6 to calculate 28 modulo 6.
  • Submit the answer and have a look at the R output in the console.
  • Note how the # symbol is used to add comments on the R code. 

  • script.R
    • R Console
      ;

      Comments

      Popular posts from this blog

      5 Kilowatt Solar System: Empowering Your Home with Energy! / 5 किलोवॉट सौर प्रणाली: ऊर्जा के साथ अपने घर को सशक्त बनाएं!

      backlink

      Carbon and its Compounds