I am working on a code that I started some weeks ago. However, (I am not sure why) the code suddenly converts some of the columns into integer64 format. With this format, the rest of the code does not run any longer and I am not familiar with integer64 format. I would simply like to convert the integer64 column into integer or numeric format. The usual commands as.numeric or as.integer do not work. What can I do?
here is a sample of my data
> dput(head(my_data3, n = 30))
structure(list(year = c(2007, 2009, 2011, 2012, 2005, 2017, 2001,
2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012, 2013, 2014, 2016,
2017, 2018, 2018, 2011, 2014, 2002, 2015, 2004, 2008, 2009, 2011,
2012), export_value = structure(c(0, 0, 0, 0, 5.74548939548786e-319,
3.29556607745487e-319, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2.20704064653743e-319,
0, 0, 0, 3.13731685109192e-320, 3.82307996751957e-320, 0, 0,
1.39406056696212e-318, 7.3185450052818e-319, 1.72873569479852e-320,
7.06760906375903e-320, 1.04667807071468e-319, 2.30382810655773e-320,
1.01915861424132e-319), class = "integer64"), location_code = c("AGO",
"AGO", "AGO", "AGO", "MDG", "MDG", "MOZ", "MOZ", "MOZ", "MOZ",
"MOZ", "MOZ", "MOZ", "MOZ", "MOZ", "MOZ", "MOZ", "MOZ", "MOZ",
"MOZ", "SWZ", "SYC", "SYC", "TZA", "TZA", "ZAF", "ZAF", "ZAF",
"ZAF", "ZAF"), partner_code = c("AFG", "AFG", "AFG", "AFG", "AFG",
"AFG", "AFG", "AFG", "AFG", "AFG", "AFG", "AFG", "AFG", "AFG",
"AFG", "AFG", "AFG", "AFG", "AFG", "AFG", "AFG", "AFG", "AFG",
"AFG", "AFG", "AFG", "AFG", "AFG", "AFG", "AFG"), export_destination = c("RoW",
"RoW", "RoW", "RoW", "RoW", "RoW", "RoW", "RoW", "RoW", "RoW",
"RoW", "RoW", "RoW", "RoW", "RoW", "RoW", "RoW", "RoW", "RoW",
"RoW", "RoW", "RoW", "RoW", "RoW", "RoW", "RoW", "RoW", "RoW",
"RoW", "RoW"), product_group = c("Food", "Food", "Food", "Food",
"Food", "Food", "Food", "Food", "Food", "Food", "Food", "Food",
"Food", "Food", "Food", "Food", "Food", "Food", "Food", "Food",
"Food", "Food", "Food", "Food", "Food", "Food", "Food", "Food",
"Food", "Food"), exporter = c("Angola", "Angola", "Angola", "Angola",
"Madagascar", "Madagascar", "Mozambique", "Mozambique", "Mozambique",
"Mozambique", "Mozambique", "Mozambique", "Mozambique", "Mozambique",
"Mozambique", "Mozambique", "Mozambique", "Mozambique", "Mozambique",
"Mozambique", "Eswatini", "Seychelles", "Seychelles", "Tanzania",
"Tanzania", "South Africa", "South Africa", "South Africa", "South Africa",
"South Africa"), export_destination_country = c("Afghanistan",
"Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",
"Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",
"Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",
"Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",
"Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan",
"Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan")), row.names = c(NA,
-30L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x00000295b7981ef0>)
The integer64 class is created by teh bit64 package. There are many questions that have arisen over the years that have been answered on SO. Need to recover the data without mangling by using functions from the package that created the integer64 object.
I didn't notice earlier that there were both an
as.integerand anas.doublegeneric defined for 'integer64' objects, so it might be better to use them. Certainly if an integer were needed it might be better to start withas.integer.I suppose that one or more of those earlier questions and answers might have contained an answer to this question but I didn't come across a duplicate in the first 5 I looked at.