Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7540315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:36:45+00:00 2026-05-30T07:36:45+00:00

I am looking for a pair of R commands that dump a dataframe to

  • 0

I am looking for a pair of R commands that dump a dataframe to the disk and that are able to recreate the same dataframe from the dump.

I suppose write.table is the de facto for export/import but it fails in the following example since it doesn’t preserve the type of the columns:

df = data.frame('foo' = 'bar')
df$foo = as.character(df$foo)

typeof(df$foo)
# = "character"

write.table(df,'~/df.rdata')
df2 = read.table('~/df.rdata')

typeof(df2$foo)
# = "integer"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:36:46+00:00Added an answer on May 30, 2026 at 7:36 am

    As @TylerRinker said, dput and save are probably the most fitting.

    …but save and load are sometimes a bit inconvenient in that you give save the names of the objects to save, and then load loads the objects back into those names.

    An alternative is saveRDS and readRDS (yes, the naming is a bit weird!). They are a bit more low-level and saves a single object:

    df <- data.frame(foo = 'bar', stringsAsFactors=FALSE)
    saveRDS(df, file='foo.rds')
    df2 <- readRDS('foo.rds')
    identical(df, df2)
    

    Also note the use of stringsAsFactors=FALSE when creating the data frame…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking to write a pair of utilities that read in a newline separated
I'm looking for a key/value pair object that I can include in a web
I am looking for an open source C implementation of a hash table that
I am looking for an app that does iCloud key value pair syncing? Can
I'm looking to write a function in python that accepts a dictionary and a
I'm looking to persist and retrieve a large amount of key-value pair(s) type data
Looking around the web, I've seen this simple pattern that implements a (thread-safe) singleton
Looking for an example that: Launches an EXE Waits for the EXE to finish.
Looking for C# class which wraps calls to do the following: read and write
Looking for a Linux application (or Firefox extension) that will allow me to scrape

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.