String in R



Any values provided by the user in single quote ‘’ or double quotes “” compiler treats as string




Syntax
firstname<-"Rupesh"
print(firstname)

String Manipulation
·         paste() concatenates strings.
·         str_c() (or stringr) .
·         cat() prints and concatenates strings.

#Function without input/output
vectorVariable <- c("Ram","Mohan","Shyam")

paste(vectorVariable,collapse=" ")

cat(c("Primary","Secondary","Tersary"), sep = "+")

Splitting a string
·         strsplit splits the string using specific literal.

fullname<-"Rupesh.Kumar.Rupak"
strsplit(fullname, "\\.")
#To unlist the splitted values
unlist(strsplit(fullname, "\\."))
Formatter Syntax
 format(x, digits, nsmall, scientific, width, justify = c("left", "right", "centre", "none"))
 demoformat <- format("WelcometoR", width = 8, justify = "c")
print(demoformat)
String in R Reviewed by Rupesh on 12:32 Rating: 5

No comments:

All Rights Reserved by Technology from Developers Eye © 2014 - 2015
Powered By Blogger, Designed by Aadics
Disclaimers:: The information provided within this blogsite is for general informational purposes only. While we try to keep the information up-to-date and correct, there are no representations or warranties, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information, products, services, or related graphics contained in this blogsite for any purpose.The author does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause.

Contact Form

Name

Email *

Message *

Powered by Blogger.