(R Example for Citizen Data Scientist & Business Analyst) Square <- function(x) { return(x^2) } print(Square(4)) print(Square(x=4)) # same thing [1] 16 [1] 16 Defining functions Functions can be defined like this: function(parameter1, parameter2, parameter3){code}. For use they are assigned to a variable (using normal <- assignment operator). Return values The return function is used for return values: return(value). If no …
Day: February 3, 2021
(R Example for Citizen Data Scientist & Business Analyst) To run the code paste it into an R console window. a <- 42 A <- a * 2 # R is case sensitive print(a) cat(A, “n”) # “84” is concatenated with “n” if(A>a) # true, 84 > 42 { cat(A, “>”, a, “n”) } …
(R Example for Citizen Data Scientist & Business Analyst) We find it easiest to use RStudio. You can also paste the code in a normal R console or let R run a source file. However these approaches are a bit less fail-safe. Using RStudio Download and install RStudio. Open RStudio and do this: Click …
(SQL Example for Citizen Data Scientist & Business Analyst) SQL | Numeric Functions Numeric Functions are used to perform operations on numbers and return numbers. Following are the numeric functions defined in SQL: ABS(): It returns the absolute value of a number. Syntax: SELECT ABS(-243.5); Output: 243.5 SQL> SELECT ABS(-10); +————————————–+ | ABS(10) +————————————–+ | 10 +————————————–+ …
(SQL Example for Citizen Data Scientist & Business Analyst) SQL | Date functions In SQL, dates are complicated for newbies, since while working with database, the format of the date in table must be matched with the input date in order to insert. In various scenarios instead of date, datetime (time is also involved …
(SQL Example for Citizen Data Scientist & Business Analyst) SQL Server Mathematical functions (SQRT, PI, SQUARE, ROUND, CEILING & FLOOR) Mathematical functions are present in SQL server which can be used to perform mathematical calculations. Some commonly used mathematical functions are given below: 1. SQRT(): SQRT() function is the most commonly used function. It …
(SQL Example for Citizen Data Scientist & Business Analyst) SQL | Join (Inner, Left, Right and Full Joins) A SQL Join statement is used to combine data or rows from two or more tables based on a common field between them. Different types of Joins are: INNER JOIN LEFT JOIN RIGHT JOIN FULL JOIN …
(SQL Example for Citizen Data Scientist & Business Analyst) SQL | BETWEEN & IN Operator BETWEEN The SQL BETWEEN condition allows you to easily test if an expression is within a range of values (inclusive). The values can be text, date, or numbers. It can be used in a SELECT, INSERT, UPDATE, or DELETE …
(SQL Example for Citizen Data Scientist & Business Analyst) SQL | Except Clause In SQL, EXCEPT returns those tuples that are returned by the first SELECT operation, and not returned by the second SELECT operation. This is the same as using a subtract operator in relational algebra. Example: Say we have two relations, Students and …
(SQL Example for Citizen Data Scientist & Business Analyst) SQL | MINUS Operator The Minus Operator in SQL is used with two SELECT statements. The MINUS operator is used to subtract the result set obtained by first SELECT query from the result set obtained by second SELECT query. In simple words, we can say …