/** create a new factor REXP * @param ids indices (one-based!) * @param levels levels * @param attr attributes */ public REXPFactor(int[] ids, String[] levels, REXPList attr) { super(ids, attr); this.levels = (levels==null)?(new String[0]):levels; factor = new RFactor(this.payload, this.levels, false, 1); }
/** create a new factor REXP from an existing RFactor * @param factor factor object (can be of any index base, the contents will be pulled with base 1) * @param attr attributes */ public REXPFactor(RFactor factor, REXPList attr) { super(factor.asIntegers(1), attr); this.factor = factor; this.levels = factor.levels(); }
public String[] asStrings() { return factor.asStrings(); }
/** count the number of occurences of a given level name */ public int count(String name) { return count(levelIndex(name)); }
/** return the factor as an array of strings */ public String[] asStrings() { String[] s = new String[ids.length]; int i = 0; while (i < ids.length) { s[i] = at(i); i++; } return s; }
/** return <code>true</code> if the factor contains the given level (it is NOT the same as levelIndex==-1!) */ public boolean contains(String name) { int li = levelIndex(name); if (li<0) return false; int i = 0; while (i < ids.length) { if (ids[i] == li) return true; i++; } return false; }
/** count the number of occurences of a given level name */ public int count(String name) { return count(levelIndex(name)); }
/** return the factor as an array of strings */ public String[] asStrings() { String[] s = new String[ids.length]; int i = 0; while (i < ids.length) { s[i] = at(i); i++; } return s; }
/** return <code>true</code> if the factor contains the given level (it is NOT the same as levelIndex==-1!) */ public boolean contains(String name) { int li = levelIndex(name); if (li<0) return false; int i = 0; while (i < ids.length) { if (ids[i] == li) return true; i++; } return false; }
/** create a new factor REXP from an existing RFactor * @param factor factor object (can be of any index base, the contents will be pulled with base 1) * @param attr attributes */ public REXPFactor(RFactor factor, REXPList attr) { super(factor.asIntegers(1), attr); this.factor = factor; this.levels = factor.levels(); }
/** create a new factor REXP * @param ids indices (one-based!) * @param levels levels * @param attr attributes */ public REXPFactor(int[] ids, String[] levels, REXPList attr) { super(ids, attr); this.levels = (levels==null)?(new String[0]):levels; factor = new RFactor(this.payload, this.levels, false, 1); }
public String[] asStrings() { return factor.asStrings(); }
/** create a new factor REXP from an existing RFactor * @param factor factor object (can be of any index base, the contents will be pulled with base 1) */ public REXPFactor(RFactor factor) { super(factor.asIntegers(1)); this.factor = factor; this.levels = factor.levels(); attr = new REXPList( new RList( new REXP[] { new REXPString(this.levels), new REXPString("factor") }, new String[] { "levels", "class" })); }
/** create a new factor REXP * @param ids indices (one-based!) * @param levels levels */ public REXPFactor(int[] ids, String[] levels) { super(ids); this.levels = (levels==null)?(new String[0]):levels; factor = new RFactor(this.payload, this.levels, false, 1); attr = new REXPList( new RList( new REXP[] { new REXPString(this.levels), new REXPString("factor") }, new String[] { "levels", "class" })); }
/** create a new factor REXP from an existing RFactor * @param factor factor object (can be of any index base, the contents will be pulled with base 1) */ public REXPFactor(RFactor factor) { super(factor.asIntegers(1)); this.factor = factor; this.levels = factor.levels(); attr = new REXPList( new RList( new REXP[] { new REXPString(this.levels), new REXPString("factor") }, new String[] { "levels", "class" })); }
/** create a new factor REXP * @param ids indices (one-based!) * @param levels levels */ public REXPFactor(int[] ids, String[] levels) { super(ids); this.levels = (levels==null)?(new String[0]):levels; factor = new RFactor(this.payload, this.levels, false, 1); attr = new REXPList( new RList( new REXP[] { new REXPString(this.levels), new REXPString("factor") }, new String[] { "levels", "class" })); }