Example #1
0
	SEXP get_all_obsnames_R(SEXP s) {
		//testDbg << "get_all_obsnames_R"<<endl;
		AbstractMatrix * p = getAbstractMatrixFromSEXP(s);

		if (p == NULL) {
			error_R("pointer is NULL\n");
			return R_NilValue;
		}

		//R_len_t nobss = (R_len_t) 0;
		unsigned long int nobss = 0;

		try {
			nobss = p->getNumObservations();
		} catch (int errcode) {
			return R_NilValue;
		}

		FixedChar tmp;
		SEXP ret;
		PROTECT(ret = allocVector(STRSXP, (R_len_t) nobss));

		try {
			for (unsigned long i = 0; i< nobss; i++) {
				tmp = p->readObservationName(i);
				SET_STRING_ELT(ret, i, mkChar(tmp.name));
			}
		} catch (int errcode) {
			error_R("something went terribly wrong in get_all_obsnames_R\n");
			UNPROTECT(1);
			return ret;
		}
		UNPROTECT(1);
		return ret;
	}
Example #2
0
SEXP get_all_obsnames_R(SEXP s) {
	CHECK_PTR(s);

	AbstractMatrix * p = (AbstractMatrix*) R_ExternalPtrAddr(s);

	if (p == NULL) {
		error_R("pointer is NULL\n");
		return R_NilValue;
	}

	R_len_t nobss = (R_len_t) 0;

	try {
		nobss = p->getNumObservations();
	} catch (int errcode) {
		return R_NilValue;
	}

	fixedchar tmp;
	SEXP ret;
	PROTECT(ret = allocVector(STRSXP, (R_len_t) nobss));

	try {
		for (unsigned long int i = 0; i < nobss; i++) {
			tmp = p->readObservationName(i);
			SET_STRING_ELT(ret, i, mkChar(tmp.name));
		}
	} catch (int errcode) {
		error_R("something went terribly wrong in get_all_obsnames_R\n");
		UNPROTECT(1);
		return ret;
	}
	UNPROTECT(1);
	return ret;
}