Entering Data to R

March 30, 2013

(This article was first published on Analysis with R, and kindly contributed to R-bloggers)

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 on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


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)