0

I am having some trouble printing the first column of my sparse matrix. here is a snapshot of the matrix

           RESOURCE17183 RESOURCE39353 MGR_ID85475
1             .             1           1
2             1             .           .

I try to print it by using the the command

print(x_train[,1])

However I get some weird output

1 2 
1 0 

The output I was expecting was something like

      RESOURCE17183
1     .
2     1

What am I doing wrong? Please help

Abhi
  • 399
  • 2
  • 7
  • 21
  • 1
    Try `print(x_train[,1,drop=FALSE])` - this is not a sparse matrix issue specifically. Check out the help file and the `drop=` argument here - `?"["` – thelatemail Dec 03 '14 at 04:14
  • Please edit your question to include a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). That will help us provide a more specific answer. – MrFlick Dec 03 '14 at 04:14
  • @thelatemail The dropping was not surprising to me, the change from `("1"=.,"2"=1)` to `c("1"=1,"2"=0)` was odd. Maybe the output was just "representative" and not what was actually observed which I would have expected to be `c("1"=0,"2"=1)`. – MrFlick Dec 03 '14 at 04:27

0 Answers0