private string BuildCommandLine(bool preview) {
if (string.IsNullOrEmpty(_utf8FilePath)) {
return null;
}
var encoding = GetSelectedString(EncodingComboBox);
var input = new Dictionary<string, string> {
["file"] = _utf8FilePath.ToRPath().ToRStringLiteral(),
["header"] = (HeaderCheckBox.IsChecked != null && HeaderCheckBox.IsChecked.Value).ToString().ToUpperInvariant(),
["row.names"] = GetSelectedNullableIntValueAsString(RowNamesComboBox),
["encoding"] = "UTF-8".ToRStringLiteral(),
["sep"] = GetSelectedValue(SeparatorComboBox),
["dec"] = GetSelectedValue(DecimalComboBox),
["quote"] = GetSelectedValue(QuoteComboBox),
["comment.char"] = GetSelectedValue(CommentComboBox),
["na.strings"] = string.IsNullOrEmpty(NaStringTextBox.Text) ? null : NaStringTextBox.Text.ToRStringLiteral()
};
var inputString = string.Join(", ", input
.Where(kvp => kvp.Value != null)
.Select(kvp => Invariant($"{kvp.Key}={kvp.Value}")));
return preview
? Invariant($"read.csv({inputString}, nrows=20)")
: Invariant($"`{VariableNameBox.Text}` <- read.csv({inputString})");
}