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: 5

No comments:

All Rights Reserved by Technology from Developers Eye © 2014 - 2015
Powered By Blogger, Designed by Aadics
Disclaimers:: The information provided within this blogsite is for general informational purposes only. While we try to keep the information up-to-date and correct, there are no representations or warranties, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information, products, services, or related graphics contained in this blogsite for any purpose.The author does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause.

Contact Form

Name

Email *

Message *

Powered by Blogger.