Data type exploration
To get started, here are some of R's most basic data types:
- Numerics are decimal numbers like
4.5
. A special type of numeric is an integer, which is a numeric without a decimal piece. Integers must be specified like4L
. - Logicals are the boolean values
TRUE
andFALSE
. Capital letters are important here; true and false are not valid. - Characters are text values like
"hello world"
.
This exercise is part of the course
Introduction to R for Finance
Exercise instructions
- Assign the numeric 150.45 to
apple_stock
. - Assign the character "AAA" to
credit_rating
. - Answer the final question with either
TRUE
orFALSE
, we won't judge! - Print
my_answer
!
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Apple's stock price is a numeric
apple_stock <-
# Bond credit ratings are characters
credit_rating <-
# You like the stock market. TRUE or FALSE?
my_answer <-
# Print my_answer