Displaying 20 results from an estimated 10000 matches similar to: "extracting duplicated elements"
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))
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
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 <-
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
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
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
2011 Jul 07
2
elimination duplicate elements sampling!
Hi everyone!
I have a data frame with 1112 time series and I am going to randomly
sampling r samples for z times to compose different portfolio size(r
securities portfolio). As for r=2 and z=10000,that's:
z=10000
A=seq(1:1112)
x1=sample(A,z,replace =TRUE)
x2=sample(A,z,replace =TRUE)
M=cbind(x1,x2) # combination of 2 series
Because in a portfolio with x1[i]=x2[i],(i=1,2,...,10000) means a 1
2020 Sep 10
2
aplicar codigo
Yo copio y pego este código y me sale correctamente. Se me ocurre que
pueda deberse a la versión de R ¿cuál usas?
El 10/09/2020 a las 17:51, Samura . escribió:
> Gracias por las respuestas.
>
> Probé lo de hacer la función y no me salía. Pensaba que hacía algo mal.
> Ahora con el código de Marcelino tampoco me sale.
>
> col1 <- c('x1', 'x2', 'x11',
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
2012 Aug 10
1
Solving binary integer optimization problem
Hi,
I am new to R for solving optimization problems, I have set of communication
channels with limited capacity with two types of costs, fixed and variable
cost. Each channel has expected gain for a single communication.
I want to determine optimal number of communications for each channel
maximizing ROI)return on investment) with overall budget as constraint.60000
is the budget allocated.
2005 Jul 19
3
extracting row means from a list
Hello: I'm reading in a series of text files (100 files that are each 2000
rows by 6 columns). I wish to combine the columns (6) of each file (100) and
get the row mean. I'd like to end up with a data.frame of 2000 rows by 6
columns.
foo <- list()
for(i in 1:10){
# The real data are read in from a series of numbered text files
foo[[i]] <- data.frame(x1 = rnorm(100), x2 =
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
2011 Oct 19
1
Subsetting data by eliminating redundant variables
Dear All,
I am new to R, I have one question which might be easy.
I have a large data with more than 250 variable, i am reducing number of
variables by redun function as in the example below,
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 <-
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
?
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
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)
2003 May 19
1
plotting a simple graph
I am having great difficulty plotting what should be a simple graph.
I have measured 1 'y' and 5 'x' variables in each of two groups.
Linear regression shows significant differences in the slopes of the
regression for each 'x' variable between the two groups.
All that I want to do is to plot one graph that shows the scatterplot
for the three groups (each group represented
2017 Aug 22
1
boot.stepAIC fails with computed formula
SImplify your call to lm using the "." argument instead of
manipulating formulas.
> strt <- lm(y1 ~ ., data = dat)
and you do not need to explicitly specify the "1+" on the rhs for lm, so
> frm2<-as.formula(paste(trg," ~ ", paste(xvars,collapse = "+")))
works fine, too.
Anyway, doing this gives (but see end of output)"
bst <-
2004 Oct 28
1
gsub() on Matrix
Hi,
Suppose I've got a matrix, and the first few elements look like
"x1 + x3 + x4 + x5 + x1:x3 + x1:x4"
"x1 + x2 + x3 + x5 + x1:x2 + x1:x5"
"x1 + x3 + x4 + x5 + x1:x3 + x1:x5"
and so on (have got terms from x1 ~ x14).
If I want to replace all the x1 with i7, all x2 with i14, all x3 with i13,
for example. Is there an easy way?
I tried to put what I want