117k views
5 votes
Try making a character (string) variable and a logical variable . Try creating a variable with a "missing" value NA. You can call these variables whatever you would like. Use class(variablename) to make sure they are the right type of variable.

User CrazyJony
by
4.7k points

1 Answer

2 votes

Answer:

The solution code is written in R script.

  1. #string variable
  2. character_str<- "Hello World"
  3. #logical variable
  4. logic <- a > b
  5. #Missing value
  6. myVec <-c(1, 2, 3, NA)
  7. #Use class to check data type
  8. class(character_str)
  9. class(logic)
  10. class(myVec)

Step-by-step explanation:

A string variable is a variable that hold a string (the letters enclosed within quotation marks) (Line 2)

A logical variable is a variable that hold a logical value (either True or False). The logical value is created by comparing two variables (Line 5).

In R, missing value is an unknown value which is represented by NA symbol (Line 8).

We can use in-built method class to check for the variable type in R (Line 11-13). For example, the output of class(character_str) is "character"

User Abhinav Kumar
by
4.4k points