Skip to content
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

Merged
merged 2 commits into from
Sep 8, 2021
Merged

Fix dataSetToDataFrame #606

merged 2 commits into from
Sep 8, 2021

Conversation

PavelBal
Copy link
Member

@PavelBal PavelBal commented Sep 8, 2021

Fixes #603; #604

- replace all mapply and sapply by lapply in dataSetToDataFrame
xValue <- unlist(mapply(.makeDataFrameColumn, dataSets, "xValues"))
yValue <- unlist(mapply(.makeDataFrameColumn, dataSets, "yValues"))
yErrorValues <- unlist(mapply(.makeDataFrameColumn, dataSets, "yErrorValues"))
name <- unlist(lapply(dataSets, function(x) {
Copy link
Member Author

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.

Copy link
Member Author

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,
Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

@msevestre msevestre left a 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,
Copy link
Member

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

@PavelBal
Copy link
Member Author

PavelBal commented Sep 8, 2021

@msevestre done.
Also the build is not failing any more.

@msevestre msevestre merged commit 5376271 into develop Sep 8, 2021
@msevestre msevestre deleted the data-frame-from-data-sets branch September 8, 2021 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataSet: add "name" to print
2 participants