Yong Wang
2005-Jun-01 05:04 UTC
[R] A problem on sink() and format,suggestions appreciated
Dear R users I get a weired problem when use sink: since the data set pretty big, I sink intermediate result for further use,following lines are consistently used when write data ########################### sink("dataname.txt") data sink() ########################## at first couples of run, all 10 variables are wrote to a file in following format: V1 V2 ....... V10 1 10457 132356.7 ....... 4356.8 2 75690.2 66697 ....... 98777 . .................................. 10000 654786 3412.54 ...... 98712.567 then I did modifcations somewhere else, the format change to: V1 V2 ....... V9 1 10457 132356.7 ....... 7823.569 2 75690.2 66697 ....... 77024 . .................................. 10000 654786 3412.54 ...... 336721 V10 1 4356.8 2 98777 . ....... 10000 98712.567 this format is not convenient to read. can you hint me where the problem is and how can I make it back to the first format? I worked on this hours but still can not figure out. any suggestions highly appreciated! thank you yong
luan_sheng
2005-Jun-01 06:07 UTC
[R] A problem on sink() and format,suggestions appreciated
Yong Wang 佸啓侀亾:> Dear R users > I get a weired problem when use sink: > since the data set pretty big, I sink intermediate result for further > use,following > lines are consistently used when write data > > ########################### > sink("dataname.txt") > data > sink() > ########################## > > at first couples of run, all 10 variables are wrote to a file in > following format: > > > V1 V2 ....... V10 > 1 10457 132356.7 ....... 4356.8 > 2 75690.2 66697 ....... 98777 > . .................................. > 10000 654786 3412.54 ...... 98712.567 > > > > then I did modifcations somewhere else, the format change to: > > V1 V2 ....... V9 > 1 10457 132356.7 ....... 7823.569 > 2 75690.2 66697 ....... 77024 > . .................................. > 10000 654786 3412.54 ...... 336721 > > V10 > 1 4356.8 > 2 98777 > . ....... > 10000 98712.567 > > this format is not convenient to read. > can you hint me where the problem is and how can I make it back to the > first format? > I worked on this hours but still can not figure out. > > any suggestions highly appreciated! > > thank you > > yong > > ______________________________________________ > R-help at 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 >I dont' know the method you write data into your file.But if you use "write" function ,then you can specify the colums by the "ncolumns". The following is the usage "write" write(x, file = "data", ncolumns = if(is.character(x)) 1 else 5, append = FALSE) __________________________________________________ 佈伵伝仮伱佲伔佈G佊伿佅佷仯伃佒佇伖侜伒佢佉伝伨侙佄佫伬伂伝侙佊伿伡侢伾仹伻伵伋伂伌侒佊伿佅佷