[R] decimal seperator

2010-07-23 Thread Jennifer Sabatier
Hi R-List,

I have a question regarding R-language formats, I think.  I am producing a
series of graphs (using plot, barplot, barchart, and bwplot, using either
text or mtext to place values on the graphs) and tables for a Francophone
country.  In fact, I have already done so.  However, while they are pleased
with the results they've requested I convert all of my decimal points into
the French format which uses commas rather than points.  I have no idea how
to do this for the graphs, despite searching the help, other than to convert
all of my statistics into strings and manually reset the decimal separators,
which would take a long time.  Is there some quick and easy way?  It's only
the graphs I need assistance with.  For tables I simply output to excel and
it's easy to change them there.

Here's an example (I'm sure it's crude but I'm still new at R.  To make the
graph look right you have to expand the java window...which I'm sure you
don't need to do if you know how to do this in a more elegant manner):


sites - c(Kayes, Kita, Koulikoro, Fana, Sikasso, Koutiala,
SgFam, SgHop, Bla, Mopti, Douentz, Tombc,
Dire,Gao,Ansongo,Kidal,Tessalit,BkoCommI,BkoCommIII,BkoCommV)
size -
list(2.91,2.36,5.09,3.21,2.27,4.09,2.31,2.76,1.2,2.03,3.06,0.53,1.43,1.83,1,0.93,0,4.01,4.13,3.47)
site_size - data.frame(cbind(sites, size))
newdata - (sapply(subset(site_size, select=c(size)), as.numeric))
rownames(newdata) - site_size$sites

library(grid)

plot(newdata, ylab = , xlab=   , axes = FALSE)#, type=h, lwd=16)
points(newdata, cex = 10, col = topo.colors(20), bg=topo.colors(20), pch=22)
lines(newdata, type=h, lwd=40, col=topo.colors(20))
axis(1, at=seq(1, 20, by=1), labels = FALSE)
text(seq(1, 20, by=1), par(usr)[3] - 0.2, labels = site2_labels, srt = 45,
pos = 1, xpd = TRUE)
reg.txt - as.character(c(Kayes  Koulikoro
SikassoSegou   Mopti
 Tombouctou  GaoKidal
   Bamako))
mtext(paste(reg.txt), side=3, font=4, cex=1, adj=0)#, outer=T)
text(0, 5.35, Region:, cex = 1, font=4, xpd=T)
text(0, -.5, Sites:, cex=1.2, font=1, xpd=T)
abline(v=c(2.5, 4.5, 6.5, 9.5, 11.5, 13.5, 15.5, 17.5))
axis(2, at=3, labels = FALSE)
mtext(paste(VIH Prevalence (%)), side=2, font=2, cex=1.2)
text(1,3, labels=newdata[1], col=white, cex=1.5);text(2,2.45,
labels=newdata[2], col=white, cex=1.5)
text(3,5.2, labels=newdata[3], col=white, cex=1.5);text(4,3.27,
labels=newdata[4], col=white, cex=1.5)
text(5,2.35, labels=newdata[5], col=white, cex=1.5);text(6,4.2,
labels=newdata[6], col=white, cex=1.5)
text(7,2.36, labels=newdata[7], col=black, cex=1.5);text(8,2.85,
labels=newdata[8], col=black, cex=1.5)
text(9,1.28, labels=newdata[9], col=black, cex=1.5);text(10,2.1,
labels=newdata[10], col=black, cex=1.5)
text(11,3.13, labels=newdata[11], col=black, cex=1.5);text(12,.6,
labels=newdata[12], col=black, cex=1.5)
text(13,1.48, labels=newdata[13], col=black, cex=1.5);text(14,1.9,
labels=newdata[14], col=black, cex=1.5)
text(15,1.05, labels=newdata[15], col=black, cex=1.5);text(16,1,
labels=newdata[16], col=black, cex=1.5)
text(17,.1, labels=newdata[17], col=black, cex=1.5);text(18,4.1,
labels=newdata[18], col=black, cex=1.5)
text(19,4.2, labels=newdata[19], col=black, cex=1.5);text(20,3.55,
labels=newdata[20], col=black, cex=1.5)




 Thanks,

Jen

[[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] decimal seperator

2010-07-23 Thread David Winsemius


On Jul 23, 2010, at 11:32 AM, Jennifer Sabatier wrote:


Hi R-List,

I have a question regarding R-language formats, I think.  I am  
producing a
series of graphs (using plot, barplot, barchart, and bwplot, using  
either
text or mtext to place values on the graphs) and tables for a  
Francophone
country.  In fact, I have already done so.  However, while they are  
pleased
with the results they've requested I convert all of my decimal  
points into

the French format which uses commas rather than points.


?options

OutDec: character string containing a single-byte character. The  
character to be used as the decimal point in output conversions, that  
is in printing, plotting and as.character but not deparsing.


--
DAvid.

I have no idea how
to do this for the graphs, despite searching the help, other than to  
convert
all of my statistics into strings and manually reset the decimal  
separators,
which would take a long time.  Is there some quick and easy way?   
It's only
the graphs I need assistance with.  For tables I simply output to  
excel and

it's easy to change them there.

Here's an example (I'm sure it's crude but I'm still new at R.  To  
make the
graph look right you have to expand the java window...which I'm sure  
you

don't need to do if you know how to do this in a more elegant manner):


sites - c(Kayes, Kita, Koulikoro, Fana, Sikasso,  
Koutiala,

SgFam, SgHop, Bla, Mopti, Douentz, Tombc,
Dire 
,Gao 
,Ansongo,Kidal,Tessalit,BkoCommI,BkoCommIII,BkoCommV)

size -
list 
(2.91,2.36,5.09,3.21,2.27,4.09,2.31,2.76,1.2,2.03,3.06,0.53,1.43,1.83,1,0.93,0,4.01,4.13,3.47 
)

site_size - data.frame(cbind(sites, size))
newdata - (sapply(subset(site_size, select=c(size)), as.numeric))
rownames(newdata) - site_size$sites

library(grid)

plot(newdata, ylab = , xlab=   , axes = FALSE)#, type=h, lwd=16)
points(newdata, cex = 10, col = topo.colors(20), bg=topo.colors(20),  
pch=22)

lines(newdata, type=h, lwd=40, col=topo.colors(20))
axis(1, at=seq(1, 20, by=1), labels = FALSE)
text(seq(1, 20, by=1), par(usr)[3] - 0.2, labels = site2_labels,  
srt = 45,

pos = 1, xpd = TRUE)
reg.txt - as.character(c(Kayes   
Koulikoro
   Sikasso 
Segou   Mopti
Tombouctou  Gao 
Kidal

  Bamako))
mtext(paste(reg.txt), side=3, font=4, cex=1, adj=0)#, outer=T)
text(0, 5.35, Region:, cex = 1, font=4, xpd=T)
text(0, -.5, Sites:, cex=1.2, font=1, xpd=T)
abline(v=c(2.5, 4.5, 6.5, 9.5, 11.5, 13.5, 15.5, 17.5))
axis(2, at=3, labels = FALSE)
mtext(paste(VIH Prevalence (%)), side=2, font=2, cex=1.2)
text(1,3, labels=newdata[1], col=white, cex=1.5);text(2,2.45,
labels=newdata[2], col=white, cex=1.5)
text(3,5.2, labels=newdata[3], col=white, cex=1.5);text(4,3.27,
labels=newdata[4], col=white, cex=1.5)
text(5,2.35, labels=newdata[5], col=white, cex=1.5);text(6,4.2,
labels=newdata[6], col=white, cex=1.5)
text(7,2.36, labels=newdata[7], col=black, cex=1.5);text(8,2.85,
labels=newdata[8], col=black, cex=1.5)
text(9,1.28, labels=newdata[9], col=black, cex=1.5);text(10,2.1,
labels=newdata[10], col=black, cex=1.5)
text(11,3.13, labels=newdata[11], col=black, cex=1.5);text(12,.6,
labels=newdata[12], col=black, cex=1.5)
text(13,1.48, labels=newdata[13], col=black, cex=1.5);text(14,1.9,
labels=newdata[14], col=black, cex=1.5)
text(15,1.05, labels=newdata[15], col=black, cex=1.5);text(16,1,
labels=newdata[16], col=black, cex=1.5)
text(17,.1, labels=newdata[17], col=black, cex=1.5);text(18,4.1,
labels=newdata[18], col=black, cex=1.5)
text(19,4.2, labels=newdata[19], col=black, cex=1.5);text(20,3.55,
labels=newdata[20], col=black, cex=1.5)




David Winsemius, MD
West Hartford, CT

__
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] decimal seperator

2010-07-23 Thread Jennifer Sabatier
Worked like a charm!  Thanks a lot!

Jen



On Fri, Jul 23, 2010 at 11:48 AM, Alain Guillet
alain.guil...@uclouvain.bewrote:

  Hi,

 I am sure there is a better solution but a possibility is that you use
 sub(\\.,,,as.character(newdata))  instead of newdata in the text calls.

 HTH,
 Alain




 On 23-Jul-10 17:32, Jennifer Sabatier wrote:

 Hi R-List,

 I have a question regarding R-language formats, I think.  I am producing a
 series of graphs (using plot, barplot, barchart, and bwplot, using either
 text or mtext to place values on the graphs) and tables for a Francophone
 country.  In fact, I have already done so.  However, while they are
 pleased
 with the results they've requested I convert all of my decimal points into
 the French format which uses commas rather than points.  I have no idea
 how
 to do this for the graphs, despite searching the help, other than to
 convert
 all of my statistics into strings and manually reset the decimal
 separators,
 which would take a long time.  Is there some quick and easy way?  It's
 only
 the graphs I need assistance with.  For tables I simply output to excel
 and
 it's easy to change them there.

 Here's an example (I'm sure it's crude but I'm still new at R.  To make
 the
 graph look right you have to expand the java window...which I'm sure you
 don't need to do if you know how to do this in a more elegant manner):


 sites- c(Kayes, Kita, Koulikoro, Fana, Sikasso, Koutiala,
 SgFam, SgHop, Bla, Mopti, Douentz, Tombc,

 Dire,Gao,Ansongo,Kidal,Tessalit,BkoCommI,BkoCommIII,BkoCommV)
 size-

 list(2.91,2.36,5.09,3.21,2.27,4.09,2.31,2.76,1.2,2.03,3.06,0.53,1.43,1.83,1,0.93,0,4.01,4.13,3.47)
 site_size- data.frame(cbind(sites, size))
 newdata- (sapply(subset(site_size, select=c(size)), as.numeric))
 rownames(newdata)- site_size$sites

 library(grid)

 plot(newdata, ylab = , xlab=   , axes = FALSE)#, type=h, lwd=16)
 points(newdata, cex = 10, col = topo.colors(20), bg=topo.colors(20),
 pch=22)
 lines(newdata, type=h, lwd=40, col=topo.colors(20))
 axis(1, at=seq(1, 20, by=1), labels = FALSE)
 text(seq(1, 20, by=1), par(usr)[3] - 0.2, labels = site2_labels, srt =
 45,
 pos = 1, xpd = TRUE)
 reg.txt- as.character(c(Kayes  Koulikoro
 SikassoSegou
 Mopti
  Tombouctou  GaoKidal
Bamako))
 mtext(paste(reg.txt), side=3, font=4, cex=1, adj=0)#, outer=T)
 text(0, 5.35, Region:, cex = 1, font=4, xpd=T)
 text(0, -.5, Sites:, cex=1.2, font=1, xpd=T)
 abline(v=c(2.5, 4.5, 6.5, 9.5, 11.5, 13.5, 15.5, 17.5))
 axis(2, at=3, labels = FALSE)
 mtext(paste(VIH Prevalence (%)), side=2, font=2, cex=1.2)
 text(1,3, labels=newdata[1], col=white, cex=1.5);text(2,2.45,
 labels=newdata[2], col=white, cex=1.5)
 text(3,5.2, labels=newdata[3], col=white, cex=1.5);text(4,3.27,
 labels=newdata[4], col=white, cex=1.5)
 text(5,2.35, labels=newdata[5], col=white, cex=1.5);text(6,4.2,
 labels=newdata[6], col=white, cex=1.5)
 text(7,2.36, labels=newdata[7], col=black, cex=1.5);text(8,2.85,
 labels=newdata[8], col=black, cex=1.5)
 text(9,1.28, labels=newdata[9], col=black, cex=1.5);text(10,2.1,
 labels=newdata[10], col=black, cex=1.5)
 text(11,3.13, labels=newdata[11], col=black, cex=1.5);text(12,.6,
 labels=newdata[12], col=black, cex=1.5)
 text(13,1.48, labels=newdata[13], col=black, cex=1.5);text(14,1.9,
 labels=newdata[14], col=black, cex=1.5)
 text(15,1.05, labels=newdata[15], col=black, cex=1.5);text(16,1,
 labels=newdata[16], col=black, cex=1.5)
 text(17,.1, labels=newdata[17], col=black, cex=1.5);text(18,4.1,
 labels=newdata[18], col=black, cex=1.5)
 text(19,4.2, labels=newdata[19], col=black, cex=1.5);text(20,3.55,
 labels=newdata[20], col=black, cex=1.5)




  Thanks,

 Jen

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


 --
 Alain Guillet
 Statistician and Computer Scientist

 SMCS - IMMAQ - Université catholique de Louvain
 Bureau c.316
 Voie du Roman Pays, 20
 B-1348 Louvain-la-Neuve
 Belgium

 tel: +32 10 47 30 50



[[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] decimal seperator

2010-07-23 Thread Jennifer Sabatier
Wow, that's even better!

Thanks to you both.  I know both options will come in handy!

Jen



On Fri, Jul 23, 2010 at 11:58 AM, David Winsemius dwinsem...@comcast.netwrote:


 On Jul 23, 2010, at 11:32 AM, Jennifer Sabatier wrote:

  Hi R-List,

 I have a question regarding R-language formats, I think.  I am producing a
 series of graphs (using plot, barplot, barchart, and bwplot, using either
 text or mtext to place values on the graphs) and tables for a Francophone
 country.  In fact, I have already done so.  However, while they are
 pleased
 with the results they've requested I convert all of my decimal points into
 the French format which uses commas rather than points.


 ?options

 OutDec: character string containing a single-byte character. The character
 to be used as the decimal point in output conversions, that is in printing,
 plotting and as.character but not deparsing.

 --
 DAvid.

  I have no idea how
 to do this for the graphs, despite searching the help, other than to
 convert
 all of my statistics into strings and manually reset the decimal
 separators,
 which would take a long time.  Is there some quick and easy way?  It's
 only
 the graphs I need assistance with.  For tables I simply output to excel
 and
 it's easy to change them there.

 Here's an example (I'm sure it's crude but I'm still new at R.  To make
 the
 graph look right you have to expand the java window...which I'm sure you
 don't need to do if you know how to do this in a more elegant manner):


 sites - c(Kayes, Kita, Koulikoro, Fana, Sikasso, Koutiala,
 SgFam, SgHop, Bla, Mopti, Douentz, Tombc,

 Dire,Gao,Ansongo,Kidal,Tessalit,BkoCommI,BkoCommIII,BkoCommV)
 size -

 list(2.91,2.36,5.09,3.21,2.27,4.09,2.31,2.76,1.2,2.03,3.06,0.53,1.43,1.83,1,0.93,0,4.01,4.13,3.47)
 site_size - data.frame(cbind(sites, size))
 newdata - (sapply(subset(site_size, select=c(size)), as.numeric))
 rownames(newdata) - site_size$sites

 library(grid)

 plot(newdata, ylab = , xlab=   , axes = FALSE)#, type=h, lwd=16)
 points(newdata, cex = 10, col = topo.colors(20), bg=topo.colors(20),
 pch=22)
 lines(newdata, type=h, lwd=40, col=topo.colors(20))
 axis(1, at=seq(1, 20, by=1), labels = FALSE)
 text(seq(1, 20, by=1), par(usr)[3] - 0.2, labels = site2_labels, srt =
 45,
 pos = 1, xpd = TRUE)
 reg.txt - as.character(c(Kayes  Koulikoro
   SikassoSegou   Mopti
Tombouctou  GaoKidal
  Bamako))
 mtext(paste(reg.txt), side=3, font=4, cex=1, adj=0)#, outer=T)
 text(0, 5.35, Region:, cex = 1, font=4, xpd=T)
 text(0, -.5, Sites:, cex=1.2, font=1, xpd=T)
 abline(v=c(2.5, 4.5, 6.5, 9.5, 11.5, 13.5, 15.5, 17.5))
 axis(2, at=3, labels = FALSE)
 mtext(paste(VIH Prevalence (%)), side=2, font=2, cex=1.2)
 text(1,3, labels=newdata[1], col=white, cex=1.5);text(2,2.45,
 labels=newdata[2], col=white, cex=1.5)
 text(3,5.2, labels=newdata[3], col=white, cex=1.5);text(4,3.27,
 labels=newdata[4], col=white, cex=1.5)
 text(5,2.35, labels=newdata[5], col=white, cex=1.5);text(6,4.2,
 labels=newdata[6], col=white, cex=1.5)
 text(7,2.36, labels=newdata[7], col=black, cex=1.5);text(8,2.85,
 labels=newdata[8], col=black, cex=1.5)
 text(9,1.28, labels=newdata[9], col=black, cex=1.5);text(10,2.1,
 labels=newdata[10], col=black, cex=1.5)
 text(11,3.13, labels=newdata[11], col=black, cex=1.5);text(12,.6,
 labels=newdata[12], col=black, cex=1.5)
 text(13,1.48, labels=newdata[13], col=black, cex=1.5);text(14,1.9,
 labels=newdata[14], col=black, cex=1.5)
 text(15,1.05, labels=newdata[15], col=black, cex=1.5);text(16,1,
 labels=newdata[16], col=black, cex=1.5)
 text(17,.1, labels=newdata[17], col=black, cex=1.5);text(18,4.1,
 labels=newdata[18], col=black, cex=1.5)
 text(19,4.2, labels=newdata[19], col=black, cex=1.5);text(20,3.55,
 labels=newdata[20], col=black, cex=1.5)



 David Winsemius, MD
 West Hartford, CT



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