[R] Extending my code: RESOLVED

2019-02-16 Thread Ogbos Okike
Dear Jeff and Jim, Thank you for sorting out this for me. Replacing text(as.Date("2005-03-13"),5900,"b") with: text(as.POSIXct(("2005-03-13 09:00:00"),5900,"b") resolved the problem. Warmest regards Ogbos On Sun, Feb 17, 2019 at 3:05 AM Jim Lemon wrote: > > Hi Ogbos, > Remember that there is an un

Re: [R] Extending my code

2019-02-16 Thread Jim Lemon
Hi Ogbos, Remember that there is an underlying numeric representation of dates. as.Date assigns dates a number of days from an agreed origin (1970-01-01) while POSIX dates assign a number of seconds. If you plot in one system and then try to add points in another, it's not going to work. Jim On S

Re: [R] Extending my code

2019-02-16 Thread Jeff Newmiller
Jim has pointed out the strptime function, but you can use as.POSIXct function also... so as.POSIXct( "2005-03-13 09:00:00" ) as.POSIXct( "03/13/2005 9:00", format="%m/%d/%Y %H:%M" ) or other variations should work. On February 16, 2019 5:41:29 PM PST, Ogbos Okike wrote: >Dear Jeff, >My erro

Re: [R] Extending my code

2019-02-16 Thread Ogbos Okike
Dear Jeff, My error please and sorry about that. Not "1960-05-04 09:00:00". I meant to write as.Date("2005-03-13"),-9,"b") and "2005-03-13 09:00:00". My problem is the additional time factor. I can text anywhere on my plot when dealing with /mm/dd but I can't handle the new /mm/dd/hh/mm/

Re: [R] Extending my code

2019-02-16 Thread Jim Lemon
Hi Ogbos, It may be easier to use strptime: dta<-data.frame(year=rep(2005,5),month=rep("05",5), day=c("01","06","11","16","21"), hour=c(2,4,6,8,10),minute=rep(0,5),second=rep(0,5),value=1:5) dta$Ptime<-strptime(paste(paste(dta$year,dta$month,dta$day,sep="-"), paste(dta$hour,dta$minute,dta$secon

Re: [R] Problem with combining 2 data frame

2019-02-16 Thread David L Carlson
This is another approach using match(): df1 = data.frame(x1 = letters[1:26],x2 = NA, stringsAsFactors=FALSE) df2 = data.frame(x1 = letters[10:15],x2 = c("1a","2a","3a","4a","5a","6a"), stringsAsFactors =FALSE) df1$x2[match(df2$x1, df1$x1)] <- df2$x2 -

Re: [R] Extending my code

2019-02-16 Thread Jeff Newmiller
I have no idea how text(as.Date("2005-03-13"),-9,"b") would mark your plot anywhere near 1960-05-04 09:00:00. Perhaps someone else does. Or perhaps you can provide an actual minimal working example of what you had working before you changed to POSIXct. On February 16, 2019 1:08:38 PM PST, Ogbos

Re: [R] Extending my code

2019-02-16 Thread Ogbos Okike
Dear Jeff, One more problem please. When I used as.Date(ISOdate(dta$year, dta$month, dta$day,dta$hour)) to handle date, I could use text(as.Date("2005-03-13"),-9,"b") to label my plot. Now that I am using as.POSIXct(ISOdatetime(year, month,day,hour,0,0))), can you please tell me how to text "b" o

Re: [R] Remove cases with -Inf from a data frame

2019-02-16 Thread Rui Barradas
Hello, An alternative, same dataset. df[apply(df, 1, function(x) all(is.finite(x))), ] Hope this helps, Rui Barradas Às 16:14 de 16/02/2019, Martin Møller Skarbiniks Pedersen escreveu: On Sat, 16 Feb 2019 at 16:07, AbouEl-Makarim Aboueissa < abouelmakarim1...@gmail.com> wrote: I have a lo

Re: [R] Remove cases with -Inf from a data frame

2019-02-16 Thread Bert Gunter
Sorry, that's function(x)all(is.finite(x) | is.na(x) ) of course. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Feb 16, 2019 at 8:25 AM Bert Gunter w

Re: [R] Remove cases with -Inf from a data frame

2019-02-16 Thread Bert Gunter
Many ways. I assume you know that Inf and -Inf are (special) numeric values that can be treated like other numerics. i.e. > 1 == - Inf [1] FALSE So straightforward indexing (selection) would do it. But there is also ?is.infinite and ?is.finite, so apply(yourdat, 1, function(x)all(is.finite(x)))

Re: [R] Remove cases with -Inf from a data frame

2019-02-16 Thread Martin Møller Skarbiniks Pedersen
On Sat, 16 Feb 2019 at 16:07, AbouEl-Makarim Aboueissa < abouelmakarim1...@gmail.com> wrote: > > I have a log-transformed data frame with some *-Inf* data values. > > *my question: *how to remove all rows with *-Inf* data value from that data > frame? Hi, Here is a solution which uses apply. F

Re: [R] Remove cases with -Inf from a data frame

2019-02-16 Thread Michael Dewey
Dear Abou Depends on exact details of your variables but ?is.finite Gives you the basic tool. On 16/02/2019 15:05, AbouEl-Makarim Aboueissa wrote: Dear All: good morning I have a log-transformed data frame with some *-Inf* data values. *my question: *how to remove all rows with *-Inf* data

[R] Remove cases with -Inf from a data frame

2019-02-16 Thread AbouEl-Makarim Aboueissa
Dear All: good morning I have a log-transformed data frame with some *-Inf* data values. *my question: *how to remove all rows with *-Inf* data value from that data frame? with many thanks abou __ *AbouEl-Makarim Aboueissa, PhD* *Professor, Statistics and Data Science* *