Floating point numbers are approximations in base 2, so any fractions not representing such numbers may round off in unexpected directions.
sprintf( "%22.20f", 0.5 ) sprintf( "%22.20f", 0.575 ) See R FAQ 7.31. On October 9, 2018 10:14:54 AM PDT, Ryan Derickson <rlderick...@gmail.com> wrote: >Hello, > >Apologies if this is a simple misunderstanding. > >round((.575*100),0) gives 57 >round(57.5,0) gives 58 > >Why? > >Ryan Derickson >University of Cincinnati > >On Tue, Oct 9, 2018, 10:08 AM PIKAL Petr <petr.pi...@precheza.cz> >wrote: > >> Hi >> >> You could use brute force approach. Just print out "file.names" and >> estimate ordering vector. >> In czech locale it is >> >> oo <- c(6, 11, 1, 4, 5, 2, 3, 10, 12, 9, 7, 8) >> >> In english locale it is different :-) >> >> After that >> file.names[oo] >> >> should give you correct order of file names >> >> Cheers >> Petr >> >> > -----Original Message----- >> > From: R-help <r-help-boun...@r-project.org> On Behalf Of Ek Esawi >> > Sent: Tuesday, October 9, 2018 3:44 PM >> > To: r-help@r-project.org >> > Subject: [R] Reorder file names read by list.files function >> > >> > Hi All-- >> > >> > I used base R list.file function to read files from a directory. >The >> file names are >> > months (April, August, etc). That's the system reads them in >> alphabetical order., >> > but i want to reordered them in calendar order (January, February, >> > ...December).. I thought i might be able to do it via RegEx or >possibly >> gtools >> > package, I am wondering if there is an easier way. >> > >> > Thanks--EK >> > >> > Example >> > path = "C:/Users/name/Downloads/MyFiles" >> > file.names <- dir(path, pattern =".PDF") >> > >> > Example output >> > Output: >> > "February.PDF" "January.PDF" "March.PDF" >> > Desired output >> > "January.PDF" "February.PDF" "March.PDF" >> > >> > ______________________________________________ >> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> > 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. >> Osobní údaje: Informace o zpracování a ochraně osobních údajů >obchodních >> partnerů PRECHEZA a.s. jsou zveřejněny na: >> https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information >> about processing and protection of business partner’s personal data >are >> available on website: >> https://www.precheza.cz/en/personal-data-protection-principles/ >> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou >> důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení >> odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and >any >> documents attached to it may be confidential and are subject to the >legally >> binding disclaimer: https://www.precheza.cz/en/01-disclaimer/ >> >> ______________________________________________ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> 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. >> > > [[alternative HTML version deleted]] > >______________________________________________ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >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. -- Sent from my phone. Please excuse my brevity. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.