Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Exponentiation | Basic Syntax and Operations
R Introduction: Part I
course content

Kursusindhold

R Introduction: Part I

R Introduction: Part I

1. Basic Syntax and Operations
2. Basic Data Types and Vectors
3. Factors

book
Exponentiation

Exponentiation is another fundamental mathematical operation, which is readily available in R's base functionality.

In the context of finance, this operation plays a critical role in the computation of compound interest, which is pivotal for understanding the growth of loans or investments over time.

To exponentiate a number a to the power of n in R, the syntax is a^n. Interestingly, if you're familiar with Python, you might recognize the ** operator, which can also be used in R (a**n).

Let's consider an example related to probability and combinatorics: finding the number of possible outcomes when throwing three dice:

In this case, we calculate it as 6 (the number of outcomes for one die) raised to the power of 3 (the number of dice). Here is the code for this example:

12
# Number of possible outcomes 6^3
copy

As you can see, this results in 6^3, which equals 216 possible outcomes.

Opgave

Swipe to start coding

Let's say you invested $1,000 at an annual interest rate of 13%. To calculate the total amount of money you would accumulate over a period of 4 years with compound interest, you would perform the following calculation:

Compute the product of 1000 and 1.13 raised to the power of 4.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 6
toggle bottom row

book
Exponentiation

Exponentiation is another fundamental mathematical operation, which is readily available in R's base functionality.

In the context of finance, this operation plays a critical role in the computation of compound interest, which is pivotal for understanding the growth of loans or investments over time.

To exponentiate a number a to the power of n in R, the syntax is a^n. Interestingly, if you're familiar with Python, you might recognize the ** operator, which can also be used in R (a**n).

Let's consider an example related to probability and combinatorics: finding the number of possible outcomes when throwing three dice:

In this case, we calculate it as 6 (the number of outcomes for one die) raised to the power of 3 (the number of dice). Here is the code for this example:

12
# Number of possible outcomes 6^3
copy

As you can see, this results in 6^3, which equals 216 possible outcomes.

Opgave

Swipe to start coding

Let's say you invested $1,000 at an annual interest rate of 13%. To calculate the total amount of money you would accumulate over a period of 4 years with compound interest, you would perform the following calculation:

Compute the product of 1000 and 1.13 raised to the power of 4.

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 6
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Vi beklager, at noget gik galt. Hvad skete der?
some-alt