[R] re ad.table() and setwd() in unix batch mode

2009-06-19 Thread tbigdeli

I continually receive the error

Error in file(file, r) : cannot open the connection, when running in batch
mode, but not when inputing directly into R. 

Any ideas?

Thanks!

TB
-- 
View this message in context: 
http://www.nabble.com/read.table%28%29-and-setwd%28%29-in-unix-batch-mode-tp24107008p24107008.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] re ad.table() and setwd() in unix batch mode

2009-06-19 Thread Uwe Ligges



tbigdeli wrote:

I continually receive the error

Error in file(file, r) : cannot open the connection, when running in batch
mode, but not when inputing directly into R. 


Have you given the full path name?
If not, do you start both R instances from the same working directory?

Otherwise, do you have the same credentials in both cases?

Uwe Ligges







Any ideas?

Thanks!

TB


__
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] re ad.table() and setwd() in unix batch mode

2009-06-19 Thread tbigdeli

My apologies for being overly brief before..

I submit an R script to batch mode as follows:

a list of files (object = 'files').  In each iteration, the next file is
read, alterations made, working directory changed, and output file written
out.  R will take an inordinate amount of time processing the first file,
after which no files seem to be read-in.  For batch mode, are my paths
inappropriate?  Thanks!

setwd(/home/bigdelitb/chr20/merlin/sim/d5/ped)
files-read.table(d5.rf.list,stringsAsFactors=FALSE)

for(i in 1:length(files$V1)){
setwd(/home/bigdelitb/chr20/merlin/sim/d5/ped)
count - 1
name-files$V1[i]
ped - read.table(name,header=FALSE,stringsAsFactors=FALSE)
...
...
setwd(/home/bigdelitb/chr20/merlin/sim/d5/ped/pdt/)
write.table(ped,name,quote=FALSE,..)
}

Uwe Ligges-3 wrote:
 
 
 
 tbigdeli wrote:
 I continually receive the error
 
 Error in file(file, r) : cannot open the connection, when running in
 batch
 mode, but not when inputing directly into R. 
 
 Have you given the full path name?
 If not, do you start both R instances from the same working directory?
 
 Otherwise, do you have the same credentials in both cases?
 
 Uwe Ligges
 
 
 
 
 
 
 Any ideas?
 
 Thanks!
 
 TB
 
 __
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/read.table%28%29-and-setwd%28%29-in-unix-batch-mode-tp24107008p24114888.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] re ad.table() and setwd() in unix batch mode

2009-06-19 Thread Uwe Ligges



tbigdeli wrote:

My apologies for being overly brief before..

I submit an R script to batch mode as follows:

a list of files (object = 'files').  In each iteration, the next file is
read, alterations made, working directory changed, and output file written
out.  R will take an inordinate amount of time processing the first file,
after which no files seem to be read-in.  For batch mode, are my paths
inappropriate?  Thanks!

setwd(/home/bigdelitb/chr20/merlin/sim/d5/ped)
files-read.table(d5.rf.list,stringsAsFactors=FALSE)

for(i in 1:length(files$V1)){
setwd(/home/bigdelitb/chr20/merlin/sim/d5/ped)
count - 1
name-files$V1[i]
ped - read.table(name,header=FALSE,stringsAsFactors=FALSE)
...
...
setwd(/home/bigdelitb/chr20/merlin/sim/d5/ped/pdt/)
write.table(ped,name,quote=FALSE,..)
}




1. This should do the same for interactive and batch mode given the 
relevant things are not hidden in 

2. You are running both inteactive and batch under the same user?
3. Why do you change working directories all the time, you could give 
full path names instead.
4.  1:length(files$V1) is dangerous in loops (if length becomes 0), 
hence use  seq_along(files$V1)


Uwe Ligges






Uwe Ligges-3 wrote:



tbigdeli wrote:

I continually receive the error

Error in file(file, r) : cannot open the connection, when running in
batch
mode, but not when inputing directly into R. 

Have you given the full path name?
If not, do you start both R instances from the same working directory?

Otherwise, do you have the same credentials in both cases?

Uwe Ligges






Any ideas?

Thanks!

TB

__
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] re ad.table, row.names arg

2009-06-05 Thread Adrian Dusa



Markus Loecher-4 wrote:
 
 Dear R users,
 I had somehow expected that read.table() would treat the column specified
 by
 the row.names argument as of class character. That seems to be the only
 sensible class allowed for a column containing row names. However, that
 does
 not seem to be the case, as the following example shows:
 
   x - cbind.data.frame(ID = c(010007787048271871, 1007109516820319,
 10094843652996959, 010145176274075487), X1 = 1:4, X2 = 4:1)
 [...snip...]
 

As a better alternative, why not move directly the first column in the
rownames?

rownames(x) - x$ID
write.table(x[, -1], tmp.txt)
y - read.table(tmp.txt, header=T)
y
   X1 X2
010007787048271871  1  4
10071095168203192  3
10094843652996959   3  2
010145176274075487  4  1

In this case, X1 and X2 variables are read as numeric, while the first
column is read as character and assigned directly to the rownames.

HTH,
Adrian
-- 
View this message in context: 
http://www.nabble.com/read.table%2C-row.names-arg-tp23888975p23892826.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] re ad.table

2009-04-06 Thread calpeda

Hi,
I ve been searching a lot in internet..but I can t find a solution
Attached, you find a file.
I need for each (Materiale, tpdv, UM) to find sum,avg and count
My idea was to aggregate for the 3 parameters ..but I don t know how to get
the numeric value (SUM,COUNT,AVG) I need.
Can you help me?
thank you

http://www.nabble.com/file/p22905601/ordini2008_ex.txt ordini2008_ex.txt 
-- 
View this message in context: 
http://www.nabble.com/read.table-tp22905601p22905601.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] re ad.table prn file

2009-02-23 Thread canadiangirl19

Dear Forum,

I´ve imported a prn file with read.table
(file(E:/test.prn),sep=\t,skip=3). My problem is now, that my file has a
complicated structure: It is not tabstop seperated, it looks like that:

JEAR  JAN  FEB  MAR  APR
1938154  912
19396  71014
19409

If there are default values, there is no seperation in the line, I want that
the program seperates after every JAN, FEB (in detail after the 18., 24., 36
character). Is there a possibility to seperate after i.e.the 15. character?
i tried with strsplit, but get no satisfying result.
Please help me.  I think I could do this with exel and export it with csv,
but i would like to solve the problem with R.
-- 
View this message in context: 
http://www.nabble.com/read.table-prn-file-tp22161342p22161342.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] re ad.table prn file

2009-02-23 Thread Philipp Pagel
On Mon, Feb 23, 2009 at 05:18:28AM -0800, canadiangirl19 wrote:
 My problem is now, that my file has a
 complicated structure: It is not tabstop seperated, it looks like that:
 
 JEAR  JAN  FEB  MAR  APR
 1938154  912
 19396  71014
 19409
 
 If there are default values, there is no seperation in the line, I want that
 the program seperates after every JAN, FEB (in detail after the 18., 24., 36
 character). Is there a possibility to seperate after i.e.the 15. character?
 i tried with strsplit, but get no satisfying result.

Sounds like read.fwf may solve your problem.

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
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] re ad.table prn file

2009-02-23 Thread canadiangirl19

I´ve tried with:

write.fwf(test,file=E:/test.prn,widths=6), 
but get the error:
Fehler in write.table(t(as.matrix(colnamesMy)), file = file, append =
append,  : 
unbenutzte(s) Argument(e) (widths = 6)
My matrix hast only one column (so it is a vector), and many rows, I want to
seperate the vector (after 6 character, I don´t know, is the width=6?) in a
matrix with 5 columns. How can I do this? And with format.info I get no
output.

thanks in advance for helping me


Philipp Pagel-5 wrote:
 
 On Mon, Feb 23, 2009 at 05:18:28AM -0800, canadiangirl19 wrote:
 My problem is now, that my file has a
 complicated structure: It is not tabstop seperated, it looks like that:
 
 JEAR  JAN  FEB  MAR  APR
 1938154  912
 19396  71014
 19409
 
 If there are default values, there is no seperation in the line, I want
 that
 the program seperates after every JAN, FEB (in detail after the 18., 24.,
 36
 character). Is there a possibility to seperate after i.e.the 15.
 character?
 i tried with strsplit, but get no satisfying result.
 
 Sounds like read.fwf may solve your problem.
 
 cu
   Philipp
 
 -- 
 Dr. Philipp Pagel
 Lehrstuhl für Genomorientierte Bioinformatik
 Technische Universität München
 Wissenschaftszentrum Weihenstephan
 85350 Freising, Germany
 http://mips.gsf.de/staff/pagel
 
 __
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/read.table-prn-file-tp22161342p22162335.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] re ad.table prn file

2009-02-23 Thread Philipp Pagel
On Mon, Feb 23, 2009 at 06:24:33AM -0800, canadiangirl19 wrote:
 write.fwf(test,file=E:/test.prn,widths=6), 
 but get the error:
 Fehler in write.table(t(as.matrix(colnamesMy)), file = file, append =
 append,  : 
 unbenutzte(s) Argument(e) (widths = 6)
 My matrix hast only one column (so it is a vector), and many rows, I want to
 seperate the vector (after 6 character, I don´t know, is the width=6?) in a
 matrix with 5 columns. How can I do this? And with format.info I get no
 output.

Are you sure the above is your actual code? I didn't even know the
function write.fwf existed. I was suggesting was to READ the file with
read.fwf. Your reply seems to indicate that you are first reading the
file by some other means and then trying to write it back to a file. 

If, for some obscure reason, you really cannot use read.fwf(),
textConnection() would be an option. But it would probably only
complicate things more than necessary.

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
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] re ad.table prn file

2009-02-23 Thread canadiangirl19

It works thanks a lot

Philipp Pagel-5 wrote:
 
 On Mon, Feb 23, 2009 at 06:24:33AM -0800, canadiangirl19 wrote:
 write.fwf(test,file=E:/test.prn,widths=6), 
 but get the error:
 Fehler in write.table(t(as.matrix(colnamesMy)), file = file, append =
 append,  : 
 unbenutzte(s) Argument(e) (widths = 6)
 My matrix hast only one column (so it is a vector), and many rows, I want
 to
 seperate the vector (after 6 character, I don´t know, is the width=6?) in
 a
 matrix with 5 columns. How can I do this? And with format.info I get no
 output.
 
 Are you sure the above is your actual code? I didn't even know the
 function write.fwf existed. I was suggesting was to READ the file with
 read.fwf. Your reply seems to indicate that you are first reading the
 file by some other means and then trying to write it back to a file. 
 
 If, for some obscure reason, you really cannot use read.fwf(),
 textConnection() would be an option. But it would probably only
 complicate things more than necessary.
 
 cu
   Philipp
 
 -- 
 Dr. Philipp Pagel
 Lehrstuhl für Genomorientierte Bioinformatik
 Technische Universität München
 Wissenschaftszentrum Weihenstephan
 85350 Freising, Germany
 http://mips.gsf.de/staff/pagel
 
 __
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/read.table-prn-file-tp22161342p22176814.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] re ad.table

2008-12-19 Thread threshold

Hi , I want to use the read.table to the following example 'data.txt' format:
a   b  c  d  e  f
SPX LSZ 100 C   0   34.4
SPX LSZ 100 P   0   1.3
SPX LSZ 105 C   0   30.3
SPX LSZ 105 P   0   1.85
SPX LSZ 110 C   0   26.4

and I want to have the columns a,b,d read as the 'character' data, a the
remaining columns as 'numeric'. What I did was:
read.table(data.txt,header=T,
colClasses=c(character,character,numeric,character,
numeric,numeric), but I could not get what I want, since all values were
in the 'character' format. I will apprecaite any suggestions.
best, robert
-- 
View this message in context: 
http://www.nabble.com/read.table-tp21090550p21090550.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] re ad.table

2008-12-19 Thread jim holtman
Seems to work for me:

 x - read.table(textConnection(a   b  c  d  e  f
+ SPX LSZ 100 C   0   34.4
+ SPX LSZ 100 P   0   1.3
+ SPX LSZ 105 C   0   30.3
+ SPX LSZ 105 P   0   1.85
+ SPX LSZ 110 C   0   26.4),
+ header=T, colClasses=c(character,character,numeric,character,
+ numeric,numeric))
 x
a   b   c d e f
1 SPX LSZ 100 C 0 34.40
2 SPX LSZ 100 P 0  1.30
3 SPX LSZ 105 C 0 30.30
4 SPX LSZ 105 P 0  1.85
5 SPX LSZ 110 C 0 26.40
 str(x)
'data.frame':   5 obs. of  6 variables:
 $ a: chr  SPX SPX SPX SPX ...
 $ b: chr  LSZ LSZ LSZ LSZ ...
 $ c: num  100 100 105 105 110
 $ d: chr  C P C P ...
 $ e: num  0 0 0 0 0
 $ f: num  34.4 1.3 30.3 1.85 26.4

 sessionInfo()
R version 2.8.0 (2008-10-20)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] stats grDevices utils datasets  graphics  methods   base

other attached packages:
[1] MASS_7.2-44


On Fri, Dec 19, 2008 at 7:35 AM, threshold r.kozar...@gmail.com wrote:

 Hi , I want to use the read.table to the following example 'data.txt' format:
 a   b  c  d  e  f
 SPX LSZ 100 C   0   34.4
 SPX LSZ 100 P   0   1.3
 SPX LSZ 105 C   0   30.3
 SPX LSZ 105 P   0   1.85
 SPX LSZ 110 C   0   26.4

 and I want to have the columns a,b,d read as the 'character' data, a the
 remaining columns as 'numeric'. What I did was:
 read.table(data.txt,header=T,
 colClasses=c(character,character,numeric,character,
 numeric,numeric), but I could not get what I want, since all values were
 in the 'character' format. I will apprecaite any suggestions.
 best, robert
 --
 View this message in context: 
 http://www.nabble.com/read.table-tp21090550p21090550.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
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
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] re ad.table

2008-12-19 Thread Simon Pickett
probably best just to change each variable one by one to the correct 
classification after you have read the data frame in.


variable-as.character(variable)


- Original Message - 
From: threshold r.kozar...@gmail.com

To: r-help@r-project.org
Sent: Friday, December 19, 2008 12:35 PM
Subject: [R] re ad.table




Hi , I want to use the read.table to the following example 'data.txt' 
format:

a   b  c  d  e  f
SPX LSZ 100 C 0 34.4
SPX LSZ 100 P 0 1.3
SPX LSZ 105 C 0 30.3
SPX LSZ 105 P 0 1.85
SPX LSZ 110 C 0 26.4

and I want to have the columns a,b,d read as the 'character' data, a the
remaining columns as 'numeric'. What I did was:
read.table(data.txt,header=T,
colClasses=c(character,character,numeric,character,
numeric,numeric), but I could not get what I want, since all values 
were

in the 'character' format. I will apprecaite any suggestions.
best, robert
--
View this message in context: 
http://www.nabble.com/read.table-tp21090550p21090550.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] re ad.table problem

2008-07-10 Thread Schleuh

did you remark you obtain the half of rows (636615*2=1273230) ; maybe the
columns aren't good sliced

phoebe kong wrote:
 
 Dear all,
 
 I have problem when reading a table into R. The total row of read in table
 has is much less than the original saved table.
 
 I built a 1,273,230 by 6 data set named mydata2, it was saved in the
 following command,
 
 write.table(mydata2, mydata2.txt,
 row.name=F,col.name=T,quote=F,sep=\t)
 
 The next day I read in above saved text file into R,
 
 temp-read.table(mydata2.txt,header=T,sep=\t,na.strings=NA)
 
 However, the dimension of temp is 636,615 X 6.
 
 Do yo know why?
 
 Thanks in advanced,
 
 Sityee
 
   [[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.
 
 

-- 
View this message in context: 
http://www.nabble.com/read.table-problem-tp18370284p18379571.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.