Displaying 20 results from an estimated 10000 matches similar to: "re-ordering a vector by name"
2004 Jul 19
10
How to compare X1 = X2 = ... = Xn?
Dear All,
I have a data frame with n columns: X1, X2, ., Xn. Now I want to create a
new column: if X1 = X2 = . = Xn, the value is 1; Otherwise, the value is 0.
How to do that in a quick way instead of doing (n choose 2) comparisons?
Thank you,
Frank
[[alternative HTML version deleted]]
2004 Sep 14
3
reshaping some data
Hi all,
I have a data.frame with the following colnames pattern:
x1 y11 x2 y21 y22 y23 x3 y31 y32 ...
I.e. I have an x followed by a few y's. What I would like to do is turn
this wide format into a tall format with two columns: "x", "y". The
structure is that xi needs to be associated with yij (e.g. x1 should
next to y11 and y12, x2 should be next to y21, y22, and
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 Feb 15
2
wire.frame tick labels from matrix
Dear R Users, close to the end of this I used wireframe to create a 3D plot
from a matrix. The x and y axis tick labels (1-6) for each were created
from the matrix being a 6X6 matrix. I need the axis tick labels to be the
row and column headings which you can see in the output (mat.x). I have
tried several work arounds, but they have not been successful.
Thanks in advance. keith
rm(list=ls())
2006 Aug 24
3
generating an expression for a formula automatically
Hi!
I would like to be able to create formulas automatically. For example, I
want to be able to create a function that takes on two values: resp and
x, and then creates the proper formula to regress resp on x.
My code:
fit.main <- function(resp,x) {
form <- expression(paste(resp," ~ ",paste(x,sep="",collapse=" + "),sep=""))
z <-
2006 Mar 11
1
Non-linear Regression : Error in eval(expr, envir, enclos)
Hi..
i have an expression of the form:
model1<-nls(y~beta1*(x1+(k1*x2)+(k1*k1*x3)+(k2*x4)+(k2*k1*x5)+(k2*k2*x6)+(k3*x7)+(k3*k4*x8)+(k3*k2*x9)+(k3*k3*x10)+ (k4*x11)+(k4*k1*x12)+(k4*k2*x13)+(k4*k3*x14)+(k4*k4*x15)+(k5*x16)+(k5*k1*x17)+(k5*k2*x18)+(k5*k3*x19)+
2013 Aug 27
2
Encontrar las variables más importantes en componentes principales
Hola compañeros de la lista. Qué tal.
Tengo un análisis de componentes principales, en el que se evalúan
aproximadamente 1000 variables. Usando la función dudi.pca e
inertia.dudi obtengo una cantidad de información sobre la influencia de
las variables sobre los dos componentes principales. Me gustaría saber
si existe alguna función que sobre esta información me arrojara la lista
de
2010 Aug 20
4
Regex exercise
For regular expression afficianados, I'd like a cleverer solution to
the following problem (my solution works just fine for my needs; I'm
just trying to improve my regex skills):
Given the string (entered, say, at a readline prompt):
"1 2 -5, 3- 6 4 8 5-7 10" ## only integers will be entered
parse it to produce the numeric vector:
c(1, 2, 3, 4, 5, 3, 4, 5, 6, 8, 5, 6,
2009 Sep 22
2
Semi continous variable- define bounds using lpsolve
How to define bounds for a semi continous variable in lp_solve.
Min 5x1 +9x2 +7.15x3 +0.1x4
subject to
x1+x2+x3+x4=6.7
x1+x4 <= 6.5
And x3 can be 0 or greater than 3.6
hence x3 is a semi continous variable
how to define bounds as well as semicontinous function because using
set.semicont and set. bound simantaneously doesn't seem to work.Thanks in
advance for the help
--
View this
2011 May 02
2
Lasso with Categorical Variables
Hi! This is my first time posting. I've read the general rules and
guidelines, but please bear with me if I make some fatal error in
posting. Anyway, I have a continuous response and 29 predictors made
up of continuous variables and nominal and ordinal categorical
variables. I'd like to do lasso on these, but I get an error. The way
I am using "lars" doesn't allow for the
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
2010 Dec 14
2
How to bind models into a list of models?
Hi R-helpers,
I have a character object called dd that has 32 elements each of which
is a model formula contained within quotation marks. Here's what it
looks like:
> dd
[1] "lm(y ~ 1,data=Cement)" "lm(y ~
X,data=Cement)" "lm(y ~ X1,data=Cement)"
[4] "lm(y ~ X2,data=Cement)" "lm(y ~
2012 Apr 20
1
predictOMatic for regression. Please try and advise me
I'm pasting below a working R file featuring a function I'd like to polish up.
I'm teaching regression this semester and every time I come to
something that is very difficult to explain in class, I try to
simplify it by writing an R function (eventually into my package
"rockchalk"). Students have a difficult time with predict and newdata
objects, so right now I'm
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 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
2012 Jan 05
1
delete.response leaves response in attribute dataClasses
I posted this one as an R bug
(https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14767), but
Prof. Ripley says I'm premature, and I should raise the question here.
Here's the behavior I assert is a bug:
The output from delete.response on a terms object alters the formula
by removing the dependent variable. It removes the response from the
"variables" attribute and it changes
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
2004 Feb 26
2
Structural Equation Model
Hello all!
I want to estimate parameters in a MIMIC model. I have one latent
variable (ksi), four reflexive indicators (y1, y2, y3 and y4) and four
formative indicators (x1, x2, x3, x4). Is there a way to do it in R? I
know there is the SEM library, but it seems not to be possible to
specify formative indicators, that is, observed exogenous variables
which causes the latent variable.
Thanks,
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