← Back to R Course | Chapter 1: Getting Started | Lesson 3 of 6

Scripts चलाना

एक R script commands की एक saved list है जिसे आप एक साथ चला सकते हैं, top to bottom follow करने वाली एक recipe की तरह। आप इसे एक single command से terminal से चलाते हैं।

In this page:

  1. Scripts चलाना
Syntax
r
Rscript script_name.R

Scripts चलाना

एक R script Rscript filename.R से command line से चलाई जाती है, हर statement top to bottom execute करते हुए। यह non-interactive R code चलाने का standard तरीका है, जैसे automation या batch jobs में।

Interactive console और Rscript automatic printing को छोड़कर almost identically behave करते हैं।

Note:
  • Batch execution के लिए Rscript इस्तेमाल करें।
  • Exploratory work के लिए interactive R console (या RStudio) इस्तेमाल करें।

उदाहरण: Running Scripts

bash
# Run an R script from the command line
Rscript analysis.R

# Start the interactive R console
R

⚠️ Run this in your own terminal or Node.js environment.

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. गलत folder से Rscript analysis.R चलाना, इसलिए R cannot open file 'analysis.R' report करता है।
  2. यह उम्मीद करना कि values एक script में console की तरह automatically print होंगी, जब एक script को ज़्यादातर results के लिए print() या cat() चाहिए।
  3. command line की बजाय R console में Rscript type करना, जहाँ यह एक R function नहीं है।
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 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.