← Back to R Course | Chapter 2: Variables & Types | Lesson 4 of 7

Character Type क्या है

Character values text के pieces हैं, जैसे words या sentences, quote marks के अंदर लिखे गए। ये वह तरीका हैं जिससे R names और messages रखता है।

In this page:

  1. Character Type
Syntax
r
text <- "some text"
class(text)    # "character"

Character Type

R का character type text strings store करता है, single या double quotes से लिखे गए। कुछ languages के उलट, कोई separate single-character type नहीं है -- एक one-letter string फिर भी character है।

String concatenation और formatting typically एक + operator की बजाय paste() से होते हैं।

Note: R में Single और double quotes strings के लिए identically काम करते हैं -- एक style चुनें और consistent रहें।

उदाहरण: Character Type

markup
name <- "Ada"
greeting <- 'Hello'

cat(class(name), "\n")
cat(greeting, name, "\n")
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. text के चारों ओर quotes भूल जाना, जैसे name <- Ada, जो Ada नाम का एक variable ढूंढता है और fail होता है।
  2. "a" + "b" जैसे + से strings add करने की कोशिश करना, जो एक error है; paste() इस्तेमाल करें।
  3. "Hello' जैसे quotes की एक mismatched pair mix up करना, जो string को unclosed छोड़ देता है।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.