-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dataSetToDataFrame #606
Conversation
- replace all mapply and sapply by lapply in dataSetToDataFrame
R/utilities-data-set.R
Outdated
xValue <- unlist(mapply(.makeDataFrameColumn, dataSets, "xValues")) | ||
yValue <- unlist(mapply(.makeDataFrameColumn, dataSets, "yValues")) | ||
yErrorValues <- unlist(mapply(.makeDataFrameColumn, dataSets, "yErrorValues")) | ||
name <- unlist(lapply(dataSets, function(x) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mapply and sapply and so produce weird results sometimes (in case of data sets loaded from excel the output was a matrix, in the case of manually created data sets it was a vector...), lapply
is the only function that always will return a list, so lets use it where possible.
Adding use.naames = FALSE
to unlist
speeds up the whole thing and should be used when we do not need a named list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hannaei FYI
|
||
df <- data.frame( | ||
name, xValue, yValue, yErrorValues, xDimension, xUnit, yDimension, | ||
yUnit, yErrorType, yErrorUnit, yMolWeight | ||
name, xValues, yValues, yErrorValues, xDimension, xUnit, yDimension, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed column names (using plural) and added a LLOQ column.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if feels like you could write a method
makeColums <- function(dataSets, columnName) {
unlist(lapply(dataSet, function(x){
.makeDatqaFrameColumn(x, columnsName)
}
}
or sthg like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see suggestion to avoid code duplicatin
|
||
df <- data.frame( | ||
name, xValue, yValue, yErrorValues, xDimension, xUnit, yDimension, | ||
yUnit, yErrorType, yErrorUnit, yMolWeight | ||
name, xValues, yValues, yErrorValues, xDimension, xUnit, yDimension, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if feels like you could write a method
makeColums <- function(dataSets, columnName) {
unlist(lapply(dataSet, function(x){
.makeDatqaFrameColumn(x, columnsName)
}
}
or sthg like this
fix tests
@msevestre done. |
Fixes #603; #604