Displaying 20 results from an estimated 10000 matches similar to: "Create new Vector based on two colums"
2012 Apr 25
1
Create a new Vector based on two columns
Hello,
I am trying to get a new vector 'x1' based on the not NA-values in
column 'a' and 'b'. I found a way but I am sure this is not the best
solution. So any ideas on how to "optimize" this would be great!
m <- factor(c("a1", "a1", "a2", "b1", "b2", "b3", "d1", "d1"), ordered
2012 Apr 19
3
How to "flatten" a multidimensional array into a dataframe?
Hi,
I have a three dimensional array, e.g.,
my.array = array(0, dim=c(2,3,4), dimnames=list( d1=c("A1","A2"),
d2=c("B1","B2","B3"), d3=c("C1","C2","C3","C4")) )
what I would like to get is then a dataframe:
d1 d2 d3 value
A1 B1 C1 0
A2 B1 C1 0
.
.
.
A2 B3 C4 0
I'm sure there is one function to do
2012 Jun 02
2
Add a dim to an array
Dear list,
I'm trying to add a new dim to a multidimensional array. My array looks
like this
a1 <- array(1:8, c(2, 2, 2))
dimnames(a1) <- list(A = c("A1", "A2"),
B = c("B1", "B2"),
D = c("D1", "D2"))
I would like to add a new dim 'group' with the value "low".
2007 Sep 21
1
Error using nls()
Hallo HelpeRs,
I try to reconstruct some results from an econometric text book
(Heij et al. (2004), pp. 218-20).
For the data
> x <- structure(list(q1 = c(345, 331, 320, 314, 299, 395, 415,
490, 547, 656, 628, 627), d1 = c(1, 1, 1, 1, 1, 1, 1.05,
1.05, 1.05, 1.15, 1.15, 1.15)), .Names = c("q1", "d1"), row.names =
as.integer(c(NA,
12)), class =
2012 May 04
7
Breaking up a Row in R (transpose)
I have the following:
Time A1 A1 B1 B1 C1 C2
x y x y x y
0 5 6 6 7 7 9
1 3 4 4 3 9 9
2 5 2 6 4 7 4
I want to change it to the following:
0 1 2
x y x y x y
A1 5 6 3 4 5 2
B1
2005 Jun 03
2
rearrange data
Dear all:
I have this:
A1 B1 C1 D1 E1
A2 B2 C2 D2 E2
A3 B3 C3 D3 E3
And I want this
A1 E1
B1 E1
C1 E1
D1 E1
A2 E2
B2 E2
C2 E2
D2 E2
A3 E3
B3 E3
C3 E3
D3 E3
Example:
m<- matrix(1:15,nrow=3,byrow=T)
m
v<- unlist(list(t(m[,1:4])))
u<- rep(c(5,10,15),c(4,4,4))
data.frame(v,u)
This is the result I want but I would like to learn a simpler way to do it.
Any clue?
2007 Mar 09
1
Applying some equations over all unique combinations of 4 variables
#I have a data set that looks like this. A bit more
complicated actually with
# three factor levels but these calculations need to
be done on one factor at a
#I then have a set of different rates that are applied
#to it.
#dataset
cata <- c( 1,1,6,1,1,2)
catb <- c( 1,2,3,4,5,6)
doga <- c(3,5,3,6,4, 0)
data1 <- data.frame(cata, catb, doga)
rm(cata,catb,doga)
data1
# start rates
#
2012 Feb 05
2
Would difference in size (and content) of a file on replicated bricks be healed?
Hi...
Started playing with gluster. And the heal functions is my "target" for
testing.
Short description of my test
----------------------------
* 4 replicas on single machine
* glusterfs mounted locally
* Create file on glusterfs-mounted directory: date >data.txt
* Append to file on one of the bricks: hostname >>data.txt
* Trigger a self-heal with: stat data.txt
=>
2013 Nov 21
1
how can I import a number of datsets in a folder in my working directory to a list in R
Hi,
Suppose, if I create 15 files in my working directory.
set.seed(48)
lapply(1:15,function(i) {m1 <- matrix(sample(1:20,1686*2,replace=TRUE),nrow=1686,ncol=2); write.table(m1,paste0("file_",i,".txt"),row.names=FALSE,quote=FALSE)})
?D <-dir()
D1 <- D[order(as.numeric(gsub("\\D+","",D)))]
D1
?res <- t(sapply(D1,function(x) {x1<-
2002 Mar 11
1
problem with deriv3?
Using S+ 6 for Linux and
R 1.4.1
Taking verbatim some lines from S-Plus that work
perfectly, and running them on R, I get an
unexpected error message:
R : Copyright 2002, The R Development Core Team
Version 1.4.1 (2002-01-30)
> library(MASS)
> data <- read.table("/usr/local/data/mcmanus.dat",header=T)
> mcmanus.frm <-
2012 Oct 15
3
Puppet 3 and master cert error ...
Hey all,
after installing the 3.0.0 version of puppet (debian package from
puppetlabs), doing the initial config, doing an initial start of master to
generate the certs needed and then starting apache with passenger to
control puppetmaster. I can do:
puppet ca list --all
and get a listing of the certs in the system (initially only the master).
afterwards, on the client node, I run:
puppet
2004 Jul 08
2
Getting elements of a matrix by a vector of column indice s
See if the following helps:
> m <- outer(letters[1:5], 1:4, paste, sep="")
> m
[,1] [,2] [,3] [,4]
[1,] "a1" "a2" "a3" "a4"
[2,] "b1" "b2" "b3" "b4"
[3,] "c1" "c2" "c3" "c4"
[4,] "d1" "d2" "d3" "d4"
[5,]
2005 May 31
2
help
Dear all:
I have this:
A1 B1 C1 D1 E1
A2 B2 C2 D2 E2
A3 B3 C3 D3 E3
And I want this
A1 E1
B1 E1
C1 E1
D1 E1
A2 E2
B2 E2
C2 E2
D2 E2
A3 E3
B3 E3
C3 E3
D3 E3
Example:
m<- matrix(1:15,nrow=3,byrow=T)
m
v<- unlist(list(t(m[,1:4])))
u<-
2005 Aug 12
1
help on cross hedge optimal hedge variance ratio
Hi everyone
I am trying to estimate the optimal hedge variance ratio for cross
hedging two commodities. the price levels are used (compared to price
change and % price change) and used the OLS with dummy variable for
estimating the co-efficients. the equation looks like this
Y = B + B1*D1 + B2*X + B3*(X*D1)
Where Y = Daily Cash market price
D1 = Dummy variable taking value 1 for period Oct-Mar
2013 Feb 07
1
Merging data in arrays
Dear All,
Here is a hypothetical sample (sorry for the clumsy code):
A1 <- matrix(1:5, nrow=5, ncol=1)
A2 <- matrix(6:10, nrow=5, ncol=1)
A3 <- matrix(11:15, nrow=5, ncol=1)
A4 <- matrix(16:20, nrow=5, ncol=1)
A5 <- matrix(21:25, nrow=5, ncol=1)
A6 <- matrix(26:30, nrow=5, ncol=1)
B1 <- matrix(c(A1, A2, A3), nrow=5, ncol=3)
B2 <- matrix(c(A2, A3, A4), nrow=5, ncol=3)
B3
2013 Nov 19
2
Optim function & Hessian matrix
Dear R Users
Hi,
I have very emergency problems in my programming about finding MLE
with optim command. I reproduced it with real data. I guess that my
function object in optim is very sensitive because it has power
function .
Then optim give me lower or initial values for estimates with these
warnings for Hessian matrix computation:
1: In log(B2 * (C2^(y + v))) : NaNs produced
2: In log(B3
2004 Nov 28
1
Could anyone help me reshape this "wide" data into "longitudinal" one? Thanks
Dear R people,
I have a matrix like this:
var1 var2 var3 var4
a1 7.1 7.2 8.1 8.2
a2 10.5 10.6 ... ...
a3
b1
b2
b3
b4
c1
c2
...
The matrix row names are "a1", "a2", ...... and the matrix column
names are "var1", "var2", "var3" and "var4". Now I want to reshape
this data into a
2011 Dec 06
1
Sequential Sum in R
I am trying to code the following excel formula in R.
a b c Result Formula
1 10 0.1 #N/A
IF(B2<20,NA(),C2+IF(ISERROR(D1),0,D1))
2 20 0.2 0.2
IF(B3<20,NA(),C3+IF(ISERROR(D2),0,D2))
3 30 0.3 0.5
IF(B4<20,NA(),C4+IF(ISERROR(D3),0,D3))
4 40
2013 Sep 26
2
Sums based on values of other matrix
Dear all,
I have a big problem:
- I got two matrices, A and B
- A shows identifies the value of B, however the values of B must be summed
- For instance,
1 1 2 2
2 2 1 1
gives matrix a
3 4 2 1
1 1 2 2
gives matrix b
Now the result for the value 1 would be
7
4
which are the rowsums of the values of matrix B given that matrix A has the value 1.
How can I do this automatically? I
2003 May 20
1
How to use pakcage SEM
Hi.
I have tried to use Package "SEM".
As a learning, I try to convert a program running well of EQS
which is as follows to SEM:
### EQS ###
/SPECIFICATION
CAS=100; VAR=5 MAT=COR; ANA=COR;
/EQUATIONS
V1=*F1+E1; V2=*F1+E2; V3=*F1+*F2+E3; V4=**F1+*F2*E4;
V5=*F2+E5;
/VAR
E1 TO E5=*; F1*1.0; F2=1.0;
/COV
E1,E2=*; F1,F2=*:
/PRINT
FIT ALL;
/MATRIX ......
/END
This is the converted SEM