private static RData checkEmptyValue(JToken jparent, String type, String rclass, String name) { RData data = null; if (!(jparent["value"] == null)) { return(null); } if (type == Constants.TYPE_MATRIX) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumericMatrix(name, null); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RStringMatrix(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBooleanMatrix(name, null); } else { data = new RNumericMatrix(name, null); } } else if (type == Constants.TYPE_VECTOR) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumericVector(name, null); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RStringVector(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBooleanVector(name, null); } else if (rclass == Constants.RCLASS_DATE) { data = new RDateVector(name, null, ""); } else { data = new RNumericVector(name, null); } } else if (type == Constants.TYPE_PRIMITIVE) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumeric(name, 0); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RString(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBoolean(name, false); } else { data = new RNumeric(name, 0); } } else if (type == Constants.TYPE_DATE) { data = new RDate(name, null, ""); } else if (type == Constants.TYPE_FACTOR) { data = new RFactor(name, null); } else if (type == Constants.TYPE_DATAFRAME) { data = new RDataFrame(name, null); } else if (type == Constants.TYPE_LIST) { data = new RList(name, null); } return(data); }
private static RData checkEmptyValue(JToken jparent, String type, String rclass, String name) { RData data = null; if (!(jparent["value"] == null)) { return null; } if (type == Constants.TYPE_MATRIX) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumericMatrix(name, null); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RStringMatrix(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBooleanMatrix(name, null); } else { data = new RNumericMatrix(name, null); } } else if (type == Constants.TYPE_VECTOR) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumericVector(name, null); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RStringVector(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBooleanVector(name, null); } else if (rclass == Constants.RCLASS_DATE) { data = new RDateVector(name, null, ""); } else { data = new RNumericVector(name, null); } } else if (type == Constants.TYPE_PRIMITIVE) { if (rclass == Constants.RCLASS_NUMERIC) { data = new RNumeric(name, 0); } else if (rclass == Constants.RCLASS_CHARACTER) { data = new RString(name, null); } else if (rclass == Constants.RCLASS_BOOLEAN) { data = new RBoolean(name, false); } else { data = new RNumeric(name, 0); } } else if (type == Constants.TYPE_DATE) { data = new RDate(name, null, ""); } else if (type == Constants.TYPE_FACTOR) { data = new RFactor(name, null); } else if (type == Constants.TYPE_DATAFRAME) { data = new RDataFrame(name, null); } else if (type == Constants.TYPE_LIST) { data = new RList(name, null); } return data; }
/// <summary> /// Create an RFactor /// </summary> /// <param name="name">name of the RData instance</param> /// <param name="jparent">Parent json.net object</param> /// <returns>RData object</returns> /// <remarks></remarks> public static RData parseFactor(String name, JToken jparent) { RData data = null; List <String> fValues = new List <String>(); List <String> fLevels = new List <String>(); List <String> fLabels = new List <String>(); if (!(jparent["value"] == null)) { JArray jvalues = jparent["value"].Value <JArray>(); foreach (var j in jvalues) { if (j.Type != JTokenType.Null) { fValues.Add(j.Value <string>()); } else { fValues.Add(null); } } } if (!(jparent["labels"] == null)) { JArray jvalues = jparent["labels"].Value <JArray>(); foreach (var j in jvalues) { if (j.Type != JTokenType.Null) { fLabels.Add(j.Value <string>()); } else { fLabels.Add(null); } } } if (!(jparent["levels"] == null)) { JArray jvalues = jparent["levels"].Value <JArray>(); foreach (JValue j in jvalues) { if (j.Type != JTokenType.Null) { fLevels.Add(j.Value <string>()); } else { fLevels.Add(null); } } } JToken f = jparent["ordered"].Value <JToken>(); data = new RFactor(name, fValues, fLevels, fLabels, f.Value <bool>()); return(data); }
/// <summary> /// Create an RFactor /// </summary> /// <param name="name">name of the RData instance</param> /// <param name="jparent">Parent json.net object</param> /// <returns>RData object</returns> /// <remarks></remarks> public static RData parseFactor(String name, JToken jparent) { RData data = null; List<String> fValues = new List<String>(); List<String> fLevels = new List<String>(); List<String> fLabels = new List<String>(); if (!(jparent["value"] == null)) { JArray jvalues = jparent["value"].Value<JArray>(); foreach (var j in jvalues) { if (j.Type != JTokenType.Null) { fValues.Add(j.Value<string>()); } else { fValues.Add(null); } } } if (!(jparent["labels"] == null)) { JArray jvalues = jparent["labels"].Value<JArray>(); foreach (var j in jvalues) { if (j.Type != JTokenType.Null) { fLabels.Add(j.Value<string>()); } else { fLabels.Add(null); } } } if (!(jparent["levels"] == null)) { JArray jvalues = jparent["levels"].Value<JArray>(); foreach (JValue j in jvalues) { if (j.Type != JTokenType.Null) { fLevels.Add(j.Value<string>()); } else { fLevels.Add(null); } } } JToken f = jparent["ordered"].Value<JToken>(); data = new RFactor(name, fValues, fLevels, fLabels, f.Value<bool>()); return data; }