Featured Post

14 Top Data Pipeline Key Terms Explained

Image
 Here are some key terms commonly used in data pipelines 1. Data Sources Definition: Points where data originates (e.g., databases, APIs, files, IoT devices). Examples: Relational databases (PostgreSQL, MySQL), APIs, cloud storage (S3), streaming data (Kafka), and on-premise systems. 2. Data Ingestion Definition: The process of importing or collecting raw data from various sources into a system for processing or storage. Methods: Batch ingestion, real-time/streaming ingestion. 3. Data Transformation Definition: Modifying, cleaning, or enriching data to make it usable for analysis or storage. Examples: Data cleaning (removing duplicates, fixing missing values). Data enrichment (joining with other data sources). ETL (Extract, Transform, Load). ELT (Extract, Load, Transform). 4. Data Storage Definition: Locations where data is stored after ingestion and transformation. Types: Data Lakes: Store raw, unstructured, or semi-structured data (e.g., S3, Azure Data Lake). Data Warehous...

How to Execute Commands in R Language

The next step after installing R is how to run commands. You can run directly by entering commands. The other way is you need to write an R script, that contains all the series of commands. The benefit of the script is you can save your commands, it saves your time. Second, as a script, you can run it whenever you need.


#How to Run-commands in R:
#How to Run-commands in R:

Executing Commands in R

Commands can be entered directly into the R console (the window that opens when you start R),
following the red > prompt, and sent to the computer by pressing enter.

For example, typing 1 + 2 and pressing enter will output the result 3:
> 1+2
[1] 3
Your entered code always follows the > prompt, and output always follows a number in square
brackets.
  • Each command should take its own line of code, or else a line of code should be continued with { } 
  • It is possible to press enter before the line of code is completed, and often R will recognize this. For example, if you were to type 1 + but then press enter before typing 2, R knows that 1+ by itself doesn’t make any sense, so prompts for you to continue the line with a + sign. At this point, you could continue the line by pressing 2 then enter. This commonly occurs if you forget to close parentheses or brackets. 
  • If you keep pressing enter and keep seeing a + sign rather than the regular > prompt that allows you to type new code, and if you can’t figure out why, often the easiest option is to simply press ESC, which will get you back to the normal > prompt and allow you to enter a new line of code. 
Capitalization and punctuation need to be exact in R, but spacing doesn’t matter. If you get errors when entering the code, you may want to check for these common mistakes:
  1. Did you start your line of code with a fresh prompt (>)? If not, press ESC.
  2. Are your capitalization and punctuation correct?
  3. Are all your parentheses and brackets closed? For every forward (, {, or [, make sure there is a corresponding backward), }, or ]

R Script

Rather than typing a command in a console, you can create a script using a group of commands.  Code (commands) can be typed here, and then entered into the console in one of three ways:
  1. Copy the code in the R script and paste in the console
  2. Right-click on a line or highlighted group of lines and choose “Run line or selection”
  3. Place your cursor on a line or highlight a group of lines and press CTRL+R. 
The Scripts in R-Language are powerful and re-usable.

Comments

Popular posts from this blog

How to Fix datetime Import Error in Python Quickly

SQL Query: 3 Methods for Calculating Cumulative SUM

Big Data: Top Cloud Computing Interview Questions (1 of 4)