tbrown122387 / gradeR

helps grade R script assignment submissions!
Other
4 stars 3 forks source link

How to handle locale-specific behavior? #13

Open tbrown122387 opened 4 years ago

tbrown122387 commented 4 years ago

A student submission featured code that read in a data set. On his machine and on mine, it looked like

                      Series.Name    Series.Code   Country.Name Country.Code X2014..YR2014.
1 Income share held by second 20% SI.DST.02ND.20    Afghanistan          AFG             ..
2 Income share held by second 20% SI.DST.02ND.20        Albania          ALB             ..
3 Income share held by second 20% SI.DST.02ND.20        Algeria          DZA             ..
4 Income share held by second 20% SI.DST.02ND.20 American Samoa          ASM             ..
5 Income share held by second 20% SI.DST.02ND.20        Andorra          ADO             ..
6 Income share held by second 20% SI.DST.02ND.20         Angola          AGO             ..

However, when it runs on the server, it looks like this

                  X...Series.Name    Series.Code   Country.Name Country.Code
1 Income share held by second 20% SI.DST.02ND.20    Afghanistan          AFG
2 Income share held by second 20% SI.DST.02ND.20        Albania          ALB
3 Income share held by second 20% SI.DST.02ND.20        Algeria          DZA
4 Income share held by second 20% SI.DST.02ND.20 American Samoa          ASM
5 Income share held by second 20% SI.DST.02ND.20        Andorra          ADO
6 Income share held by second 20% SI.DST.02ND.20         Angola          AGO

All subsequent code that assumed column names therefore broke.

This stackoverflow post mentions that default column names are not always consistent across machines with different locales.