/// <summary> /// Create an RList /// </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 parseRList(String name, JToken jparent) { RData data = null; List <RData> values = new List <RData>(); JArray jvalues = jparent["value"].Value <JArray>(); if (!(jvalues == null)) { foreach (JObject j in jvalues) { values.Add(parseRObject(j)); } } data = new RList(name, values); 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); }
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 RList /// </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 parseRList(String name, JToken jparent) { RData data = null; List<RData> values = new List<RData>(); JArray jvalues = jparent["value"].Value<JArray>(); if (!(jvalues == null)) { foreach (JObject j in jvalues) { values.Add(parseRObject(j)); } } data = new RList(name, values); return data; }