Markdown to R DataFrame Converter

Transform Markdown tables into R DataFrame format

Markdown Input

R DataFrame Output

About Markdown to R DataFrame Converter

Convert Markdown tables to R data frame code with automatic type detection. Perfect for data analysis, statistical computing, and R programming.

Key Features

  • Data Frame Creation: Generates R data.frame() code
  • Type Inference: Detects logical, integer, numeric, and character types
  • Column Sanitization: Converts column names to valid R identifiers
  • NA Handling: Empty cells become NA values
  • Helper Code: Includes print(), summary(), and str() commands
  • Download: Save as .R file

How to Use

  1. Input Markdown Table: Paste your Markdown table or upload a .md file
  2. Review Code: The R data frame code is generated automatically
  3. Check Types: Verify the detected column types
  4. Copy or Download: Use the code in your R project
  5. Run in R: Execute the code in R or RStudio

Type Detection

  • logical: Values are "true" or "false" (case-insensitive) → TRUE/FALSE
  • integer: Whole numbers without decimals → 1, 2, 3, -5
  • numeric: Numbers with decimals or scientific notation → 3.14, 1.5e10
  • character: All other values (default type) → "text", "data"

Example Conversion

Markdown Input:

| Name | Age | City | Department |
|------|-----|------|------------|
| John Doe | 28 | New York | Engineering |
| Jane Smith | 34 | London | Marketing |
| Bob Johnson | 45 | Toronto | Sales |

R DataFrame Output:

# Rows: 3, Columns: 4
# Column types: Name (character), Age (integer), City (character), Department (character)

df <- data.frame(
  Name = c("John Doe", "Jane Smith", "Bob Johnson"),
  Age = c(28, 34, 45),
  City = c("New York", "London", "Toronto"),
  Department = c("Engineering", "Marketing", "Sales")
  stringsAsFactors = FALSE
)

# View the data frame
print(df)

# Summary statistics
summary(df)

# Structure
str(df)

Common Use Cases

  • Data Analysis: Load data for statistical analysis in R
  • Visualization: Create data frames for ggplot2 charts
  • Machine Learning: Prepare datasets for modeling
  • Research: Convert research data to R format
  • Teaching: Create example datasets for R tutorials
  • Reports: Generate reproducible research reports
  • Testing: Create test data for R packages

R DataFrame Features

  • data.frame(): Standard R data frame constructor
  • stringsAsFactors: Set to FALSE to keep strings as character type
  • c() Vectors: Each column is a vector of values
  • NA Values: Missing data represented as NA
  • Type Safety: Columns have consistent types

Column Name Sanitization

Column names are automatically sanitized for R:

  • Spaces and special characters → underscores
  • Leading/trailing underscores → removed
  • Multiple underscores → collapsed to single
  • Names starting with numbers → prefixed with "X"
  • Duplicate names → numbered suffixes (_2, _3, etc.)
  • Example: "First Name" → "First_Name"

Using the Generated Code

In R Console:

# Copy and paste the generated code
df <- data.frame(
  Name = c("John Doe", "Jane Smith"),
  Age = c(28, 34)
  stringsAsFactors = FALSE
)

# Access columns
df$Name
df$Age

# Filter rows
df[df$Age > 30, ]

# Add new column
df$Salary <- c(75000, 85000)

In RStudio:

  1. Create a new R script
  2. Paste the generated code
  3. Run the script (Ctrl+Enter or Cmd+Enter)
  4. View the data frame in the Environment pane
  5. Use View(df) to see the data in a spreadsheet-like view

Data Frame Operations

Common Operations:

# View data
print(df)           # Print to console
View(df)            # Open in viewer
head(df)            # First 6 rows
tail(df)            # Last 6 rows

# Dimensions
nrow(df)            # Number of rows
ncol(df)            # Number of columns
dim(df)             # Rows and columns

# Summary
summary(df)         # Statistical summary
str(df)             # Structure
names(df)           # Column names

# Subsetting
df[1, ]             # First row
df[, 1]             # First column
df$Name             # Column by name
df[df$Age > 30, ]   # Filter rows

Integration with tidyverse

Convert to tibble:

library(tibble)
library(dplyr)

# Convert to tibble
df_tibble <- as_tibble(df)

# Use dplyr verbs
df_tibble %>%
  filter(Age > 30) %>%
  select(Name, Age) %>%
  arrange(desc(Age))

Visualization with ggplot2

Create plots:

library(ggplot2)

# Bar plot
ggplot(df, aes(x = Name, y = Age)) +
  geom_bar(stat = "identity")

# Scatter plot
ggplot(df, aes(x = Age, y = Salary)) +
  geom_point()

# Box plot
ggplot(df, aes(x = Department, y = Age)) +
  geom_boxplot()

Export to Other Formats

Save data frame:

# CSV
write.csv(df, "data.csv", row.names = FALSE)

# RDS (R data format)
saveRDS(df, "data.rds")

# Excel
library(writexl)
write_xlsx(df, "data.xlsx")

# JSON
library(jsonlite)
write_json(df, "data.json")

Tips for Best Results

  • Use descriptive column names (they become variable names)
  • Ensure consistent data types within columns
  • Avoid special characters in column names
  • Use lowercase_with_underscores naming convention
  • Review detected types and adjust if needed
  • Test the code in R before using in production
  • Add comments to document the data source

R Packages for Data Frames

Useful packages for working with data frames:

  • dplyr: Data manipulation (filter, select, mutate, etc.)
  • tidyr: Data tidying (pivot, separate, unite, etc.)
  • tibble: Modern data frames with better printing
  • data.table: Fast data manipulation for large datasets
  • readr: Fast reading and writing of data files
  • ggplot2: Data visualization

Privacy & Security

All conversions happen locally in your browser. Your Markdown data is never uploaded to any server, ensuring complete privacy and security.