Quantcast

import text file into R

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

import text file into R

dhanush
can anyone tell me how to import a text file in R? the text file I want to import is a large file, about 800MB in size. Thanks in advance.

I tried using the following

data<-read.table("file",header=T,sep="\t")

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: import text file into R

Erik Iverson-3


dhanush wrote:
> can anyone tell me how to import a text file in R? the text file I want to
> import is a large file, about 800MB in size. Thanks in advance.
>
> I tried using the following
>
> data<-read.table("file",header=T,sep="\t")
>
>

And what happened??

Your specification is incomplete, as we don't know what your text file
looks like.  Is it CSV, etc.?  How much memory does your system have?

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: import text file into R

Sarah Goslee
In reply to this post by dhanush
That sounds like a good plan.

What went wrong?

You're more likely to get an answer if you tell us what your
problem/question actually is.

Sarah

On Thu, Jun 3, 2010 at 7:32 AM, dhanush <[hidden email]> wrote:
>
> can anyone tell me how to import a text file in R? the text file I want to
> import is a large file, about 800MB in size. Thanks in advance.
>
> I tried using the following
>
> data<-read.table("file",header=T,sep="\t")
>



--
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: import text file into R

John Kane-2
In reply to this post by dhanush
What does the text look like?  

--- On Thu, 6/3/10, dhanush <[hidden email]> wrote:

> From: dhanush <[hidden email]>
> Subject: [R] import text file into R
> To: [hidden email]
> Received: Thursday, June 3, 2010, 7:32 AM
>
> can anyone tell me how to import a text file in R? the text
> file I want to
> import is a large file, about 800MB in size. Thanks in
> advance.
>
> I tried using the following
>
> data<-read.table("file",header=T,sep="\t")
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/import-text-file-into-R-tp2241525p2241525.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email]
> 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.
>

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: import text file into R

Bird James-R31391
In reply to this post by dhanush
You may want to try read.delim if you are having troubles with
read.table.

Jim

-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
On Behalf Of dhanush
Sent: Thursday, June 03, 2010 4:33 AM
To: [hidden email]
Subject: [R] import text file into R


can anyone tell me how to import a text file in R? the text file I want
to import is a large file, about 800MB in size. Thanks in advance.

I tried using the following

data<-read.table("file",header=T,sep="\t")


--
View this message in context:
http://r.789695.n4.nabble.com/import-text-file-into-R-tp2241525p2241525.
html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: import text file into R

dhanush
In reply to this post by Sarah Goslee
Sorry guys....

It is a tab delimited text file which I just exported from SAS. I want to
import this in R. Pl let me know what is the delimiter I should use and R
syntax.

Thanks



On Thu, Jun 3, 2010 at 9:20 PM, Sarah Goslee <[hidden email]> wrote:

> That sounds like a good plan.
>
> What went wrong?
>
> You're more likely to get an answer if you tell us what your
> problem/question actually is.
>
> Sarah
>
> On Thu, Jun 3, 2010 at 7:32 AM, dhanush <[hidden email]> wrote:
> >
> > can anyone tell me how to import a text file in R? the text file I want
> to
> > import is a large file, about 800MB in size. Thanks in advance.
> >
> > I tried using the following
> >
> > data<-read.table("file",header=T,sep="\t")
> >
>
>
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>


--
Best
Dhanasekaran

"Without trust, words become the hollow sound of a wooden gong. With trust,
words become life itself.”

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: import text file into R

Erik Iverson-3
Dhanasekaran wrote:
> Sorry guys....
>
> It is a tab delimited text file which I just exported from SAS. I want to
> import this in R. Pl let me know what is the delimiter I should use and R
> syntax.
>
You still don't say the error you're getting when you try your read.table command.

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: import text file into R

dhanush
please look at the error..

> LosA<-read.table("E:\\Temporary
Tasks\\rub\\Los_R\\ca_los.txt",header=T,sep="\t")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
:
  line 11022 did not have 87 elements

ca_los.txt is my tab delimited large text file which contains about 16lakhs
observations.

thank you

On Fri, Jun 4, 2010 at 9:44 AM, Erik Iverson <[hidden email]> wrote:

> Dhanasekaran wrote:
>
>> Sorry guys....
>>
>> It is a tab delimited text file which I just exported from SAS. I want to
>> import this in R. Pl let me know what is the delimiter I should use and R
>> syntax.
>>
>> You still don't say the error you're getting when you try your read.table
> command.
>


--
Best
Dhanasekaran

"Without trust, words become the hollow sound of a wooden gong. With trust,
words become life itself.”

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: import text file into R

Peter Ehlers
On 2010-06-03 22:51, Dhanasekaran wrote:
> please look at the error..
>
>> LosA<-read.table("E:\\Temporary
> Tasks\\rub\\Los_R\\ca_los.txt",header=T,sep="\t")
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
> :
>    line 11022 did not have 87 elements

That error message seems pretty explicit to me: you have a problem with
line 11022. Did you check it with a text editor?

It's always a good idea to run count.fields() on the file, as
recommended on the help page for read.table.

If you're trying to import SAS data, you might want to check out the
'foreign' package.

Note also that read.delim is convenient for tab-delimited files.

  -Peter Ehlers

>
> ca_los.txt is my tab delimited large text file which contains about 16lakhs
> observations.
>
> thank you
>
> On Fri, Jun 4, 2010 at 9:44 AM, Erik Iverson<[hidden email]>  wrote:
>
>> Dhanasekaran wrote:
>>
>>> Sorry guys....
>>>
>>> It is a tab delimited text file which I just exported from SAS. I want to
>>> import this in R. Pl let me know what is the delimiter I should use and R
>>> syntax.
>>>
>>> You still don't say the error you're getting when you try your read.table
>> command.
>>
>

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: import text file into R

GlenB
In reply to this post by dhanush
On Fri, Jun 4, 2010 at 2:51 PM, Dhanasekaran <[hidden email]> wrote:
>
> ca_los.txt is my tab delimited large text file which contains about 16lakhs
> observations.

Most readers of this list probably won't know that a 'lakh' is a
hundred thousand. "16lakhs" means 1.6 million.

Glen

______________________________________________
[hidden email] 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: import text file into R

Jim Lemon
In reply to this post by dhanush
On 06/03/2010 09:32 PM, dhanush wrote:
>
> can anyone tell me how to import a text file in R? the text file I want to
> import is a large file, about 800MB in size. Thanks in advance.
>
> I tried using the following
>
> data<-read.table("file",header=T,sep="\t")
>
>
Hi dhanush,
If the problem is with read.table, maybe:

# "whatlist" is a list of data types defining what
# is in each line of data - see the help page
data<-scan("file",skip=1,sep="\t",what=whatlist)

will get it in for you.

Jim

______________________________________________
[hidden email] 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.
Loading...