Order() sorts text differently on ShinyApps

31 views
Skip to first unread message

john...@operamail.com

unread,
Aug 19, 2014, 9:11:14 AM8/19/14
to shinyap...@googlegroups.com
Hello,
 I have a app. up on ShinyApps and all is working well. I have noticed one issue that surprised me. I have a list of plant names, some of which start with capital letters ("Norway maple") some of which start with lower case letters ("red maple"). I have done all of my coding using a windows desktop. I am using these names as choices in a selectInput. To put them  in the correct order I am using a variation on   

selectInput( inputId='myId", label="whatever", choices=c(Names[ order(Names) ] ) 

where Names is my list of plant names. On  my desktop this works fine, and sorts in alphabetical order as I expected. However when I do the same thing on ShinyApps, it puts all of the names that start with upper case letters first, and then the names that start with lower case letters. Why is this happening? I is some sort of encoding issue?  How can I fix this?

Thanks,
John Paul

William Beasley

unread,
Aug 20, 2014, 9:59:41 PM8/20/14
to shinyap...@googlegroups.com

How can I fix this?
 
Does this work as desired?  The vector that determines the sort order doesn't need to be the same as the vector that's returned.
selectInput( inputId='myId", label="whatever", choices=c(Names[ order(tolower(Names)) ] ) 


Why is this happening? I is some sort of encoding issue?  
 What is the collate order returned by Sys.getlocale(category = "LC_ALL") in the two machines?

john...@operamail.com

unread,
Aug 21, 2014, 1:10:33 PM8/21/14
to shinyap...@googlegroups.com
William Beasley
 That was a very useful work-around, I did not consider the tolower() function. I am still curious as to why this occurs though.

Andy Kipp

unread,
Aug 21, 2014, 4:06:54 PM8/21/14
to john...@operamail.com, shinyap...@googlegroups.com
This is probably caused by the difference in platform/locale. ShinyApps run applications on Linux servers which have a different default collation. 


On Thu, Aug 21, 2014 at 1:10 PM, <john...@operamail.com> wrote:
William Beasley
 That was a very useful work-around, I did not consider the tolower() function. I am still curious as to why this occurs though.

--
You received this message because you are subscribed to the Google Groups "ShinyApps Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-use...@googlegroups.com.
To post to this group, send email to shinyap...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/0029adf4-f89f-418e-a070-67c64f870f52%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Yihui Xie

unread,
Aug 22, 2014, 12:10:31 AM8/22/14
to Andy Kipp, john...@operamail.com, shinyap...@googlegroups.com
Yep, sorting is locale-dependent. For consistent ordering, you will
have to use the same locale, e.g. use Sys.setlocale() to set the
locale, do sorting, and restore the locale.

Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Web: http://yihui.name
Reply all
Reply to author
Forward
0 new messages