Re: [R] renaming objects

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue, 04 Mar 2008 10:28:45 -0500

You might be able to just read in that single column rather than read the file in chunks by using colClasses arg of read.table with "NULL" for all columns except the one you want.

The sqldf package is another way -- see example 6 on the home page. You specify what you want using SQL: http://sqldf.googlecode.com

readTableIndex in R.utils has the purpose of only reading a single column.
http://finzi.psych.upenn.edu/R/library/R.utils/html/readTableIndex.html

On Tue, Mar 4, 2008 at 9:52 AM, <Giles.Crane_at_doh.state.nj.us> wrote:
>
> Thank you all for your enlightening replies.
>
> Hadley mentioned first that a mere assignment in R does not double storage.
> Hence once solution is:
> y <- x
> rm(x)
>
> Gabor gave a deeper solution which permits assigning a second name:
> makeActive Binding("y",function() x, .GlobalEnv)
>
> The reason for my question was to form a function:
> --read, in chunks, a large file which does not fit in memory
> --abstract one variable, which does fit in memory.
> -- save that variable in .Rdata format under a chosen name.
>
> DIAG1 = getvar("bigfile.txt", startchar, endchar)
> save(DIAG1, file = "DIAG1.Rdata")
>
> I am now testing this approach.
> Cordially,
> Giles
>
> Giles Crane, M.Phil., MPH
> Research Scientist & Statistician
> Tel 609 292-8012, -5666
> Fax 609 292-9288
> giles.crane_at_doh.state.nj.us
>
> __________________
>
>
> This does not really answer your question but the following
> lets you refer to an object by a second name although the object
> still has its original name as well.
>
> > a <- 3
> > makeActiveBinding("b", function() a, .GlobalEnv)
> NULL
> > b
> [1] 3
> > a <- 4
> > b
> [1] 4
>
>
> On Mon, Mar 3, 2008 at 4:20 PM, <Giles.Crane_at_doh.state.nj.us> wrote:
> >
> > Is there a way to rename R objects?
> > I am looking for a way to rename objects
> > without making new objects.
> >
> > #For example:
> > x = c(1:40)
> > # I wish to use a function to rename x, already created, to y, perhaps by
> > obj.rename(x,y)
> > # or
> > obj.rename("x","y")
> >
> > There are numerous examples of renaming
> > variables (columns) in dataframes, but I have
> > found no methods for renaming objects.
> > The functionassign() does not do this.
> >
> > Thank you for any help you can give.
> > Cordially
> >
> > Giles Crane, M.Phil., MPH
> > Research Scientist & Statistician
> > New Jersey Department of Health & Senior Services
> > Tel 609 292-8012, -5666
> > Fax 609 292-9288
> > giles.crane_at_doh.state.nj.us
> >
> > ______________________________________________
>
> > R-help_at_r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 04 Mar 2008 - 15:35:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 04 Mar 2008 - 16:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive