Questions tagged [dput]

`dput` is a R function that "writes an ASCII text representation of an R object to a file or connection, or uses one to recreate the object."

16 questions
6
votes
2 answers

How to put the output of `dput` in one line in R?

How to make the output of dput be displayed in one line in R? How to copy to the clipboard the string obtained with dput?
Julien
  • 1,613
  • 1
  • 10
  • 26
3
votes
1 answer

dput(as.Date(df$date)) shows up as number

I have a dataframe df with date column date, df$date: [1] "2013-01-31" "2013-02-28" "2013-03-31" "2013-04-30" "2013-05-31" "2013-06-30", etc. When I dput(as.Date(df$date)), it shows up as numbers: structure(c(15736, 15764, 15795, 15825, 15856, ...),…
ah bon
  • 9,293
  • 12
  • 65
  • 148
2
votes
3 answers

How to dput a list with an environment?

I am working on a function to basically grab arguments from inside a function. It works as expected, but when I try and transport the result, I have an envir in the list. It outputs fine via dput, but I CANNOT transport it. > test(iris) list(envir…
mshaffer
  • 959
  • 1
  • 9
  • 19
2
votes
1 answer

R: Understanding dput() output

I have recently learnt the command dput() thanks to SO users. The issue now is that I don't understand the output. I am wanting to understand the data for my variable edu.deg.level. I can see there are 10 values in a list format but I do not…
1
vote
0 answers

Storing dput fails

I am trying to get the dput from one of my data frames. Something that I do often, without any issues. However for the dput below, I cannot seem to store it back in an object, it keeps asking for more characters +. I have checked in visual studio…
Tom
  • 2,173
  • 1
  • 17
  • 44
1
vote
1 answer

How to copy all outputs when all outputs cannot be shown due to size in R console?

I have a data, named Grain, and this data is enormous (until 7849 rows). After upload the excel file in R, I'd like to convert this data as code. So I used dput(Grain). Grain<- read_excel("Grain.xlsx", sheet=1) dput(Grain) However, due to enormous…
Jin.w.Kim
  • 599
  • 1
  • 4
  • 15
1
vote
2 answers

Struggling to unnest tibble (dput, code, and error included) in r

I'm trying to unnest a species count tibble so I can turn it into a dataframe. The last four columns are species counts and are currently in 'list' form (seems nested?). I'd like to have each column and row for these last four species columns to…
1
vote
2 answers

How to assign the output of dput() into an object or insert the double quote and then comma after every words?

I have a data frame like that: x <- data.table(c('ACCN-NJ-A55O-01A-11D-A25L-08','ACCN-NJ-A55O-11D-11D-A25L-08', 'ACCN-05-4249-01A-01D-1105-08', 'ACCN-S2-AA1A-15C-12D-A397-08')) Now I want to put every word inside the double quote and then place a…
SUMIT
  • 563
  • 4
  • 12
1
vote
1 answer

reproduce R function call with text

in an application I use RODBC to access a database. Specifically I call a function like this: sqlQuery(conn, qry), where qry is a string, and conn is a RODBC connection object. Is it possible to paste this into a file in such a way that if I copy…
Frank
  • 952
  • 1
  • 9
  • 23
1
vote
1 answer

Alternative to dput(), cat() to save vector to global env

I have several cases where I am trying to save a vector of elements to my global environment to be able to use for querying a database or other subsequent analyses. As an example, I have a dataframe below, but in reality my data consists of…
kholden
  • 15
  • 3
1
vote
0 answers

Paste into RStudio script pane without auto formatting without turning off auto indent?

Is there any way to paste into the RStudio script pane without having the code auto indent itself, AND without turning off the auto indent feature? Example The output of dput(iris) looks organised in the console, but spreads very wide when pasted…
stevec
  • 41,291
  • 27
  • 223
  • 311
0
votes
1 answer

Using dput to save a tidymodels model object

I'm doing an ML course and I'm trying to save a trained model from the course's workspace so that I can reproduce everything on my own computer. So far I've just used dput() on a variable and it has worked perfectly. Now I'm trying to do the same on…
Economist
  • 173
  • 8
0
votes
1 answer

Using large dput output

I have a dataframe I want to share using dput. I want all of it and not just some of it. When I use dput(), the result is so big that it does not all fit in the Rstudio Console. I tried assigning the dput to a variable and saving that variable as a…
0
votes
1 answer

Dput function in R no longer working for me, give a pointer

For some days now I realized anytime I post a problem here people are unable to help and it kept me wondering what was wrong until I realized my dput function output added a pointer (problems = ) in my output making it…
0
votes
2 answers

Cannot manage to remove $ pattern in dataframe

I have a column in my dataset which looks like that (not the exact numbers) : Cost 50 75 $ 1,789,456 $ 1,200,923 690.3490200 The type of this column is character. In order to do my computations i want to remove the "," the "$"…
katdataecon
  • 185
  • 8
1
2