Re: [R] matrix manipulation question

2015-03-31 Thread Stéphane Adamowicz
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 «

Re: [R] matrix manipulation question

2015-03-30 Thread peter dalgaard
> 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

Re: [R] matrix manipulation question

2015-03-30 Thread Berend Hasselman
> 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

Re: [R] matrix manipulation question

2015-03-30 Thread Stéphane Adamowicz
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(

Re: [R] matrix manipulation question

2015-03-27 Thread Henric Winell
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

Re: [R] matrix manipulation question

2015-03-27 Thread Jatin Kala
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

Re: [R] matrix manipulation question

2015-03-27 Thread David Winsemius
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

Re: [R] matrix manipulation question

2015-03-27 Thread Stéphane Adamowicz
> >> 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

Re: [R] matrix manipulation question

2015-03-27 Thread PIKAL Petr
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

Re: [R] matrix manipulation question

2015-03-27 Thread Stéphane Adamowicz
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

Re: [R] matrix manipulation question

2015-03-27 Thread PIKAL Petr
: [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

Re: [R] matrix manipulation question

2015-03-27 Thread Stéphane Adamowicz
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

Re: [R] matrix manipulation question

2015-03-27 Thread peter dalgaard
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

Re: [R] matrix manipulation question

2015-03-27 Thread Stéphane Adamowicz
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

Re: [R] matrix manipulation question

2015-03-26 Thread Richard M. Heiberger
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

[R] matrix manipulation question

2015-03-26 Thread Jatin Kala
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