0% found this document useful (0 votes)
5 views3 pages

R Programming: Variables and Data Types

The document is an R program demonstrating the use of various data types and variables, including Boolean, Integer, Floating Point, Character, and Complex types. It includes examples of printing values and their respective classes. Additionally, it showcases the use of constants and logical data types.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

R Programming: Variables and Data Types

The document is an R program demonstrating the use of various data types and variables, including Boolean, Integer, Floating Point, Character, and Complex types. It includes examples of printing values and their respective classes. Additionally, it showcases the use of constants and logical data types.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Lab Program 2 : Write a R program that includes variables, constants and data types

x = 13.8
# print variable
print(x)

#Boolean Variable
a = TRUE
print(a)
print(class(a))

#Integer Variable
A = 14L
print(A)
print(class(A))

#Floating Point Variable


x = 13.4
print(x)
print(class(x))

#Character Variable
alphabet = "a"
print(alphabet)
print(class(alphabet))
#String Variables
message = "Welcome to R Programming"
print(message)
print(class(message))

#Integer Constants
x <- 15L
print(typeof(x))
print(class(x))

#Numeric Constants
z <- 3e-3
print(z) # 0.003
print(class(z)) # "numeric"
y <- 3.4
print(y) # 3.4
print(class(z)) # "numeric"

#Logical Data type


bool1 <- TRUE
print(bool1)
print(class(bool1))
bool2 <- FALSE
print(bool2)
print(class(bool2))

#Numeric Data type


# floating point values
weight <- 63.5
print(weight)
print(class(weight))

# real numbers
height <- 182
print(height)
print(class(height))

#Integer Data type


integer_variable <- 186L
print(class(integer_variable))

#Complex Data type


# 2i represents imaginary part
complex_value <- 3 + 2i

# print class of complex_value


print(class(complex_value))

#Character Data type


# create a string variable
fruit <- "Apple"
print(class(fruit))

# create a character variable


my_char <- 'A'
print(class(my_char))

You might also like