Displaying 20 results from an estimated 116 matches for "varnames".

Did you mean:
varname

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="...

2007 Oct 16

2

Adding axis lines to splom plots

...on''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,...

2006 Sep 15

2

Formula aruguments with NLS and model.frame()

...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, wei...

2006 Jan 11

7

Re: SPSS and R ? do they like each other?

... and is there also such a nice tool (like spss.get) for exporting
data frames to SPSS? write.table does not keep the data frame labels -
neither did the other exporting tools that I found.
Thanks!
Michael
[[alternative HTML version deleted]]
______________________________________________
R-help@stat.math.ethz.ch mailing list

2012 Feb 07

2

predict.naiveBayes() bug in e1071 package

...e with the treatment of the
log-transformed probabilities inside the predict.naiveBayes function.
Here is an example to demonstrate the problem (you might need to
increase ''nvar'' depending on your machine):
-------------------- 8< --------------------
N <- 100
nvar <- 60
varnames <- paste("v", 1:nvar, sep="")
dat <- sapply(1:nvar, function(dummy) {c(rnorm(N/2, 0, 1), rnorm(N/2, 10, 1))})
colnames(dat) <- varnames
out <- rep(c("a","b"), each=N/2)
names(dat) <- varnames
nb <- naiveBayes(x=dat, y=out)
ne...

2007 Feb 09

1

How to add the variable name to a qqplot or densityplot in the diagonal of an splom?

splom() doesn''t complain here, but writes no names in the diagonal
boxes. What am I missing?
I believe that I need to add something like grid.text(x, ...) to the
diagonal panel, but I don''t know how to get it cycle through the
column labels. And should
varname.col = ''blue'', varname.cex = 1
be inside the diag.panel() function?
splom(szw[, n], pscales

2006 Aug 16

1

bwplot in loop doesn''t produce any output

Hi,
running the following code by itself runs as expected.
----------------------------------------------------------------------------
k <- 1
i <- 2
j <- 3
NumName <- varnames[num.cols[k]]
FacNames <- varnames[fac.cols[c(i,j)]]
tmp <- paste(FacNames[1],NumName,sep="~")
fml <- formula(paste(tmp,FacNames[2],sep="|"))
bwplot(fml, data = X)
----------------------------------------------------------------------------
But when set in...

2011 Aug 21

3

Multiple R linear models into one Latex table

...### R models to Latex table ####
#################################
# nice() - Multiple R linear models into one Latex table.
#
# nice(list(fit1,fit2,...,fitn)) for generic table with n models
#
# or
#
# for better tables, create objects ''model.names'' and ''final.varnames'', then
#
# nice(list(fit1,fit2,...,fitn), model.names, final.varnames)
nice <- function(modelos, model.names=NULL, final.varnames=NULL) {
var.names<-vector(mode="character")
k<-1
for (i in 1:length(modelos)) {
l<-length(names(coef(modelos[[i]])))...

2009 Dec 17

2

issue with using rm: cannot generate on-the-fly list

Hello,
I have the following problem when trying to use rm:
In a top level script file I have a loop iterating over some index. The loop
is not contained within a function, so the scope of variables declared in
the loop is global. Within this loop I generate several variables which
should be removed at the end of each iteration. To do this, I wrote a
function to clean up the workspace. An example

2017 Dec 04

2

Dynamic reference, right-hand side of function

Hi!
Thanks for the replies!
I understand people more accustomed to R doesn't like looping much, and that thinking about loops is something I do since I worked with Stata a lot. The syntax from Peter Dalgaard was really clever, and I learned a lot from it, even though it didn't solve my problem (I guess it wasn't very well explained). My problem was basically that I have a data matrix

2017 Dec 04

1

Dynamic reference, right-hand side of function

Um, if you insist on doing it that way, at least use
assign(varname, as.vector(get(varname)))
-pd
> On 4 Dec 2017, at 22:46 , Love Bohman <love.bohman at sociology.su.se> wrote:
>
> Hi!
> Thanks for the replies!
> I understand people more accustomed to R doesn't like looping much, and that thinking about loops is something I do since I worked with Stata a lot. The

2004 Feb 18

2

using names() as a variable in a formula

...me formula which doesn''t. I want to be able to reference the column of the dataC table so I can run the variogram iteratively with a loop.
> v<-variogram(A1~1,loc=~x+y, dataC)
> v<-variogram(names(dataC[3])~1,loc=~x+y, dataC)
Error in model.frame(formula, rownames, variables, varnames, extras, extranames, :
invalid variable type
Where dataC looks like:
x y A1 A2 A3
1 514030 4793587 0.0 7.9 0.1
2 517995 4792516 5.8 5.1 0.0
3 514232 4792210 0.0 6.5 0.0
I though initially that it might need some escape character if quotes are added, and trie...

2017 Dec 05

2

Dynamic reference, right-hand side of function

Hi again!
I know you don't find loops evil (well, at least not diabolic :-) ). (After many hours googling I have realized that thinking about loops rather than lists is a newbie thing we Stata-users do, I just jokingly pointed it out). Anyway, I'm really happy that you try to teach me some R-manners. Since I still get questions about what the h**k I mean by my strange question, I sort it

2012 Dec 18

2

Changing Variable Names In VCD

...ange the plotted variable names in mosaic plots in the vcd package? Should one do a separate contingency table first, change the dimension names there and then pass that to mosaic?
Or is there a way to do it simply within mosaic.
I was thinking something like:
mosaic(~var1+var2, labelling_args=list(varnames=c(''newvar1'', ''newvar2''))
Simon Kiss
*********************************
Simon J. Kiss, PhD
Assistant Professor, Wilfrid Laurier University
73 George Street
Brantford, Ontario, Canada

2017 Oct 22

1

Syntax for fit.contrast

I have a model (run with glm) that has a factor, type. Type has two levels, "general" and "regional". I am trying to get estimates (and SEs) for the model with type="general" and type ="regional" using fit.contrast but I can't get the syntax of the coefficients to use in fit.contrast correct. I hope someone can show me how to use fit.contrast, or some

2017 Dec 05

1

Dynamic reference, right-hand side of function

By the way, R 'vectors' are not the equivalents of mathematical 'vectors'.
In R, a vector is something that can have arbitrary length and which has
no 'attributes', other than perhaps element names. Vectors can be numeric,
character,
complex, lists, etc. Functions, names, and NULL are not vectors. In my
opinion,
the typical data scientist will rarely find the R vector

2017 Dec 04

1

Dynamic reference, right-hand side of function

Loops are not evil, and no-one in this thread said they are. But I
believe your failure to provide a reproducible example is creating
confusion, since you may be using words that mean one thing to you and
something else to the readers here.
################################
# A reproducible example includes a tiny set of sample data
# Since we cannot reproducibly refer to filenames (your

2017 Dec 04

1

Dynamic reference, right-hand side of function

:-)
I don't insist on anything, I'm just struggling to learn a new language and partly a new way of thinking, and I really appreciate the corrections. I hope I someday will be able to handle lists in R as easy as I handle loops in Stata...
Thanks again!
Love
-----Ursprungligt meddelande-----
Fr?n: peter dalgaard [mailto:pdalgd at gmail.com]
Skickat: den 4 december 2017 23:09
Till:

2017 Oct 22

1

Syntax for fit.contrast

> On Oct 22, 2017, at 6:04 AM, Sorkin, John <jsorkin at som.umaryland.edu> wrote:
>
> I have a model (run with glm) that has a factor, type. Type has two levels, "general" and "regional". I am trying to get estimates (and SEs) for the model with type="general" and type ="regional" using fit.contrast
?fit.contrast
No documentation for