Re: [R] Help - Importing data from txt and xlsx files

2012-04-16 Thread AMFTom
Hi all, it turns out I had left absent data as a blank space instead of
filling it with a zero. Now I am able to import data. 

Thanks for all your help, I'm sure I will be calling on your expertise in
future.

Tom

--
View this message in context: 
http://r.789695.n4.nabble.com/Help-Importing-data-from-txt-and-xlsx-files-tp4554622p4561522.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] Help - Importing data from txt and xlsx files

2012-04-13 Thread steven mosher
read your file with readLines(). copy the first few lines for me to read
here

test <- readLines(yur filename)
test[1:5]

post the result. we can figure it out from there
On Apr 13, 2012 11:46 AM, "AMFTom"  wrote:

> Dear Thierry,
>
> Thanks for your help. Now though, I try to import data from a txt file, and
> it says either
>
> > mydataframe <- read.table("Lv2.8.txt")
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
> :
>  line 3 did not have 15 elements
>
> or
>
> > mydataframe <- read.table("Lv2.8.txt", header = TRUE)
> Error in read.table("Lv2.8.txt", header = TRUE) :
>  more columns than column names
>
> even though I seem to have put a column name into the txt file for each
> column. Any ideas?
>
> Thanks again!
>
> Tom
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Help-Importing-data-from-txt-and-xlsx-files-tp4554622p4555001.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> 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.
>

[[alternative HTML version deleted]]

__
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.


Re: [R] Help - Importing data from txt and xlsx files

2012-04-13 Thread MacQueen, Don
Have you correctly set the value of the 'sep' argument to read.table?

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 4/13/12 7:28 AM, "AMFTom"  wrote:

>Dear Thierry, 
>
>Thanks for your help. Now though, I try to import data from a txt file,
>and
>it says either 
>
>> mydataframe <- read.table("Lv2.8.txt")
>Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>na.strings, 
>: 
>  line 3 did not have 15 elements
>
>or
>
>> mydataframe <- read.table("Lv2.8.txt", header = TRUE)
>Error in read.table("Lv2.8.txt", header = TRUE) :
>  more columns than column names
>
>even though I seem to have put a column name into the txt file for each
>column. Any ideas?
>
>Thanks again!
>
>Tom
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/Help-Importing-data-from-txt-and-xlsx-files-
>tp4554622p4555001.html
>Sent from the R help mailing list archive at Nabble.com.
>
>__
>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.

__
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.


Re: [R] Help - Importing data from txt and xlsx files

2012-04-13 Thread jim holtman
This is a case where you need to provide a sample of your data.  Most
likely it is not in a format that read.table can read with the parameters
you have given it.  It may have different field separators, it might have
"#" in data fields, you might have unbalanced quotes, etc.  So it is a
problem in your data and the way you are trying to read it.  You have to
include  commented, minimal, self-contained, reproducible code.

On Fri, Apr 13, 2012 at 10:28 AM, AMFTom  wrote:

> Dear Thierry,
>
> Thanks for your help. Now though, I try to import data from a txt file, and
> it says either
>
> > mydataframe <- read.table("Lv2.8.txt")
> Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,
> :
>  line 3 did not have 15 elements
>
> or
>
> > mydataframe <- read.table("Lv2.8.txt", header = TRUE)
> Error in read.table("Lv2.8.txt", header = TRUE) :
>  more columns than column names
>
> even though I seem to have put a column name into the txt file for each
> column. Any ideas?
>
> Thanks again!
>
> Tom
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Help-Importing-data-from-txt-and-xlsx-files-tp4554622p4555001.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> 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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

[[alternative HTML version deleted]]

__
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.


Re: [R] Help - Importing data from txt and xlsx files

2012-04-13 Thread AMFTom
Dear Thierry, 

Thanks for your help. Now though, I try to import data from a txt file, and
it says either 

> mydataframe <- read.table("Lv2.8.txt")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, 
: 
  line 3 did not have 15 elements

or

> mydataframe <- read.table("Lv2.8.txt", header = TRUE)
Error in read.table("Lv2.8.txt", header = TRUE) : 
  more columns than column names

even though I seem to have put a column name into the txt file for each
column. Any ideas?

Thanks again!

Tom

--
View this message in context: 
http://r.789695.n4.nabble.com/Help-Importing-data-from-txt-and-xlsx-files-tp4554622p4555001.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] Help - Importing data from txt and xlsx files

2012-04-13 Thread ONKELINX, Thierry
Dear Tom,

R does not searches your entire file system for the file. It only looks in the 
working directory. Have a look at ?setwd() and ?getwd()

So you will need to set the working directory, use a relative path to the file 
or use and absolute path to the file.

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure 
that a reasonable answer can be extracted from a given body of data.
~ John Tukey


-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
AMFTom
Verzonden: vrijdag 13 april 2012 14:29
Aan: r-help@r-project.org
Onderwerp: [R] Help - Importing data from txt and xlsx files

Hi all,

I have just started to use R for my PhD project and have no previous
experience in programming. I am having trouble importing data to R.   This
is the output:

> mydata <- read.table("Lv2.8.txt")
Error in file(file, "rt") : cannot open the connection In addition: Warning 
message:
In file(file, "rt") :
  cannot open file 'Lv2.8.txt': No such file or directory

I know there is a file on my computer with this name though... What am I doing 
wrong?

Thanks in advance!

Tom

--
View this message in context: 
http://r.789695.n4.nabble.com/Help-Importing-data-from-txt-and-xlsx-files-tp4554622p4554622.html
Sent from the R help mailing list archive at Nabble.com.

__
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.
* * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * *
Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en 
binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is 
door een geldig ondertekend document.
The views expressed in this message and any annex are purely those of the 
writer and may not be regarded as stating an official position of INBO, as long 
as the message is not confirmed by a duly signed document.

__
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.


[R] Help - Importing data from txt and xlsx files

2012-04-13 Thread AMFTom
Hi all, 

I have just started to use R for my PhD project and have no previous
experience in programming. I am having trouble importing data to R.   This
is the output:

> mydata <- read.table("Lv2.8.txt")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'Lv2.8.txt': No such file or directory

I know there is a file on my computer with this name though... What am I
doing wrong?

Thanks in advance!

Tom

--
View this message in context: 
http://r.789695.n4.nabble.com/Help-Importing-data-from-txt-and-xlsx-files-tp4554622p4554622.html
Sent from the R help mailing list archive at Nabble.com.

__
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.