Displaying 20 results from an estimated 10000 matches similar to: "Extracting only odd columns from a matrix"
2011 Mar 25
4
read.xls -> rotate data.frame
Hi to all,
how could I to rotate automatically a data sheet which was imported by
read.xls?
x1 x2 x3 .... xn
y1 1 4 7 ... xn/y1
y2 2 5 8 .... xn/y2
y3 3 6 9 ....xn/y2
yn ... ... ... Xn/Yn
to
y1 y2 y3 .... yn
x1 1 2 3 ..... Yn/x1
x2 4 5 6 .... Yn/x2
x3 7 8 9 .... Yn/x2
xn ... ... ... ..... Yn/xn
Kind regards Knut
2012 Oct 10
3
Generating random geographical coordinates
Dear all,
I have two coordinates vectors, say X and Y of length n.
I want to generate for each couple of coordinates X1,Y1 X2,Y2
X3,Y3....Xn,Yn a random coordinate which is located in a square define
as X +/- dx and Y +/- dy.
I saw the runif function which can generate for just one value at a time
what I want : runif(1, X - dx, X + dx) for X and runif(1, Y - dy, Y +
dy) for Y.
I would like
2011 Mar 04
2
Reading in and manipulating multiple data sets from the same input file
Hi,
I am attempting to write code which will read in my data which is of this
form:
X1 Y1 X2 Y2 .... Xn Yn
0 0 0 0 0 0
1 0 1 255 1 0
2 255 2 0 2 255
3 0 3 0
2009 Dec 15
1
Help in R
Hello,
Can anyone give me some suggestion in term of calculating the sum below.
Is there a function in R that can help doing it faster?
x1, x2, ...xn where xi can be 0 or 1. I want to calculate the following:
sum{ beta[a+sum(xi), b+n-sum(xi) ]* [ (1-x1)dnorm(0,1)+x1dnorm(2,1) ]* [
(1-x2)dnorm(0,1)+x2dnorm(2,1) ]* ...* [ (1-xn)dnorm(0,1)+xndnorm(2,1) ] }
The sum in the beginning is over all
2012 Feb 23
5
cor() on sets of vectors
suppose I have two sets of vectors: x1,x2,...,xN and y1,y2,...,yN.
I want N correlations: cor(x1,y1), cor(x2,y2), ..., cor(xN,yN).
my sets of vectors are arranged as data frames x & y (vector=column):
x <- data.frame(a=rnorm(10),b=rnorm(10),c=rnorm(10))
y <- data.frame(d=rnorm(10),e=rnorm(10),f=rnorm(10))
cor(x,y) returns a _matrix_ of all pairwise correlations:
cor(x,y)
2007 Mar 01
1
covariance question which has nothing to do with R
This is a covariance calculation question so nothing to do with R but
maybe someone could help me anyway.
Suppose, I have two random variables X and Y whose means are both known
to be zero and I want to get an estimate of their covariance.
I have n sample pairs
(X1,Y1)
(X2,Y2)
.
.
.
.
.
(Xn,Yn)
, so that the covariance estimate is clearly 1/n *(sum from i = 1 to n
of ( X_i*Y_i) )
But,
2005 Aug 03
1
filter data set unique, duplicate..
Hello
First, thanks for the help for an earlier question about error handling!
I have problem filtering a dataset.
I'm trying to filter the data in the y columns based on the values in the x
column, e.g.:
x y1 y2 yn
1.0 1 NA 3
2.0 1 NA 11
2.0 2 NA NA
3.0
2003 Apr 02
8
lm with an arbitrary number of terms
Hello folks,
Any ideas how to do this?
data.frame is a data frame with column names "x1",...,"xn"
y is a response variable of length dim(data.frame)[1]
I want to write a function
function(y, data.frame){
lm(y~x1+...+xn)
}
This would be easy if n was always the same.
If n is arbitrary how could I feed the x1+...+xn terms into lm(response~terms)?
Thanks
Richard
--
Dr.
2010 Oct 24
6
Contour Plot on a non Rectangular Grid
Dear All,
I would like to plot a scalar (e.g. a temperature) on a non-rectangular
domain (or even better: I would simply like to be able to draw a contour
plot on an arbitrary 2D domain). I wonder if there is any tool to
achieve that with R. I did some online search in particular on the list
archives, found several queries similar to this one but was not able to
find any conclusive answer.
I
2006 Sep 22
2
"logistic" + "neg binomial" + ...
Hi Folks,
I've just come across a kind of problem which leads
me to wonder how to approach it in R.
Basically, each a set of items is subjected to a series
of "impacts" until it eventually "fails". The "force"
of each impact would depend on covariates X,Y say;
but as a result of preceding impacts an item would be
expected to have a "cumulative
2008 Dec 29
4
Merge or combine data frames with missing columns
Hi R-experts,
suppose I have a list with containing data frame elements:
[[1]]
(Intercept) y1 y2 y3 y4
-6.64 0.761 0.383 0.775 0.163
[[2]]
(Intercept) y2 y3
-3.858 0.854 0.834
Now I want to put them into ONE dataframe like this:
(Intercept) y1
2012 Apr 11
1
inference for customized regression in R?
Hi all,
Are there functions in R that could help me do the following?
We have a special type of regression which is called Geometric Mean
Regression.
We have done some search and found the following:
https://stat.ethz.ch/pipermail/r-help/2011-July/285022.html
The question is: how to do the statistical inference on GMR results?
More specifically, we are looking for the prediction interval:
2006 Jul 28
2
subset of rows from matrix
Hi all,
I have a dataframe of rownames that I would like to extract from a
larger matrix to form a new matrix. I have tried to use subset, in
this manner
x<-subset(largematrix, rownames$names=largematrix$rownames)
where largematrix is the larger matrix and rownames$names is the
dataframe with the row names of the rows I want to extract from the
larger matrix.
Of course, I get error
2011 Aug 15
1
update() ignores object
Hi all,
I'm extracting the name of the term in a regression model that
dropterm specifies as the least significant one, and I'm assigning
this name to an object. However, when I use update(), it ignores this
object. Is there a way I can make it not ignore it? A reproducible
example is below:
> lm(x1~1+y1*y2+y3+y4,data=anscombe)->my.lm
>
2010 Sep 26
1
compare a vector and a row of a matrix
From: xxgreat@hotmail.com
To: r-help-bounces@r-project.org
Subject: compare a vector and a row of a matrix
Date: Sun, 26 Sep 2010 23:23:52 +0800
Hi Everyone:
I am trying to compare a vector and rows of a matrix
for example
> xn <- c(1,2,4,4,5,5,5,6)
>yn <- c(1,2,5,7,1,2,3,1)
>mtrx <- cbind(xn, yn)
when I tried, say, > c (1,4), the result was TRUE, TRUE.
2005 Feb 14
1
corrupt data frame: columns will be truncated or padded with NAs in: format.data.frame(x, digits = digits)
Hello!
I posted on saturday mail with the same subject on r-help seeking
for help in my work, but now I realized that this list is more
appropriate for this. I think I found I bug. Bellow are comments
and reproducible examples:
# Create a data frame
(tmp <- data.frame(y1=1:4, f1=factor(c("A", "B", "C", "D"))))
y1 f1
1 1 A
2 2 B
3 3 C
4 4 D
#
2005 Feb 14
1
corrupt data frame: columns will be truncated or padded with NAs in: format.data.frame(x, digits = digits)
Hello!
I posted on saturday mail with the same subject on r-help seeking
for help in my work, but now I realized that this list is more
appropriate for this. I think I found I bug. Bellow are comments
and reproducible examples:
# Create a data frame
(tmp <- data.frame(y1=1:4, f1=factor(c("A", "B", "C", "D"))))
y1 f1
1 1 A
2 2 B
3 3 C
4 4 D
#
2004 Apr 13
1
postscript image problem (PR#6763)
Full_Name: Jonathan Lees
Version: 1.8.1
OS: GNU/Linux 2.4.20-20.8smp #1 SMP
Submission from: (NULL) (152.2.75.114)
I am having trouble with the postscript output of images.
They have lines on them that are not supposed to be there.
I have noticed this on numerous trials of printing various images.
I looked at the postscript and I see that it
appears to plot each individual block - so perhaps
2007 Dec 26
1
Can you recover default argument values of a function?
Hi.
Maybe this is a stupid question. If so, I apologize, but here goes. Suppose I have a function f1(x,...) that calls a function f2(y1,y2,...,yn) in the following way: if x satisfies a certain condition, then I want to call f2(x,y2,...,yn); otherwise I want to use the default value of y1, if there is one. I could do something like the following:
v <- ifelse ( is.null(x), f2( , y2,...,
2006 May 30
2
merging
Dear List,
Given,
y <- matrix(c(0,1,1,1,0,0,0,4,4), ncol = 3, byrow = TRUE)
rownames(y) <- c("a","b","c")
colnames(y) <- c("1","2","3")
y
y2 <- y[2:3, ]
rownames(y2) <- c("x","z")
y2
how can I stop
merge(y, y2, all = TRUE, sort = FALSE)
squishing the extra rows? Ideally I want the same as:
rbind(y,