-
-
Save trestletech/d07fa170b613c5c0107ef000a15ef72e to your computer and use it in GitHub Desktop.
Rcpp data.frame issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Rcpp Dataframe issue" | |
output: github_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` | |
```{r} | |
fun <- Rcpp::cppFunction(' | |
List DataFrameExample() { | |
Rcpp::IntegerVector a = {1, 2, 3}; | |
// create a new data frame | |
Rcpp::DataFrame DF = Rcpp::DataFrame::create( | |
Rcpp::Named("a1")=a | |
); | |
Rcpp::DataFrame NDF = clone(DF); | |
//NDF.push_back(a, "a2"); | |
NDF["a2"] = a; | |
return(Rcpp::List::create( | |
Rcpp::Named("origDataFrame")=DF, | |
Rcpp::Named("newDataFrame")=NDF) | |
); | |
}') | |
dfs <- fun() | |
dfs | |
lapply(dfs, class) | |
lapply(dfs, attributes) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment