Installing R and RStudio

પહેલાં CRAN પરથી R (engine) install કરો, પછી RStudio Desktop (dashboard), અને ચાર પાટિયાં શીખો: console, source, environment, અને files/plots.

8 min read · 9 cards · 2 checks

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


Theory

બે downloads, એક સામાન્ય ભૂલ

Lab નો દિવસ. અડધો વર્ગ પહેલાં "RStudio" download કરે છે કારણ કે નામ સંપૂર્ણ લાગે છે, બે વાર click કરે છે... અને ભૂલ મળે છે: કોઈ R નું installation મળ્યું નથી.

કારણ કે RStudio એ R નથી. R એ engine છે: એ ભાષા જે ગણતરી કરે છે. RStudio એ એની આસપાસ જડેલું dashboard છે: editor, આલેખ, મદદ, બધું એક બારીમાં.

Engine વગર dashboard નકામું છે. સાચા ક્રમમાં install કરો અને આખું કામ દસ મિનિટ લે છે.

Theory

પહેલાં engine, પછી એની આસપાસ ગાડી

એકલું R એ સ્ટેન્ડ પર મુકાયેલું ચાલતું engine છે: તમે એને ખુલ્લું ચલાવી શકો છો (એક સાદું સફેદ console: commands ટાઈપ કરો, જવાબ મેળવો).

RStudio એ engine ની આસપાસ બંધાયેલી ગાડી છે: બેઠકો (editor), speedometer (environment નું પાટિયું), પાછળનો અરીસો (ઇતિહાસ), સંગીતની system (આલેખ). આરામદાયક, પણ engine પહેલાં જડ્યા વગર એ એક ઇંચ પણ ખસશે નહીં.

Install નો ક્રમ = આધારનો ક્રમ: engine, પછી ગાડી.

Follow along

Installation, ક્રમમાં

  1. CRAN પરથી R install કરો: cran.r-project.org તમારું OS પસંદ કરો: Windows: 'base' installer (.exe); Mac: .pkg; Linux: તમારું package manager. Defaults સ્વીકારો.
  2. posit.co પરથી RStudio Desktop (મફત) install કરો RStudio પાછળની કંપનીએ પોતાનું નામ બદલીને Posit કર્યું: એ જ મફત IDE. RStudio પગલું 1માં install કરેલું R આપોઆપ શોધી લે છે.
  3. ચકાસો: RStudio ખોલો Console (નીચે ડાબે) R ના version નું banner છાપે છે. જો એ R ખૂટવાની ફરિયાદ કરે, તો પગલું 1 છોડી દેવાયું હતું.
  4. > prompt પર 2 + 2 ટાઈપ કરો અને Enter દબાવો R જવાબ આપે છે [1] 4. એ [1] એ R જવાબના પહેલા ઘટકને નંબર આપે છે: સામાન્ય છે, ભૂલ નથી.
  5. આ course માટે working directory ગોઠવો Session menu > Set Working Directory > Choose Directory: એને survey.csv ધરાવતા folder તરફ તાકો. getwd() થી તપાસો.

Theory

RStudio નાં ચાર પાટિયાં

એક બારી, ચાર ખૂણા, દરેકનું પોતાનું કામ:

  • Console (નીચે ડાબે): command ટાઈપ કરો, જવાબ મેળવો: interactive હૃદય.
  • Source (ઉપર ડાબે): .R script files લખો: સચવાયેલી, ફરી ચલાવી શકાય એવી; Ctrl+Enter હાલની લીટી console માં મોકલે છે.
  • Environment (ઉપર જમણે): અત્યારે memory માં રહેલું દરેક variable, જીવંત.
  • Files / Plots / Packages / Help (નીચે જમણે): તમારા charts Plots હેઠળ દેખાય છે; ?mean Help હેઠળ documentation ખોલે છે.

Console = ચબરખી (તમે બંધ કરો ત્યારે ગઈ); Script = નોંધ (તમારું ખરેખરું કામ). ગંભીર વિશ્લેષણ scripts માં વસે છે.

Quiz

એક student નવા laptop પર ફક્ત RStudio install કરે છે અને ખોલે છે. શું થાય છે, અને કેમ?

  1. R નું installation ખૂટવાની ભૂલ: RStudio ફક્ત IDE છે અને એને પહેલાં R નું engine install થયેલું જોઈએ
  2. એ બરાબર ચાલે છે: RStudio ની અંદર જ R હોય છે
  3. એ ચાલે છે, પણ ફક્ત નાના datasets માટે
  4. Laptop માં એને બદલે Python install થયેલું જોઈએ
Show the answer

R નું installation ખૂટવાની ભૂલ: RStudio ફક્ત IDE છે અને એને પહેલાં R નું engine install થયેલું જોઈએ

RStudio સાથે કોઈ engine આવતું નથી: એ dashboard છે જે યંત્ર પર જે R મળે એને ચલાવે છે, અને અહીં કશું મળતું નથી. ઉકેલ સાચો ક્રમ છે: પહેલાં CRAN પરથી R, પછી posit.co પરથી RStudio. આ engine/dashboard નો ભેદ, અને કઈ website કયો ટુકડો આપે છે, એ જ પરીક્ષાનો "R અને RStudio નું installation સમજાવો" પ્રશ્ન માંગે છે.

Think first

ખૂટતી file નું નિદાન કરો

R અને RStudio બરાબર install થયેલાં છે. Student read.csv("survey.csv") ટાઈપ કરે છે અને મળે છે: cannot open file 'survey.csv': No such file or directory. File ચોક્કસ છે, Downloads ના folder માં. Tap કરતાં પહેલાં: શું ખોટું છે, અને બે ઉકેલ આપો.

Show the answer

R પોતાની working directory માં files શોધે છે, જે Downloads નથી. ઉકેલ:

1. નિશાન ખસેડો: Session > Set Working Directory > Choose Directory (કે setwd("C:/Users/you/Downloads")), પછી ખાલી file નું નામ ચાલે છે.

2. પૂરો રસ્તો આપો: read.csv("C:/Users/you/Downloads/survey.csv").

R ક્યાં જુએ છે એ getwd() થી તપાસો. આ BCA303ના connect ના typo ના ફાંદાનું R નું રૂપ છે: શરૂઆત કરનારની નંબર એક ભૂલ, અને એ code ની નહીં, જગ્યાની વાત છે.

Watch out

કામ ગુમાવતાં અટકાવતી નાની ટેવો

Console સામે script: console માં ટાઈપ કરેલી commands session સાથે અદૃશ્ય થાય છે: રાખવા જેવું બધું .R file (ઉપર ડાબે) માં જાય અને Ctrl+Enter થી ચાલે.

Output માં [1] નો prefix એ R ઘટકનું સ્થાન દર્શાવે છે, ભૂલનો code નથી.

Case sensitivity હમણાંથી શરૂ: Mean(x) નિષ્ફળ જાય; mean(x) ચાલે: R મોટા અક્ષર ક્યારેય માફ કરતું નથી.

Theory

તમારી કાર્યજગ્યા તૈયાર છે

Engine install થયું, dashboard જડાયું, working directory survey ના data તરફ તકાયું. આગલા પાઠમાં ખરેખરી ભાષા શરૂ થાય છે: <- નું assignment નું તીર, c() થી બંધાતાં vectors, અને R ના data ના પ્રકારો: એ વ્યાકરણ જે પછીની દરેક command વાપરે છે. આ પાઠ ભણતી વખતે RStudio ખુલ્લું રાખો: તમે જુઓ છો એ દરેક code નો ટુકડો ટાઈપ કરીને ચલાવવા માટે છે.

Summary

Key takeaways

  • R (engine) CRAN પરથી install થાય છે; RStudio Desktop (IDE) posit.co પરથી: એ જ ક્રમમાં.
  • R વગર RStudio = ભૂલ: એની સાથે કોઈ engine આવતું નથી.
  • ચાર પાટિયાં: console (આપ-લે), source (scripts, Ctrl+Enter), environment (variables), files/plots/help.
  • Scripts ટકે છે, console નો ઇતિહાસ નહીં: ખરેખરું કામ .R files માં વસે છે.
  • Working directory (getwd/setwd કે Session menu) એ છે જ્યાં read.csv જુએ છે: file-not-found નું જાણીતું કારણ.
  • R case-sensitive છે; output માં [1] એ ઘટકનું ક્રમાંકન છે.
  • Memory hook: પહેલાં engine, પછી એની આસપાસ ગાડી.

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