x <- 7
sprintf("x is %s ", x)
## [1] "x is 7 "
print(class(x))
## [1] "numeric"
x <- 'seven'
print(paste('x is ', x))
## [1] "x is  seven"
print(class(x))
## [1] "character"
x <- "seven"
print(paste('x is ', x))
## [1] "x is  seven"
print(class(x))
## [1] "character"
x <- "\"seven"
print(paste('x is', x))
## [1] "x is \"seven"
print(class(x))
## [1] "character"
x <-  'seven "'
print(paste('x is', x))
## [1] "x is seven \""
print(class(x))
## [1] "character"
x <-  "Hello"
y = "R"
z <- "Basic"
print(paste(x, y, x))
## [1] "Hello R Hello"
#collapse

x <- "Hello"
y <- "R"
z <-  "Basic !a"
print(paste(x, y, x, sep = "", collapse = " "))
## [1] "HelloRHello"
x <- format(68.123456789, digits = 6)
print(x)
## [1] "68.1235"
#Display numbers in scientific notation.
x <- format(c(6, 18.14521), scientific = TRUE)
print(x)
## [1] "6.000000e+00" "1.814521e+01"
#Format treats everything as a string
x <- format(6)
print(x)
## [1] "6"
#Number are padded with blank in the beginning for width.
x <- format(16.8, width = 6)
print(x)
## [1] "  16.8"
#Left justify strings.

x <- format("Hello R", width = 8, justify = "l")
print(x)
## [1] "Hello R "
#Justfy string with center.
x <- format("Hello R", width=8, justify="c")
print(x)
## [1] "Hello R "
#Couting number of characters in a string - nchar() function
x <- nchar("Count the number of characters")
print(x)
## [1] 30
#Changing to upper case.
x <- toupper("ho duc duy")
print(x)
## [1] "HO DUC DUY"
#Changing to lower case.
x <- tolower("HO DUC DUY")
print(x)
## [1] "ho duc duy"
x <- substring("Extract", 6, 8)
print(x)
## [1] "ct"