Scripts चलाना
एक R script commands की एक saved list है जिसे आप एक साथ चला सकते हैं, top to bottom follow करने वाली एक recipe की तरह। आप इसे एक single command से terminal से चलाते हैं।
In this page:
Syntax
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
# 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. #}
आम गलतियां
- गलत folder से
Rscript analysis.Rचलाना, इसलिए Rcannot open file 'analysis.R'report करता है। - यह उम्मीद करना कि values एक script में console की तरह automatically print होंगी, जब एक script को ज़्यादातर results के लिए
print()याcat()चाहिए। - command line की बजाय R console में
Rscripttype करना, जहाँ यह एक R function नहीं है।
🔒
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: