Hi,
something very strange today as I'm trying to simply read in the
attached CSV into R (it's small).
I seem to be losing all decimals in the last column. I tried to set
`colClasses`, but made no difference.
Not sure what's wrong with me today!
Can any one replicate? I suppose it's in the input file, will keep digging.
Thx, --Mel.
E.g. this is what I see when opening the CSV in emacs:
And then this is what shows up in R:
```r
pcn <- fread("PovCalServlet_15.08.03.csv")
sapply(pcn, class)
# country povLine mean hcr gap sev
# "character" "numeric" "numeric" "numeric" "numeric" "numeric"
# watts popM yearNum
# "numeric" "numeric" "numeric"
# => looks as expected, but then no decimal...
pcn08$yearNum
# [1] 2008 2012 2009 2009 2006 2008 2007 2008 2011 2004 2006 2011 2008
2010 2005
# [16] 2003 2006 2008 2007 2012 2002 2005 2010 2007 2010 2010 2010 2008
2008 2012
# [31] 2006 2009 2010 2011 2010 2011 2010 2011 2006 2011 2011 2009 2010
2012 2011
# [46] 2008 2012 2009 2010 2008 2012 2009 2009 2006 2008 2007 2008 2011
2004 2006
# [61] 2011 2008 2010 2005 2003 2006 2008 2007 2012 2002 2005 2010 2007
2010 2010
# [76] 2010 2008 2008 2012 2006 2009 2010 2011 2010 2011 2010 2011 2006
2011 2011
# [91] 2009 2010 2012 2011 2008 2012 2009 2010
sessionInfo()
# R version 3.2.1 (2015-06-18)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows 7 x64 (build 7601) Service Pack 1
#
# locale:
# [1] LC_COLLATE=English_United States.1252
# [2] LC_CTYPE=English_United States.1252
# [3] LC_MONETARY=English_United States.1252
# [4] LC_NUMERIC=C
# [5] LC_TIME=English_United States.1252
#
# attached base packages:
# [1] stats graphics grDevices utils datasets methods base
#
# other attached packages:
# [1] rgdal_1.0-4 sp_1.1-1 data.table_1.9.4 rj_2.0.3-2
#
# loaded via a namespace (and not attached):
# [1] magrittr_1.5 plyr_1.8.3 tools_3.2.1 rj.gd_2.0.0-1
# [5] reshape2_1.4.1 Rcpp_0.11.6 stringi_0.5-5 grid_3.2.1
# [9] stringr_1.0.0 chron_2.3-47 lattice_0.20-33
```
--
Melanie BACOU
International Food Policy Research Institute
Snr. Program Manager, Spatial Data and Analytics
Work +1(202)862-5699
E-mail [email protected]
Visit www.harvestchoice.org
country,povLine,mean,hcr,gap,sev,watts,popM,yearNum
Angola,2.00,60.31,67.02,31.17,18.07,50.21,20.18,2008.50
Benin,2.00,54.68,74.25,35.91,20.74,56.67,9.78,2011.50
Botswana,2.00,255.50,23.23,8.25,3.99,51.41,1.99,2009.25
Burkina Faso,2.00,59.74,69.31,29.20,15.37,43.89,16.00,2009.00
Burundi,2.00,30.07,92.85,54.62,35.28,92.32,9.54,2006.00
Cabo Verde,2.00,122.19,31.87,9.88,4.20,13.12,0.49,2007.50
Cameroon,2.00,84.19,50.09,18.18,8.47,25.60,21.16,2007.00
Central African Republic,2.00,59.18,75.46,41.98,27.89,75.38,4.44,2008.00
Chad,2.00,67.79,60.52,27.32,15.89,44.79,12.08,2011.00
Comoros,2.00,89.76,66.84,35.72,23.22,62.77,0.70,2004.00
"Congo, Democratic Republic of",2.00,25.12,93.49,63.40,46.92,126.55,63.93,2005.50
"Congo, Republic of",2.00,69.57,57.23,24.13,13.24,37.85,4.23,2011.00
Cote d'Ivoire,2.00,67.50,61.52,27.45,15.60,43.89,19.39,2008.00
Ethiopia,2.00,55.44,72.17,27.56,13.53,40.21,89.39,2010.50
Gabon,2.00,155.60,19.42,5.23,2.03,6.71,1.59,2005.00
"Gambia, The",2.00,81.17,56.33,24.64,13.63,38.48,1.73,2003.00
Ghana,2.00,105.81,37.27,13.83,6.87,20.33,24.82,2005.50
Guinea,2.00,53.89,71.90,29.92,15.73,45.15,11.16,2008.00
Guinea,2.00,60.88,66.02,28.37,15.31,43.39,11.16,2007.00
Guinea,2.00,52.14,73.38,30.31,15.84,45.60,11.16,2012.00
Guinea-Bissau,2.00,48.56,77.76,34.70,19.04,53.50,1.62,2002.00
Kenya,2.00,73.03,61.99,27.94,15.85,44.31,42.03,2005.40
Lesotho,2.00,72.24,63.66,34.65,23.16,64.82,2.03,2010.00
Liberia,2.00,35.67,89.58,49.18,31.09,93.67,4.08,2007.00
Madagascar,2.00,23.42,95.22,65.19,47.88,131.63,21.68,2010.00
Malawi,2.00,37.51,87.81,51.59,34.51,91.98,15.46,2010.23
Mali,2.00,46.17,78.91,35.44,19.28,54.12,14.42,2010.00
Mauritania,2.00,84.16,47.81,17.72,8.71,25.86,3.70,2008.00
Mauritius,2.00,247.89,1.77,0.44,0.23,0.47,1.29,2008.00
Mauritius,2.00,247.89,1.85,0.48,0.25,0.51,1.29,2012.00
Mauritius,2.00,247.89,1.34,0.27,0.11,0.30,1.29,2006.00
Mozambique,2.00,49.79,79.21,40.19,24.64,67.77,24.58,2008.64
Namibia,2.00,168.92,41.58,15.38,7.10,21.44,2.22,2009.50
Niger,2.00,51.98,76.11,29.26,13.96,41.55,16.51,2011.00
Nigeria,2.00,43.66,80.90,43.34,27.56,74.75,164.19,2009.83
Rwanda,2.00,50.30,82.10,44.36,27.87,73.57,11.14,2010.83
Sao Tome and Principe,2.00,52.47,71.92,30.31,15.99,45.73,0.18,2010.00
Senegal,2.00,67.97,60.28,24.93,13.21,37.91,13.33,2011.00
Seychelles,2.00,501.19,1.30,0.26,0.10,0.29,0.09,2006.50
Sierra Leone,2.00,44.35,82.49,38.94,21.82,60.40,5.87,2011.00
South Africa,2.00,319.60,26.17,7.64,2.83,10.27,51.58,2010.67
Sudan,2.00,87.03,40.14,13.57,6.23,19.33,36.43,2009.00
Swaziland,2.00,81.39,59.61,28.66,16.94,46.49,1.21,2009.50
Tanzania,2.00,55.91,72.98,30.61,15.83,45.34,46.35,2011.80
Togo,2.00,53.76,72.73,37.97,23.81,64.67,6.47,2011.00
Uganda,2.00,70.79,63.08,26.44,13.87,39.58,35.15,2008.00
Uganda,2.00,70.79,62.83,26.75,14.17,40.23,35.15,2012.50
Uganda,2.00,70.79,63.36,26.10,13.52,38.85,35.15,2009.30
Zambia,2.00,40.35,85.83,55.57,40.46,109.84,13.63,2010.00
Angola,1.25,60.31,42.97,16.24,8.03,23.88,20.18,2008.50
Benin,1.25,54.68,51.61,18.82,8.68,26.50,9.78,2011.50
Botswana,1.25,255.50,10.02,2.93,1.33,41.33,1.99,2009.25
Burkina Faso,1.25,59.74,40.80,12.86,5.51,17.17,16.00,2009.00
Burundi,1.25,30.07,79.79,34.70,17.82,50.70,9.54,2006.00
Cabo Verde,1.25,122.19,11.87,2.64,0.89,3.30,0.49,2007.50
Cameroon,1.25,84.19,24.94,6.18,2.02,7.72,21.16,2007.00
Central African Republic,1.25,59.18,56.68,26.86,16.11,44.06,4.44,2008.00
Chad,1.25,67.79,36.53,14.18,7.38,21.45,12.08,2011.00
Comoros,1.25,89.76,48.18,22.12,13.00,35.62,0.70,2004.00
"Congo, Democratic Republic of",1.25,25.12,84.01,47.60,31.23,83.94,63.93,2005.50
"Congo, Republic of",1.25,69.57,32.82,11.47,5.43,16.02,4.23,2011.00
Cote d'Ivoire,1.25,67.50,37.31,13.79,6.76,20.06,19.39,2008.00
Ethiopia,1.25,55.44,36.79,10.39,4.08,13.80,89.39,2010.50
Gabon,1.25,155.60,5.39,1.09,0.37,1.34,1.59,2005.00
"Gambia, The",1.25,81.17,34.02,11.89,5.44,16.90,1.73,2003.00
Ghana,1.25,105.81,18.02,5.59,2.54,7.54,24.82,2005.50
Guinea,1.25,53.89,41.28,13.07,5.71,17.87,11.16,2008.00
Guinea,1.25,60.88,39.45,13.07,5.72,17.96,11.16,2007.00
Guinea,1.25,52.14,41.73,13.07,5.70,17.85,11.16,2012.00
Guinea-Bissau,1.25,48.56,48.66,16.44,7.50,22.70,1.62,2002.00
Kenya,1.25,73.03,38.03,14.16,7.13,20.83,42.03,2005.40
Lesotho,1.25,72.24,45.70,22.22,13.75,38.62,2.03,2010.00
Liberia,1.25,35.67,70.91,29.40,15.89,64.39,4.08,2007.00
Madagascar,1.25,23.42,87.83,48.93,31.06,93.46,21.68,2010.00
Malawi,1.25,37.51,71.56,33.74,19.51,52.95,15.46,2010.23
Mali,1.25,46.17,50.83,16.57,7.08,22.55,14.42,2010.00
Mauritania,1.25,84.16,23.54,6.84,2.85,9.18,3.70,2008.00
Mauritius,1.25,247.89,0.39,0.16,0.14,0.10,1.29,2008.00
Mauritius,1.25,247.89,0.43,0.18,0.16,0.11,1.29,2012.00
Mauritius,1.25,247.89,0.20,0.07,0.05,0.06,1.29,2006.00
Mozambique,1.25,49.79,55.77,22.85,12.19,34.99,24.58,2008.64
Namibia,1.25,168.92,21.98,5.08,1.52,6.20,2.22,2009.50
Niger,1.25,51.98,40.81,10.42,3.71,13.11,16.51,2011.00
Nigeria,1.25,43.66,60.08,26.15,14.48,40.93,164.19,2009.83
Rwanda,1.25,50.30,63.02,26.53,13.97,39.01,11.14,2010.83
Sao Tome and Principe,1.25,52.47,42.19,13.33,5.63,18.24,0.18,2010.00
Senegal,1.25,67.97,34.06,11.08,4.81,15.21,13.33,2011.00
Seychelles,1.25,501.19,0.20,0.06,0.04,0.05,0.09,2006.50
Sierra Leone,1.25,44.35,56.63,19.24,8.48,26.58,5.87,2011.00
South Africa,1.25,319.60,9.42,1.19,0.20,1.33,51.58,2010.67
Sudan,1.25,87.03,17.21,4.59,1.84,6.08,36.43,2009.00
Swaziland,1.25,81.39,39.84,15.53,7.73,22.89,1.21,2009.50
Tanzania,1.25,55.91,43.48,12.98,5.12,17.31,46.35,2011.80
Togo,1.25,53.76,52.46,22.52,12.20,34.46,6.47,2011.00
Uganda,1.25,70.79,36.95,11.65,4.92,15.64,35.15,2008.00
Uganda,1.25,70.79,37.78,11.96,4.93,16.01,35.15,2012.50
Uganda,1.25,70.79,36.00,11.31,4.90,15.21,35.15,2009.30
Zambia,1.25,40.35,73.19,40.64,26.60,71.61,13.63,2010.00
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help