Go to Sign up
Note: Your files never leave your device. We don't upload, transfer, or store your data.
|
|
|
|
|---|---|---|
|
|
|
R is a programming language and environment for statistical computing, data analysis, and visualization. It is widely used in statistics, bioinformatics, finance, and data science.
# R console
> x <- c(1, 2, 3, 4, 5)
> mean(x)
[1] 3
A data.frame is R's primary data structure for tabular data — similar to a spreadsheet or SQL table. Each column can hold a different data type.
df <- data.frame(
name = c("Alice", "Bob", "Charlie"),
age = c(30, 25, 35),
city = c("New York", "London", "Tokyo")
)
print(df)
name age city
1 Alice 30 New York
2 Bob 25 London
3 Charlie 35 Tokyo
| Property | Description |
|---|---|
| Columns | Named vectors, each with a single type |
| Rows | Observations, accessed by row number or name |
| Types | Each column has one type (numeric, character, factor, logical) |
| Dimensions | nrow(df) rows × ncol(df) columns |
| Access | df$column, df[1, ], df[, "name"] |
df <- read.csv("data.csv", stringsAsFactors = FALSE)| Aspect | read.csv() |
|---|---|
| When to use | Dynamic CSV files at runtime |
| Requires | File path or URL at runtime |
| Flexibility | Handles any CSV with many options |
| Dependencies | Requires CSV file present |
| Aspect | This Tool |
|---|---|
| When to use | Static data, testing, examples, tutorials |
| Output | Self-contained R code |
| Flexibility | Editable R source code |
| Dependencies | None at runtime — data is literal code |
| Use Case | Description |
|---|---|
| R tutorials | Embed sample datasets directly in R Markdown or tutorials |
| Testing | Create test data.frames for unit tests (testthat) |
| R Markdown | Include data in .Rmd documents without external files |
| Shiny apps | Hardcode small datasets in Shiny applications |
| Data analysis | Paste CSV data into R scripts as data.frame code |
| Education | Teach R with concrete, reproducible data examples |
| Package examples | Create example datasets in R package documentation |
| Data cleaning | Use the table editor to clean CSV before generating R code |
After loading CSV data, an interactive spreadsheet grid lets you edit before converting:
| Operation | Description |
|---|---|
| Transpose | Swap rows and columns |
| Clear | Remove all data |
| Delete Empty | Remove empty rows/columns |
| Deduplicate | Remove duplicate rows |
| Replace | Find and replace (with regex support) |
| Case transform | UPPERCASE, lowercase, Title Case |
| Insert/delete | Right-click for row/column operations |
| First Row as Header | Toggle header treatment |
Sets the variable name for the generated data.frame:
# DataFrame Name = "employees"
employees <- data.frame(
name = c("Alice", "Bob"),
age = c(30, 25)
)
Use descriptive names: sales_data, user_table, sensor_readings, survey_results.
Controls whether string columns are converted to factors.
R 4.0+ changed the default from TRUE to FALSE. This option ensures compatibility.
Enabled (stringsAsFactors = TRUE):
df <- data.frame(
name = c("Alice", "Bob"),
stringsAsFactors = TRUE
)
# name column is a factor with levels "Alice", "Bob"
class(df$name) # "factor"
Disabled (stringsAsFactors = FALSE):
df <- data.frame(
name = c("Alice", "Bob"),
stringsAsFactors = FALSE
)
# name column is character
class(df$name) # "character"
| When to Use | Setting |
|---|---|
| Statistical modeling (lm, glm) | stringsAsFactors = TRUE — factors work with formulas |
| Data manipulation (dplyr, stringr) | stringsAsFactors = FALSE — character is easier to work with |
| Compatibility with old code | stringsAsFactors = TRUE — matches R < 4.0 behavior |
| Modern R (tidyverse) | stringsAsFactors = FALSE — tidyverse prefers character |
Sets row names for the data.frame. Row names appear on the left side of the output.
With row names:
df <- data.frame(
name = c("Alice", "Bob"),
row.names = c("row1", "row2")
)
# name
# row1 Alice
# row2 Bob
Without row names (default):
df <- data.frame(
name = c("Alice", "Bob")
)
# name
# 1 Alice
# 2 Bob
Controls code indentation:
| Option | When to Use |
|---|---|
| 2 spaces | Default — compact, readable |
| 4 spaces | Deeply nested code |
| Tab | Match project conventions |
All processing runs entirely in your browser. No data is uploaded to any server.
Choose one of two input methods:
Upload a file: Click "Choose File" and select a .csv file.
Paste data: Click "Enter Data" to switch to the code editor. Paste your CSV.
Use the toolbar to clean your data before converting.
Use the Properties panel:
DataFrame Name: Enter a variable name (e.g., sales_data).
Strings As Factors: Enable for statistical modeling; disable for tidyverse.
Row Names: Optionally set row names.
Indent: Choose formatting.
Click Convert. The R code appears in the "Output Data" panel.
Click Copy to Clipboard to paste into your .R or .Rmd file.
Premium users can click Download File to save.
Input CSV:
name,department,salary,active
Alice,Engineering,95000,true
Bob,Marketing,78000,false
Charlie,Engineering,102000,true
Diana,Design,85000,true
Configuration:
DataFrame Name: employees
Strings As Factors: FALSE
Row Names: (none)
Indent: 2 spaces
Output:
employees <- data.frame(
name = c("Alice", "Bob", "Charlie", "Diana"),
department = c("Engineering", "Marketing", "Engineering", "Design"),
salary = c(95000, 78000, 102000, 85000),
active = c("true", "false", "true", "true"),
stringsAsFactors = FALSE
)
Input CSV:
species,petal_length,petal_width
setosa,1.4,0.2
setosa,1.3,0.2
versicolor,4.7,1.4
versicolor,4.5,1.5
virginica,6.0,2.5
virginica,5.9,2.1
Configuration: Strings As Factors: TRUE
Output:
iris_data <- data.frame(
species = c("setosa", "setosa", "versicolor", "versicolor", "virginica", "virginica"),
petal_length = c(1.4, 1.3, 4.7, 4.5, 6.0, 5.9),
petal_width = c(0.2, 0.2, 1.4, 1.5, 2.5, 2.1),
stringsAsFactors = TRUE
)
# Now fit a linear model
model <- lm(petal_width ~ petal_length + species, data = iris_data)
summary(model)
Input CSV:
product,price,stock
Laptop,1299.99,45
Phone,699.99,120
Tablet,499.99,0
Configuration: Strings As Factors: FALSE
After converting, use with dplyr:
library(dplyr)products <- data.frame(
product = c("Laptop", "Phone", "Tablet"),
price = c(1299.99, 699.99, 499.99),
stock = c(45, 120, 0),
stringsAsFactors = FALSE
)
products %>%
filter(stock > 0) %>%
mutate(value = price * stock) %>%
arrange(desc(value))
| CSV Value | R Type | Example |
|---|---|---|
"hello" | character | c("hello", "world") |
42 | numeric | c(42, 100) |
3.14 | numeric | c(3.14, 2.72) |
TRUE / FALSE | character (from CSV) | c("TRUE", "FALSE") |
| Empty cell | NA | NA |
Note: CSV values are all text. The tool outputs character vectors. Convert types in R:
df$age <- as.integer(df$age)
df$price <- as.numeric(df$price)
df$active <- as.logical(df$active)
# Basic info
nrow(df) # Number of rows
ncol(df) # Number of columns
colnames(df) # Column names
str(df) # Structure
summary(df) # Statistical summary
head(df) # First 6 rows
# Access
df$column_name # Column as vector
df[1, ] # First row
df[, "name"] # Column by name
df[df$age > 28, ] # Filter rows
# Modify
df$new_col <- df$a + df$b # Add column
df$name <- tolower(df$name) # Transform column
df <- df[order(df$age), ] # Sort
# Export
write.csv(df, "output.csv", row.names = FALSE)
No. All conversion happens locally in your browser using JavaScript. Your data never leaves your device.
A data.frame is R's primary tabular data structure. It stores data in rows and columns where each column has a single data type. It is similar to a spreadsheet or SQL table.
stringsAsFactors controls whether string columns become factors (categorical data). In R 4.0+, the default is FALSE (character). Enable for statistical modeling with lm() or glm(); disable for tidyverse data manipulation.
Character is plain text — easy to manipulate with stringr and dplyr. Factor is a categorical variable with fixed levels — required by many R modeling functions (lm, glm, aov). Factors use less memory for repeated values.
Yes. Paste the generated code directly into an R Markdown .Rmd code chunk. The data.frame will be created when the document is knitted.
read.csv() reads CSV files at runtime. This tool generates R source code that creates a data.frame from literal values. Use this tool for static data, tutorials, and examples; use read.csv() for dynamic data.
Yes. The built-in table editor lets you modify cells, transpose, deduplicate, find/replace, change case, and insert/delete rows and columns.
Standard CSV with comma delimiters. The first row can be used as column headers (enable "First Row as Header").
The tool processes data entirely in your browser. Files up to 10 MB typically convert without issues on modern hardware.
Yes. The tool is responsive, though the table editor is best experienced on desktop.