Yes it is obvious --- once someone else pointed it out.
Thanks for the hint.
Terry T.
On 07/16/2015 12:52 PM, Peter Langfelder wrote:
Hi Terry,
maybe I'm missing something, but why not define a matrix BB = V'B;
then t(B) %*% V = t(BB), then your problem reduces to finding A such
that t(BB) %*
Hi Terry,
maybe I'm missing something, but why not define a matrix BB = V'B;
then t(B) %*% V = t(BB), then your problem reduces to finding A such
that t(BB) %*% A = 0?
Peter
On Thu, Jul 16, 2015 at 10:28 AM, Therneau, Terry M., Ph.D.
wrote:
> This is as much a mathematics as an R question, in t
This is as much a mathematics as an R question, in the "this should be easy but I don't
see it" category.
Assume I have a full rank p by p matrix V (aside: V = (X'X)^{-1} for a particular setup),
a p by k matrix B, and I want to complete an orthagonal basis for the space with distance
functio
> On Jul 4, 2015, at 3:09 AM, Alex Kim wrote:
>
> Hi guys,
>
> Suppose I have an extremely large data frame with 2 columns and .5 mil
> rows. For example, the last 6 rows may look like this:
> .
> ..
> ...
> 89 100
> 93 120
> 95 125
> 101NA
> 115NA
> 123
Hi guys,
Suppose I have an extremely large data frame with 2 columns and .5 mil
rows. For example, the last 6 rows may look like this:
.
..
...
89 100
93 120
95 125
101NA
115NA
123NA
124NA
I would like to manipulate this data frame to output
Hi guys,
Suppose I have an extremely large data frame with 2 columns and .5 mil
rows. For example, the last 6 rows may look like this:
.
..
...
89 100
93 120
95 125
101NA
115NA
123NA
124NA
I would like to manipulate this data frame to output
Hi guys,
Suppose I have an extremely large data frame with 2 columns and .5 mil
rows. For example, the last 6 rows may look like this:
.
..
...
89 100
93 120
95 125
101NA
115NA
123NA
124NA
I would like to manipulate this data frame to output
Many thanks,
Stéphane
Le 30 mars 2015 à 10:42, peter dalgaard a écrit :
>
>> On 30 Mar 2015, at 09:59 , Stéphane Adamowicz
>> wrote:
>>
>>
>> However, in order to help me understand, would you be so kind as to give me
>> a matrix or data.frame example where « complete.cases(X)== T » or «
> On 30 Mar 2015, at 09:59 , Stéphane Adamowicz
> wrote:
>
>
> However, in order to help me understand, would you be so kind as to give me a
> matrix or data.frame example where « complete.cases(X)== T » or «
> complete.cases(X)== TRUE » would give some unwanted result ?
The standard proble
> On 30-03-2015, at 09:59, Stéphane Adamowicz
> wrote:
>
>
> Le 27 mars 2015 à 18:01, David Winsemius a écrit :
>
>>
>> On Mar 27, 2015, at 3:41 AM, Stéphane Adamowicz wrote:
>>
>>> Well, it seems to work with me.
>>>
>>
>> No one is doubting that it worked for you in this instance. What
Le 27 mars 2015 � 18:01, David Winsemius a �crit :
>
> On Mar 27, 2015, at 3:41 AM, St�phane Adamowicz wrote:
>
>> Well, it seems to work with me.
>>
>
> No one is doubting that it worked for you in this instance. What Peter D. was
> criticizing was the construction :
>
> complete.cases(t(
On 2015-03-27 11:41, Stéphane Adamowicz wrote:
Well, it seems to work with me.
Y <- as.matrix(airquality)
head(Y, n=8)
Ozone Solar.R Wind Temp Month Day
[1,]41 190 7.4 67 5 1
[2,]36 118 8.0 72 5 2
[3,]12 149 12.6 74 5 3
[4,]18 313
Thanks Richard,
This works, rather obvious now that i think of it!
=)
On 27/03/2015 4:30 pm, Richard M. Heiberger wrote:
just reverse what you did before.
newdata <- data
newdata[] <- NA
newdata[,!apply(is.na(data), 2, any)] <- myfunction(data_no_NA)
On Fri, Mar 27, 2015 at 1:13 AM, Jatin Kala
On Mar 27, 2015, at 3:41 AM, Stéphane Adamowicz wrote:
> Well, it seems to work with me.
>
No one is doubting that it worked for you in this instance. What Peter D. was
criticizing was the construction :
complete.cases(t(Y))==T
... and it was on two bases that it is "wrong". The first is tha
>
>> example. Furthermore in my example no unwanted format occurred. You can
>
> Yes because data.frame was (luckily) numeric.
>
Luck has nothing to do with this. I Chose this example on purpose …
Stéphane
__
R-help@r-project.org mailing list -- To
Hi
> -Original Message-
> From: Stéphane Adamowicz [mailto:stephane.adamow...@avignon.inra.fr]
> Sent: Friday, March 27, 2015 1:26 PM
> To: PIKAL Petr
> Cc: peter dalgaard; r-help@r-project.org
> Subject: Re: [R] matrix manipulation question
>
>
> Le 27 mars
Le 27 mars 2015 à 12:34, PIKAL Petr a écrit :
> Very, very, very bad solution.
>
> as.matrix can change silently your data to unwanted format,
> complete.cases()==T is silly as Peter already pointed out.
>
>
Perhaps, but it happens that in the original message, the question dealt with a
: [R] matrix manipulation question
Well, it seems to work with me.
Y <- as.matrix(airquality)
head(Y, n=8)
Ozone Solar.R Wind Temp Month Day
[1,]41 190 7.4 67 5 1
[2,]36 118 8.0 72 5 2
[3,]12 149 12.6 74 5 3
[4,]18 313 11.5 62
Well, it seems to work with me.
Y <- as.matrix(airquality)
head(Y, n=8)
Ozone Solar.R Wind Temp Month Day
[1,]41 190 7.4 67 5 1
[2,]36 118 8.0 72 5 2
[3,]12 149 12.6 74 5 3
[4,]18 313 11.5 62 5 4
[5,]NA NA 14.3 56
On 27 Mar 2015, at 09:58 , Stéphane Adamowicz
wrote:
> data_no_NA <- data[, complete.cases(t(data))==T]
Ouch! logical == TRUE is bad, logical == T is worse:
data[, complete.cases(t(data))]
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 200
Why not use complete.cases() ?
data_no_NA <- data[, complete.cases(t(data))==T]
Le 27 mars 2015 à 06:13, Jatin Kala a écrit :
> Hi,
> I've got a rather large matrix of about 800 rows and 60 columns.
> Each column is a time-series 800 long.
>
> Out of these 60 time series, some have mi
just reverse what you did before.
newdata <- data
newdata[] <- NA
newdata[,!apply(is.na(data), 2, any)] <- myfunction(data_no_NA)
On Fri, Mar 27, 2015 at 1:13 AM, Jatin Kala wrote:
> Hi,
> I've got a rather large matrix of about 800 rows and 60 columns.
> Each column is a time-series 800 lon
Hi,
I've got a rather large matrix of about 800 rows and 60 columns.
Each column is a time-series 800 long.
Out of these 60 time series, some have missing values (NA).
I want to strip out all columns that have one or more NA values, i.e.,
only want full time series.
This should do the
Wednesday, January 16, 2013 2:59 AM
Subject: [R] matrix manipulation with its rows
Dear R users,
I have a question about matrix manipulation with its rows.
Plz see the simple example below
sample <- list(matrix(1:6, nr=2,nc=3), matrix(7:12, nr=2,nc=3),
matrix(13:18,nr=2,nc=3))
> sample
[[1]
Not a great solution, I don't think, but:
> kronecker(diag(2), matrix(1:6, 2, byrow=TRUE))[c(1,4),]
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]123000
[2,]000456
So using a function that does this in 'lapply'
should solve the problem you state. I'm gue
ect.org] On Behalf Of Kathryn Lord
> Sent: Wednesday, January 16, 2013 9:00 AM
> To: r-help@r-project.org
> Subject: [R] matrix manipulation with its rows
>
> Dear R users,
>
> I have a question about matrix manipulation with its rows.
>
> Plz see the simple example bel
Dear R users,
I have a question about matrix manipulation with its rows.
Plz see the simple example below
sample <- list(matrix(1:6, nr=2,nc=3), matrix(7:12, nr=2,nc=3),
matrix(13:18,nr=2,nc=3))
> sample
[[1]]
[,1] [,2] [,3]
[1,]135
[2,]246
[[2]]
[,1] [,2] [,
On Thu, Jun 14, 2012 at 02:24:20PM -0400, cowboy wrote:
> thank you, Petr.
> This is exactly what I'm looking for in my post.
> An related question can be how to get an arbitrary weight, say if row1
> and row 2 have 1 common value 1, then assign a weight 10, if row 1 and
> row 2 have 2 common value
thank you, Petr.
This is exactly what I'm looking for in my post.
An related question can be how to get an arbitrary weight, say if row1
and row 2 have 1 common value 1, then assign a weight 10, if row 1 and
row 2 have 2 common value 1, then assign a weight 12. I'm not so sure
how to expand your me
On Thu, Jun 14, 2012 at 01:11:45PM +, G. Dai wrote:
> Dear Rlisters,
> I'm writing to ask how to manipulate a matrix or dataframe in a specific way.
>
> To elaborate, let's consider an example. Assume we have the following
> 3 by 4 matrix A with elements either 0 or 1,
> 0 1 1 0
> 1 0 1
Dear Rlisters,
I'm writing to ask how to manipulate a matrix or dataframe in a specific way.
To elaborate, let's consider an example. Assume we have the following
3 by 4 matrix A with elements either 0 or 1,
0 1 1 0
1 0 1 1
0 0 0 1
>From the original matrix A, I'd like to generate a new
It's very easy to do in two steps:
> testmat <- matrix(c(.2, .3, 1, -1, 3, .2, .4, 5, .5, -1), byrow=TRUE, nrow=2)
> testmat
[,1] [,2] [,3] [,4] [,5]
[1,] 0.2 0.31 -1.03
[2,] 0.2 0.45 0.5 -1
> testmat[testmat >= 1] <- 1
> testmat[testmat < 0] <- 0
> testmat
[,1] [,2] [,
Hello everyone,
I have a 2 x 5 matrix: say
0.2 0.3 1 -1 3
0.2. 0.4 5 0.5 -1
I want to replace all the values greater than or equal to 1 with 1 and those
less than or equal to 0 with 0. So I should end up with a mtrix looking
like:
0.2 0.3 1 0 1
0.2. 0.4 1 0.5 0
An
hello
I think if you try this:
for(j in 1: length(nsample)){
MEANS[,]<-create.means.one.size(j,var,nboot)
}
it will work
--
View this message in context:
http://r.789695.n4.nabble.com/Matrix-manipulation-in-for-loop-tp3525849p3525888.html
Sent from the R help mailing list arc
Hi all,
I have a problem with getting my code to do what I want!
This is the code I have:
create.means.one.size<-function(nsample,var,nboot){
mat.x<-matrix(0,nrow=nboot,ncol=nsample)
for(i in 1:nboot){
mat.x[i,]<-sample(var,nsample,replace=T)
}
mean.mat<-rep(0,nboot)
for(i in 1
HI,
here is another solution:
int <- sample(1:20,10)
int
[1] 10 4 5 2 14 17 9 11 16 13
mat<-matrix(11:30,ncol=4)
mat
[,1] [,2] [,3] [,4]
[1,] 11 16 21 26
[2,] 12 17 22 27
[3,] 13 18 23 28
[4,] 14 19 24 29
[5,] 15 20 25 30
mat[apply(mat,1, funct
Hi:
Here' s one approach:
> int <- sample(1:20,10)
> m <- matrix(sample(1:40, 20), nrow = 10)
> int
[1] 7 12 4 6 1 19 17 20 15 5
> m
[,1] [,2]
[1,]9 15
[2,] 23 32
[3,] 40 14
[4,] 19 38
[5,] 286
[6,] 26 18
[7,] 34 22
[8,]7 35
[9,] 21
Hi all!
I have a vector, let's say for example int <- sample(1:20,10);
for now:
now I have a matrix...
M = m x n
where the first column is a "feature" column and most likely shares at least
one of the int (interesting) numbers.
I want to extract the rows where int[] = M[,1]
I thought:
rownames(
Many thanks-its worked a treat :-)
Emma
--
View this message in context:
http://r.789695.n4.nabble.com/Matrix-Manipulation-tp3027266p3027307.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://st
try this:
> x
V2 V3 V4
[1,] 1 1 1
[2,] 2 2 2
[3,] 3 3 3
[4,] 4 4 4
[5,] 5 NA 5
[6,] NA NA 6
[7,] NA NA NA
> offset <- c(0,2,1)
> # add the control to the data and make two copies so we can offset
> x.new <- rbind(offset, x, x)
> result <- apply(x.new, 2, function(.col){
+ .
Hi,
Is there a quick way to go from this matrix:
> A
[,1] [,2] [,3]
[1,]111
[2,]222
[3,]333
[4,]444
[5,]5 NA5
[6,] NA NA6
[7,] NA NA NA
to this matrix:
> B
[,1] [,2] [,3]
[1,]1 NA NA
[2,]2 NA1
[3,
On Tue, 1 Sep 2009, Gregory Gentlemen wrote:
Dear fellow R-users,
Say we have a matrix x, defined as follows
set.seed(50)
x <- matrix(rbinom(100*5,1, p=0.75),nrow=100, ncol=5)
Now the interpretation of x is that each for of x is actually a sequence
of length 5, and i would like to transform
Dear fellow R-users,
Say we have a matrix x, defined as follows
set.seed(50)
x <- matrix(rbinom(100*5,1, p=0.75),nrow=100, ncol=5)
Now the interpretation of x is that each for of x is actually a sequence of
length 5, and i would like to transform x in such a way that I can describe the
frequen
Or perhaps:
M10[rowSums(M10 == 63) == 0, ]
On Thu, Jun 11, 2009 at 4:49 PM, David Winsemius wrote:
>
> On Jun 11, 2009, at 2:53 PM, Payam Minoofar wrote:
>
>> Hello everyone,
>>
>> I have a couple of fairly simple questions (I hope) the answers to which I
>> cannot find through the documentation
On 6/11/09 2:13 PM, "William Dunlap" wrote:
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius
> Sent: Thursday, June 11, 2009 1:49 PM
> To: Payam Minoofar
> Cc: r-help@r-project.org
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius
> Sent: Thursday, June 11, 2009 1:49 PM
> To: Payam Minoofar
> Cc: r-help@r-project.org
> Subject: Re: [R] Matrix manipulation
>
>
&g
On Jun 11, 2009, at 2:53 PM, Payam Minoofar wrote:
Hello everyone,
I have a couple of fairly simple questions (I hope) the answers to
which I cannot find through the documentation at the moment.
1. I would like to delete the a row from a matrix if a certain
elimination criterion is met
Try this:
For the first and the second question:
transform(subset(d, row.names(d) != 2), row.names=NULL)
On Thu, Jun 11, 2009 at 3:53 PM, Payam Minoofar wrote:
> Hello everyone,
>
> I have a couple of fairly simple questions (I hope) the answers to which I
> cannot find through the documentati
Hello everyone,
I have a couple of fairly simple questions (I hope) the answers to which I
cannot find through the documentation at the moment.
1. I would like to delete the a row from a matrix if a certain elimination
criterion is met. I am familiar with x <- x[-7,] (to remove row 7, for
e
From: metal_lical...@live.com
To: r-help@r-project.org
Subject: About Matrix
Date: Tue, 28 Apr 2009 11:28:43 +0300
Hi, Dear R users,
I have a question:
I have A matrix which is 11519X14
and B matrix which is 1764X14,
How do I get C matrix which is The remaining matrix after removing
Matrices are not made of paper! :) If you index a matrix with negative
numbers, you'll get back that matrix minus that column or row.
A quick example:
>a<-matrix(c(1:9),ncol=3) # Create a sample matrix
>a# Display it
[,1] [,2] [,3]
[1,]147
[2,]2
use the '-' feature.
>mat <- matrix(rnorm(100), nrow = 10)
#snip the second row
>mat[-2,]
#snip the third column
>mat[,-3]
#snip rows 5 and 7
>mat[-c(5,7),]
cheers
tc
On 10/23/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> suppose I have a 2D matrix, is there a command to
Hi everyone,
suppose I have a 2D matrix, is there a command to snip out a specific
row/column and then remerge the remaining columns/rows back into a
contiguous matrix? I will need to repeat this operation quite a
bit(reverse selection).
Thanks for any insights you can offer.
Yifei
53 matches
Mail list logo