How to Create a Function in R
How to Repeat Vectors in R
How to Use Apply to Create Tabular Summaries in R

How to Enter Data into the R Text Editor

Although R is primarily a programming language, R has a very basic data editor that allows you to enter data directly using the edit() function.

The edit() function is only available in some R code editors, so depending on which software you’re using to edit your R code, this approach may not work. As of this writing, this option is not yet supported by RStudio.

To use the R text editor, first you need to initiate a variable. For example, to create a data frame and manually enter some of the periodic table data, enter the following:

elements <- data.frame()
elements <- edit(elements)

This displays an interactive editor where you can enter data. Notice that because the data frame is empty, you can scroll left and right, or up and down, to extend the editing range. Notice also that the editor doesn’t allow you to modify column or row names.

image0.png

Enter some data. Then to save your work, click the X in the top-right corner.

To view the details that you’ve just entered, use the print() function:

> print(elements)
 var1   var2 var3
1  1 Hydrogen  H
2  2  Helium  He
3  3 Lithium  Li
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
How to Count Unique Data Values in R
How to Describe the Center of Continuous Data in R
How to Create a Two-Way Data Table with R
How to Reduce the Number of Lines in R
How to Create a Bar Chart Using ggplot2 in R
Advertisement

Inside Dummies.com