2
我有這樣一個data.frame:轉換數據框柱連接字符串沒有雙引號
df = data.frame(str_col = c("when xyz = 'some_string' then 'this_string'",
"when xyz = 'some_string2' then 'this_string'"))
我想將str_col以逗號分隔的矢量轉換不喜歡雙引號:
c(when xyz = 'some_string' then 'this_string', when xyz = 'some_string2' then 'this_string')
我是想這樣的: str_vec <- paste(shQuote(df$str_col), collapse=",")
但我得到這個:
[1] "\"when xyz = 'some_string' then 'this_string'\",\"when xyz = 'some_string2' then 'this_string'\""
我不想反斜槓或雙引號。我正在嘗試構造一個SQL查詢。
我的預期輸出我想了一個小錯誤。 。時間之間不應該有逗號,但我通過在答案中調整了崩潰參數來修復它。謝謝 ! – vagabond