Tutorial by Examples: and

One might want to group their data by the runs of a variable and perform some sort of analysis. Consider the following simple dataset: (dat <- data.frame(x = c(1, 1, 2, 2, 2, 1), y = 1:6)) # x y # 1 1 1 # 2 1 2 # 3 2 3 # 4 2 4 # 5 2 5 # 6 1 6 The variable x has three runs: a run of l...
To install Eclipse, go to the Eclipse Downloads Web page where there is usually a direct link to download the latest version of Eclipse. Starting Eclipse Mars (version 4.5), an installer can be downloaded which guides you through the installation procedure, as opposed to downloading the whole instal...
This a basic example aimed at new users. It does not focus on explaining the difference between char and cellstring. It might happen that you want to get rid of the ' in your strings, although you never added them. In fact, those are artifacts that the command window uses to distinguish between ...
function Invoke-MyCmdlet { [CmdletBinding(SupportsShouldProcess = $true)] param() # ... }
class Person { [string] $FirstName [string] $LastName [string] Greeting() { return "Greetings, {0} {1}!" -f $this.FirstName, $this.LastName } } $x = [Person]::new() $x.FirstName = "Jane" $x.LastName = "Doe" $greeting = $x.Greeting() #...
Vector size is simply the number of elements in the vector: Current vector size is queried by size() member function. Convenience empty() function returns true if size is 0: vector<int> v = { 1, 2, 3 }; // size is 3 const vector<int>::size_type size = v.size(); cout << size...
MATLAB code can be saved in m-files to be reused. m-files have the .m extension which is automatically associated with MATLAB. An m-file can contain either a script or functions. Scripts Scripts are simply program files that execute a series of MATLAB commands in a predefined order. Scripts do no...
The data.table package provides a convenient way to group by runs in data. Consider the following example data: library(data.table) (DT <- data.table(x = c(1, 1, 2, 2, 2, 1), y = 1:6)) # x y # 1: 1 1 # 2: 1 2 # 3: 2 3 # 4: 2 4 # 5: 2 5 # 6: 1 6 The variable x has three runs: a run ...
DT[where, select|update|do, by] syntax is used to work with columns of a data.table. The "where" part is the i argument The "select|update|do" part is the j argument These two arguments are usually passed by position instead of by name. Our example data below is mtcars =...
<PROJECT_ROOT>\app\build.gradle is specific for app module. <PROJECT_ROOT>\build.gradle is a "Top-level build file" where you can add configuration options common to all sub-projects/modules. If you use another module in your project, as a local library you would have another...
R is able to access the current date, time and time zone: Sys.Date() # Returns date as a Date object ## [1] "2016-07-21" Sys.time() # Returns date & time at current locale as a POSIXct object ## [1] "2016-07-21 10:04:39 CDT" as.numeric(Sys...
# test date-time object options(digits.secs = 3) d = as.POSIXct("2016-08-30 14:18:30.58", tz = "UTC") format(d,"%S") # 00-61 Second as integer ## [1] "30" format(d,"%OS") # 00-60.99… Second as fractional ## [1] "30.579" for...
To start coding in the first place, you have to right click your VBA Project in the left list and add a new Module. Your first Hello-World Code could look like this: Sub HelloWorld() MsgBox "Hello, World!" End Sub To test it, hit the Play-Button in your Toolbar or simply hit the...
Fixed precision and scale decimal numbers. DECIMAL and NUMERIC are functionally equivalent. Syntax: DECIMAL ( precision [ , scale] ) NUMERIC ( precision [ , scale] ) Examples: SELECT CAST(123 AS DECIMAL(5,2)) --returns 123.00 SELECT CAST(12345.12 AS NUMERIC(10,5)) --returns 12345.12000
Approximate-number data types for use with floating point numeric data. SELECT CAST( PI() AS FLOAT) --returns 3.14159265358979 SELECT CAST( PI() AS REAL) --returns 3.141593
Data types that represent monetary or currency values. Data typeRangeStoragemoney-922,337,203,685,477.5808 to 922,337,203,685,477.58078 bytessmallmoney-214,748.3648 to 214,748.36474 bytes
Binary data types of either fixed length or variable length. Syntax: BINARY [ ( n_bytes ) ] VARBINARY [ ( n_bytes | max ) ] n_bytes can be any number from 1 to 8000 bytes. max indicates that the maximum storage space is 2^31-1. Examples: SELECT CAST(12345 AS BINARY(10)) -- 0x0000000000000000...
String data types of either fixed length or variable length. Syntax: CHAR [ ( n_chars ) ] VARCHAR [ ( n_chars ) ] Examples: SELECT CAST('ABC' AS CHAR(10)) -- 'ABC ' (padded with spaces on the right) SELECT CAST('ABC' AS VARCHAR(10)) -- 'ABC' (no padding due to variable character) SELE...
UNICODE string data types of either fixed length or variable length. Syntax: NCHAR [ ( n_chars ) ] NVARCHAR [ ( n_chars | MAX ) ] Use MAX for very long strings that may exceed 8000 characters.
Long vectors with long runs of the same value can be significantly compressed by storing them in their run-length encoding (the value of each run and the number of times that value is repeated). As an example, consider a vector of length 10 million with a huge number of 1's and only a small number o...

Page 17 of 153