String 字元/Create 建立

  • R 語言文字的型別稱為 character
  • 使用單引號或雙引號將值包括起來
    • 不論是在引號中放置數值、文字或者布林,都會以文字型別儲存。
asset_tony_stark <- "12.4 billion"
class(asset_tony_stark)
## [1] "character"

asset_tony_stark <- "12400000000"
class(asset_tony_stark)
## [1] "character"

tony_stark_is_rich <- "True"
class(tony_stark_is_rich)
## [1] "character"
  • 文字內容中有出現雙引號或單引號的時候,要特別留意
    • 兩種解法:
      • 在 O’Neal 的單引號前面加上跳脫符號 \
      • 以雙引號包括姓名
writeLines("Okay. Let's put aside the fact that you \"accidentally\" picked up my grandmother's ring and you \"accidentally\" proposed to Rachel.")

## Okay. Let's put aside the fact that you "accidentally" picked up my grandmother's ring and you "accidentally" proposed to Rachel.

Reference:

results matching ""

    No results matching ""