Hi > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Luca Meyer > Sent: Thursday, August 30, 2012 7:55 AM > To: R help > Subject: [R] Leading plus in numeric fields > > Hello R experts, > > I have go this data frame: > > 'data.frame': 1 obs. of 20 variables: > $ Anno : chr "PREVISIONI VS TARGET" > $ OreTot: num 41 > $ GioTot: logi NA > $ OrGTot: logi NA > $ OreCli: num 99 > $ GioCli: logi NA > $ OrGCli: logi NA > $ OreFor: num -27 > $ GioFor: logi NA > $ OrGFor: logi NA > $ OreOrt: num -18 > $ GioOrt: logi NA > $ OrGOrt: logi NA > $ OreSpo: num -6 > $ GioSpo: logi NA > $ OrGSpo: logi NA > $ OreUff: num -7 > $ GioUff: logi NA > $ OrGUff: logi NA > $ temp : num 0 > > Is there any way I can format the numeric fields so that I get a > leading "+" whenever the value is > 0? In the specific case I would > need something like:
Why? What do you want to do with it? If you want format numbers/strings you can use sprintf x<-rnorm(5) sprintf("%+f",x) but resulting values are eventually not numbers Regards Petr > > 'data.frame': 1 obs. of 20 variables: > $ Anno : chr "PREVISIONI VS TARGET" > $ OreTot: num +41 > $ GioTot: logi NA > $ OrGTot: logi NA > $ OreCli: num +99 > $ GioCli: logi NA > $ OrGCli: logi NA > $ OreFor: num -27 > $ GioFor: logi NA > $ OrGFor: logi NA > $ OreOrt: num -18 > $ GioOrt: logi NA > $ OrGOrt: logi NA > $ OreSpo: num -6 > $ GioSpo: logi NA > $ OrGSpo: logi NA > $ OreUff: num -7 > $ GioUff: logi NA > $ OrGUff: logi NA > $ temp : num 0 > > Thank you in advance, > > Luca > > Mr. Luca Meyer > www.lucameyer.com > R version 2.15.1 > Mac OS X 10.8 > > > > > > > > [[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. ______________________________________________ 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.