Re: [R] Importing multiple text files with lapply.

2011-01-18 Thread Ivan Calandra
Hi, The solution with lapply() should work; it seems that the problem was with the file name. mylist <- lapply(a, read.table, header = TRUE, sep = '\n') What is "a"? Is it an object containing a path+file name? Maybe not. Second, I'm not sure sep should be "\n". I think "," would be better. Ju

Re: [R] Importing multiple text files with lapply.

2011-01-17 Thread Simon Kiss
Hi Jim, Ultimately, I'm going to want to count the frequency of dates by particular time periods (months, quarters, years) for each state and then plot the data. I know there are commands in ggplots that will do that, so I'm not too worried about that, but I was stuck on getting 50 text files (

Re: [R] Importing multiple text files with lapply.

2011-01-17 Thread Simon Kiss
readLines worked great Jim, thanks! Simon Kiss On 2011-01-17, at 7:44 PM, jim holtman wrote: > It sounds like you want to use 'readLines' and not 'read.table' > >> x <- readLines(textConnection("January 11, 2009 > + January 11, 2009 > + October 19, 2008 > + October 13, 2008 > + August 16, 2008 >

Re: [R] Importing multiple text files with lapply.

2011-01-17 Thread jim holtman
It should work just fine. If you want to send me a small subset of the your data and the script you are using, I can see what it is doing and suggest a solution. I use that approach all the time to read in data. On Mon, Jan 17, 2011 at 8:07 PM, Simon Kiss wrote: > Hi Jim, > Ultimately, I'm goin

Re: [R] Importing multiple text files with lapply.

2011-01-17 Thread jim holtman
It sounds like you want to use 'readLines' and not 'read.table' > x <- readLines(textConnection("January 11, 2009 + January 11, 2009 + October 19, 2008 + October 13, 2008 + August 16, 2008 + June 19, 2008 + April 19, 2008 + April 16, 2008 + February 9, 2008 + September 2, 2007")) > closeAllConnect

Re: [R] Importing multiple text files with lapply.

2011-01-17 Thread Simon Kiss
Dear jim, Yes, it's true, the data are separated onto new lines as follows: January 11, 2009 January 11, 2009 October 19, 2008 October 13, 2008 August 16, 2008 June 19, 2008 April 19, 2008 April 16, 2008 February 9, 2008 September 2, 2007 I tried your attempt and it didn't work either; it

Re: [R] Importing multiple text files with lapply.

2011-01-17 Thread jim holtman
try: mylist <- lapply(a, read.table, header = TRUE, sep = '\n') also is the separator really '\n' meaning a new-line? What exactly does the data look like? On Mon, Jan 17, 2011 at 11:47 AM, Simon Kiss wrote: > Hello, > I'm trying to read in 50 text filess with dates as content to create a list

[R] Importing multiple text files with lapply.

2011-01-17 Thread Simon Kiss
Hello, I'm trying to read in 50 text filess with dates as content to create a list of tables. a is the list of filenames that need to be read in. The following command returns the following error mylist<-lapply(a, read.table(header=TRUE, sep="\n")) Error in read.table(header = TRUE, sep = "\n