From fperickson at wisc.edu Tue May 5 22:49:12 2015 From: fperickson at wisc.edu (Frank Erickson) Date: Tue, 5 May 2015 16:49:12 -0400 Subject: [datatable-help] dt[, 0, with=FALSE] doesn't return an empty data.table Message-ID: Hi, In answering this question http://stackoverflow.com/q/30062012/1191259 ...I noticed that * df[,0] gives an empty data.frame, but * dt[,0,with=FALSE] does not give an empty data.table. Should it? I switched to using `[.listof`(dt,0), which gives my expected result. Best, Frank -------------- next part -------------- An HTML attachment was scrubbed... URL: From aragorn168b at gmail.com Tue May 5 23:01:11 2015 From: aragorn168b at gmail.com (Arunkumar Srinivasan) Date: Tue, 5 May 2015 23:01:11 +0200 Subject: [datatable-help] dt[, 0, =?utf-8?Q?with=3DFALSE=5D_?=doesn't return an empty data.table In-Reply-To: References: Message-ID: Frank, for consistency, I think it should. --? Arun On 5 May 2015 at 22:49:41, Frank Erickson (fperickson at wisc.edu) wrote: Hi, In answering this question? http://stackoverflow.com/q/30062012/1191259? ...I noticed that * df[,0] gives an empty data.frame, but * dt[,0,with=FALSE] does not give an empty data.table. Should it? I switched to using `[.listof`(dt,0), which gives my expected result. Best, Frank _______________________________________________ datatable-help mailing list datatable-help at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help -------------- next part -------------- An HTML attachment was scrubbed... URL: From fperickson at wisc.edu Tue May 5 23:55:47 2015 From: fperickson at wisc.edu (Frank Erickson) Date: Tue, 5 May 2015 17:55:47 -0400 Subject: [datatable-help] dt[, 0, with=FALSE] doesn't return an empty data.table In-Reply-To: References: Message-ID: Okay, thanks. Shall I submit it then? (I haven't used the github since y'all moved to it.) On Tue, May 5, 2015 at 5:01 PM, Arunkumar Srinivasan wrote: > Frank, for consistency, I think it should. > > -- > Arun > > On 5 May 2015 at 22:49:41, Frank Erickson (fperickson at wisc.edu) wrote: > > Hi, > > In answering this question > http://stackoverflow.com/q/30062012/1191259 > > ...I noticed that > * df[,0] gives an empty data.frame, but > * dt[,0,with=FALSE] does not give an empty data.table. > > Should it? I switched to using `[.listof`(dt,0), which gives my expected > result. > > Best, > > Frank > _______________________________________________ > datatable-help mailing list > datatable-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > > > _______________________________________________ > datatable-help mailing list > datatable-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aragorn168b at gmail.com Wed May 6 12:36:55 2015 From: aragorn168b at gmail.com (Arunkumar Srinivasan) Date: Wed, 6 May 2015 12:36:55 +0200 Subject: [datatable-help] dt[, 0, =?utf-8?Q?with=3DFALSE=5D_?=doesn't return an empty data.table In-Reply-To: References: Message-ID: Frank, yes please :-). --? Arun On 5 May 2015 at 23:56:08, Frank Erickson (fperickson at wisc.edu) wrote: Okay, thanks. Shall I submit it then? (I haven't used the github since y'all moved to it.) On Tue, May 5, 2015 at 5:01 PM, Arunkumar Srinivasan wrote: Frank, for consistency, I think it should. --? Arun On 5 May 2015 at 22:49:41, Frank Erickson (fperickson at wisc.edu) wrote: Hi, In answering this question? http://stackoverflow.com/q/30062012/1191259? ...I noticed that * df[,0] gives an empty data.frame, but * dt[,0,with=FALSE] does not give an empty data.table. Should it? I switched to using `[.listof`(dt,0), which gives my expected result. Best, Frank _______________________________________________ datatable-help mailing list datatable-help at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help _______________________________________________ datatable-help mailing list datatable-help at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help -------------- next part -------------- An HTML attachment was scrubbed... URL: From gerald.jean at dgag.ca Thu May 14 16:04:17 2015 From: gerald.jean at dgag.ca (Gerald Jean) Date: Thu, 14 May 2015 14:04:17 +0000 Subject: [datatable-help] Can you explain what is going on??? Message-ID: <7889EDA06EB6454D92349FFF17BF790F4BE3AE04@PWPRIMX72.mvt.desjardins.com> Hello, the following code is extracted from a function where roughly 150 variables of a large data set are transformed using data.table. The variable "membre" was coming out with one missing value, in trying to understand why, I extracted the code from the function, added a few "cat" statements and ran it directly in the terminal. ttt.test.sima[, ":=" (membre = {## + cat(" Processing: membre", sep = "\n") + ttt <- membre + cat(paste(" Class ttt = ", class(ttt), sep = ""), sep = "\n") + cat(paste(" Length ttt = ", length(ttt), sep = ""), sep = "\n") + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = "\n") + ttt[ttt == "0"] <- "O" ## A few capital "O" are coded as zero "0". + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = "\n") + ttt <- ifelse(PROV != " QC", " OAO", + ifelse(membre == "", " Ma ", membre)) + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = "\n") + merge.levels(factor(ttt, levels = c("O", "N", " Ma ", " OAO"), + labels = c(" Oui", " Non", " Ma ", " OAO")), + k = list(" Oui" = c(" Oui", " OAO")))})] Processing: membre Class ttt = character Length ttt = 4750880 sum(ttt == 0) = 2 sum(ttt == 0) = 0 sum(ttt == 0) = 1 I don't understand why after the ? ifelse? statement the temporary variable ? ttt? is back with a single ? 0 (zero)? in it, resulting of course in the missing value of the factor created from it. Thanks for your support, G?rald [cid:image001.gif at 01D08E2D.142361C0] Gerald Jean, M. Sc. en statistiques Conseiller senior en statistiques Actuariat corporatif, Mod?lisation et Recherche Assurance de dommages Mouvement Desjardins L?vis (si?ge social) 418 835-4900, poste 5527639 1 877 835-4900, poste 5527639 T?l?copieur : 418 835-6657 Faites bonne impression et imprimez seulement au besoin! Ce courriel est confidentiel, peut ?tre prot?g? par le secret professionnel et est adress? exclusivement au destinataire. Il est strictement interdit ? toute autre personne de diffuser, distribuer ou reproduire ce message. Si vous l'avez re?u par erreur, veuillez imm?diatement le d?truire et aviser l'exp?diteur. Merci. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: image/gif Size: 6632 bytes Desc: image001.gif URL: From fperickson at wisc.edu Thu May 14 19:18:36 2015 From: fperickson at wisc.edu (Frank Erickson) Date: Thu, 14 May 2015 13:18:36 -0400 Subject: [datatable-help] Can you explain what is going on??? In-Reply-To: <7889EDA06EB6454D92349FFF17BF790F4BE3AE04@PWPRIMX72.mvt.desjardins.com> References: <7889EDA06EB6454D92349FFF17BF790F4BE3AE04@PWPRIMX72.mvt.desjardins.com> Message-ID: Hi G?rald, Your question is not really data.table specific, I think. Your ttt[ttt == "0"] <- "O" does not affect the result because you overwrite with ttt <- ifelse(... immediately afterwards. Maybe you meant to have ttt on the right-hand side of the latter command, instead of membre. --Frank On Thu, May 14, 2015 at 10:04 AM, Gerald Jean wrote: > Hello, > > > > the following code is extracted from a function where roughly 150 > variables of a large data set are transformed using data.table. > > > > The variable ?membre? was coming out with one missing value, in trying to > understand why, I extracted the code from the function, added a few ?cat? > statements and ran it directly in the terminal. > > > > ttt.test.sima[, ":=" (membre = {## > > + cat(" Processing: membre", sep = "\n") > > + ttt <- membre > > + cat(paste(" Class ttt = ", class(ttt), sep = ""), sep = "\n") > > + cat(paste(" Length ttt = ", length(ttt), sep = ""), sep = "\n") > > + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = > "\n") > > + ttt[ttt == "0"] <- "O" ## A few capital ?O? are coded as zero ?0?. > > + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = > "\n") > > + ttt <- ifelse(PROV != " QC", " OAO", > > + ifelse(membre == "", " Ma ", membre)) > > + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = > "\n") > > + merge.levels(factor(ttt, levels = c("O", "N", " Ma ", " OAO"), > > + labels = c(" Oui", " Non", " Ma ", " OAO")), > > + k = list(" Oui" = c(" Oui", " OAO")))})] > > Processing: membre > > Class ttt = character > > Length ttt = 4750880 > > sum(ttt == 0) = 2 > > sum(ttt == 0) = 0 > > sum(ttt == 0) = 1 > > > > I don?t understand why after the ? ifelse? statement the temporary > variable ? ttt? is back with a single ? 0 (zero)? in it, resulting of > course in the missing value of the factor created from it. > > > > Thanks for your support, > > > > G?rald > > > > *Gerald Jean, M. Sc. en statistiques* > Conseiller senior en statistiques > > Actuariat corporatif, > Mod?lisation et Recherche > Assurance de dommages > Mouvement Desjardins > > > L?vis (si?ge social) > > 418 835-4900, > > poste 5527639 > 1 877 835-4900, > > poste 5527639 > T?l?copieur : 418 835-6657 > > > > > > > > Faites bonne impression et imprimez seulement au besoin! > > Ce courriel est confidentiel, peut ?tre prot?g? par le secret > professionnel et est adress? exclusivement au destinataire. Il est > strictement interdit ? toute autre personne de diffuser, distribuer ou > reproduire ce message. Si vous l'avez re?u par erreur, veuillez > imm?diatement le d?truire et aviser l'exp?diteur. Merci. > > > > > > _______________________________________________ > datatable-help mailing list > datatable-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: image/gif Size: 6632 bytes Desc: not available URL: From gerald.jean at dgag.ca Thu May 14 20:45:09 2015 From: gerald.jean at dgag.ca (Gerald Jean) Date: Thu, 14 May 2015 18:45:09 +0000 Subject: [datatable-help] Can you explain what is going on??? In-Reply-To: References: <7889EDA06EB6454D92349FFF17BF790F4BE3AE04@PWPRIMX72.mvt.desjardins.com> Message-ID: <7889EDA06EB6454D92349FFF17BF790F4BE3B327@PWPRIMX72.mvt.desjardins.com> Hello, thanks Frank, you were right. I am converting roughly 2000 lines of code using data.frames to the data.table way, this one skipped me!!! By the way, on this data set, 4750880 observations, the processing time went from 1hr.45 to 12.5 minutes. If we could parallelize this it would run under a minute, I have 24 processors on the server where that runs. Thanks again, G?rald [cid:image001.gif at 01D08E54.6EF8F1B0] Gerald Jean, M. Sc. en statistiques Conseiller senior en statistiques Actuariat corporatif, Mod?lisation et Recherche Assurance de dommages Mouvement Desjardins L?vis (si?ge social) 418 835-4900, poste 5527639 1 877 835-4900, poste 5527639 T?l?copieur : 418 835-6657 Faites bonne impression et imprimez seulement au besoin! Ce courriel est confidentiel, peut ?tre prot?g? par le secret professionnel et est adress? exclusivement au destinataire. Il est strictement interdit ? toute autre personne de diffuser, distribuer ou reproduire ce message. Si vous l'avez re?u par erreur, veuillez imm?diatement le d?truire et aviser l'exp?diteur. Merci. De : by.hook.or at gmail.com [mailto:by.hook.or at gmail.com] De la part de Frank Erickson Envoy? : 14 mai 2015 13:19 ? : Gerald Jean Cc : datatable-help at lists.r-forge.r-project.org Objet : Re: [datatable-help] Can you explain what is going on??? Hi G?rald, Your question is not really data.table specific, I think. Your ttt[ttt == "0"] <- "O" does not affect the result because you overwrite with ttt <- ifelse(... immediately afterwards. Maybe you meant to have ttt on the right-hand side of the latter command, instead of membre. --Frank On Thu, May 14, 2015 at 10:04 AM, Gerald Jean > wrote: Hello, the following code is extracted from a function where roughly 150 variables of a large data set are transformed using data.table. The variable ?membre? was coming out with one missing value, in trying to understand why, I extracted the code from the function, added a few ?cat? statements and ran it directly in the terminal. ttt.test.sima[, ":=" (membre = {## + cat(" Processing: membre", sep = "\n") + ttt <- membre + cat(paste(" Class ttt = ", class(ttt), sep = ""), sep = "\n") + cat(paste(" Length ttt = ", length(ttt), sep = ""), sep = "\n") + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = "\n") + ttt[ttt == "0"] <- "O" ## A few capital ?O? are coded as zero ?0?. + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = "\n") + ttt <- ifelse(PROV != " QC", " OAO", + ifelse(membre == "", " Ma ", membre)) + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = "\n") + merge.levels(factor(ttt, levels = c("O", "N", " Ma ", " OAO"), + labels = c(" Oui", " Non", " Ma ", " OAO")), + k = list(" Oui" = c(" Oui", " OAO")))})] Processing: membre Class ttt = character Length ttt = 4750880 sum(ttt == 0) = 2 sum(ttt == 0) = 0 sum(ttt == 0) = 1 I don?t understand why after the ? ifelse? statement the temporary variable ? ttt? is back with a single ? 0 (zero)? in it, resulting of course in the missing value of the factor created from it. Thanks for your support, G?rald [cid:image001.gif at 01D08E54.6EF8F1B0] Gerald Jean, M. Sc. en statistiques Conseiller senior en statistiques Actuariat corporatif, Mod?lisation et Recherche Assurance de dommages Mouvement Desjardins L?vis (si?ge social) 418 835-4900, poste 5527639 1 877 835-4900, poste 5527639 T?l?copieur : 418 835-6657 Faites bonne impression et imprimez seulement au besoin! Ce courriel est confidentiel, peut ?tre prot?g? par le secret professionnel et est adress? exclusivement au destinataire. Il est strictement interdit ? toute autre personne de diffuser, distribuer ou reproduire ce message. Si vous l'avez re?u par erreur, veuillez imm?diatement le d?truire et aviser l'exp?diteur. Merci. _______________________________________________ datatable-help mailing list datatable-help at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: image/gif Size: 6632 bytes Desc: image001.gif URL: From gleynes+r at gmail.com Fri May 22 22:51:49 2015 From: gleynes+r at gmail.com (Gene Leynes) Date: Fri, 22 May 2015 15:51:49 -0500 Subject: [datatable-help] Can you explain what is going on??? In-Reply-To: <7889EDA06EB6454D92349FFF17BF790F4BE3B327@PWPRIMX72.mvt.desjardins.com> References: <7889EDA06EB6454D92349FFF17BF790F4BE3AE04@PWPRIMX72.mvt.desjardins.com> <7889EDA06EB6454D92349FFF17BF790F4BE3B327@PWPRIMX72.mvt.desjardins.com> Message-ID: Sorry for the off topic question, but what is "merge.levels"? That looks potentially useful. On Thu, May 14, 2015 at 1:45 PM, Gerald Jean wrote: > Hello, > > > > thanks Frank, you were right. I am converting roughly 2000 lines of code > using data.frames to the data.table way, this one skipped me!!! By the > way, on this data set, 4750880 observations, the processing time went from > 1hr.45 to 12.5 minutes. If we could parallelize this it would run under a > minute, I have 24 processors on the server where that runs. > > > > Thanks again, > > > > G?rald > > > > *Gerald Jean, M. Sc. en statistiques* > Conseiller senior en statistiques > > Actuariat corporatif, > Mod?lisation et Recherche > Assurance de dommages > Mouvement Desjardins > > > L?vis (si?ge social) > > 418 835-4900, > > poste 5527639 > 1 877 835-4900, > > poste 5527639 > T?l?copieur : 418 835-6657 > > > > > > > > Faites bonne impression et imprimez seulement au besoin! > > Ce courriel est confidentiel, peut ?tre prot?g? par le secret > professionnel et est adress? exclusivement au destinataire. Il est > strictement interdit ? toute autre personne de diffuser, distribuer ou > reproduire ce message. Si vous l'avez re?u par erreur, veuillez > imm?diatement le d?truire et aviser l'exp?diteur. Merci. > > > > > > *De :* by.hook.or at gmail.com [mailto:by.hook.or at gmail.com] *De la part de* > Frank Erickson > *Envoy? :* 14 mai 2015 13:19 > *? :* Gerald Jean > *Cc :* datatable-help at lists.r-forge.r-project.org > *Objet :* Re: [datatable-help] Can you explain what is going on??? > > > > Hi G?rald, > > > > Your question is not really data.table specific, I think. Your > > ttt[ttt == "0"] <- "O" > > does not affect the result because you overwrite with > > ttt <- ifelse(... > > immediately afterwards. Maybe you meant to have ttt on the right-hand side > of the latter command, instead of membre. > > > > --Frank > > > > > > On Thu, May 14, 2015 at 10:04 AM, Gerald Jean wrote: > > Hello, > > > > the following code is extracted from a function where roughly 150 > variables of a large data set are transformed using data.table. > > > > The variable ?membre? was coming out with one missing value, in trying to > understand why, I extracted the code from the function, added a few ?cat? > statements and ran it directly in the terminal. > > > > ttt.test.sima[, ":=" (membre = {## > > + cat(" Processing: membre", sep = "\n") > > + ttt <- membre > > + cat(paste(" Class ttt = ", class(ttt), sep = ""), sep = "\n") > > + cat(paste(" Length ttt = ", length(ttt), sep = ""), sep = "\n") > > + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = > "\n") > > + ttt[ttt == "0"] <- "O" ## A few capital ?O? are coded as zero ?0?. > > + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = > "\n") > > + ttt <- ifelse(PROV != " QC", " OAO", > > + ifelse(membre == "", " Ma ", membre)) > > + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = > "\n") > > + merge.levels(factor(ttt, levels = c("O", "N", " Ma ", " OAO"), > > + labels = c(" Oui", " Non", " Ma ", " OAO")), > > + k = list(" Oui" = c(" Oui", " OAO")))})] > > Processing: membre > > Class ttt = character > > Length ttt = 4750880 > > sum(ttt == 0) = 2 > > sum(ttt == 0) = 0 > > sum(ttt == 0) = 1 > > > > I don?t understand why after the ? ifelse? statement the temporary > variable ? ttt? is back with a single ? 0 (zero)? in it, resulting of > course in the missing value of the factor created from it. > > > > Thanks for your support, > > > > G?rald > > > > *Gerald Jean, M. Sc. en statistiques* > Conseiller senior en statistiques > > Actuariat corporatif, > Mod?lisation et Recherche > Assurance de dommages > Mouvement Desjardins > > > L?vis (si?ge social) > > 418 835-4900, > > poste 5527639 > 1 877 835-4900, > > poste 5527639 > T?l?copieur : 418 835-6657 > > > > > > > Faites bonne impression et imprimez seulement au besoin! > > Ce courriel est confidentiel, peut ?tre prot?g? par le secret > professionnel et est adress? exclusivement au destinataire. Il est > strictement interdit ? toute autre personne de diffuser, distribuer ou > reproduire ce message. Si vous l'avez re?u par erreur, veuillez > imm?diatement le d?truire et aviser l'exp?diteur. Merci. > > > > > > > _______________________________________________ > datatable-help mailing list > datatable-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > > > > _______________________________________________ > datatable-help mailing list > datatable-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: image/gif Size: 6632 bytes Desc: not available URL: From gerald.jean at dgag.ca Mon May 25 13:47:09 2015 From: gerald.jean at dgag.ca (Gerald Jean) Date: Mon, 25 May 2015 11:47:09 +0000 Subject: [datatable-help] Can you explain what is going on??? In-Reply-To: References: <7889EDA06EB6454D92349FFF17BF790F4BE3AE04@PWPRIMX72.mvt.desjardins.com> <7889EDA06EB6454D92349FFF17BF790F4BE3B327@PWPRIMX72.mvt.desjardins.com> Message-ID: <7889EDA06EB6454D92349FFF17BF790F4BE3B940@PWPRIMX72.mvt.desjardins.com> Hello, maybe I shouldn?t have put that function in there, it is ? stolen? from Splus, it just merges factor levels as specified by the arguments, levels not specified remains the same. I use it all the time!!! G?rald [cid:image001.gif at 01D096BE.BE56DA20] Gerald Jean, M. Sc. en statistiques Conseiller senior en statistiques Actuariat corporatif, Mod?lisation et Recherche Assurance de dommages Mouvement Desjardins L?vis (si?ge social) 418 835-4900, poste 5527639 1 877 835-4900, poste 5527639 T?l?copieur : 418 835-6657 Faites bonne impression et imprimez seulement au besoin! Ce courriel est confidentiel, peut ?tre prot?g? par le secret professionnel et est adress? exclusivement au destinataire. Il est strictement interdit ? toute autre personne de diffuser, distribuer ou reproduire ce message. Si vous l'avez re?u par erreur, veuillez imm?diatement le d?truire et aviser l'exp?diteur. Merci. De : gleynes at gmail.com [mailto:gleynes at gmail.com] De la part de Gene Leynes Envoy? : 22 mai 2015 16:52 ? : Gerald Jean Cc : Frank Erickson; datatable-help at lists.r-forge.r-project.org Objet : Re: [datatable-help] Can you explain what is going on??? Sorry for the off topic question, but what is "merge.levels"? That looks potentially useful. On Thu, May 14, 2015 at 1:45 PM, Gerald Jean > wrote: Hello, thanks Frank, you were right. I am converting roughly 2000 lines of code using data.frames to the data.table way, this one skipped me!!! By the way, on this data set, 4750880 observations, the processing time went from 1hr.45 to 12.5 minutes. If we could parallelize this it would run under a minute, I have 24 processors on the server where that runs. Thanks again, G?rald [cid:image001.gif at 01D096BE.BE56DA20] Gerald Jean, M. Sc. en statistiques Conseiller senior en statistiques Actuariat corporatif, Mod?lisation et Recherche Assurance de dommages Mouvement Desjardins L?vis (si?ge social) 418 835-4900, poste 5527639 1 877 835-4900, poste 5527639 T?l?copieur : 418 835-6657 Faites bonne impression et imprimez seulement au besoin! Ce courriel est confidentiel, peut ?tre prot?g? par le secret professionnel et est adress? exclusivement au destinataire. Il est strictement interdit ? toute autre personne de diffuser, distribuer ou reproduire ce message. Si vous l'avez re?u par erreur, veuillez imm?diatement le d?truire et aviser l'exp?diteur. Merci. De : by.hook.or at gmail.com [mailto:by.hook.or at gmail.com] De la part de Frank Erickson Envoy? : 14 mai 2015 13:19 ? : Gerald Jean Cc : datatable-help at lists.r-forge.r-project.org Objet : Re: [datatable-help] Can you explain what is going on??? Hi G?rald, Your question is not really data.table specific, I think. Your ttt[ttt == "0"] <- "O" does not affect the result because you overwrite with ttt <- ifelse(... immediately afterwards. Maybe you meant to have ttt on the right-hand side of the latter command, instead of membre. --Frank On Thu, May 14, 2015 at 10:04 AM, Gerald Jean > wrote: Hello, the following code is extracted from a function where roughly 150 variables of a large data set are transformed using data.table. The variable ?membre? was coming out with one missing value, in trying to understand why, I extracted the code from the function, added a few ?cat? statements and ran it directly in the terminal. ttt.test.sima[, ":=" (membre = {## + cat(" Processing: membre", sep = "\n") + ttt <- membre + cat(paste(" Class ttt = ", class(ttt), sep = ""), sep = "\n") + cat(paste(" Length ttt = ", length(ttt), sep = ""), sep = "\n") + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = "\n") + ttt[ttt == "0"] <- "O" ## A few capital ?O? are coded as zero ?0?. + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = "\n") + ttt <- ifelse(PROV != " QC", " OAO", + ifelse(membre == "", " Ma ", membre)) + cat(paste(" sum(ttt == 0) = ", sum(ttt == "0"), sep = ""), sep = "\n") + merge.levels(factor(ttt, levels = c("O", "N", " Ma ", " OAO"), + labels = c(" Oui", " Non", " Ma ", " OAO")), + k = list(" Oui" = c(" Oui", " OAO")))})] Processing: membre Class ttt = character Length ttt = 4750880 sum(ttt == 0) = 2 sum(ttt == 0) = 0 sum(ttt == 0) = 1 I don?t understand why after the ? ifelse? statement the temporary variable ? ttt? is back with a single ? 0 (zero)? in it, resulting of course in the missing value of the factor created from it. Thanks for your support, G?rald [cid:image001.gif at 01D096BE.BE56DA20] Gerald Jean, M. Sc. en statistiques Conseiller senior en statistiques Actuariat corporatif, Mod?lisation et Recherche Assurance de dommages Mouvement Desjardins L?vis (si?ge social) 418 835-4900, poste 5527639 1 877 835-4900, poste 5527639 T?l?copieur : 418 835-6657 Faites bonne impression et imprimez seulement au besoin! Ce courriel est confidentiel, peut ?tre prot?g? par le secret professionnel et est adress? exclusivement au destinataire. Il est strictement interdit ? toute autre personne de diffuser, distribuer ou reproduire ce message. Si vous l'avez re?u par erreur, veuillez imm?diatement le d?truire et aviser l'exp?diteur. Merci. _______________________________________________ datatable-help mailing list datatable-help at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help _______________________________________________ datatable-help mailing list datatable-help at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: image/gif Size: 6632 bytes Desc: image001.gif URL: From bluehonour at yahoo.com Tue May 26 13:16:14 2015 From: bluehonour at yahoo.com (blue honour) Date: Tue, 26 May 2015 04:16:14 -0700 Subject: [datatable-help] Maintaining key after a join operation Message-ID: <1432638974.9900.YahooMailIosMobile@web121704.mail.ne1.yahoo.com> An HTML attachment was scrubbed... URL: From bluehonour at yahoo.com Tue May 26 15:50:49 2015 From: bluehonour at yahoo.com (blue honour) Date: Tue, 26 May 2015 06:50:49 -0700 Subject: [datatable-help] When do we need J() ? Message-ID: <1432648249.12250.YahooMailIosMobile@web121706.mail.ne1.yahoo.com> An HTML attachment was scrubbed... URL: