Installing R and RStudio

पहले R (engine) CRAN से install कीजिए, फिर RStudio Desktop (dashboard) दूसरे नंबर पर, और चार panes सीखिए: console, source, environment, और files/plots।

8 min read · 9 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

दो downloads, एक common mistake

Lab day। आधी class पहले "RStudio" download करती है क्योंकि नाम complete लगता है, double-click करती है... और एक error मिलती है: no R installation found।

क्योंकि RStudio, R नहीं है। R engine है: वह language जो compute करती है। RStudio उसके चारों तरफ़ लगा dashboard है: editor, plots, help, सब एक window में।

Dashboards engines के बिना बेकार हैं। सही order में install कीजिए और पूरी चीज़ दस मिनट लेती है।

Theory

पहले engine, फिर उसके चारों तरफ़ car

अकेला R एक stand पर काम करता engine है: आप इसे नंगे बारे में चला सकते हैं (एक plain white console: commands type कीजिए, जवाब पाइए)।

RStudio उस engine के चारों तरफ़ बनी car है: seats (editor), speedometer (environment pane), rear-view mirror (history), music system (plots)। Comfortable, पर यह एक इंच नहीं हिलेगी बिना पहले engine बोल्ट किए।

Installation का order = dependency का order: पहले engine, फिर car।

Follow along

Installation, order में

  1. CRAN से R install कीजिए: cran.r-project.org अपना OS चुनिए: Windows: 'base' installer (.exe); Mac: .pkg; Linux: आपका package manager। Defaults accept कीजिए।
  2. posit.co से RStudio Desktop (free) install कीजिए RStudio के पीछे की company ने ख़ुद को Posit rename किया: वही free IDE। RStudio step 1 में install किए R को auto-detect करता है।
  3. Verify कीजिए: RStudio खोलिए Console (bottom-left) R version banner print करता है। अगर यह missing R की शिकायत करे, तो step 1 skip हो गया था।
  4. > prompt पर 2 + 2 type कीजिए और Enter दबाइए R जवाब देता है [1] 4। वह [1] R है जो answer के पहले element को numbering कर रहा है: normal, error नहीं।
  5. इस course के लिए working directory set कीजिए Session menu > Set Working Directory > Choose Directory: इसे उस folder पर point कीजिए जिसमें survey.csv है। getwd() से check कीजिए।

Theory

RStudio के चार panes

एक window, चार quadrants, हर एक का एक काम:

  • Console (bottom-left): एक command type कीजिए, जवाब पाइए: interactive heart।
  • Source (top-left): .R script files लिखिए: saved, repeatable; Ctrl+Enter current line को console तक भेजता है।
  • Environment (top-right): memory में मौजूद हर variable, live।
  • Files / Plots / Packages / Help (bottom-right): आपके charts Plots के नीचे दिखते हैं; ?mean Help के नीचे documentation खोलता है।

Console = scratchpad (quit करने पर चला जाता है); Script = record (आपका असली काम)। असली analysis scripts में रहता है।

Quiz

एक student एक नए laptop पर सिर्फ़ RStudio install करता है और इसे खोलता है। क्या होता है, और क्यों?

  1. एक missing R installation के बारे में error: RStudio सिर्फ़ IDE है और इसे पहले R engine install होना चाहिए
  2. यह ठीक काम करता है: RStudio के अंदर R है
  3. यह काम करता है, पर सिर्फ़ छोटे datasets के लिए
  4. Laptop को इसके बजाय Python install होना चाहिए
Show the answer

एक missing R installation के बारे में error: RStudio सिर्फ़ IDE है और इसे पहले R engine install होना चाहिए

RStudio में कोई engine नहीं आता: यह वह dashboard है जो machine पर जो भी R मिलती है उसे चलाता है, और यहाँ कोई नहीं मिलती। fix सही order है: पहले CRAN से R, फिर posit.co से RStudio। यह engine/dashboard distinction, और कौन सी website कौन सा हिस्सा देती है, बिल्कुल वही है जो exam का "R और RStudio के installation को explain कीजिए" सवाल चाहता है।

Think first

Missing file को diagnose कीजिए

R और RStudio perfectly install हैं। Student read.csv("survey.csv") type करता है और पाता है: cannot open file 'survey.csv': No such file or directory। File definitely exist करती है, Downloads folder में। tap करने से पहले: क्या ग़लत है, और DO fixes नाम दीजिए।

Show the answer

R अपनी working directory में files ढूँढती है, जो Downloads नहीं है। Fixes:

1. Pointer हिलाइए: Session > Set Working Directory > Choose Directory (या setwd("C:/Users/you/Downloads")), फिर बिना path वाला filename काम करता है।

2. पूरा path दीजिए: read.csv("C:/Users/you/Downloads/survey.csv")।

getwd() से check कीजिए R कहाँ देख रही है। यह R का वर्ज़न है BCA303 के connect-typo trap का: number one beginner error, और यह location के बारे में है, code के बारे में नहीं।

Watch out

छोटी आदतें जो lost work से बचाती हैं

Console बनाम script: console में type किए commands session के साथ ग़ायब हो जाते हैं: रखने लायक़ कुछ भी एक .R file (top-left) में जाता है और Ctrl+Enter से चलता है।

Output में [1] prefix R द्वारा element positions label करना है, कोई error code नहीं।

Case sensitivity अभी से शुरू: Mean(x) fail होता है; mean(x) काम करता है: R capitals कभी माफ़ नहीं करता।

Theory

आपका workspace तैयार है

Engine installed, dashboard fitted, working directory survey data पर aimed। अगला lesson असली language शुरू करता है: <- assignment arrow, c() से बने vectors, और R के data types: वह grammar जो बाद का हर command इस्तेमाल करता है। इन lessons को पढ़ते समय RStudio खुला रखिए: जो भी code block आप देखें वह type और run किए जाने के लिए है।

Summary

Key takeaways

  • R (engine) CRAN से install होता है; RStudio Desktop (IDE) posit.co से: उसी order में।
  • R के बिना RStudio = error: इसमें कोई engine नहीं आता।
  • चार panes: console (interact), source (scripts, Ctrl+Enter), environment (variables), files/plots/help।
  • Scripts persist करते हैं, console history नहीं: असली काम .R files में रहता है।
  • Working directory (getwd/setwd या Session menu) वह है जहाँ read.csv देखता है: classic file-not-found कारण।
  • R case-sensitive है; output में [1] element numbering है।
  • Memory hook: पहले engine, फिर उसके चारों तरफ़ car।

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Introduction to R and working with Data

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Installing R and RStudio · Statistical Methods and Data Analysis (MDC-03) · Gri-Learn