Displaying 20 results from an estimated 10000 matches similar to: "the difference between "x1" and x1"
2006 Apr 13
2
assignment to a symbol created by paste
Hello,
I am creating a number of objects that I wish to have a common name with
an index such as x1, x2, x3, ... I would like to do everyting in a loop to
make the code compact and minimize the probability of an error by typo.
A test problem may look like
for (j in 1:10){
as.symbol(paste("x",j,sep="")) <- j;
}
which ideally would produce x1 = 1, ... x10 = 10. However,
2011 Dec 19
2
Summing x1 to x6
Suppose I have the following:
x1<-as.vector(rnorm(10))
x2<-as.vector(rnorm(10))
x3<-as.vector(rnorm(10))
x4<-as.vector(rnorm(10))
x5<-as.vector(rnorm(10))
x6<-as.vector(rnorm(10))
x7<-as.vector(rnorm(10))
x8<-as.vector(rnorm(10))
x9<-as.vector(rnorm(10))
x10<-as.vector(rnorm(10))
I would like the mean of x1 to x6 for each vector position. I would do
something else
2006 Mar 31
1
add1() and glm
Hello,
I have a question about the add1() function and quasilikelihoods for GLMs.
I am fitting quasi-Poisson models using glm(, family = quasipoisson).
Technically, with the quasilikelihood approach the deviance does not have
the interpretation as a likelihood-based measure of sample information.
Functions such as stepAIC() cannot be used. The function add1() returns
the change in the scaled
2008 Mar 29
1
Tabulating Sparse Contingency Table
I have a sparse contingency table (most cells are 0):
> xtabs(~.,data[,idx:(idx+4)])
, , x3 = 1, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 31
2 0 0 112
3 0 0 94
, , x3 = 2, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 0
2 0 0 0
3 0 0 0
, , x3 = 3, x4 = 1, x5 = 1
x2
x1 1 2 3
1 0 0 0
2 0 0 0
3 0 0 0
, , x3 = 1, x4
2012 Sep 12
3
how to create a substraction matrix (subtract a row of every column from the same row in other columns)
Hello
I have data like this
x1 x2 x3 x4 x5
I want to create a matrix similar to a correlation matrix, but with the
difference between the two values, like this
x1 x2 x3 x4 x5
x1 x2-x1 x3-x1 x4-x1 x5-x1
x2 x3-x2 x4-x2 x5-x2
x3 x4-x3 x5-x3
x4 x5-x4
x5
Then I
2013 May 29
3
bootstrap
Hi,
You might need to check library(boot).? I have never used that before.? So, I can't comment much.? It is better to post on R-help list.? I had seen your postings on Nabble in the past.? Unfortunately those postings were not accepted in R-help.? You have to directly post at ? r-help at r-project.org after registering at:
https://stat.ethz.ch/mailman/listinfo/r-help
?
2012 Nov 22
4
Data Extraction
Hello,
I would appreciate if someone could help me resolve the following:
1. df1[!is.na( X1 | X2 | X3 | X4 | X5),][,1:5] # This does not work
2. Is these message harmful? The following object(s) are masked from 'df1 (position 3)':
X1, X2, X3, X4, X5
Thanks,
Pradip Muhuri
#Reproducible Example
set.seed(5)
df1<-data.frame(matrix(sample(c(1:10,NA),100,replace=TRUE),ncol=5))
2003 Oct 05
3
stepAIC problem
Dear R-users
I have a probelm running stepAIC in R1.7.1
I wrote a program which used stepAIC as a part of it,
and it worked fine while I was using the previous version of
R1.7.0. However, I found the program did not work any more.
Now, R produces a message which tells
"Error in as.data.frame.default(data) :
can't coerce function into a data.frame" every time I
run the part of
2005 Oct 05
8
R crashes for large formulas in lm() (PR#8180)
Full_Name: Hallgeir Grinde
Version: 2.1.1
OS: Windows XP
Submission from: (NULL) (144.127.1.1)
While using lm(y~(x*z*c*...*v)^2) R crashes/closes if the numbers of variables
are at least 8.
2020 Sep 10
5
aplicar codigo
Hola:
Como dice Carlos, algo así, por ejemplo:
transforma <- function(df) sapply(df, function(x)
ifelse(x%in%c("x1","x2","x3"),
"prueba1",ifelse(x%in%c("x4","x5","x6"),"prueba2",x)))
> transforma(df1)
col1
[1,] "prueba1"
[2,] "prueba1"
[3,] "x11"
[4,]
2013 Apr 13
1
how to add a row vector in a dataframe
Hi,
Using S=1000
and
simdata <- replicate(S, generate(3000))
#If you want both "m1" and "m0" #here the missing values are 0
res1<-sapply(seq_len(ncol(simdata.psm1)),function(i) {x1<-merge(simdata.psm0[,i],simdata.psm1[,i],all=TRUE); x1[is.na(x1)]<-0; x1})
res1[,997:1000]
#????? [,1]???????? [,2]???????? [,3]???????? [,4]???????
#x1??? Numeric,3000 Numeric,3000
2020 Sep 10
3
aplicar codigo
Hola,
me gustar?a hacer algo como en el siguiente ejemplo
A un df a?adirle una columna que es la transformaci?n de otra,
en plan a todo lo que sea x1, x2, x3 lo llamo prueba 1
todo lo que sea x4,x5,x6 lo llamo prueba 2
el resto de x las dejo como est?n.
Ser?a algo as?
col1 <- c('x1', 'x2', 'x11', 'x1','x33', 'x1','x4', 'x5',
2011 Oct 31
3
How to get Quartiles when data contains both numeric variables and factors
When data contains both factor and numeric variables, how to get quartiles
for all numeric variables?
n <- 100
x1 <- runif(n)
x2 <- runif(n)
x3 <- x1 + x2 + runif(n)/10
x4 <- x1 + x2 + x3 + runif(n)/10
x5 <- factor(sample(c('a','b','c'),n,replace=TRUE))
x6 <- factor(1*(x5=='a' | x5=='c'))
data1 <- cbind(x1,x2,x3,x4,x5,x6)
data
2005 Jun 29
2
quick way to construct formula
Dear R users,
I have a data with 1000 variables named "x1", "x2", ..., "x1000", and
I want to construct a formula like this format:
~x1+x2+...+x1000+x1:x2+x1:x3+x999:x1000+log(x1)+...+log(x1000)
That is: the base variables followed by all interaction terms and all
base feature log-transformations. I know I can use several paste
functions to construct it. But is
2008 Dec 22
1
sem package fails when no of factors increase from 3 to 4
#### I checked through every 3 factor * 3 loading case.
#### While, 4 factor * 3 loading failed.
#### the data is 6 factor * 3 loading
require(sem);
cor18<-read.moments();
1
.68 1
.60 .58 1
.01 .10 .07 1
.12 .04 .06 .29 1
.06 .06 .01 .35 .24 1
.09 .13 .10 .05 .03 .07 1
.04 .08 .16 .10 .12 .06 .25 1
.06 .09 .02 .02 .09 .16 .29 .36 1
.23 .26 .19 .05 .04 .04 .08 .09 .09 1
.11 .13 .12 .03 .05 .03
2005 Oct 05
1
Ad: Re: R crashes for large formulas in lm() (PR#8180)
Dette er en melding med flere deler i MIME-format.
--=_alternative 004613C000257091_=
Content-Type: text/plain; charset="US-ASCII"
And some more informastion I forgot.
R does not crash if I write out the formula:
set.seed(123)
x1 <- runif(1000)
x2 <- runif(1000)
x3 <- runif(1000)
x4 <- runif(1000)
x5 <- runif(1000)
x6 <- runif(1000)
x7 <- runif(1000)
x8 <-
2010 Apr 19
2
How to pass a list of parameters into a function
Does anyone know how to pass a list of parameters into a function?
for example:
somefun=function(x1,x2,x3,x4,x5,x6,x7,x8,x9){
ans=x1+x2+x3+x4+x5+x6+x7+x8+x9
return(ans)
}
somefun(1,2,3,4,5,6,7,8,9)
# I would like this to work:
temp=c(x3=3,x4=4,x5=5,x6=6,x7=7,x8=8,x9=9)
somefun(x1=1,x2=2,temp)
# OR I would like this to work:
temp=list(x3=3,x4=4,x5=5,x6=6,x7=7,x8=8,x9=9)
2006 Aug 16
1
Specifying Path Model in SEM for CFA
I'm using specify.model for the sem package. I can't figure out how to
represent the residual errors for the observed variables for a CFA
model. (Once I get this working I need to add some further constraints.)
Here is what I've tried:
model.sa <- specify.model()
F1 -> X1,l11, NA
F1 -> X2,l21, NA
F1 -> X3,l31, NA
F1 -> X4,l41, NA
F1 -> X5, NA, 0.20
2006 Aug 31
3
what's wrong with my simulation programs on logistic regression
Dear friends,
I'm doing a simulation on logistic regression model, but the programs can't
work well,please help me to correct it and give some suggestions.
My programs:
data<-matrix(rnorm(400),ncol=8) #sample size is 50
data<-data.frame(data)
names(data)<-c(paste("x",1:8,sep="")) #8 independent variables,x1-x8;
#logistic regression model is
2012 Nov 24
5
subsetting - questions
Hello,
I have two very basic questions (console attached):
1) What am I getting an error message for # 5 and # 7 ?
2) How to fix the code?
I would appreciate receiving your help.
Thanks,
Pradip Muhuri
###### Reproducible Example #####
N <- 100
set.seed(13)
df<-data.frame(matrix(sample(c(1:10),N, replace=TRUE),ncol=5))
keep_var <- c("X1", "X2")
drop_var