如何在 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("Tutorialspoint","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)
Tutorialspoint
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
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP