data-raw/non-ascii-dir.R

getwd()

library(tools)




#terminal 
# pcregrep --color='auto' -n '[^\x00-\x7F]' Tx.Rd                       


showNonASCIIDir <- function(mydir, checkcpp=FALSE, checkrdata=FALSE)
{
  allfile <- dir(mydir, full.names = TRUE)
  if(checkcpp)
    allfile <- grep(x=allfile, pattern="[.][c][p][p]", value=TRUE)
  if(checkrdata)
  {
    rmfile <- grep(x=allfile, pattern="[.][R][D][a][t][a]")
    allfile <- allfile[-rmfile]
  }
  cat(allfile[1], "\n")
  #stop("ici")
  for(i in 1:length(allfile))
  {
    myfi <- allfile[i]
    cat("num", i, "\t", myfi, "\n")
    
    res <- showNonASCIIfile(myfi)
    cat("<------\n")
  }
}

showNonASCIIDir(".")
showNonASCIIDir("data")
showNonASCIIDir("inst")
showNonASCIIDir("man")
showNonASCIIDir("R")
showNonASCIIDir("src", TRUE)
showNonASCIIDir("tests")
showNonASCIIDir("vignettes", checkrdata = TRUE)

library(lifecontingencies)
data("demoUk")
head(demoUk)
tail(demoUk)
showNonASCII(demoUk)

iconv(demoUk, from="latin1", to="UTF-8", sub="")

demoUk <- cbind.data.frame(17:90, 
      c(0.000427, 0.000426, 0.000425, 0.000425, 0.000425, 0.000427, 0.000429, 
        0.000431, 0.000435, 0.00044, 0.000447, 0.000455, 0.000465, 0.000476, 
        0.00049, 0.000507, 0.000527, 0.00055, 0.000577, 0.000608, 0.000644, 
        0.000685, 0.000733, 0.000788, 0.000851, 0.000922, 0.001003, 0.001096, 
        0.001201, 0.00132, 0.001455, 0.001607, 0.001778, 0.001971, 0.002189, 
        0.002433, 0.002707, 0.003014, 0.003358, 0.003742, 0.004171, 0.004649, 
        0.005182, 0.005774, 0.006433, 0.007164, 0.007974, 0.008871, 0.009864, 
        0.01096, 0.012169, 0.013502, 0.014969, 0.016582, 0.018353, 0.020296, 
        0.022423, 0.02475, 0.027293, 0.030067, 0.03309, 0.036379, 0.039954, 
        0.043833, 0.048037, 0.052586, 0.057501, 0.062804, 0.068516, 0.074661, 
        0.081258, 0.088331, 0.095902, 0.10399),
      c(0.000113, 0.000117, 0.000121, 0.000125, 0.00013, 0.000135, 0.000141, 
        0.000148, 0.000155, 0.000163, 0.000172, 0.000182, 0.000193, 0.000205, 
        0.000218, 0.000233, 0.000249, 0.000267, 0.000287, 0.000309, 0.000334, 
        0.000361, 0.000391, 0.000424, 0.000461, 0.000502, 0.000547, 0.000597, 
        0.000652, 0.000713, 0.000781, 0.000855, 0.000938, 0.00103, 0.001132, 
        0.001244, 0.001368, 0.001506, 0.001658, 0.001827, 0.002014, 0.00222, 
        0.002449, 0.002701, 0.002981, 0.003291, 0.003634, 0.004013, 0.004432, 
        0.004897, 0.00541, 0.005978, 0.006607, 0.007302, 0.008071, 0.008922, 
        0.009863, 0.010903, 0.012053, 0.013325, 0.01473, 0.016284, 0.018, 
        0.019897, 0.021993, 0.024307, 0.026862, 0.029683, 0.032795, 0.036229, 
        0.040016, 0.04419, 0.048789, 0.053854))
colnames(demoUk) <- c("Age", "AM92", "AF92")
showNonASCII(demoUk)


save(demoUk, file=paste("data","demoUk.rda", sep="/"))


data("demoUsa")
head(demoUsa)

showNonASCII(demoUsa)

iconv(demoUsa, from="latin1", to="UTF-8", sub="")


demoUsa <- cbind.data.frame(0:113,
  c(1e+05, 99262, 99213, 99182, 99158, 99138, 99120, 99104, 99089, 99075, 
    99065, 99056, 99047, 99032, 99007, 98968, 98912, 98841, 98754, 98654, 
    98541, 98414, 98275, 98128, 97980, 97834, 97693, 97555, 97419, 97284, 
    97147, 97009, 96868, 96724, 96576, 96423, 96264, 96096, 95919, 95729, 
    95525, 95303, 95062, 94800, 94517, 94209, 93875, 93513, 93120, 92691, 
    92224, 91716, 91165, 90572, 89940, 89270, 88558, 87800, 86995, 86138, 
    85227, 84254, 83217, 82111, 80935, 79684, 78351, 76929, 75411, 73792, 
    72066, 70223, 68254, 66161, 63947, 61612, 59147, 56545, 53811, 50951, 
    47974, 44882, 41683, 38401, 35063, 31699, 28341, 25024, 21785, 18670, 
    15722, 12986, 10501, 8297, 6393, 4794, 3496, 2479, 1711, 1149, 754, 481, 
    298, 179, 104, 58, 31, 16, 8, 4, 2, 1, NA, NA),
  c(1e+05, 99390, 99347, 99322, 99303, 99288, 99275, 99262, 99250, 99238, 
    99228, 99218, 99208, 99196, 99180, 99160, 99133, 99101, 99064, 99025, 
    98983, 98939, 98894, 98846, 98796, 98746, 98694, 98640, 98584, 98527, 
    98466, 98403, 98336, 98266, 98190, 98108, 98020, 97925, 97822, 97709, 
    97586, 97452, 97305, 97144, 96968, 96776, 96566, 96336, 96087, 95819, 
    95530, 95219, 94885, 94526, 94143, 93737, 93304, 92841, 92342, 91804, 
    91220, 90585, 89895, 89147, 88340, 87473, 86537, 85524, 84427, 83236, 
    81944, 80537, 79008, 77355, 75580, 73679, 71638, 69441, 67090, 64587, 
    61930, 59109, 56112, 52942, 49608, 46123, 42504, 38776, 34973, 31141, 
    27333, 23610, 20038, 16680, 13593, 10824, 8415, 6384, 4726, 3415, 2411, 
    1659, 1111, 722, 454, 275, 160, 90, 48, 24, 11, 5, 2, 1),
  c(1e+05, 99241, 99187, 99150, 99122, 99100, 99081, 99062, 99044, 99027, 
    99013, 99000, 98987, 98969, 98938, 98892, 98829, 98749, 98654, 98548, 
    98432, 98307, 98173, 98035, 97896, 97761, 97631, 97505, 97381, 97257, 
    97129, 96998, 96863, 96722, 96574, 96415, 96245, 96063, 95866, 95654, 
    95426, 95180, 94915, 94627, 94316, 93978, 93611, 93214, 92788, 92337, 
    91862, 91361, 90830, 90260, 89644, 88976, 88248, 87457, 86600, 85675, 
    84678, 83605, 82446, 81197, 79853, 78409, 76859, 75195, 73412, 71505, 
    69471, 67300, 64991, 62554, 60005, 57353, 54595, 51726, 48753, 45685, 
    42532, 39310, 36035, 32730, 29421, 26141, 22932, 19837, 16901, 14164, 
    11660, 9414, 7444, 5755, 4342, 3191, 2283, 1589, 1076, 710, 456, 285, 
    172, 101, 57, 31, 16, 8, 4, 2, 1, NA, NA, NA),
  c(1e+05, 99377, 99332, 99302, 99283, 99264, 99248, 99233, 99219, 99206, 
    99194, 99183, 99171, 99157, 99138, 99114, 99084, 99048, 99007, 98964, 
    98920, 98875, 98830, 98783, 98736, 98689, 98640, 98590, 98539, 98485, 
    98427, 98366, 98300, 98229, 98151, 98066, 97974, 97873, 97763, 97642, 
    97511, 97369, 97213, 97045, 96864, 96671, 96464, 96240, 96000, 95741, 
    95463, 95162, 94836, 94481, 94094, 93670, 93205, 92695, 92138, 91529, 
    90865, 90141, 89351, 88492, 87558, 86546, 85448, 84257, 82971, 81591, 
    80113, 78526, 76820, 74994, 73048, 70978, 68769, 66410, 63898, 61233, 
    58414, 55434, 52289, 48990, 45552, 41996, 38346, 34636, 30905, 27201, 
    23579, 20098, 16817, 13789, 11059, 8660, 6614, 4924, 3573, 2526, 1742, 
    1168, 761, 479, 291, 170, 95, 51, 26, 12, 5, 2, 1, NA),
  c(1e+05, 98972, 98896, 98844, 98804, 98771, 98742, 98714, 98688, 98664, 
    98645, 98629, 98613, 98589, 98549, 98487, 98399, 98287, 98157, 98015, 
    97867, 97714, 97556, 97392, 97226, 97056, 96885, 96711, 96534, 96352, 
    96163, 95966, 95762, 95550, 95329, 95098, 94854, 94599, 94333, 94058, 
    93777, 93487, 93186, 92870, 92536, 92178, 91795, 91382, 90936, 90456, 
    89937, 89375, 88766, 88102, 87380, 86593, 85737, 84806, 83794, 82697, 
    81510, 80226, 78841, 77357, 75777, 74103, 72330, 70452, 68465, 66369, 
    64161, 61840, 59405, 56858, 54202, 51444, 48592, 45656, 42652, 39601, 
    36523, 33438, 30369, 27346, 24400, 21560, 18848, 16286, 13893, 11687, 
    9683, 7891, 6317, 4961, 3817, 2874, 2116, 1522, 1070, 735, 494, 323, 
    206, 128, 77, 44, 25, 13, 7, 3, 2, 1, NA, NA),
  c(1e+05, 99185, 99120, 99083, 99053, 99028, 99007, 98987, 98969, 98953, 
    98937, 98922, 98907, 98889, 98866, 98837, 98801, 98757, 98709, 98659, 
    98609, 98560, 98511, 98461, 98410, 98356, 98299, 98240, 98178, 98112, 
    98042, 97969, 97892, 97810, 97723, 97631, 97533, 97428, 97317, 97198, 
    97073, 96939, 96796, 96640, 96468, 96279, 96069, 95838, 95582, 95302, 
    94994, 94656, 94286, 93881, 93439, 92958, 92436, 91869, 91251, 90577, 
    89843, 89043, 88174, 87236, 86234, 85166, 84028, 82812, 81511, 80119, 
    78629, 77031, 75318, 73487, 71538, 69468, 67266, 64923, 62439, 59818, 
    57062, 54168, 51135, 47972, 44694, 41320, 37870, 34374, 30866, 27385, 
    23976, 20687, 17566, 14658, 12001, 9627, 7560, 5808, 4364, 3207, 2306, 
    1619, 1108, 737, 476, 297, 179, 103, 57, 30, 15, 7, 3, 1)
)
colnames(demoUsa) <- c( "age","USSS2007M", "USSS2007F", "USSS2000M", 
                        "USSS2000F","USSS1990M", "USSS1990F")
showNonASCII(demoUsa)

save(demoUsa, file=paste("data","demoUsa.rda", sep="/"))


data("soaLt")
head(soaLt)

iconv(soaLt, from="latin1", to="UTF-8", sub="")

soaLt <- cbind.data.frame(0:110,
  c(1e+07, 9949900.6, 9899801.2, 9849701.8, 9799602.4, 9749503, 9740720, 
    9731937, 9723154, 9714371, 9705588, 9697216.6, 9688845.2, 9680473.8, 
    9672102.4, 9663731, 9654545.2, 9645359.4, 9636173.6, 9626987.8, 
    9617802, 9607896, 9597695, 9587169, 9576288, 9565017, 9553319, 
    9541153, 9528475, 9515235, 9501381, 9486854, 9471591, 9455522, 
    9438571, 9420657, 9401688, 9381566, 9360184, 9337427, 9313166, 
    9287264, 9259571, 9229925, 9198149, 9164051, 9127426, 9088049, 
    9045679, 9000057, 8950901, 8897913, 8840770, 8779128, 8712621, 
    8640861, 8563435, 8479908, 8389826, 8292713, 8188074, 8075403, 
    7954179, 7823879, 7683979, 7533964, 7373338, 7201635, 7018432, 
    6823367, 6616155, 6396609, 6164663, 5920394, 5664051, 5396081, 
    5117152, 4828182, 4530360, 4225163, 3914365, 3600038, 3284542, 
    2970496, 2660734, 2358246, 2066090, 1787299, 1524758, 1281083, 
    1058491, 858676, 682707, 530959, 403072, 297981, 213977, 148832, 
    99965, 64617, 40049, 23705, 13339, 7101, 3558, 1668, 727, 292, 108, 36, 11)             
)
colnames(soaLt) <- c("x", "Ix")

showNonASCII(soaLt)

save(soaLt, file=paste("data","soaLt.rda", sep="/"))



data("AF92Lt")
head(AF92Lt)
AF92Lt2 <- data.frame(x=AF92Lt@x, lx=AF92Lt@lx)
showNonASCII(AF92Lt2)

iconv(AF92Lt2, from="latin1", to="UTF-8", sub="")


AF92Lt3 <- cbind.data.frame(0:110,
      c(1e+05, 99983, 99968, 99954, 99942, 99931, 99920, 99910, 99899, 
        99888, 99878, 99868, 99858, 99848, 99838, 99826, 99815, 99804, 
        99793, 99781, 99769, 99756, 99743, 99730, 99716, 99701, 99686, 
        99669, 99652, 99634, 99615, 99594, 99573, 99550, 99525, 99498, 
        99470, 99439, 99406, 99370, 99331, 99289, 99243, 99193, 99139, 
        99080, 99015, 98945, 98867, 98783, 98690, 98588, 98477, 98354, 
        98220, 98072, 97909, 97730, 97534, 97317, 97079, 96817, 96528, 
        96210, 95861, 95476, 95053, 94587, 94076, 93513, 92895, 92217, 
        91473, 90657, 89762, 88784, 87714, 86545, 85270, 83882, 82372, 
        80733, 78957, 77038, 74969, 72743, 70358, 67809, 65095, 62219, 
        59183, 55996, 52717, 49332, 45863, 42337, 38782, 35231, 31719, 
        28283, 24961, 21787, 18796, 16016, 13472, 11178, 9143, 7376, 
        5856, 4591, 3086)
)
colnames(AF92Lt3) <- c("x", "lx")
showNonASCII(AF92Lt3)
AF92Lt <- AF92Lt3

save(AF92Lt, file=paste("data","AF92Lt.rda", sep="/"))


data("de_angelis_di_falco")
head(de_angelis_di_falco)
iconv(de_angelis_di_falco[[1]], from="latin1", to="UTF-8", sub="")

write.csv(de_angelis_di_falco[[1]], file="de_angelis_di_falco_1.csv", row.names = FALSE)
dadf1 <- read.csv("de_angelis_di_falco_1.csv")
iconv(dadf1, from="latin1", to="UTF-8", sub="")
spedygiorgio/lifecontingencies documentation built on March 21, 2021, 5:36 a.m.