Skip to content
Prev 178305 / 398506 Next

Reading files

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

            
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
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"