如何在R中用换行符写字符串?
在编写字符串向量时,我们将它们放在一行中,但是我们可能想用不同的行来表示字符串,尤其是在字符串向量的每个值具有不同含义的情况下。这对程序员和其他读者都是有帮助的。我们可以使用R中的writeLines函数将单行更改为多行。
示例
单行阅读-
> String1<-c("Covid-19","2020","Lockdown","Quarantine","Life Changing")> String1
[1] "Covid-19" "2020" "Lockdown" "Quarantine" "Life Changing"
用换行读取相同的向量-
> String1<-writeLines(c("Covid-19","2020","Lockdown","Quarantine","Life Changing"))Covid-19
2020
Lockdown
Quarantine
Life Changing
> String2<-c("Nhooo","SIMPLY EASY LEARNING","You are browsing the best resource for Online Education","Library","Videos","Ebooks","GATE Exams",
+ "Coding Ground","Current Affairs","UPSC Notes","Whiteboard","Net Meeting","Tutorix")
> writeLines(String2)
Nhooo
SIMPLY EASY LEARNING
You are browsing the best resource for Online Education
Library
Videos
Ebooks
GATE Exams
Coding Ground
Current Affairs
UPSC Notes
Whiteboard
Net Meeting
Tutorix
> String3<-c("Office","IT","Academic","Development","Business","Design","Others")
> writeLines(String3)
Office
IT
Academic
Development
Business
Design
Others
> String4<-c("Machine Learning","Computer Science","Web Development","Mobile App Development","Database Management","Microsoft Technologies",
+ "Big Data and Analytics")
> writeLines(String4)
Machine Learning
Computer Science
Web Development
Mobile App Development
Database Management
Microsoft Technologies
Big Data and Analytics
以上是 如何在R中用换行符写字符串? 的全部内容, 来源链接: utcz.com/z/347173.html