如何在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热门推荐
10 小红书平安祝福语简短
11 生日祝福语大全女孩简短
12 收生日红包祝福语 简短
13 领证幽默祝福语简短
14 法考面试祝福语简短
15 老哥出门祝福语简短语
16 送灯祝福语简短独特
17 幼儿狗年祝福语大全简短
18 好听的元旦简短祝福语