-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
# need to make this to avoid possible memory leak in data.table melt | ||
|
||
melt_aorsf <- | ||
function(data, | ||
id.vars, | ||
measure.vars, | ||
variable.name = "variable", | ||
value.name = "value") { | ||
if (!is.data.frame(data)) { | ||
stop("Input 'data' must be a data frame.") | ||
} | ||
|
||
if (!is.character(id.vars)) { | ||
stop("Input 'id.vars' must be a character vector.") | ||
} | ||
|
||
if (!is.character(measure.vars)) { | ||
stop("Input 'measure.vars' must be a character vector.") | ||
} | ||
|
||
# Select id variables and measure variables | ||
id_data <- data[id.vars] | ||
measure_data <- data[measure.vars] | ||
|
||
# Create a sequence variable to represent the variable names | ||
variable_data <- rep(names(measure_data), each = nrow(data)) | ||
|
||
# Reshape the data | ||
long_data <- data.frame(id_data, | ||
variable = variable_data, | ||
value = unlist(measure_data, use.names = FALSE)) | ||
|
||
names(long_data)[names(long_data) == 'variable'] <- variable.name | ||
names(long_data)[names(long_data) == 'value'] <- value.name | ||
|
||
return(long_data) | ||
} | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
CXX_STD = CXX14 | ||
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) | ||
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) |