[R] Adding RcppFrame to RcppResultSet causes segmentation fault

R_help Help rhelpacc at gmail.com
Tue Mar 30 02:53:38 CEST 2010


Hi,

I'm a bit puzzled. I uses exactly the same code in RcppExamples
package to try adding RcppFrame object to RcppResultSet. When running
it gives me segmentation fault problem. I'm using gcc 4.1.2 on redhat
64bit. I'm not sure if this is the cause of the problem. Any advice
would be greatly appreciated. Thank you.

Rob.


int numCol=4;
	std::vector<std::string> colNames(numCol);
	colNames[0] = "alpha"; // column of strings
	colNames[1] = "beta";  // column of reals
	colNames[2] = "gamma"; // factor column
	colNames[3] = "delta"; // column of Dates
	RcppFrame frame(colNames);

	// Third column will be a factor. In the current implementation the
	// level names are copied to every factor value (and factors
	// in the same column must have the same level names). The level names
	// for a particular column will be factored out (pardon the pun) in
	// a future release.
	int numLevels = 2;
	std::string *levelNames = new std::string[2];
	levelNames[0] = std::string("pass"); // level 1
	levelNames[1] = std::string("fail"); // level 2

	// First row (this one determines column types).
	std::vector<ColDatum> row1(numCol);
	row1[0].setStringValue("a");
	row1[1].setDoubleValue(3.14);
	row1[2].setFactorValue(levelNames, numLevels, 1);
	row1[3].setDateValue(RcppDate(7,4,2006));
	frame.addRow(row1);

	// Second row.
	std::vector<ColDatum> row2(numCol);
	row2[0].setStringValue("b");
	row2[1].setDoubleValue(6.28);
	row2[2].setFactorValue(levelNames, numLevels, 1);
	row2[3].setDateValue(RcppDate(12,25,2006));
	frame.addRow(row2);

RcppResultSet rs;
rs.add("PreDF", frame);



More information about the R-help mailing list