Featured Post

SQL Interview Success: Unlocking the Top 5 Frequently Asked Queries

Image
 Here are the five top commonly asked SQL queries in the interviews. These you can expect in Data Analyst, or, Data Engineer interviews. Top SQL Queries for Interviews 01. Joins The commonly asked question pertains to providing two tables, determining the number of rows that will return on various join types, and the resultant. Table1 -------- id ---- 1 1 2 3 Table2 -------- id ---- 1 3 1 NULL Output ------- Inner join --------------- 5 rows will return The result will be: =============== 1  1 1   1 1   1 1    1 3    3 02. Substring and Concat Here, we need to write an SQL query to make the upper case of the first letter and the small case of the remaining letter. Table1 ------ ename ===== raJu venKat kRIshna Solution: ========== SELECT CONCAT(UPPER(SUBSTRING(name, 1, 1)), LOWER(SUBSTRING(name, 2))) AS capitalized_name FROM Table1; 03. Case statement SQL Query ========= SELECT Code1, Code2,      CASE         WHEN Code1 = 'A' AND Code2 = 'AA' THEN "A" | "A

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

Explained Ideal Structure of Python Class

How to Check Kafka Available Brokers