Entering Data to R

[This article was first published on Analysis with R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

To enter data into R, two common and easy to use R functions are utilized.

  • The concatenate function, c; and,
  • The data.frame function.
The concatenate function, c, is use for combining data points into a single numeric R object. The usage of this function is simply c(), the entries inside the parentheses will be the data points separated by comma. Below is an example of this,

The RData above is a numeric R object with entries of the data points 36, 6, 15, and so on. This R object is then the data, and is ready for some tests.

The data.frame function, on the other hand, is use for entering data into R object in data frame class. This will generate a table when applying fix function to it, which is used as data editor similar to that in Minitab and SPSS.

To do this, assign the variable name of the data first, say R.df. Then run the following

The data frame class above is assigned to R.df variable. Hence, R.df has this frame of data points. But because no data points were entered yet, then fix function is used to open the data editor and enter the data into this R.df data frame.

To leave a comment for the author, please follow the link and comment on their blog: Analysis with R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)