Displaying 20 results from an estimated 454 matches for "varnames".
Did you mean:
varname
2008 Oct 12
1
Conditionally skip over "for(..){" and "}"??
...loops over them all.
So, for a single run, I could have the following kind of thing
in a file code.R to be sourced by source("code.R"):
# VarName <- "Var1"
VarName <- "Var2"
# VarName <- "Var3"
# VarName <- "Var4"
### CUT OUT LOOP
# VarNames <- c("Var1","Var2","Var3","Var4")
# for( VarName in VarNames ) {
<< Lots of code related to analysis of variable VarName >>
### CUT OUT END OF LOOP
# }
which would do the single case for Var2. A run for a different VarName
would be done by e...
2006 Jul 13
1
writeForeignSAS and potential extensions
...ne (507) 266-1650, fax 284-9542
-------------- next part --------------
--- writeForeignSAS.R Fri Feb 17 03:30:53 2006
+++ /tmp/writeForeignSAS.R Thu Jul 13 12:24:24 2006
@@ -1,21 +1,52 @@
-writeForeignSAS<-function(df,datafile,codefile,dataname="rdata"){
+make.SAS.names <- function(varnames, validvarname = c("V7", "V6")){
+ validvarname <- match.arg(validvarname)
+ nmax <- if(validvarname == "V7") 32 else 8
+ x <- sub("^([0-9])", "_\\1", varnames)
+ x <- gsub("[^a-zA-Z0-9_]", "_", x)
+ x <- a...
2010 Feb 11
4
Access variables by string
...ction
that I am building, which should only exclude rows that have NA in
certain columns. Maybe there is already a function which does
exactly what I need, so I'd highly appreciate if someone could point
me there ;)
My current implementation looks like this:
naexlcude <- function(data, varnames)
{
for(v in varnames){
data = subset(data, !is.na(v))
}
data
}
Best
Philipp
2007 Jan 26
2
Use a text variable's value to specify another varaible?
Greetings guRus --
If a variable, e.g., 'varname', is a character string, e.g. varname <-
"datavector", and I want to apply a function, such as table(), to
datavector, what syntax or method will do so using only the variable
varname? This seems similar to indirect addressing, but I have not seen
a method for it in the R manuals. Is there a general name for such
indirect
2003 May 31
5
parse on left hand side of R assignment
I keep finding myself in a situation where I want to calculate a
variable name and then use it on the left hand side of an assignment.
For example
iteration <- 1
varName <- paste("run",iteration,sep="")
myList$parse(text=varName) <- aColumn
I want to take some existing variable "aColumn" and use the name
"varName" name for it and put it into a
2003 Nov 10
3
Reading an upper triangular matrix
...but all give the same error). The items in the
data file is delimited by white space.
(Part of) script to read:
myfile <- file("Paises.dat", open="r")
# opens a connection which stays open until closed by
close(myfile)
name <- readLines(con=myfile, n=1)
varnames <- scan( myfile, what=character(0), nlines=1 )
stopifnot( length(varnames) == 21 )
Paises <- matrix(0, 21, 21)
colnames(Paises) <- varnames
rownames(Paises) <- varnames
for (i in 1:21) {
temp <- scan(myfile, what=list("a", rep(0,22-i) ), nlines=1,
sep="")...
2017 Aug 13
1
ggplot's aes_ doesn't work as expected for x=factor()
...dataset
df <- data.frame(LogicalVar = c(FALSE, TRUE, FALSE, TRUE, FALSE, TRUE),
Var1 = c(0.01, 0.01, 1, 1, 30, 30),
pct1 = c(12, 88, 60, 40, 93, 7),
Var2 = c(2, 2, 4, 4, 8, 8),
pct2 = c(43, 57, 10, 90, 50, 50)
)
varnames <- names(df)
# using aes()--this works
ggplot(df, aes(x=factor(Var1), y=pct1, fill=LogicalVar)) + geom_bar(stat="identity") # works
# using aes_() works in this instance
ggplot(df, aes_(x=as.name(varnames[2]), y=as.name(varnames[3]), fill=as.name(varnames[1]))) + geom_bar(stat="...
2010 Jun 28
1
mathematical expression in varnames of lattice parallel plot
How can I insert mathematical expressions for variable names in a
lattice parallel plot? I tried to implement mathematical expressions in
varnames, however, without success.
For example, neither
parallel(~iris[1:4] | Species, iris,
varnames=c("P[Width]", "Petal[length]", "alpha[Width]", "Sepal[Length]"))
nor
parallel(~iris[1:4] | Species, iris,
varnames=c(expression(P[Width]), exp...
2013 Jan 11
2
[LLVMdev] Make a comparation with IR builder
Hi Justin,
my class is a visitor pattern and I use accept method to go recursive in
suboject in my AST.
In locals I store AllocaInst pointer.
void *visit(var1_init_decl_c *symbol) {
llvm::Type *lType;
varNames.clear();
varType = "";
symbol->var1_list->accept(*this); /* get a vector contains variable names */
symbol->spec_init->accept(*this); /* Store in varType variable list */
lType = typeOf(varType);
for (unsigned int i = 0; i < varNames.size(); i++) {
AllocaI...
2011 Jun 17
1
is this a bug?
Hello,
Is the following a bug? I always thought that df$varname <- does the same as
df["varname"] <-
> df <- data.frame(weight=round(runif(10, 10, 100)), sex=round(runif(100, 0,
1)))
> df$pct <- df["weight"] / ave(df["weight"], df["sex"], FUN=sum)*100
> names(df)
[1] "weight" "sex" "pct" ###
2010 Aug 11
2
assignment functions with inherited class error
...t;,
representation=representation(
"matrix"
)
)
i<-new("XXX");
m=matrix();
colnames(m)<-c("colA");
i at .Data=m;
# >i
# An object of class ?XXX?
# colA
#[1,] NA
#________________________________________________________________________
#First Test
"varnames<-" <- function(x,value){
colnames(x at .Data)<-value;
}
#==========================================================
#Result:
# > varnames(i)<-c("a")
# > i
# [1] "a"
# x lost class type an value from XXX to vector.
#______________________________________...
2009 Oct 02
3
help with regexp mass substitution
Hello *
i have to rename a lot of variables, and, given that they have regular name constructs, I would like to use regexps.
Here's a dump of my head(names(df))
varnames <- c("id.quest", "txt.1.3", "col1.1.3", "col2.1.3", "col3.1.3",
"col4.1.3", "col5.1.3", "txt.2.3", "col1.2.3", "col2.2.3", "col3.2.3",
"col4.2.3", "col5.2.3", "...
2006 Jul 13
2
simple question about variables....
Dear R users,
I have a simple question on variable manipulation.
Imagine I have an object "OBJ" that has "toto" as one of its variables.
I would like to understand why if I do
> varname <- "toto"
>OBJ$varname returns no results
whereas
> OBJ[varname] returns the column entitled
2006 Sep 15
1
Formula aruguments with NLS and model.frame()
...is change in daily temperatures, id is just a time trend and the
a*sin is a one year fourier series.
I have tried to debug the nls code using the following code
t1<-data.frame(t=as.vector(x),id=index(x))
data=t1;
formula <- as.formula(t ~ a *sin(w *2* pi/365 * id + p) + b * id + int);
varNames <- all.vars(formula)
algorithm<-'default';
mf <- match.call(definition=nls,expand.dots=FALSE,
call('nls',formula, data=parent.frame(),start,control = nls.control(),
algorithm = "default", trace = FALSE,
subset, weights, na.action, mod...
2012 Jul 14
2
Loading in Large Dataset + variables via loop
Hello, I'm new to R with a (probably elementary) question.
Suppose I have a dataset called /A/ with /n/ locations, and each location
contains within it 3 time series of different variables (all of 100 years
length); each time series is of a weather variable (for each location there
is a temperature, precipitation, and pressure). For instance, location 1
has a temperature1 time series, a
2012 Jun 22
3
dropping variables from a data frame inside a function
Why doesn't this work?
#Drop a variable name from a data frame
DropLikeSAS <- function(x,df) {
df[[x]] <- NULL
0
}
DropLikeSAS("VarName", DataFrameName)
Try it. The column VarName will not be deleted from the data frame DataFrameName.
But
x <-
2007 Oct 16
1
Adding axis lines to splom plots
...d I don't know how to superimpose the grid with the thicker
lines (separating the 10x10 groups) onto the overall grid of all 30x30
plots. I enclose a reproducible example:
#####
require(lattice)
temp.df <- sapply(1:30, function(i) rnorm(20, 0,1))
splom(~temp.df, aspect="fill", varnames=paste("coord", 1:30, sep=""),
xlab="", pscales=0, varname.cex=0.6, panel=function(x, y, ...){
panel.xyplot(x,y, cex=0.2, xlab="", ylab="")
})
splom(~matrix(c(1,2,3), nc=3), aspect="fill", varnames=NULL, xlab="",
pscales=0,...
2013 Jan 11
0
[LLVMdev] Make a comparation with IR builder
...lt;manuele.conti at sirius-es.it>wrote:
> Hi Justin,
> my class is a visitor pattern and I use accept method to go recursive in
> suboject in my AST.
> In locals I store AllocaInst pointer.
>
>
> void *visit(var1_init_decl_c *symbol) {
> llvm::Type *lType;
>
> varNames.clear();
> varType = "";
> symbol->var1_list->accept(*this); /* get a vector contains variable names */
> symbol->spec_init->accept(*this); /* Store in varType variable list */
> lType = typeOf(varType);
> for (unsigned int i = 0; i < varNames.size(...
2013 Jan 11
2
[LLVMdev] Make a comparation with IR builder
Hi All,
I'm writing a code generation with my compiler. I read sever example and
documentation but I did understand what I make wrong.
What I try to do is a compare a local variable with a constant.
But when I create a ICMP instruction I get that instruction are not of
same type.
I'm using llvm by svn repository updated at two week ago.
The code that I try to generation is something
2006 Feb 12
1
lme, nlsList, nlsList.selfStart
...)
However when trying to fit the model with nlsList, I get:
mymod3<-nlsList(Conc~Dose * exp(lKe+lKa-lCl) *
(exp(-exp(lKe)*Tps)-exp(-exp(lKa)*Tps)) /(exp(lKa)-exp(lKe)),
data=mydata,
start= c(lKe=-2.77, lKa=-1.41, lCl=-1.13)
)
Error in model.frame(formula, rownames, variables, varnames, extras,
extranames, :
variable lengths differ
Error in model.frame(formula, rownames, variables, varnames, extras,
extranames, :
variable lengths differ
Error in model.frame(formula, rownames, variables, varnames, extras,
extranames, :
variable lengths differ
Or spec...