search for: creatematrix

Displaying 4 results from an estimated 4 matches for "creatematrix".

Did you mean: create_matrix
2012 Dec 05
1
RInside, rcpp compilation problem
...ide.h header file references the rcpp.h header file, which is not included with RInclude download. This is the sample code provided in one of the RInside manuals: #include <iostream> #include <RInside.h> // for the embedded R via RInside rcpp::NumericMatrix createMatrix(const int n) { Rcpp::NumericMatrix M(n,n); for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { M(i,j) = i*10 + j; } } return(M); } [[alternative HTML version deleted]]
2007 Nov 16
2
expand.grid overflows?
>cbn<-as.matrix(expand.grid( rep( list(0:1), 50))) Error in rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) : invalid 'times' value In addition: Warning message: In rep.int(rep.int(seq_len(nx), rep.int(rep.fac, nx)), orep) : NAs introduced by coercion But I'm only interested in cbn matrix rows where: cbn<- cbn[rowSums(cbn)==5,] Is there a way to evaluate it
2007 Feb 22
4
Sorting rows of a binary matrix
Hallo, The command: x <- 3 mat <- as.matrix(expand.grid(rep(list(0:1), x))) generates a matrix with 2^x columns containing the binary representations of the decimals from 0 to (2^x-1), here from 0 to 7. But the rows are not sorted in this order. How can sort the rows the ascending order of the decimals they represent, preferably without a function which converts binaries to decimals
2007 Jul 27
4
Looping through all possible combinations of cases
Hello! I have a regular data frame (DATA) with 10 people and 1 column ('variable'). Its cases are people with names ('a', 'b', 'c', 'd', 'e', 'f', etc.). I would like to write a function that would sum up the values on 'variable' of all possible combinations of people, i.e. 1. I would like to write a loop - in such a way that it