DataFrames in R
Data
frames are data structure for most tabular data which we use for statistics in
R. It has attributes rownames()which is used to annotate the entity. Data frame is a special type of
list where every element of a list has same length. Few additional built in
function:-
·
data.matrix()
·
nrow(df)
·
ncol(df)
·
cbind(df)
·
head()
·
tail()
·
Data frame is a special type of list where every element of a list
has same length
#
Empty
Command::
data.frame()
#Example
dFrame
<- data.frame(id = letters[2:5], x = 2:5, y = rnorm(4))
print(dFrame)
id x y
1 b 2 0.3129572
2 c 3 1.6263950
3 d 4 0.8441991
4 e 5 1.0301756
cbind(dFrame,
data.frame(z = 4))
id x
y z
1 b 2 0.3129572 4
2 c 3 1.6263950 4
3 d 4 0.8441991 4
4 e 5 1.0301756 4
If
we need to take header values
head(dFrame,2)
id x
y
1 b 2 0.3129572
2 c 3 1.6263950
Footer
values from frames
tail(dFrame,2)
id x
y
3 d 4 0.8441991
4 e 5 1.0301756
DataFrames in R
Reviewed by Rupesh
on
00:28
Rating:
No comments: