Re: [R] separate numbers from chars in a string

2014-07-30 Thread arun
If you have some variations of the order of numbers followed by chars, library(stringr) v1 <- c("absdfds0213451ab", "123abcs4145") pattern=c("[A-Za-z]+", "\\d+") do.call(`Map`,c(c,lapply(pattern, function(.pat) str_extract_all(v1, .pat #[[1]] #[1] "absdfds" "ab"  "0213451" #[[2]] #[1] "

Re: [R] Question

2014-07-30 Thread arun
Hi Farnoosh, Regarding the first question: dat2 <- dat1 dat1$Mean <- setNames(unsplit(sapply(split(dat1[,-1], dat1[,1]),rowMeans, na.rm=T),dat1[,1]),NULL) dat1   Unit q1 q2 q3 Mean 1    A  3  1  2 2.00 2    A  2 NA  1 1.50 3    B  2  2  4 2.67 4    B NA  2  5 3.50 5    C  3 

Re: [R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread arun
With >1 ID_CASE, you may try: xN <- x xN$ID_CASE <- "CB27A" #creating another ID_CASE, other data same x <- rbind(x, xN) res1 <- do.call(rbind, lapply(split(x, x$ID_CASE), function(.x) {     indx <- with(.x, t(sapply(min(MTH_SUPPORT):(max(MTH_SUPPORT) - 2), function(y) c(y,     y + 2  

Re: [R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread arun
For the example, you gave: x ##dataset indx <- t(sapply(min(x$MTH_SUPPORT):(max(x$MTH_SUPPORT) - 2), function(x) c(x, x +     2))) res <- do.call(rbind, apply(indx, 1, function(.indx) {     x1 <- x[x$MTH_SUPPORT >= .indx[1] & x$MTH_SUPPORT <= .indx[2], ]     Period <- paste(.indx[1], .indx[2],

Re: [R] lattice, latticeExtra: Adding moving averages to double y plot

2014-07-30 Thread Duncan Mackay
Hi Anna I am still unsure what you want 1 do you want 1 panel or 3? 2 do you want 1 y axis on the left and 1 on the right or 1 y axis on the left and 2 on the right or 1 on the right varying with groups in a multipanel plot For starters try xyplot(Value

Re: [R] is.na() == TRUE for POSIXlt time / date of "2014-03-09 02:00:00"

2014-07-30 Thread arun
Not able to reproduce the problem. str(q) # POSIXlt[1:1], format: "2014-03-09 02:00:00"  is.na(q) #[1] FALSE sessionInfo() R version 3.1.0 (2014-04-10) Platform: x86_64-unknown-linux-gnu (64-bit) A.K. On Wednesday, July 30, 2014 1:10 PM, John McKown wrote: "I'm so confused!" Why does is.na()

[R] Eager To Learn And Contribute!

2014-07-30 Thread Kartik Singh
Hi, I am Kartik Singh , an open source enthusiast who is aspiring to be a Data Scientist . Getting and Cleaning of data and its Analysis through R is something that fascinates me. I am not new to the field of Computer Science or Statistics but R is something i have started to learn and explore r

Re: [R] a knitr question

2014-07-30 Thread Yihui Xie
No. That is not my suggestion. Joshua Wiley correctly explained what I was suggesting. Prompts are useful in the R console, but not necessarily in a report. Regards, Yihui -- Yihui Xie Web: http://yihui.name On Wed, Jul 30, 2014 at 6:47 PM, Duncan Murdoch wrote: > So your suggestion is that th

Re: [R] separate numbers from chars in a string

2014-07-30 Thread carol white
There are some level of variation either chars followed by numbers or chars, numbers, chars Perhaps, I should use gsub as you suggested all and if the string is composed of chars followed by numbers, it will return the 3rd part empty? Regards, Carol On Wednesday, July 30, 2014 10:52 PM, Mar

Re: [R] a knitr question

2014-07-30 Thread Duncan Murdoch
On 30/07/2014, 8:06 PM, Joshua Wiley wrote: > On Thu, Jul 31, 2014 at 9:47 AM, Duncan Murdoch > mailto:murdoch.dun...@gmail.com>> wrote: > > On 30/07/2014, 2:20 PM, Yihui Xie wrote: > > As a reader, I often want to run the code by myself _while_ I'm > > reading a particular part of an

Re: [R] a knitr question

2014-07-30 Thread Michael Hannon
That's what I thought. Also, just FYI, the "ed" editor on *nix systems doesn't have a prompt (at least not by default). My son thought I was "trolling" him when I told him that. -- Mike On Wed, Jul 30, 2014 at 5:06 PM, Joshua Wiley wrote: > On Thu, Jul 31, 2014 at 9:47 AM, Duncan Murdoch > wr

Re: [R] a knitr question

2014-07-30 Thread Joshua Wiley
On Thu, Jul 31, 2014 at 9:47 AM, Duncan Murdoch wrote: > On 30/07/2014, 2:20 PM, Yihui Xie wrote: > > As a reader, I often want to run the code by myself _while_ I'm > > reading a particular part of an article/report. I find it convenient > > to be able to copy the code as I'm reading it, instead

Re: [R] a knitr question

2014-07-30 Thread Duncan Murdoch
On 30/07/2014, 2:20 PM, Yihui Xie wrote: > As a reader, I often want to run the code by myself _while_ I'm > reading a particular part of an article/report. I find it convenient > to be able to copy the code as I'm reading it, instead of minimizing > my current window, opening an R script, and runn

Re: [R] xtable problems with xts objects

2014-07-30 Thread Stergios Marinopoulos
I can live with that.  Thanks Ista!   -- Stergios Marinopoulos - Original Message - From: Ista Zahn To: Stergios Marinopoulos Cc: R. Project Help Sent: Wednesday, July 30, 2014 2:50 PM Subject: Re: [R] xtable problems with xts objects Hi Stergios, I think as.data.frame(x) solves bo

Re: [R] xtable problems with xts objects

2014-07-30 Thread Ista Zahn
Hi Stergios, I think as.data.frame(x) solves both your problems. Best, Ista On Wed, Jul 30, 2014 at 5:22 PM, Stergios Marinopoulos wrote: > Hi, I'm having trouble getting xtable to print a simple xts object. When > the frequency is 1800 I get an error. However when frequency(x) is reporte

[R] xtable problems with xts objects

2014-07-30 Thread Stergios Marinopoulos
Hi,  I'm having trouble getting xtable to print a simple xts object.  When the frequency is 1800 I get an error.  However when frequency(x) is reported as 1 it works.  I have included example below. Another question is how can I have the time index printed in place of the row number?   Thank

Re: [R] separate numbers from chars in a string

2014-07-30 Thread Uwe Ligges
On 30.07.2014 22:13, carol white wrote: Hi, If I have a string of consecutive chars followed by consecutive numbers and then chars, like "absdfds0213451ab", how to separate the consecutive chars from consecutive numbers? grep doesn't seem to be helpful grep("[a-z]","absdfds0213451ab", ignor

Re: [R] separate numbers from chars in a string

2014-07-30 Thread Marc Schwartz
On Jul 30, 2014, at 3:13 PM, carol white wrote: > Hi, > If I have a string of consecutive chars followed by consecutive numbers and > then chars, like "absdfds0213451ab", how to separate the consecutive chars > from consecutive numbers? > > grep doesn't seem to be helpful > > grep("[a-z]","ab

Re: [R] separate numbers from chars in a string

2014-07-30 Thread Rui Barradas
Hello, Maybe ?gregexpr and ?regmatches. SOmething like the following. m1 <- gregexpr("[a-z]+","absdfds0213451ab") regmatches("absdfds0213451ab", m1) m2 <- gregexpr("[0-9]+","absdfds0213451ab") regmatches("absdfds0213451ab", m2) Hope this helps, Rui Barradas Em 30-07-2014 21:13, carol white

Re: [R] Technological/Logistic substitution model.

2014-07-30 Thread Jeff Newmiller
You are repeating yourself. At least post as a reply to your earlier post. Does RSiteSearch("technological logistic") help? --- Jeff NewmillerThe . . Go Live... DCN:Basics:

Re: [R] a quick list mode question

2014-07-30 Thread Jeff Newmiller
I don't. Please post code to demonstrate your result when asking a question like this. test <- list() mode(test) [1] "list" --- Jeff NewmillerThe . . Go Live... DCN:Basics: #

Re: [R] binary to R object

2014-07-30 Thread Ramiro Barrantes
rawConnection did it!! Thank you very much!!! From: Prof Brian Ripley [rip...@stats.ox.ac.uk] Sent: Wednesday, July 30, 2014 4:14 PM To: Ramiro Barrantes; r-help@r-project.org Subject: Re: [R] binary to R object What type actually is 'binary' here? We can

Re: [R] binary to R object

2014-07-30 Thread Prof Brian Ripley
What type actually is 'binary' here? We cannot tell, as writeBin will handle many types. If 'binary' means a raw vector, two ways: 1) Use load() on a raw connection (see ?rawConnection). 2) Make use of the information in ?readRDS. You can read the header from save() format by skipping the f

Re: [R] a quick list mode question

2014-07-30 Thread Erin Hodgess
Sorry again... I put in mode(list), not mode(mylist) Rr! On Wed, Jul 30, 2014 at 4:07 PM, Erin Hodgess wrote: > Hello yet again > > I was looking at the class and the mode of a list. For the class of a > list, of course I got a list, but for the mode, I got a function. > > Wh

[R] separate numbers from chars in a string

2014-07-30 Thread carol white
Hi, If I have a string of consecutive chars followed by consecutive numbers and then chars, like "absdfds0213451ab", how to separate the consecutive chars from consecutive numbers? grep doesn't seem to be helpful grep("[a-z]","absdfds0213451ab", ignore.case=T) [1] 1  grep("[0-9]","absdfds0213

[R] a quick list mode question

2014-07-30 Thread Erin Hodgess
Hello yet again I was looking at the class and the mode of a list. For the class of a list, of course I got a list, but for the mode, I got a function. Why do you get a function, please? Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of

[R] binary to R object

2014-07-30 Thread Ramiro Barrantes
Hello, I have stored R objects as hexadecimals in a mysql database, I then usually transform them to binary and then save it into a file. E.g. hex <- getBlob #gets blob from database as hexadecimal binary <- transformToBinary(hex) #moves from hex to binary I would usually save them into

[R] xtable problems with xts objects

2014-07-30 Thread Stergios Marinopoulos
Hi,  I'm having trouble getting xtable to print a simple xts object.  When the frequency is 1800 seconds I get an error.  However when frequency(x) is reported as 1 it works.  I have included example below. Another question is how can I have the the time index printed in place of the row numbe

Re: [R] interactive labeling/highlighting on multiple xy scatter plots

2014-07-30 Thread Ramnath Vaidyanathan
ggvis is an excellent option to do this kind of stuff. The only limitation currently is that all sorts of interactivity (tooltips, brushing etc.) are done on the server side using Shiny. So you have to upload your HTML to a shiny server for the interactivity to work. Best, Ramnath _

Re: [R] is.na() == TRUE for POSIXlt time / date of "2014-03-09 02:00:00"

2014-07-30 Thread John McKown
Probably not the best, but here: con <- odbcConnect("BMC"); timezone <- Sys.timezone(); # query=paste0("select CONVERT(smalldatetime,Int_Start_Date,11) as Int_Start_Date,", " CONVERT(smalldatetime,CASE WHEN Int_Start_Time is NULL then '00:00' ", "else LEFT(Int_Start_Time,

Re: [R] is.na() == TRUE for POSIXlt time / date of "2014-03-09 02:00:00"

2014-07-30 Thread William Dunlap
I meant what R commands did you use to change the database's version of the time/date object to the R version? Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Jul 30, 2014 at 11:07 AM, John McKown wrote: > On Wed, Jul 30, 2014 at 12:54 PM, William Dunlap wrote: >>> I should have mentioned

Re: [R] is.na() == TRUE for POSIXlt time / date of "2014-03-09 02:00:00"

2014-07-30 Thread John McKown
OK, daylight saving time, may be be cursed, is definitely my problem. Strangely, the DB has data for time , 0100, 0200, 0400, 0500, ... 2300. It is closed source, so I have _no_ idea how this happened. And I cannot report bugs because it is no longer supported. The encoding is a 4 character (di

Re: [R] a knitr question

2014-07-30 Thread Yihui Xie
As a reader, I often want to run the code by myself _while_ I'm reading a particular part of an article/report. I find it convenient to be able to copy the code as I'm reading it, instead of minimizing my current window, opening an R script, and running the part that I'm interested in. Of course, t

Re: [R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread Abhinaba Roy
Hi, > x <- read.csv("log1.csv",header=TRUE,as.is=TRUE)> > dput(x=x)structure(list(ID_CASE = c("CB26A", "CB26A", "CB26A", "CB26A", "CB26A", "CB26A", "CB26A", "CB26A", "CB26A", "CB26A", "CB26A" ), MTH_SUPPORT = c(201302L, 201302L, 201303L, 201304L, 201305L, 201305L, 201306L, 201307L, 201309L, 20131

Re: [R] is.na() == TRUE for POSIXlt time / date of "2014-03-09 02:00:00"

2014-07-30 Thread John McKown
On Wed, Jul 30, 2014 at 12:54 PM, William Dunlap wrote: >> I should have mentioned that I tried other time stamps, generated the >> same way as "q" above. > > How did you generate q and in what time zone were you? I got it from an MS-SQL data base which is maintained by some closed-source vendor

Re: [R] is.na() == TRUE for POSIXlt time / date of "2014-03-09 02:00:00"

2014-07-30 Thread Jeff Newmiller
Isn't that a timestamp that doesn't exist in standard US timezones? Maybe use a timezone that doesn't consider daylight savings (like "Etc/GMT+5")? --- Jeff NewmillerThe . . Go Live..

Re: [R] Count number of change in a specified time interval

2014-07-30 Thread Adams, Jean
I may not understand exactly what you want, because when I try to follow your instructions, I get a different result. But, perhaps you can use this code and modify it to suit your needs. # number of rows L <- dim(df)[1] # determine for each row if it is within the first 3 months mins <- aggregat

Re: [R] is.na() == TRUE for POSIXlt time / date of "2014-03-09 02:00:00"

2014-07-30 Thread William Dunlap
> I should have mentioned that I tried other time stamps, generated the > same way as "q" above. How did you generate q and in what time zone were you? Note that 2am on 9 March 2014 is when 'daylight savings time' started in the parts of the US where it is observed. Does 2am exist or do we jump

Re: [R] ATTN: Urgent Guidance Needed on scraping tweets for last 10 years using TwitteR / search twitter function.

2014-07-30 Thread Hadley Wickham
The first twitter message was sent on March 21st, 2006... Hadley On Wed, Jul 30, 2014 at 3:58 AM, Abhishek Dutta wrote: > Hi > > > This is Abhishek and I am trying to look for tweets on 'Election' from > 2000 to YTD. I have registered on twitter and performed a handshake > between the systems as

Re: [R] a knitr question

2014-07-30 Thread Greg Snow
My preference when teaching is to have the code and results look the same as it appears in the R console window, so with the prompts and without the output commented. But then I also `purl` my knitr file to create a script file to give to the students that they can copy and paste from easily. On

Re: [R] is.na() == TRUE for POSIXlt time / date of "2014-03-09 02:00:00"

2014-07-30 Thread John McKown
On Wed, Jul 30, 2014 at 12:18 PM, Duncan Murdoch wrote: > On 30/07/2014 1:08 PM, John McKown wrote: >> >> "I'm so confused!" Why does is.na() report TRUE for a POSIXlt date & >> time of 2014-03-09 02:00:00 ? >> >> > q >> [1] "2014-03-09 02:00:00" >> > is.na(q) >> [1] TRUE >> > as.POSIXct(q) >> [1]

Re: [R] is.na() == TRUE for POSIXlt time / date of "2014-03-09 02:00:00"

2014-07-30 Thread Duncan Murdoch
On 30/07/2014 1:08 PM, John McKown wrote: "I'm so confused!" Why does is.na() report TRUE for a POSIXlt date & time of 2014-03-09 02:00:00 ? > q [1] "2014-03-09 02:00:00" > is.na(q) [1] TRUE > as.POSIXct(q) [1] NA > dput(q) structure(list(sec = 0, min = 0L, hour = 2, mday = 9L, mon = 2L, ye

[R] is.na() == TRUE for POSIXlt time / date of "2014-03-09 02:00:00"

2014-07-30 Thread John McKown
"I'm so confused!" Why does is.na() report TRUE for a POSIXlt date & time of 2014-03-09 02:00:00 ? > q [1] "2014-03-09 02:00:00" > is.na(q) [1] TRUE > as.POSIXct(q) [1] NA > dput(q) structure(list(sec = 0, min = 0L, hour = 2, mday = 9L, mon = 2L, year = 114L, wday = 0L, yday = 67L, isdst = 0L,

Re: [R] interactive labeling/highlighting on multiple xy scatter plots

2014-07-30 Thread Greg Snow
Another option that is in developement, but may do what you want is ggvis (http://ggvis.rstudio.com/). I have seen an example of brushing created with ggvis that can then be embedded in a web page. I am not sure if you can send the html and support files directly to someone without R (probably Rs

Re: [R] Technological/Logistic substitution model.

2014-07-30 Thread Peter Maclean
 Any one with an idea of estimating the Technological/Logistic substitution model. The model is specified as: fi(t(j)) = 1/[1-exp(-alpa(t(i))-beta(i)] for t 0 fi(t(j)) = 1-sum(f(j-1))- sum(f(j+1)) for tb <=t <= tc fi(t(j)) = 1/[1+ exp(alpas(t(i)-betas(i))] for t >=tc and alphas >0. T The model

Re: [R] one more knitr question, please

2014-07-30 Thread Yihui Xie
Not sure if you mean \newpage{}/\pagebreak{} in LaTeX. If that is the case, it is possible but easy, and I do not understand why you want to break a code chunk onto two pages. The easiest thing to do is just to write two code chunks. Regards, Yihui -- Yihui Xie Web: http://yihui.name On Wed, Ju

Re: [R] a knitr question

2014-07-30 Thread Ista Zahn
On Tue, Jul 29, 2014 at 10:17 PM, Erin Hodgess wrote: > I was thinking that for teaching, it may be helpful for them to see the > whole thing. Hopefully you're teaching them to write their code in a script, in which case the prompt will not be helpful. Best, Ista > > > On Tue, Jul 29, 2014 at 6:

Re: [R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread PIKAL Petr
Hi Maybe ?aggregate Use dput for data presentation and no HTML as everything gets scrambled with it. Regards Petr > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Abhinaba Roy > Sent: Wednesday, July 30, 2014 2:46 PM > To:

Re: [R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread Bert Gunter
Is this homework? There is a no homework policy here. And stop posting in HTML --- plain text only-- and learn to use ?dput to post example data. -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 "Data is not information. Information is not knowledge. And knowledge is certa

Re: [R] one more knitr question, please

2014-07-30 Thread Jeff Newmiller
In general, I don't thiink so. But are you aware that knitr has its own help forum [1]? [1] https://groups.google.com/forum/m/#!forum/knitr --- Jeff NewmillerThe . . Go Live... DCN:

[R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread Abhinaba Roy
Hi R-helpers, I have dataframe like ID_CASE YEAR_MTH ATT_1 A1 A2 A3 CB26A 201302 1 146 42 74 CB26A 201302 0 140 50 77 CB26A 201303 0 128 36 77 CB26A 201304 1 146 36 72 CB26A 201305 1 134 36 80 CB26A 201305 0 148 30 80 CB26A 201306 0 134 20 72 CB26A

Re: [R] ATTN: Urgent Guidance Needed on scraping tweets for last 10 years using TwitteR / search twitter function.

2014-07-30 Thread Abhishek Dutta
Hi Tim, Thanks a tonne for your reply. Will check twitter Archives. Thanks Best Abhishek On Wed, Jul 30, 2014 at 4:57 PM, Timothy W. Cook wrote: > The Twitter API doesn't provide data that far back. There are services > that have archived the data and charge a fee depending upon your needs.

[R] one more knitr question, please

2014-07-30 Thread Erin Hodgess
Hello again: Is there a way to put a page break inside of a code chunk, please? Thanks, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] ___

Re: [R] ATTN: Urgent Guidance Needed on scraping tweets for last 10 years using TwitteR / search twitter function.

2014-07-30 Thread Timothy W. Cook
The Twitter API doesn't provide data that far back. There are services that have archived the data and charge a fee depending upon your needs. You can search for Twitter archives to find a vendor. This page may help you with getting started using the Twitter API and the services available. https

Re: [R] Copulas and spatial modeling

2014-07-30 Thread Jon Skoien
As a start you might look at the spcopula package from r-forge: install.packages("spcopula", repos = "http://r-forge.r-project.org";) Spatial copulas can also be used for interpolation in the intamap package (on CRAN). You are likely to get more responses to questions about spatial modelling o

[R] ATTN: Urgent Guidance Needed on scraping tweets for last 10 years using TwitteR / search twitter function.

2014-07-30 Thread Abhishek Dutta
Hi This is Abhishek and I am trying to look for tweets on 'Election' from 2000 to YTD. I have registered on twitter and performed a handshake between the systems as well. Next I am trying to fetching tweets chronologically using the below code:- tweets1.list = searchTwitter('Election',lang="en"

Re: [R] Map with no political border

2014-07-30 Thread Julien Million
Fantastic Jim! Thanks a lot Julien ___ Julien Million Independent Fisheries Consultant On 30/07/14 11:31, "Jim Lemon" wrote: >On Wed, 30 Jul 2014 11:18:13 AM Julien Million wrote: >> Hi, >> >> I would like to plot a map without political borders, but not black... I >>

Re: [R] Map with no political border

2014-07-30 Thread Jim Lemon
On Wed, 30 Jul 2014 11:18:13 AM Julien Million wrote: > Hi, > > I would like to plot a map without political borders, but not black... I > am mainly using the maps package, and wanted to know if it was possible > with this one, or if I should use something else, like shape file. > > If I do > >

[R] Map with no political border

2014-07-30 Thread Julien Million
Hi, I would like to plot a map without political borders, but not black... I am mainly using the maps package, and wanted to know if it was possible with this one, or if I should use something else, like shape file. If I do library(maps) map(fill=T) I have a map of the world filled in black. I

Re: [R] venn.diagram, error message: Incorrect number of elements

2014-07-30 Thread Fix Ace
Thanks! On Tuesday, July 29, 2014 3:08 PM, Sarah Goslee wrote: The venn.diagram() function in the package VennDiagram only works with sizes up to 5. That isn't horribly clear from the help file, but quite explicit in the code:     if (0 == length(x) | length(x) > 5) {         stop("Inco

[R] Count number of change in a specified time interval

2014-07-30 Thread Abhinaba Roy
Dear R-helpers, I want to count the number of times ATT_1 has changed in a period of 3 months(can be 4months) from the first YEAR_MTH entry for a CASE_ID. So if for a CASE_ID we have data only for two distinct YEAR_MTH, then all the entries should be considered, otherwise only the relevant entries