I am porting part of a program (not enough to compile and run) from R to C++. I am not familiar with R. I have done okay using the references online, but was stumped by the following line:
cnt2.2<-cnt2[,-1]
I am guessing:
cnt2
is a 2 dimensional matrixcnt2.2
is a new variable being declared with a period '.' used the same way an alphabetic character would be.<-
is an assignment.[,-1]
accesses part of the array. I thought [,5]
meant all rows, 5th column only. If this is correct, I have no idea what -1 refers to.This is covered in section 2.7 of the manual: http://cran.r-project.org/doc/manuals/R-intro.html#Index-vectors
It is a negative index into the cnt2
object specifying all rows and all columns except the first column.