On Apr 25, 2009, at 2:46 AM, Santosh wrote:

Dear R-sians
Quick question...

1) From a flat (data) file with 100+ columns, how do I read specific columns instead of reading the entire dataset? I am trying to avoid reading the
entire file followed by "subsetting".

If you are asking about how to read from an external file, then read material on files that meet you particular definition of a "flat file" in the Import/Export Manual:

cran.r-project.org/doc/manuals/R-data.pdf



2) is the a way to a call a column of dataframe through a variable.. e.g.

e,g
var="date"

something like...
data${var} <- "02 Oct 2009?

I cannot tell if you were thinking of enclosing the letters "var" in curly braces or if that it your way of indicating an abstract variable name. Curly braces are not appropriate for indexing. This really suggest that you need to begin by using an introductory text. Here are links to supporting documentation:

http://cran.r-project.org/manuals.html
http://cran.r-project.org/other-docs.html

Here's an example, but submitting a series of basic questions to the list without "doing your homework" is not going to be supported.

dta <- data.frame(a=1:5, b= paste("0",1:5," Oct 2009", sep=""), stringsAsFactors=FALSE)
 dta$b[2] <- "06 Oct 2009"
 dta

  a           b
1 1 01 Oct 2009
2 2 06 Oct 2009
3 3 03 Oct 2009
4 4 04 Oct 2009
5 5 05 Oct 2009

# Equivalent assignments to the second item of the second row:
 dta[2, "b"] <- "06 Oct 2009"
 dta[2, 2] <- "06 Oct 2009"

--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to