Re: [R] creating txt file from data.frame

2007-05-28 Thread Vladimir Eremeev

apply(dfr,1,FUN=function(x){
   cat(c(x[1],
   
ifelse(x[2]==x[3],x[2],paste(x[2],x[3],sep=-)),\n),
file=filename.txt)
 })
This code assumes the data frame with at least 3 columns, errors will occur
if there will be less than 3 columns.


Taka Matzmoto wrote:
 
 R-users
 I need to create a txt file as input for another program using data.frame 
 values
 
  Variable_name   Start End
 [1,] a   1   1
 [2,] bbb   2   2
 [3,] c   3   6
 [4,] ddd  7   10
 [5,] eee 11  16
 
 
 the text file should look like below,
 if the start and the end is the same, only put the start one in the txt 
 file.
 
 a 1
 bbb 2
 c 3-6
 ddd 7-10
 eee 11-16
 

-- 
View this message in context: 
http://www.nabble.com/creating-txt-file-from-data.frame-tf3825900.html#a10833782
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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] creating txt file from data.frame

2007-05-27 Thread Taka Matzmoto

R-users
I need to create a txt file as input for another program using data.frame 
values


Variable_name   Start End
[1,] a   1   1
[2,] bbb   2   2
[3,] c   3   6
[4,] ddd  7   10
[5,] eee 11  16


the text file should look like below,
if the start and the end is the same, only put the start one in the txt 
file.


a 1
bbb 2
c 3-6
ddd 7-10
eee 11-16

Any help will be appreciated.

Taka,

_
PC Magazine’s 2007 editors’ choice for best Web mail—award-winning Windows 
Live Hotmail.


__
R-help@stat.math.ethz.ch 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.