Markdown to R DataFrame Converter
Transform Markdown tables into R DataFrame format
Markdown Input
R DataFrame Output
Related Tools
Markdown to RDF
Convert Markdown tables to RDF (Resource Description Framework) in Turtle, RDF/XML, or N-Triples format
Markdown to reStructuredText
Convert Markdown tables to reStructuredText format for Sphinx and Python documentation
Markdown to Ruby
Convert Markdown tables to Ruby arrays, hashes, and Struct objects with automatic type detection
Markdown to SQL
Convert Markdown tables to SQL CREATE TABLE and INSERT statements with multi-dialect support
Markdown to Textile
Convert Markdown tables to Textile markup format for Redmine, Textpattern, and other Textile-based systems
Markdown to TOML
Convert Markdown tables to TOML configuration format with automatic type detection
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
- Input Markdown Table: Paste your Markdown table or upload a .md file
- Review Code: The R data frame code is generated automatically
- Check Types: Verify the detected column types
- Copy or Download: Use the code in your R project
- 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:
- Create a new R script
- Paste the generated code
- Run the script (Ctrl+Enter or Cmd+Enter)
- View the data frame in the Environment pane
- 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
FAQ
- What happens to missing values? Empty cells in the Markdown table are converted to
NAin R so you can handle them with standard missing-data tools. - How are column types chosen? The tool inspects each column and chooses logical, integer, numeric, or character based on the values it finds. Mixed-type columns default to character.
- Can I change column names? Column headers are sanitized into valid R identifiers. You can always rename columns later using
names(df)ordplyr::rename(). - Is any data sent to an external service? No. The R code is generated entirely in your browser; your Markdown content never leaves your machine.
Privacy & Security
All conversions happen locally in your browser. Your Markdown data is never uploaded to any server, ensuring complete privacy and security.
