You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: NEWS.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,8 @@
105
105
106
106
17. `t1 - t2`, where one is an `IDate` and the other is a `Date`, are now consistent with the case where both are `IDate` or both are `Date`, [#4749](https://github.com/Rdatatable/data.table/issues/4749). Thanks @George9000 for the report and @MichaelChirico for the fix.
107
107
108
+
18. `fwrite` now allows `dec` to be the same as `sep` for edge cases where only one will be written, e.g. 0-row or 1-column tables. [#7227](https://github.com/Rdatatable/data.table/issues/7227). Thanks @MichaelChirico for the report and @venom1204 for the fix.
109
+
108
110
### NOTES
109
111
110
112
1. The following in-progress deprecations have proceeded:
stopf("You have wrapped := with {} which is ok but then := must be the only thing inside {}. You have something else inside {} as well. Consider placing the {} on the RHS of := instead; e.g. DT[,someCol:={tmpVar1<-...;tmpVar2<-...;tmpVar1*tmpVar2}]")
315
+
stopf("Invalid use of `:=` inside `{}`. `:=` must be the only expression inside `{}` when used in `j`. Instead of: DT[{tmp1 <- ...; tmp2 <- ...; someCol := tmp1 * tmp2}], Use: DT[,someCol := {tmp1 <- ...; tmp2 <- ...; tmp1 * tmp2}]")
316
316
}
317
317
}
318
318
if (root=="eval"&&!any(all.vars(jsub[[2L]]) %chin% names_x)) {
# this error is detected when eval'ing isub and replaced with a more helpful one when using := in i due to forgetting a comma, #4227
2887
-
stopf('Check that is.data.table(DT) == TRUE. Otherwise, :=, `:=`(...) and let(...) are defined for use in j, once only and in particular ways. Note that namespace-qualification like data.table::`:=`(...) is not supported. See help(":=").', class="dt_invalid_let_error")
2887
+
stopf('Check that is.data.table(DT) == TRUE. Otherwise, `:=` is defined for use in j, once only and in particular ways. See help(":=", "data.table"). A common reason for this error is allocating a new column in `j` and using `<-` instead of `:=`; e.g., `DT[, new_col <- 1]` should be `DT[, new_col := 1]`. Another is using `:=` in a multi-statement `{...}` block; please use `:=` as the only statement in `j`.', class="dt_invalid_let_error")
dec!=sep, # sep2!=dec and sep2!=sep checked at C level when we know if list columns are present
48
+
`dec and sep must be distinct whenever both might be needed`= (!NROW(x) || NCOL(x) <=1L||dec!=sep), # sep2!=dec and sep2!=sep checked at C level when we know if list columns are present
\code{fwrite} beganasacommunitycontributionwith \href{https://github.com/Rdatatable/data.table/pull/1613}{pullrequest#1613} by Otto Seiskari. This gave Matt Dowle the impetus to specialize the numeric formatting and to parallelize: \url{https://h2o.ai/blog/2016/fast-csv-writing-for-r/}. Final items were tracked in \href{https://github.com/Rdatatable/data.table/issues/1664}{issue #1664} such as automatic quoting, \code{bit64::integer64} support, decimal/scientific formatting exactly matching \code{write.csv} between 2.225074e-308 and 1.797693e+308 to 15 significant figures, \code{row.names}, dates (between 0000-03-01 and 9999-12-31), times and \code{sep2} for \code{list} columns where each cell can itself be a vector.
SEXPRCHK; // a 2 item list holding vars (result of checkVars) and not_NA_indices. PROTECTed up in fmelt so that preprocess() doesn't need to PROTECT. To pass rchk, #2865
284
-
SEXPidcols,// convenience pointers into RCHK[0][0], RCHK[0][1] and RCHK[1] respectively
285
-
variable_table,// NULL or data for variable column(s).
286
-
valuecols,// list with one element per output/value column, each element is an integer vector.
287
-
not_NA_indices;
288
-
int*isfactor,
289
-
*leach,// length of each element of the valuecols(measure.vars) list.
290
-
*isidentical; // are all inputs for this value column the same type?
291
-
intlids,// number of id columns.
292
-
lvars,// number of variable columns.
293
-
lvalues,// number of value columns.
294
-
lmax,// max length of valuecols elements / number of times to repeat ids.
295
-
totlen,// of output/long DT result of melt operation.
296
-
nrow; // of input/wide DT to be melted.
285
+
SEXPRCHK; // a 2 item list holding vars (result of checkVars) and not_NA_indices. PROTECTed up in fmelt so that preprocess() doesn't need to PROTECT. To pass rchk, #2865
286
+
SEXPidcols; // convenience pointers into RCHK[0][0], RCHK[0][1] and RCHK[1] respectively
287
+
SEXPvariable_table;// NULL or data for variable column(s).
288
+
SEXPvaluecols; // list with one element per output/value column, each element is an integer vector.
289
+
SEXPnot_NA_indices;
290
+
int*isfactor;
291
+
int*leach; // length of each element of the valuecols(measure.vars) list.
292
+
int*isidentical;// are all inputs for this value column the same type?
293
+
intlids; // number of id columns.
294
+
intlvars; // number of variable columns.
295
+
intlvalues; // number of value columns.
296
+
intlmax; // max length of valuecols elements / number of times to repeat ids.
297
+
inttotlen; // of output/long DT result of melt operation.
Copy file name to clipboardExpand all lines: src/frank.c
+15-11Lines changed: 15 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -3,22 +3,26 @@
3
3
// #include <signal.h> // the debugging machinery + breakpoint aidee
4
4
// raise(SIGINT);
5
5
6
-
SEXPdt_na(SEXPx, SEXPcols) {
7
-
intn=0, elem;
8
-
6
+
SEXPdt_na(SEXPx, SEXPcols)
7
+
{
9
8
if (!isNewList(x)) internal_error(__func__, "Argument '%s' to %s is type '%s' not '%s'", "x", "Cdt_na", type2char(TYPEOF(x)), "list"); // # nocov
10
9
if (!isInteger(cols)) internal_error(__func__, "Argument '%s' to %s is type '%s' not '%s'", "cols", "Cdt_na", type2char(TYPEOF(cols)), "integer"); // # nocov
11
-
for (inti=0; i<LENGTH(cols); ++i) {
12
-
elem=INTEGER(cols)[i];
13
-
if (elem<1||elem>LENGTH(x))
14
-
error(_("Item %d of 'cols' is %d which is outside 1-based range [1,ncol(x)=%d]"), i+1, elem, LENGTH(x));
15
-
if (!n) n=length(VECTOR_ELT(x, elem-1));
10
+
11
+
intn=0;
12
+
constintnumCols=LENGTH(cols);
13
+
constint*col_ints=INTEGER_RO(cols);
14
+
for (inti=0; i<numCols; i++) {
15
+
constintelem=col_ints[i];
16
+
if (elem<1||elem>LENGTH(x))
17
+
error(_("Item %d of 'cols' is %d which is outside 1-based range [1,ncol(x)=%d]"), i+1, elem, LENGTH(x));
18
+
if (!n) n=length(VECTOR_ELT(x, elem-1));
16
19
}
17
20
SEXPans=PROTECT(allocVector(LGLSXP, n));
18
21
int*ians=LOGICAL(ans);
19
-
for (inti=0; i<n; ++i) ians[i]=0;
20
-
for (inti=0; i<LENGTH(cols); ++i) {
21
-
SEXPv=VECTOR_ELT(x, INTEGER(cols)[i]-1);
22
+
memset(ians, 0, n*sizeof(int));
23
+
24
+
for (inti=0; i<numCols; i++) {
25
+
SEXPv=VECTOR_ELT(x, col_ints[i]-1);
22
26
if (!length(v) ||isList(v)) continue; // like stats:::na.omit.data.frame, skip pairlist columns
23
27
if (n!=length(v))
24
28
error(_("Column %d of input list x is length %d, inconsistent with first column of that item which is length %d."), i+1,length(v),n);
0 commit comments