[R] 1. What function to use to read all the files in a directory to a vector in R code? 2. What function to use to coerce character string into numeric?

John McKown john.archie.mckown at gmail.com
Mon Nov 10 22:15:29 CET 2014


On Mon, Nov 10, 2014 at 7:12 AM, Aditya Singh <aps6dl at yahoo.com> wrote:

> Hi,
> I have 2 queries:
> 1. What function to use to read all the files in a directory to a vector
> in R code?
> 2. What function to use to coerce character string into numeric?
> As a help to others, I figured out to use setwd("C:/....") to set working
> directory!
> Aditya
>

​First, please don't post in HTML. It is contrary to forum policy. Thanks.

Answer 1: you can get a list of the names of all the files using the
list.files() function. Do a ?list.files for more information.

Answer 2: If I understand your question correctly, then I'd use
as.numeric() .

Suggestion 1: Get & read a good book on R programming. These were very
basic questions. I'd strongly suggest "Advanced R" by Hadley Wickham. You
can order if Amazon.com, or read it (for free!) here:
http://adv-r.had.co.nz/
​

​Another good one is "The Art of R Programming" by Norman Matloff. This
later one is what I used, but that's mainly because Hadley's book hadn't
been written (or maybe published) when I was first learning R. ​

​Suggestion 2: If you haven't already, I would strongly recommend getting &
installing RStudio. It is free (as in beer, which is a curious phrase
because beer isn't usually free). http://www.rstudio.com ​

-- 
The temperature of the aqueous content of an unremittingly ogled
culinary vessel will not achieve 100 degrees on the Celsius scale.

Maranatha! <><
John McKown

	[[alternative HTML version deleted]]



More information about the R-help mailing list