Excel To R DataFrame

Login

Email
Password

Don't have an account yet?

Go to Sign up

{{ workbook ? 'Online Table Editor' : 'Input Data' }}
Change File Enter Data
Row Col Row Col
Transpose Clear Delete Empty Deduplicate
ABC abc Abc
Replace
First Row as Header
{{ displayRows.length }} rows x {{ displayHeaders.length }} columns{{ firstRowAsHeader ? ' (1 header)' : '' }} {{ selectedRows.length > 0 ? selectedRows.length + ' selected' : '' }}
Output Data
{{ copied ? 'Copied!' : 'Copy to Clipboard' }} Download File
Properties
Convert Excel to R DataFrame online — paste, edit, and download R.

DataFrame Name
Strings As Factors
Row Names
Indent
2 4 Tab
Convert Restart
Insert Row Below
Insert Row Above
Insert Column Right
Insert Column Left
Delete Row {{ contextMenu.row + 1 }}
Delete Column {{ contextMenu.col + 1 }}
Clear Cell
Clear Row
Case sensitive Use regex Cancel Replace All

What Is an R DataFrame?

A DataFrame is the primary tabular data structure in R. It stores data in rows and columns where each column can hold a different data type — numeric, character, factor, logical, or Date. DataFrames are created using the data.frame() function and are the foundation for statistical modeling, data visualization, and machine learning in R.

When you convert Excel data to an R DataFrame, you get a ready-to-paste data.frame() constructor call that you can drop directly into R scripts, RMarkdown reports, or Shiny applications — no CSV import step required.

R data.frame() Syntax at a Glance

PatternExampleNotes
data.frame(col = values)data.frame(Name = c("A", "B"), Age = c(30, 25))Column-wise vectors
stringsAsFactorsdata.frame(..., stringsAsFactors = TRUE)Convert strings to factors (pre-4.0 default)
row.namesrow.names = c("r1", "r2")Custom row labels
str()str(df)Inspect structure and types

Why Convert Excel to R DataFrame?

  • Reproducible research — Embed data directly in RMarkdown or Quarto documents as a data.frame() call, ensuring the analysis is self-contained and reproducible.

  • Teaching and examples — Generate sample DataFrames from real Excel data for R tutorials, courses, and Stack Overflow answers.

  • Unit testing — Create test DataFrames from spreadsheet test cases for testthat or tinytest suites.

  • Avoid readxl dependency — Skip the library(readxl) + read_excel() step entirely by embedding the DataFrame inline.

  • Shiny apps — Pre-load reference or lookup data as static DataFrames inside Shiny application code.

  • Data migration — Move business data from Excel to R-based pipelines without intermediate CSV files.

Core Features

  • Custom DataFrame name — Set the variable name for the generated R code (default: df).

  • Strings As Factors toggle — Enable to wrap character columns in factor(); disable to keep them as plain character vectors.

  • Row Names toggle — Enable to include row.names in the output, using the first column or auto-generated row indices.

  • Indentation control — Choose 2 spaces, 4 spaces, or tab indentation for the generated R code.

  • Drag-and-drop upload — Drop any .xlsx, .xls, or .xlsm file onto the upload zone.

  • Built-in table editor — Modify cell values, add or delete rows and columns, transpose, deduplicate, and apply case transformations before conversion.

  • Multi-sheet support — Switch between worksheets in multi-sheet workbooks via the sheet selector dropdown.

  • First Row as Header toggle — Control whether the first row is treated as column headers or regular data.

  • Find & Replace — Bulk-replace cell values with optional regex and case-sensitive matching.

  • Undo / Redo — Full edit history so you can revert mistakes.

  • Copy to clipboard — One-click copy of the generated R code.

  • 100% client-side — Your spreadsheet data never leaves your device. No files are uploaded to any server.

How to Convert Excel to R DataFrame

  1. Upload your file — Drag an .xlsx, .xls, or .xlsm file onto the upload area, or click Click here to choose to browse.

  2. Edit if needed — Use the built-in table editor to modify values, add or remove rows and columns, transpose, deduplicate, or apply case changes.

  3. Set the DataFrame name — Enter a variable name in the DataFrame Name field (e.g., employees, sales_data).

  4. Configure options — Toggle Strings As Factors and Row Names as needed. Select your preferred Indent style.

  5. Click Convert — Press the Convert button. The R data.frame() code appears in the Output Data area.

  6. Copy the result — Click Copy to Clipboard and paste the R code into your script or RMarkdown file.

Output Example

Input spreadsheet (employees.xlsx):

NameDepartmentSalary
AliceEngineering95000
BobMarketing72000
CarolEngineering102000

Generated R code (DataFrame Name: employees, Strings As Factors OFF, 2-space indent):

employees <- data.frame(
   Name = c("Alice", "Bob", "Carol"),
   Department = c("Engineering", "Marketing", "Engineering"),
   Salary = c("95000", "72000", "102000"),
   stringsAsFactors = FALSE
)

With Strings As Factors ON:

employees <- data.frame(
   Name = factor(c("Alice", "Bob", "Carol")),
   Department = factor(c("Engineering", "Marketing", "Engineering")),
   Salary = c("95000", "72000", "102000"),
   stringsAsFactors = FALSE
)

With Row Names ON:

employees <- data.frame(
   Name = c("Alice", "Bob", "Carol"),
   Department = c("Engineering", "Marketing", "Engineering"),
   Salary = c("95000", "72000", "102000"),
   row.names = c("1", "2", "3"),
   stringsAsFactors = FALSE
)

R DataFrame vs Tibble vs Data Table

Aspectdata.frametibble (tidyverse)data.table
PackageBase R (built-in)tibble / dplyrdata.table
Print displayFull tableTruncated, types shownFirst/last rows
Speed (large data)ModerateModerateVery fast
Partial matchingYes (df$Na works)No (strict)No (strict)
Best forGeneral use, teachingTidyverse pipelinesLarge datasets, aggregation

This tool generates base R data.frame() code. To convert to a tibble, wrap the output: tibble::as_tibble(df). For data.table: data.table::as.data.table(df).

R DataFrame Quick Reference

OperationSyntaxResult
Access columndf$Name or df[["Name"]]Vector
Filter rowsdf[df$Salary > 80000, ]Subset DataFrame
Add columndf$Bonus <- df$Salary * 0.1Modified DataFrame
Summary statssummary(df)Min, median, max, etc.
Dimensionsnrow(df) / ncol(df)Row / column count
Column namescolnames(df)Character vector

Frequently Asked Questions

  • What file formats does this tool accept?

    The tool accepts Microsoft Excel files in .xlsx, .xls, and .xlsm formats. LibreOffice and Google Sheets files exported as .xlsx also work.

  • Does the tool upload my Excel file to a server?

    No. All processing happens entirely in your browser using client-side JavaScript. Your file never leaves your device. There are no server uploads, transfers, or storage of any kind.

  • What does the "Strings As Factors" option do?

    When enabled, character columns are wrapped in factor() in the generated R code. This is useful for statistical modeling where categorical variables should be treated as factors. When disabled (default since R 4.0), strings remain as character vectors.

  • What does the "Row Names" option do?

    When enabled, the output includes a row.names parameter in the data.frame() call, using sequential row indices. This is useful if you plan to reference rows by name rather than numeric index.

  • Can I change the DataFrame variable name?

    Yes. Enter any valid R variable name in the DataFrame Name field (e.g., sales_data, my_df, results). The default name is df.

  • Can I edit the data before converting?

    Yes. After uploading, a full table editor appears. You can modify individual cells, add or delete rows and columns, transpose, deduplicate, apply case transformations (UPPERCASE, lowercase, Capitalize), and perform find-and-replace operations.

  • Does the tool support multi-sheet Excel files?

    Yes. When your workbook contains multiple sheets, a dropdown selector appears in the editor header. Choose the sheet you want to convert.

  • Is there a file size limit?

    Since processing is entirely client-side, the limit depends on your browser's memory. Most modern browsers handle workbooks with tens of thousands of rows without issues. For very large datasets, consider using R's readxl package directly.

Featured Tools

Featured tools that you might find useful.

Popular Tools

List of popular tools that users love and frequently use.

New Tools

The latest tools added to our collection, designed for you.

Topics

The tools grouped by topics to quickly find what you need.
Free online JSON to YAML converter. Paste JSON and get clean YAML output instantly. Supports block and flow array styles, configurable indent. No upload, 100% private.

JSON To YAML

Free online JSON to YAML converter. Paste JSON and get clean YAML output instantly. Supports block and flow array styles, configurable indent. No upload, 100% private.
Free online JSON to XML converter. Paste JSON and generate valid XML with custom root/row elements, CDATA, XML declaration, attribute mode, and encoding options. No upload, 100% private.

JSON To XML

Free online JSON to XML converter. Paste JSON and generate valid XML with custom root/row elements, CDATA, XML declaration, attribute mode, and encoding options. No upload, 100% private.
Free online Markdown to Excel converter. Paste or upload Markdown tables, edit data in a spreadsheet editor, and download as .xlsx — all in your browser, no file upload required.

Markdown To Excel

Free online Markdown to Excel converter. Paste or upload Markdown tables, edit data in a spreadsheet editor, and download as .xlsx — all in your browser, no file upload required.
Free online JSON to CSV converter. Paste or upload JSON data and get formatted CSV instantly — no upload, 100% private. Supports custom delimiters, UTF-8 BOM, and JSON code editor.

JSON To CSV

Free online JSON to CSV converter. Paste or upload JSON data and get formatted CSV instantly — no upload, 100% private. Supports custom delimiters, UTF-8 BOM, and JSON code editor.