R语言的输出:cat() print() paste() 输入:scan() readline()

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_37345402/article/details/83387966
x=3
print(x)
paste("x=",x)
cat("x=",x)
cat("x=",x,sep = "") #默认的分隔符是空格

#paste( ,sep=" ",collapse=NULL)向量转化为字符并连接
#sep:分割组的字符串 collapse:可选的字符串分割结果串

#paste( ,sep=" ",collapse=NULL)向量转化为字符并连接
#sep:分割组的字符串 collapse:可选的字符串分割结果串
paste(1:9,c("st","nd","rd",rep("th",6)))
paste(1:9,c("st","nd","rd",rep("th",6)),sep = "?")
paste(1:9,c("st","nd","rd",rep("th",6)),collapse = ",")#默认的分隔符是空格
paste(1:9,c("st","nd","rd",rep("th",6)),sep = "",collapse = ",")

#cat( ... , file = "", sep = " ", fill = FALSE, labels = NULL,append = FALSE)
#file:一个文件链接或文件名,若不写则表示输出到控制台;
#sep:分隔符
#append:是否追加,当且晋档参数file是文件名而非链接时,此参数才有效

cat(c("AB","C"),c("E","F"),"n",sep = '/')
print(c("AB","C"))

#cat( ... , file = "", sep = " ", fill = FALSE, labels = NULL,append = FALSE)
#file:一个文件链接或文件名,若不写则表示输出到控制台;
#sep:分隔符
#append:是否追加,当且晋档参数file是文件名而非链接时,此参数才有效

关于输入:scan() 与 readline()

> x=scan()
1: 6
2: 9
3: 11
4: 19
5: 
Read 4 items
> x
[1]  6  9 11 19
> y=readline()#只能输入一行
11
> y
[1] "11"

猜你喜欢

转载自blog.csdn.net/m0_37345402/article/details/83387966
今日推荐