sparsevctrs 0.4.0
CRAN release: 2026-11-01
Improvements
coerce_to_sparse_data_frame()now also takes data frames and tibbles, turning each integer, double, logical, or character column into a sparse vector of the same type. (#126)coerce_to_sparse_data_frame()andcoerce_to_sparse_tibble()are now much faster. (#66)sparse_addition_scalar(),sparse_division_scalar(),sparse_multiplication_scalar()andsparse_subtraction_scalar()are now faster. (#88, #147)sparse_dummy()is now faster, especially for factors with missing values and many levels. (#81)sparse_multiplication()is now much faster when the result has many stored values, since sorting them no longer takes quadratic time. With one million stored values on each side it now takes milliseconds instead of minutes. (#140)sparse_replace_na()now works with sparse logical vectors. (#136)
Bug Fixes
coerce_to_sparse_data_frame()andcoerce_to_sparse_tibble()now give an error when a sparse matrix containsNaNor infinite values, as they already do for data frames, instead of creating sparse vectors that breakmin()andmax(). (#156)coerce_to_sparse_data_frame()andcoerce_to_sparse_tibble()now work with logical sparse matrices, giving sparse double columns, instead of failing with an error aboutREAL(). (#162)is.unsorted()now compares the contents of strings, not string pointers, for sparse character vectors. It also takes default values after the last non-default value into account. (#131)is.unsorted()now takes default values after the last non-default value into account for sparse integer, double, and logical vectors, and compares a single non-default value against the default. (#133)min()andmax()now ignore the default value of sparse integer and double vectors when every position is a non-default value. (#132)min()andmax()withna.rm = TRUEnow returnInfand-Infwith a warning for sparse integer and double vectors with no non-missing values, as dense vectors do. (#159)sparse_addition_scalar(),sparse_multiplication_scalar()andsparse_subtraction_scalar()now give an error whenxis not a sparse integer or double vector, instead of failing with an object not found error. (#136)sparse_addition_scalar(),sparse_multiplication_scalar()andsparse_subtraction_scalar()now always give an error whenxis a sparse integer vector andvalis not a whole number, instead of only when a result is not a whole number. (#161)sparse_addition_scalar(),sparse_division_scalar(),sparse_multiplication_scalar()andsparse_subtraction_scalar()now returnNaNinstead ofNAwhenvalisNaN, and no longer store values that are equal to the new default value after underflow or rounding. (#161)sparse_addition_scalar(),sparse_multiplication_scalar()andsparse_subtraction_scalar()now returnNAwith a warning, as dense integer vectors do, when a stored value of a sparse integer vector overflows, instead of failing with an error. (#88)sparse_division_scalar()andsparse_multiplication_scalar()now also scale the default value of the sparse vector, so they give the right result when the default is not zero. (#141)sparse_division_scalar()now gives an error whenxis not a sparse integer or double vector, instead of silently accepting sparse logical vectors. (#88)sparse_division_scalar()now gives the same result as dense division whenvalis 0, with-Inffor negative values,NaNfor zeros andNAfor missing values, instead ofInfeverywhere. (#146)sparse_double()now gives an error whendefaultisNaN,Infor-Inf, since they madesum()returnNaN. (#160)sparse_dummy()now returns missing values for missing elements of a factor with a single level andone_hot = TRUE, instead of 1. (#155)sparse_mean()andsparse_median()now returnNaNandNArespectively for length-0 vectors, instead of the default. (#158)sparse_mean(),sparse_var()andsparse_sd()now work for sparse integer vectors with a large default and length, instead of returningNAwith an overflow warning. (#157)sparse_mean()withwtssumming to zero now returnsNaN, asweighted.mean()does. (#157)sparse_multiplication()now works when one of two sparse inputs has no stored values. (#137)sparse_multiplication()no longer returns duplicated positions when a sparse double vector with a storedNAis multiplied by a dense double vector with a fractional value at the same position. (#139)sparse_multiplication()now returnsNAwith a warning, as dense integer vectors do, when the product of two integers overflows, instead of silently wrapping around. This also affectssparse_mean()with integer weights. (#150)sparse_multiplication()now returnsNaNwhere a sparse vector has its default value of 0 and the dense vector hasInf,-InforNaN, since0 * InfisNaN. Previously these positions were dropped and gave 0. (#152)sparse_multiplication()andsparse_multiplication_scalar()withval = 0now returnNaNfor storedInfandNaNvalues of a sparse double vector multiplied by 0, as dense multiplication does. PreviouslyInfwas dropped and gave 0, andNaNwas returned asNA. (#153)sparse_multiplication_scalar()now keeps storedNAvalues when multiplying by 0, sinceNA * 0isNA. Previously they were dropped. (#145)sparse_var()andsparse_sd()now work for non-sparse input, and returnNAwhen fewer than 2 non-missing observations remain, asvar()does. (#158)sum()now uses the right default value for sparse logical vectors. (#131)sum()now returns a double when the sum of a sparse integer vector is outside the integer range, assum()does for dense integer vectors in current R versions, instead of overflowing silently. (#151)sum(),min(),max(),anyNA(),is.unsorted(),[,sparse_values(),sparse_positions(), and sparse multiplication now give up-to-date results for sparse vectors that were modified in place withx[i] <- value. (#148)
sparsevctrs 0.3.6
CRAN release: 2026-01-27
- Replaced deprecated
ATTRIB()macro withR_altrep_class_name()andR_altrep_class_package()for R 4.6.0 compatibility.
sparsevctrs 0.3.5
CRAN release: 2025-12-09
- Fixed bug with sparse character vectors that occurred on R devel. (#122)
sparsevctrs 0.3.4
CRAN release: 2025-05-25
Bug Fixes
Fixed bug where
sparse_multiplication()had a stack imbalence when returning all 0s. (#113)Fixed bug where
sparse_is_na(type = "integer")would error on character vectors. (#116)
sparsevctrs 0.3.3
CRAN release: 2025-04-14
Bug Fixes
- Fixed bug where
coerce_to_sparse_matrix()would sometimes error if input had NA values. (#109)
sparsevctrs 0.3.2
CRAN release: 2025-03-21
Bug Fixes
- Fixed bug where
sparsity()error on numeric vectors with classes. (#106)
sparsevctrs 0.3.1
CRAN release: 2025-03-17
- Fixed bug where sparse multiplication caused undefined behaviour. ($103)
sparsevctrs 0.3.0
CRAN release: 2025-03-10
New Functions
Adding the scalar arithmetic functions
sparse_division_scalar(),sparse_multiplication_scalar(),sparse_addition_scalar(),sparse_subtraction_scalar(). (#87)Adding the arithmetic function
sparse_multiplication(). (#93)Helper function
sparse_lag()bas been added. (#99)Helper function
sparse_sqrt()has been added. (#90)Helper function
sparse_replace_na()has been added. (#91)Helper functions
sparse_is_na()andsparse_which_na()have been added. (#92)
Improvements
- Adding
wtsargument tosparse_mean(). (#95)
Bug Fixes
- Fixed bug in
coerce_to_sparse_data_frame()andcoerce_to_sparse_tibble()where they didn’t work with ngCMatrix. (#89)
sparsevctrs 0.2.0
CRAN release: 2025-01-22
New Functions
sparsity()has been added, allows sparsity calculations of data.frames, matrices, and sparse matrices. (#82)Utility function
has_sparse_elements()has been added. (#70)Helper function
sparse_dummy()has beenn added. (#49)Helper functions
sparse_mean(),sparse_var(),sparse_sd(),sparse_median()has been added. (#49)
Improvements
All sparse vector types now have a significant smaller base object size. (#67)
All coerce functions have received a
callargument. (#72)is_sparse_vector()has been rewritten for speed improvement. (#76)coerce_to_sparse_matrix()Now turns dense zeroes into sparse zeroes. (#77)
Bug Fixes
Fixed bug where
coerce_to_sparse_data_frame()andcoerce_to_sparse_tibble()didn’t work with matrices with fully sparse columns. (#69)Fixed bugs where
coerce_to_sparse_matrix()would error for completely sparse columns. (#77)
