In script write commands:
#writing the strings in R language
myname <- "your name"
print (myname)
Output:
[1] "your name"
Explanation:
In the first line # is defining the comment. R supports only the single line comment.
Here myname is a variable which stores the the string literal "your name"
and when a print command issued on the myname then it prints the string literal.
Here you can use single quotes or double quotes . the output will be same:
myname <- 'your name'
print(myname)
Output:
[1] "your name"
Explanation:
In the output the string literal will be in the double quotes in the two cases.
--------------------------------------------------------------------------------------------------------------------------
#writing the strings in R language
myname <- "your name"
print (myname)
Output:
[1] "your name"
Explanation:
In the first line # is defining the comment. R supports only the single line comment.
Here myname is a variable which stores the the string literal "your name"
and when a print command issued on the myname then it prints the string literal.
Here you can use single quotes or double quotes . the output will be same:
myname <- 'your name'
print(myname)
Output:
[1] "your name"
Explanation:
In the output the string literal will be in the double quotes in the two cases.
--------------------------------------------------------------------------------------------------------------------------
> vectortwo<-"your name"
Assigning the value for vectortwo
> print(vectortwo)
printing the value of the variable
Output
[1] "your name"
printing the class of the variable
Output
> print(class(vectortwo))
[1] "character"
No comments:
Post a Comment