Re: [R] Erase content of dataframe in a single stroke

2018-09-27 Thread peter dalgaard
half Of Jim Lemon >> Sent: Thursday, September 27, 2018 10:12 AM >> To: Luigi Marongiu ; r-help mailing list > project.org> >> Subject: Re: [R] Erase content of dataframe in a single stroke >> >> Ah, yes, try 'as.data.frame" on it. >> >> J

Re: [R] Erase content of dataframe in a single stroke

2018-09-27 Thread Dénes Tóth
Petr -Original Message- From: R-help On Behalf Of Jim Lemon Sent: Thursday, September 27, 2018 10:12 AM To: Luigi Marongiu ; r-help mailing list project.org> Subject: Re: [R] Erase content of dataframe in a single stroke Ah, yes, try 'as.data.frame" on it. Jim On Thu, Sep 27, 2

Re: [R] Erase content of dataframe in a single stroke

2018-09-27 Thread Jan van der Laan
giu ; r-help mailing list Subject: Re: [R] Erase content of dataframe in a single stroke Ah, yes, try 'as.data.frame" on it. Jim On Thu, Sep 27, 2018 at 6:00 PM Luigi Marongiu wrote: Thank you Jim, this requires the definition of an ad hoc function; strange that R does not have a function

Re: [R] Erase content of dataframe in a single stroke

2018-09-27 Thread Jim Lemon
You're right. Apparently one can form a list with NULL elements but not a data frame. I just saw Petr's answer, which seems to do the trick. Jim On Thu, Sep 27, 2018 at 6:19 PM Luigi Marongiu wrote: > > I am not sure if I got it right; Now I get: > > > toNull<-function(x) return(NULL) > >

Re: [R] Erase content of dataframe in a single stroke

2018-09-27 Thread PIKAL Petr
: num Cheers Petr > -Original Message- > From: R-help On Behalf Of Jim Lemon > Sent: Thursday, September 27, 2018 10:12 AM > To: Luigi Marongiu ; r-help mailing list project.org> > Subject: Re: [R] Erase content of dataframe in a single stroke > > Ah, yes, try

Re: [R] Erase content of dataframe in a single stroke

2018-09-27 Thread Jim Lemon
Ah, yes, try 'as.data.frame" on it. Jim On Thu, Sep 27, 2018 at 6:00 PM Luigi Marongiu wrote: > > Thank you Jim, > this requires the definition of an ad hoc function; strange that R > does not have a function for this purpose... > Anyway, it works but it changes the structure of the data. By >

Re: [R] Erase content of dataframe in a single stroke

2018-09-27 Thread Jim Lemon
Hi Luigi, Maybe this: testdf<-data.frame(A=1,B=2,C=3) > testdf A B C 1 1 2 3 toNull<-function(x) return(NULL) testdf<-sapply(testdf,toNull) Jim On Thu, Sep 27, 2018 at 5:29 PM Luigi Marongiu wrote: > > Dear all, > I would like to erase the content of a dataframe -- but not the > dataframe

[R] Erase content of dataframe in a single stroke

2018-09-27 Thread Luigi Marongiu
Dear all, I would like to erase the content of a dataframe -- but not the dataframe itself -- in a simple and fast way. At the moment I do that by re-defining the dataframe itself in this way: > df <- data.frame(A = numeric(), + B = numeric(), + C =