Oh, I missed one function. Try cat(paste(column1...)). This should get rid
of the start/end quotation marks.
On Wed, Dec 1, 2010 at 1:29 PM, romunov <romunov at gmail.com> wrote:
It would pay off if you provide a minimal reproducible example of working
code. That way, you higher you chance of getting an answer (faster).
Cheers,
Roman
On Wed, Dec 1, 2010 at 1:27 PM, ?? <wul1984 at gmail.com> wrote:
Hi,?romunov:
Unfortunately, the space varies, and I also tried to paste the column
with space of different blanks, but the output then becomes a
character, with quote marks outside of the columns.
However, thanks very much, and I will try to post the problem in the
stackoverflow!
Best Regards~
Marco
2010/12/1 romunov <romunov at gmail.com>:
If you have R related questions that are not directly linked to some
specific topic (i.e. spatial analysis), you might have better luck @
stackoverflow. I use it every day and I think it's a great tool. If you
don't know it yet, have a look @
http://stackoverflow.com/questions/tagged/r
Cheers,
Roman
On Wed, Dec 1, 2010 at 1:20 PM, ?? <wul1984 at gmail.com> wrote:
Sorry, I forget to sent the reply to the list:
Hi Roman:
Thanks for posting~
This is the data segment and script that I used to replace the
coordinate,
and the result is constant space in between each columns:
####old coordinates
#colnames
##site prec site ? lat ? ?lon
?7969 ? ?0 55248 ? 32.30 ? 84.05
?7970 ? ?3 55279 ? 31.37 ? 90.02
?7971 ? ?0 55294 ? 32.27 ? 91.67
?7972 ? ?0 55299 ? 31.48 ? 92.07
?7973 ? ?0 55437 ? 30.55 ? 81.43
?7974 ? ?0 55472 ? 30.95 ? 88.63
?7975 ? ?0 55493 ? 30.73 ? 92.45
?7976 ? ?0 55569 ? 29.07 ? 87.68
?7977 ? ?1 55578 ? 29.25 ? 88.88
?7978 ? ?0 55591 ? 29.67 ? 91.13
?7979 ? ?0 55598 ? 29.23 ? 91.77
?7980 ? ?2 55664 ? 28.63 ? 87.08
?7981 ? ?0 55680 ? 29.00 ? 89.63
?7982 ? ?0 55690 ? 28.70 ? 91.63
?7983 ? 12 55696 ? 28.42 ? 92.47
###new coordinates
#site lat lon
55248 32.15 84.42
55294 32.35 91.1
55437 30.28 81.25
55493 30.48 91.1
55569 29.08 87.6
55598 29.25 91.77
55680 28.92 89.6
55690 27.98 91.95
56202 30.67 93.28
56312 29.67 94.33
##My searching ID
findlist<-c(55248,55294,55437,55493,55569,55598,55680,55690)
old<-read.table('old.txt',head=F,sep='')
names(old)<-c('ID','value','site','lat','lon')
new<-read.table('new.txt',head=F,sep='')
names(x)<-c('site','lat','lon')
for (j in findlist){
old$lat[old$site==j]<-new$lat[new$site==j]
old$lon[old$site==j]<-new$lon[new$site==j]
}
write.table(old,'replaced.txt',row.names = F,col.names
=F,eol='\r',sep='
')
The script looks very silly, but that what I can do in my skill.
My aim again is to obtain the replaced.txt that confirm to the
required
format, ie: constant digit length for each column, not constant space
in
between.
Anyone could help me out?
Cheers,
Marco
2010/12/1 Roman Lu?trik <roman.lustrik at gmail.com>
Hey,
this sounds like an interesting problem. I may be a bit dense, but
could
you elaborate a bit more?
Cheers,
Roman
On Wed, Dec 1, 2010 at 11:41 AM, ?? <wul1984 at gmail.com> wrote:
Hi, list:
I am processing a kind of data which has very strict format on
digit
position, ie., for the first column, the last digit should be in
column
5,
the second in column 10, and 16, 24, 32 for the 3rd, 4th, and 5th,
respectively. Here is the segment:
? ? ? ?29 ?-999 ?1051 ? 69.58 ? 23.53
? ? ? ?30 ?-999 ?1052 ? 70.67 ? 23.67
? ? ? ?31 ?-999 ?1053 ? 70.68 ? 23.68
? ? ? ?32 ?-999 ?1055 ? 71.10 ? 24.00
? ? ? ? .......
? 13642 -999 97890 ? -7.83 ?129.67
? 13643 ? 30 97900 ? -7.98 ?131.30
? 13644 ?100 97980 ? -8.47 ?140.38
? 13645 ? 66 98132 ? 20.80 ?121.85
? 13646 -999 98133 ? 19.27 ?121.47
My aim is to replace the coordinates of certain rows using new
coordinates,
and put the whole file back into the same filee, but it seems that
I
can
only get constant spaces between each column if I use write.table,
with
sep=' '. So, my question is, is there any way that I could get the
desired
format? By the way, I have more than 10,000 rows in each file
(day),
and
365
days for each year, I think for me, R is the only way to do this.
Thanks in advance~
Best regards~
Marco
? ? ? ?[[alternative HTML version deleted]]