R paste paste0連線字串

2021-10-01 22:22:41 字數 2806 閱讀 3748

#要生成12個月的fitbit檔名

[8] "fitbit8.jpg" "fitbit9.jpg" "fitbit10.jpg" "fitbit11.jpg" "fitbit12.jpg"

#看一下collapse的用法

[1] "fitbit1.jpg; fitbit2.jpg; fitbit3.jpg"

#捉對拼接,如果某個向量較短,就自動補齊

a <- c("甲","乙","丙","丁","戊","己","庚","辛","壬","癸")

b <- c("子","醜","寅","卯","辰","巳","午","未","申","酉","戌","亥")

paste0(a, b)

[1] "甲子" "乙丑" "丙寅" "丁卯" "戊辰" "己巳" "庚午" "辛未" "壬申" "癸酉" "甲戌" "乙亥"

> for (i in 1:5)                #paste預設的sep 是空格

[1] "a 1 b"

[1] "a 2 b"

[1] "a 3 b"

[1] "a 4 b"

[1] "a 5 b"

> for (i in 1:5)

[1] "a1b"

[1] "a2b"

[1] "a3b"

[1] "a4b"

[1] "a5b"

> for (i in 1:5)

[1] "a,1,b"

[1] "a,2,b"

[1] "a,3,b"

[1] "a,4,b"

[1] "a,5,b"

> for (i in 1:5)

[1] "a1b"

[1] "a2b"

[1] "a3b"

[1] "a4b"

[1] "a5b"

> for (i in 1:5)

[1] "a1b"

[1] "a2b"

[1] "a3b"

[1] "a4b"

[1] "a5b"

> for (i in 1:5)

[1] "a1b,"

[1] "a2b,"

[1] "a3b,"

[1] "a4b,"

[1] "a5b,"

> for (i in 1:5)

[1] "a1b."

[1] "a2b."

[1] "a3b."

[1] "a4b."

[1] "a5b."

> paste(1:10)

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

> paste0(1:10)

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

> paste("a","b","c")

[1] "a b c"

> paste0("a","b","c")

[1] "abc"

> paste0("a","b","c",sep="")

[1] "abc"

> paste("a","b","c",sep="")

[1] "abc"

> paste("a","b","c",sep=",")

[1] "a,b,c"

> paste0("a","b","c",sep=",")

[1] "abc,"

> month.abb

[1] "jan" "feb" "mar" "apr" "may" "jun" "jul" "aug" "sep" "oct"

[11] "nov" "dec"

> paste(month.abb,c(1:12),sep="")

[1] "jan1" "feb2" "mar3" "apr4" "may5" "jun6" "jul7"

[8] "aug8" "sep9" "oct10" "nov11" "dec12"

> paste(month.abb,c(1:12),sep=".")

[1] "jan.1" "feb.2" "mar.3" "apr.4" "may.5" "jun.6"

[7] "jul.7" "aug.8" "sep.9" "oct.10" "nov.11" "dec.12"

> paste(month.abb,c(1:12),sep="\\")

[1] "jan\\1" "feb\\2" "mar\\3" "apr\\4" "may\\5" "jun\\6"

[7] "jul\\7" "aug\\8" "sep\\9" "oct\\10" "nov\\11" "dec\\12"

> paste(month.abb,c(1:12),sep=".",collapse=";")

[1] "jan.1;feb.2;mar.3;apr.4;may.5;jun.6;jul.7;aug.8;sep.9;oct.10;nov.11;dec.12"

六 連線模式 1) 連線簡介

可以借用 sql 的連線來解釋 假設 表a 表b 內連線 a.name b.name 儲存共有的相同值屬性 外連線 左外連線 以 外來鍵表a 左 屬性為基準。包含a屬性整列。b屬性符合a屬性值的存入,其餘b屬性被置為 null。右外連線 以 外來鍵表b 右 屬性為基準。包含b屬性整列。b屬性符合a屬...

13 連線查詢

假設 a 表中有3條記錄,b表中有 4 條記錄 那麼,語句select from a,b 會將a,b兩張表的資料交叉拼接起來,形成 3 4 12 條記錄的結果集,此結果集叫做笛卡爾積。ora 00918 未明確定義列 改進辦法 明確列的所屬 select empno,ename,emp.deptno...

004 連線查詢

再大多數的情況下,我們都需要進行連線查詢.笛卡爾積的產生 這個就是多表查詢的的最初結果集,那麼以後我們需要作的就是從結果集中篩選出需要的結果集.篩選的方式不同,導致sql的效率不同.篩選的方式就是加入連線標準.等值連線 select 字段 from 表1 表2 where 連線條件.eg 查詢員工名...