This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# dumping textual data | |
# stores data and its meta data too in a file. | |
# no need to read to read meta data back, so tables can be created | |
# back quickly. Only downside is space efficency | |
# dput & dget command generates the R code and can read back. Also | |
# dput can work on single R object | |
# create a data frame | |
y <- data.frame(a=1, b="abc") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# reading a small or moderately sized CSV data file | |
csvdata <- read.csv("data/sample.csv") | |
tabdata <- read.table("data/sample.csv") | |
#--------------------------------------------------------------------- | |
# reading larger dataset | |
# read only an initial data set | |
initdata <- read.table("data/sample.csv", nrows=100, sep=",", header=T) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# names in R | |
#------------------------------------------------------------ | |
# Vectors can have names | |
v1 <- 1:3 | |
# print names for v1 this shall return null | |
names(v1) | |
# assigning names to values | |
names(v1) <- c("a", "b", "c") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# matrix in R | |
m <- matrix(nrow=2, ncol=3) | |
# get the dimensions | |
dim(m) | |
attributes(m) | |
# matrix are filled column wise | |
n <- matrix(1:6, nrow=2, ncol=3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x <- c(1,2,NA,3) | |
is.na(x) | |
is.nan(x) | |
y <- c(1,2,NaN,3) | |
is.na(y) | |
is.nan(y) | |
z <- c(1,2,NaN,NA) | |
is.na(z) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# factor for categorical data can be ordered or unordered | |
# eg. gender (M, F), size (S, M, L, XL, XXL) | |
# (M, F) or (S, M, L, XL, XXL) are called levels | |
x <- factor(c("S", "M", "L", "XL", "XXL", "S", "XL", "XXL")) | |
# represent the class of x which is factor | |
class(x) | |
# strips out the class and shows the factors represents as integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# C stands for CONCAT and helps in creating vector | |
x <- c(1,2,3) | |
y1 <- c(T, F, T, F) | |
y2 <- c(TRUE, FALSE) | |
# sequence of numbers | |
z <- 1:100 | |
# complex numbers | |
a <- c(1+2i, 3+4i) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BizService { | |
private SqlSessionFactory sqlSessionFactory; | |
/** | |
* Initalize the | |
* | |
* @param config the config | |
*/ | |
private void init(QueryEngineConfiguration config) { | |
InputStream inputStream; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE BOOK ( | |
ID SERIAL PRIMARY KEY, | |
NAME VARCHAR (50) UNIQUE NOT NULL, | |
TITLE VARCHAR (100), | |
DESCRIPTION VARCHAR (200) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package learn.scala.polymorphism | |
trait List[T] { | |
def isEmpty: Boolean | |
def head: T | |
def tail: List[T] | |
} | |
class Nil[T] extends List[T] { | |
def isEmpty: Boolean = true |
NewerOlder