[R] What exactly is an dgCMatrix-class. There are so many attributes.
wdunlap at tibco.com
Fri Oct 20 20:42:36 CEST 2017
You should not really have worry about the internal structure of such a
thing - just treat it like a matrix. E.g.,
> train$data[1:3,1:3] # dots mean 0's
3 x 3 sparse Matrix of class "dgCMatrix"
cap-shape=bell cap-shape=conical cap-shape=convex
[1,] . . 1
[2,] . . 1
[3,] 1 . .
 6513 126
> p <- train$data %*% matrix(1:126, ncol=1)
 6513 1
If that doesn't work in some situation, convert it to a matrix with
To see the details, in R, type
In a browser seach window type
You should not have to make use of those details in your code.
On Fri, Oct 20, 2017 at 11:11 AM, C W <tmrsg11 at gmail.com> wrote:
> Dear R list,
> I came across dgCMatrix. I believe this class is associated with sparse
> I see there are 8 attributes to train$data, I am confused why are there so
> many, some are vectors, what do they do?
> Here's the R code:
> data(agaricus.train, package='xgboost')
> data(agaricus.test, package='xgboost')
> train <- agaricus.train
> test <- agaricus.test
> Where is the data, is it in $p, $i, or $x?
> Thank you very much!
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help