public static string NominalOrOrdinalToScale(string colName, List<FactorMap> fmap, string changeTo, ServerDataSource dataSource)
{
string numericVector = "c(";
string stringVector = "c(";
int i = 0;
foreach (FactorMap fm in fmap)
{
if (i < fmap.Count - 1)//put comma
{
numericVector = numericVector + fm.textbox + ",";
stringVector = stringVector + "\'" + fm.labels + "\',";// I think labels are not imp to send to R side function
}
else
{
numericVector = numericVector + fm.textbox + ")";
stringVector = stringVector + "\'" + fm.labels + "\')";
}
i++;
}
//17Apr2014 Fix for crash. If due to some reason fmap is empty, numericVector and stringVector must have "c()"
//instead of just having "c(", which is assigned on top of this function.
if (fmap.Count < 1)
{
numericVector = "c()";
stringVector = "c()";
}
return string.Format("BSkyNominalOrOrdinalToScale(colNameOrIndex='{0}', numericValues={1}, levelNames={2}, changeto='{3}', dataSetNameOrIndex='{4}')", colName, numericVector, stringVector, changeTo, dataSource.Name);
}
#endregion