Here is my data
mydata <- structure(list(GroupA_1 = c(400730000, 0, 0, 0, 4442200000, 0,
0, 0, 0, 4482700000, 0, 0, 0, 0, 0), GroupA_2 = c(375840000,
0, 0, 38008000, 7963200000, 0, 0, 0, 164980000, 4102700000, 0,
0, 0, 0, 89135000), GroupA_3 = c(342230000, 0, 0, 0, 6705700000,
14662000, 0, 0, 0, 4.665e+09, 0, 0, 0, 0, 0), GroupA_4 = c(311840000,
0, 0, 0, 4611900000, 0, 0, 0, 148700000, 5108300000, 0, 0, 0,
0, 123910000)), .Names = c("GroupA_1", "GroupA_2", "GroupA_3",
"GroupA_4"), class = "data.frame", row.names = c("first1", "first2",
"first3", "first4", "first5", "first6", "first7", "first8", "first9",
"first10", "first11", "first12", "first13", "first14", "first15"
))
I load the data like this
mydata <- read.table("path to mydata.txt", header=TRUE, row.names = 1)
then I str it and i see that the values are number
'data.frame': 15 obs. of 4 variables:
$ GroupA_1: num 4.01e+08 0.00 0.00 0.00 4.44e+09 ...
$ GroupA_2: num 3.76e+08 0.00 0.00 3.80e+07 7.96e+09 ...
$ GroupA_3: num 3.42e+08 0.00 0.00 0.00 6.71e+09 ...
$ GroupA_4: num 3.12e+08 0.00 0.00 0.00 4.61e+09 ...
I try to get convert them to integer like below
mydata2 <- data.frame(sapply(mydata, as.integer))
which introduces NA into the data
Warning messages:
1: In lapply(X = X, FUN = FUN, ...) :
NAs introduced by coercion to integer range
2: In lapply(X = X, FUN = FUN, ...) :
NAs introduced by coercion to integer range
3: In lapply(X = X, FUN = FUN, ...) :
NAs introduced by coercion to integer range
4: In lapply(X = X, FUN = FUN, ...) :
NAs introduced by coercion to integer range
How can I convert my data into integer without introducing NA?? because I don't see any reason to have NA