-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay 1.R
65 lines (49 loc) · 1.35 KB
/
Day 1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Enter file contents here
rm(list = ls(all.name=TRUE))
setwd("../Documents")
# Variable declaration
# only . and _ and no digits in starting of vriable
# Data types
#Integer. only number without decimal
a <- -1L
typeof(a)
# Numeric/Double numbers with decimal. default type when declaring a number
a <- 1
typeof(a)
# charector.. all the data with alphabets and which is inside ' and "
a <- 'Hello'
typeof(a)
# Logical ,, TRUE or FALSE
a <- T
typeof(a)
# Raw internal data type of R
# Complex real and imaginary terms
is.integer(a)
is.numeric(a)
is.character(a)
is.logical(a)
#
# Data structures..using the data types above hoe they can be binded to each other
#
# Vector-> collection of similar datatype variables
vector <- c(12,'dd',T)
vector([1]
append(vector,"b",1)
# list -> collection of R object(variables,functions,models)
list <- c(mean,'a',1)
list[[1]]
append(list,"b",1)
# Matrix ->collection of similar data types in a 2 dimensions
matrix <- matrix(data=1:6,nrow=3)
matrix[1,2]
# Array -> similar to array with no dimensions limitation
array = array(1:4,dim = 4)
array[1]
# Factors -> defining a nominal variable type . fixing the levels in a variable
# Data Frames->tabular data
data <- data.frame(
gender = c("Male", "Male","Female","Male","Female","Male"),
Age =c(42,38,26,33,55,66)
name = c('ram','sham','sita','lak','rav','one')
)
data[1,1]