本文整理汇总了Java中org.renjin.sexp.StringVector类的典型用法代码示例。如果您正苦于以下问题:Java StringVector类的具体用法?Java StringVector怎么用?Java StringVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringVector类属于org.renjin.sexp包,在下文中一共展示了StringVector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: add
import org.renjin.sexp.StringVector; //导入依赖的package包/类
@Override
public Builder add(SEXP in) {
if((in instanceof StringVector)) {
StringVector value = (StringVector)in;
String str = value.getElementAsString(0);
int index = levels.indexOf(str);
if(index == -1) {
index = levels.size();
levels.add(str);
}
// R indexes start at 1 not 0
delegate.add(index + 1);
return this;
} else {
return null;
}
}
开发者ID:james-jw,项目名称:xq-renjin,代码行数:20,代码来源:XqRenjinFactorBuilder.java
示例2: vectorToBuilder
import org.renjin.sexp.StringVector; //导入依赖的package包/类
public static Builder vectorToBuilder(Vector vector, int size) {
Builder out = null;
if(vector instanceof StringVector) {
out = new StringArrayVector.Builder(size);
} else if(vector instanceof LogicalVector) {
out = new LogicalArrayVector.Builder(size);
} else if(vector instanceof IntVector) {
out = new IntArrayVector.Builder(size);
} else if(vector instanceof ComplexVector) {
out = new ComplexVector.Builder(size);
} else if(vector instanceof DoubleVector) {
out = new DoubleArrayVector.Builder(size);
}
return out;
}
开发者ID:james-jw,项目名称:xq-renjin,代码行数:17,代码来源:XqRenjinModule.java
示例3: R_data_class
import org.renjin.sexp.StringVector; //导入依赖的package包/类
public static StringVector R_data_class(SEXP obj, boolean singleString) {
SEXP value;
SEXP klass = obj.getAttribute(Symbols.CLASS);
int n = klass.length();
if(n == 1 || (n > 0 && !singleString))
return (StringVector) (klass);
if(n == 0) {
SEXP dim = obj.getAttribute(Symbols.DIM);
int nd = dim.length();
if(nd > 0) {
if(nd == 2)
return StringVector.valueOf("matrix");
else
return StringVector.valueOf("array");
} else {
if(obj instanceof Function) {
return StringVector.valueOf("function");
} else if(obj instanceof DoubleVector) {
return StringVector.valueOf("numeric");
} else if(obj instanceof Symbol) {
return StringVector.valueOf("name");
}
}
}
return StringVector.valueOf(obj.getImplicitClass());
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:27,代码来源:Methods.java
示例4: doApply
import org.renjin.sexp.StringVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0, SEXP arg1)
throws Exception
{
if ((arg0 instanceof Vector)&&(((arg1 instanceof IntVector)||(arg1 instanceof DoubleVector))||(arg1 instanceof LogicalVector))) {
return Subsetting.getSingleElement(((Vector) arg0), WrapperRuntime.convertToInt(arg1));
} else {
if ((arg0 instanceof Vector)&&((arg1 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg1)))) {
return Subsetting.getSingleElementByExactName(((Vector) arg0), WrapperRuntime.convertToString(arg1));
} else {
if ((arg0 instanceof PairList.Node)&&(((arg1 instanceof IntVector)||(arg1 instanceof DoubleVector))||(arg1 instanceof LogicalVector))) {
return Subsetting.getSingleElement(((PairList.Node) arg0), WrapperRuntime.convertToInt(arg1));
} else {
if ((arg0 instanceof PairList.Node)&&((arg1 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg1)))) {
return Subsetting.getSingleElementByExactName(((PairList.Node) arg0), WrapperRuntime.convertToString(arg1));
} else {
if ((arg0 instanceof Environment)&&((arg1 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg1)))) {
return Subsetting.getSingleElementByExactName(((Environment) arg0), WrapperRuntime.convertToString(arg1));
} else {
throw new EvalException(String.format("Invalid argument:\n\t[[(%s, %s)\n\tExpected:\n\t[[(Vector, integer(1))\n\t[[(pairlist, integer(1))\n\t[[(pairlist, character(1))\n\t[[(Environment, character(1))\n\t[[(Vector, character(1))\n\t[[(pairlist, character(1), logical(1))\n\t[[(Vector, character(1), logical(1))", arg0 .getTypeName(), arg1 .getTypeName()));
}
}
}
}
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:26,代码来源:R$primitive$$bracket$bracket.java
示例5: doApply
import org.renjin.sexp.StringVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0)
throws Exception
{
if (((arg0 instanceof IntVector)||(arg0 instanceof DoubleVector))||(arg0 instanceof LogicalVector)) {
return Types.asEnvironment(context, WrapperRuntime.convertToInt(arg0));
} else {
if (arg0 instanceof ListVector) {
return Types.asEnvironment(((ListVector) arg0));
} else {
if (arg0 instanceof Environment) {
return Types.asEnvironment(((Environment) arg0));
} else {
if (arg0 instanceof S4Object) {
return Types.asEnvironment(((S4Object) arg0));
} else {
if ((arg0 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg0))) {
return Types.asEnvironment(context, WrapperRuntime.convertToString(arg0));
} else {
throw new EvalException(String.format("Invalid argument:\n\tas.environment(%s)\n\tExpected:\n\tas.environment(Environment)\n\tas.environment(integer(1))\n\tas.environment(character(1))\n\tas.environment(list)\n\tas.environment(S4Object)", arg0 .getTypeName()));
}
}
}
}
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:26,代码来源:R$primitive$as$environment.java
示例6: doApply
import org.renjin.sexp.StringVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0)
throws Exception
{
if (arg0 instanceof StringVector) {
return Types.charToRaw(((StringVector) arg0));
} else {
throw new EvalException(String.format("Invalid argument:\n\tcharToRaw(%s)\n\tExpected:\n\tcharToRaw(character)", arg0 .getTypeName()));
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:10,代码来源:R$primitive$charToRaw.java
示例7: R_getClassFromCache
import org.renjin.sexp.StringVector; //导入依赖的package包/类
public static SEXP R_getClassFromCache(SEXP className, Environment table) {
if(className instanceof StringVector) {
String packageName = className.getAttributes().getPackage();
SEXP cachedValue = table.getVariable(Symbol.get(((StringVector) className).getElementAsString(0)));
if(cachedValue == Symbol.UNBOUND_VALUE) {
return Null.INSTANCE;
} else {
String cachedPackage = cachedValue.getAttributes().getPackage();
if(packageName == null || cachedPackage == null ||
packageName.equals(cachedPackage)) {
return cachedValue;
} else {
return Null.INSTANCE;
}
}
} else if(!(className instanceof S4Object)) {
throw new EvalException("Class should be either a character-string name or a class definition");
} else {
return className;
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:27,代码来源:Methods.java
示例8: asVector
import org.renjin.sexp.StringVector; //导入依赖的package包/类
@Generic
@Primitive("as.vector")
public static SEXP asVector(PairList x, String mode) {
Vector.Builder result;
NamesBuilder names = NamesBuilder.withInitialCapacity(x.length());
if ("character".equals(mode)) {
result = new StringVector.Builder();
} else if ("logical".equals(mode)) {
result = new LogicalArrayVector.Builder(x.length());
} else if ("numeric".equals(mode)) {
result = new DoubleArrayVector.Builder(x.length());
} else if ("list".equals(mode)) {
result = new ListVector.Builder();
} else if ("raw".equals(mode)) {
result = new RawVector.Builder();
} else {
throw new EvalException("invalid 'mode' argument");
}
for (PairList.Node node : x.nodes()) {
if (node.hasTag()) {
names.add(node.getTag().getPrintName());
} else {
names.addNA();
}
result.add(node.getValue());
}
result.setAttribute(Symbols.NAMES.getPrintName(),
names.build(result.length()));
return result.build();
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:32,代码来源:Types.java
示例9: doApply
import org.renjin.sexp.StringVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0, SEXP arg1)
throws Exception
{
if ((arg0 instanceof IntVector)&&(arg1 instanceof Vector)) {
return Sort.sort(((IntVector) arg0), WrapperRuntime.convertToBooleanPrimitive(arg1));
} else {
if ((arg0 instanceof DoubleVector)&&(arg1 instanceof Vector)) {
return Sort.sort(((DoubleVector) arg0), WrapperRuntime.convertToBooleanPrimitive(arg1));
} else {
if ((arg0 instanceof StringVector)&&(arg1 instanceof Vector)) {
return Sort.sort(((StringVector) arg0), WrapperRuntime.convertToBooleanPrimitive(arg1));
} else {
throw new EvalException(String.format("Invalid argument:\n\tsort(%s, %s)\n\tExpected:\n\tsort(IntVector, logical(1))\n\tsort(character, logical(1))\n\tsort(DoubleVector, logical(1))", arg0 .getTypeName(), arg1 .getTypeName()));
}
}
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:18,代码来源:R$primitive$sort.java
示例10: doApply
import org.renjin.sexp.StringVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0, SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4)
throws Exception
{
if (((((arg0 instanceof SEXP)&&(((arg1 instanceof IntVector)||(arg1 instanceof DoubleVector))||(arg1 instanceof LogicalVector)))&&(arg2 instanceof Vector))&&(arg3 instanceof Vector))&&((arg4 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg4)))) {
return Connections.readLines(context, ((SEXP) arg0), WrapperRuntime.convertToInt(arg1), WrapperRuntime.convertToBooleanPrimitive(arg2), WrapperRuntime.convertToBooleanPrimitive(arg3), WrapperRuntime.convertToString(arg4));
} else {
throw new EvalException(String.format("Invalid argument:\n\treadLines(%s, %s, %s, %s, %s)\n\tExpected:\n\treadLines(any, integer(1), logical(1), logical(1), character(1))", arg0 .getTypeName(), arg1 .getTypeName(), arg2 .getTypeName(), arg3 .getTypeName(), arg4 .getTypeName()));
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:10,代码来源:R$primitive$readLines.java
示例11: doApply
import org.renjin.sexp.StringVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0, SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4)
throws Exception
{
if (((((arg0 instanceof StringVector)&&(arg1 instanceof ListVector))&&(arg2 instanceof Environment))&&(arg3 instanceof SEXP))&&(arg4 instanceof LogicalVector)) {
Conditions.addConditionHandlers(context, ((StringVector) arg0), ((ListVector) arg1), ((Environment) arg2), ((SEXP) arg3), ((LogicalVector) arg4));
return Null.INSTANCE;
} else {
throw new EvalException(String.format("Invalid argument:\n\t.addCondHands(%s, %s, %s, %s, %s)\n\tExpected:\n\t.addCondHands(character, list, Environment, any, LogicalVector)", arg0 .getTypeName(), arg1 .getTypeName(), arg2 .getTypeName(), arg3 .getTypeName(), arg4 .getTypeName()));
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:11,代码来源:R$primitive$$addCondHands.java
示例12: asCharacter
import org.renjin.sexp.StringVector; //导入依赖的package包/类
@Generic
@Primitive("as.character")
public static StringVector asCharacter(Environment env) {
Frame frame = env.getFrame();
if (frame instanceof ObjectFrame) {
ObjectFrame oframe = (ObjectFrame) frame;
Object instance = oframe.getInstance();
if (StringConverter.accept(instance.getClass())) {
return (StringVector) StringConverter.INSTANCE
.convertToR((String) instance);
} else if (StringArrayConverter.accept(instance.getClass())) {
return (StringVector) StringArrayConverter.INSTANCE
.convertToR(instance);
}
}
throw new EvalException(
"unsupported converter, only for environment with String or String[] ObjectFrame");
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:19,代码来源:Types.java
示例13: charToRaw
import org.renjin.sexp.StringVector; //导入依赖的package包/类
@Primitive
public static RawVector charToRaw(StringVector sv) {
// the R lang docs inexplicably say that
// this method converts a length-one character vector
// to raw bytes 'without taking into account any declared encoding'
// (AB) I think this means that we just dump out the
// string how ever it was stored internally. In R, the
// storage of a string depends on its encoding; in the JVM,
// its always UTF-16.
// this implementation splits the difference and dumps
// out the string as UTF-8.
if (sv.length() != 1) {
throw new EvalException(
"argument should be a character vector of length 1");
}
RawVector.Builder b = new RawVector.Builder();
byte[] bytes = sv.getElementAsString(0).getBytes(Charsets.UTF_8);
for (int i = 0; i < bytes.length; i++) {
b.add(new Raw(bytes[i]));
}
return b.build();
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:27,代码来源:Types.java
示例14: doApply
import org.renjin.sexp.StringVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0, SEXP arg1, SEXP arg2, SEXP arg3)
throws Exception
{
if (((((arg0 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg0)))&&(arg1 instanceof SEXP))&&(arg2 instanceof SEXP))&&(arg3 instanceof SEXP)) {
return Native.dynLoad(WrapperRuntime.convertToString(arg0), ((SEXP) arg1), ((SEXP) arg2), ((SEXP) arg3));
} else {
throw new EvalException(String.format("Invalid argument:\n\tdyn.load(%s, %s, %s, %s)\n\tExpected:\n\tdyn.load(character(1), any, any, any)", arg0 .getTypeName(), arg1 .getTypeName(), arg2 .getTypeName(), arg3 .getTypeName()));
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:10,代码来源:R$primitive$dyn$load.java
示例15: setStorageMode
import org.renjin.sexp.StringVector; //导入依赖的package包/类
@Primitive("storage.mode<-")
public static SEXP setStorageMode(Vector source, String newMode) {
Vector.Builder builder;
if (newMode.equals("logical")) {
builder = new LogicalArrayVector.Builder();
} else if (newMode.equals("double")) {
builder = new DoubleArrayVector.Builder();
} else if (newMode.equals("integer")) {
builder = new IntArrayVector.Builder();
} else if (newMode.equals("character")) {
builder = new StringVector.Builder();
} else {
throw new UnsupportedOperationException("storage.mode with new mode '"
+ newMode + "' invalid or not implemented");
}
for (int i = 0; i != source.length(); ++i) {
builder.setFrom(i, source, i);
}
return builder.copyAttributesFrom(source).build();
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:22,代码来源:Types.java
示例16: menu
import org.renjin.sexp.StringVector; //导入依赖的package包/类
@Override
public int menu(StringVector choices) throws IOException {
do {
String choice = reader.readLine("Selection: ");
try {
int index = Integer.parseInt(choice);
if(index == 0) {
return 0;
} else if(index >= 1 && index <= choices.length()) {
return index;
}
} catch(Exception e) {
}
reader.println("Enter an item from the menu, or 0 to exit");
} while(true);
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:17,代码来源:JlineSessionController.java
示例17: getElementByName
import org.renjin.sexp.StringVector; //导入依赖的package包/类
@Generic
@Primitive("$")
public static SEXP getElementByName(ListVector list,
@Evaluate(false) SEXP nameExp) {
String name = asString(nameExp);
SEXP match = null;
int matchCount = 0;
for (int i = 0; i != list.length(); ++i) {
String elementName = list.getName(i);
if (!StringVector.isNA(elementName)) {
if (elementName.equals(name)) {
return list.getElementAsSEXP(i);
} else if (elementName.startsWith(name)) {
match = list.get(i);
matchCount++;
}
}
}
return matchCount == 1 ? match : Null.INSTANCE;
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:22,代码来源:Subsetting.java
示例18: invValue
import org.renjin.sexp.StringVector; //导入依赖的package包/类
@Override
public Value invValue(QueryContext qc, InputInfo ii, Value... args) throws QueryException {
Value name = args[0];
int row = -1, col = -1;
Value out = null;
if(name instanceof Str) {
// Retrieve a vector by name
StringVector n = new StringArrayVector(((Str)name).toJava());
row = rows.indexOf(n, 0, 0);
if(row == -1) {
col = cols.indexOf(n, 0, 0);
}
} else {
col = (int) ((Int)name).toJava();
}
if(row >= 0) {
out = getRow(row);
} else if(col >= 0) {
out = getColumn(col);
} else {
throw new QueryException("Invalid index value for matrix: " + name.toString());
}
return out;
}
开发者ID:james-jw,项目名称:xq-renjin,代码行数:28,代码来源:XqRenjinMatrix.java
示例19: processFactorVector
import org.renjin.sexp.StringVector; //导入依赖的package包/类
private static Value processFactorVector(Vector in, StringVector levels) {
ValueBuilder vb = new ValueBuilder();
for(int i = 0; i < in.length(); i++) {
int v = in.getElementAsInt(i);
vb.add(Str.get(levels.getElementAsString(v - 1)));
}
return vb.value();
}
开发者ID:james-jw,项目名称:xq-renjin,代码行数:11,代码来源:XqRenjinModule.java
示例20: doApply
import org.renjin.sexp.StringVector; //导入依赖的package包/类
public static SEXP doApply(Context context, Environment environment, SEXP arg0, SEXP arg1, SEXP arg2, SEXP arg3, SEXP arg4, SEXP arg5, SEXP arg6, SEXP arg7, SEXP arg8, SEXP arg9, SEXP arg10, SEXP arg11, SEXP arg12, SEXP arg13, SEXP arg14, SEXP arg15, SEXP arg16, SEXP arg17)
throws Exception
{
if ((((((((((((((((((arg0 instanceof SEXP)&&(arg1 instanceof Vector))&&(((arg2 instanceof IntVector)||(arg2 instanceof DoubleVector))||(arg2 instanceof LogicalVector)))&&((arg3 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg3))))&&((arg4 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg4))))&&((arg5 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg5))))&&(((arg6 instanceof IntVector)||(arg6 instanceof DoubleVector))||(arg6 instanceof LogicalVector)))&&(((arg7 instanceof IntVector)||(arg7 instanceof DoubleVector))||(arg7 instanceof LogicalVector)))&&(arg8 instanceof StringVector))&&(arg9 instanceof Vector))&&(arg10 instanceof Vector))&&(arg11 instanceof Vector))&&(arg12 instanceof Vector))&&(arg13 instanceof Vector))&&(arg14 instanceof Vector))&&((arg15 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg15))))&&(arg16 instanceof Vector))&&((arg17 instanceof Vector)&&StringVector.VECTOR_TYPE.isWiderThanOrEqualTo(((Vector) arg17)))) {
return Scan.scan(context, ((SEXP) arg0), ((Vector) arg1), WrapperRuntime.convertToInt(arg2), WrapperRuntime.convertToString(arg3), WrapperRuntime.convertToString(arg4), WrapperRuntime.convertToString(arg5), WrapperRuntime.convertToInt(arg6), WrapperRuntime.convertToInt(arg7), ((StringVector) arg8), WrapperRuntime.convertToBooleanPrimitive(arg9), WrapperRuntime.convertToBooleanPrimitive(arg10), WrapperRuntime.convertToBooleanPrimitive(arg11), WrapperRuntime.convertToBooleanPrimitive(arg12), WrapperRuntime.convertToBooleanPrimitive(arg13), WrapperRuntime.convertToBooleanPrimitive(arg14), WrapperRuntime.convertToString(arg15), WrapperRuntime.convertToBooleanPrimitive(arg16), WrapperRuntime.convertToString(arg17));
} else {
throw new EvalException(String.format("Invalid argument:\n\tscan(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n\tExpected:\n\tscan(any, Vector, integer(1), character(1), character(1), character(1), integer(1), integer(1), character, logical(1), logical(1), logical(1), logical(1), logical(1), logical(1), character(1), logical(1), character(1))", arg0 .getTypeName(), arg1 .getTypeName(), arg2 .getTypeName(), arg3 .getTypeName(), arg4 .getTypeName(), arg5 .getTypeName(), arg6 .getTypeName(), arg7 .getTypeName(), arg8 .getTypeName(), arg9 .getTypeName(), arg10 .getTypeName(), arg11 .getTypeName(), arg12 .getTypeName(), arg13 .getTypeName(), arg14 .getTypeName(), arg15 .getTypeName(), arg16 .getTypeName(), arg17 .getTypeName()));
}
}
开发者ID:bedatadriven,项目名称:renjin-statet,代码行数:10,代码来源:R$primitive$scan.java
注:本文中的org.renjin.sexp.StringVector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论