📜  R编程中将对象转换为字符串——toString()函数

📅  最后修改于: 2022-05-13 01:55:16.790000             🧑  作者: Mango

R编程中将对象转换为字符串——toString()函数

R 语言中的toString()函数用于将对象转换为字符串。

示例 1:

# R program to convert an object to string
  
# Creating a vector
x <- c("Geeks", "for", "geeks") 
  
# Calling toString() Function
toString(x)
toString(x, width = 12)

输出:

[1] "Geeks, for, geeks"
[1] "Geeks, f...."

示例 2:

# R program to convert an object to string
  
# Creating a matrix
x <- matrix(c(1:9), 3, 3)
  
# Calling toString() Function
toString(x)

输出:

[1] "1, 2, 3, 4, 5, 6, 7, 8, 9"