Re: [R] Query about calculating the monthly average of daily data columns

2019-09-13 Thread Jim Lemon
Sorry, forgot to include the list. On Sat, Sep 14, 2019 at 10:27 AM Jim Lemon wrote: > > See inline > > On Fri, Sep 13, 2019 at 11:20 PM Subhamitra Patra > wrote: >> >> Dear Sir, >> >> Yes, I understood the logic. But, still, I have a few queries that I >> mentioned below your answers. >> >>>

Re: [R] A question on regular expression

2019-09-13 Thread Jeff Newmiller
Regular expressions are in much more widespread use than merely R... and there are correspondingly more resources for learning than just R-help. Please do make use of them. Here are a couple that googling "regex character set carat" found: https://www.regular-expressions.info/charclass.html htt

Re: [R] Query about calculating the monthly average of daily data columns

2019-09-13 Thread Subhamitra Patra
Dear PIKAL, Thank you very much for your suggestion. I tried your previous suggested code and getting the average value for each month for both country A, and B. But in your recent email, you are suggesting not to change the date column to real date. If I am going through your recently suggested

Re: [R] Query about calculating the monthly average of daily data columns

2019-09-13 Thread PIKAL Petr
Hi I am almost 100% sure that you would spare yourself much trouble if you changed your date column to real date ?as.Date reshape your wide format to long one library(reshape2) ?melt to get 3 column data.frame with one date column, one country column and one value column use ?aggregate and ?

Re: [R] Bug (?): file.copy() erases 'from' file if the "to" file already exists and is a symlinked file

2019-09-13 Thread peter dalgaard
However, notice that cat doesn't protect you in the same way: Peters-iMac:tst pd$ echo stuff > A Peters-iMac:tst pd$ ln -s A B Peters-iMac:tst pd$ ls -l total 8 -rw-r--r-- 1 pd staff 6 Sep 13 15:20 A lrwxr-xr-x 1 pd staff 1 Sep 13 15:20 B -> A Peters-iMac:tst pd$ cp A B cp: B and A are ident

Re: [R] Query about calculating the monthly average of daily data columns

2019-09-13 Thread Subhamitra Patra
Dear Sir, Yes, I understood the logic. But, still, I have a few queries that I mentioned below your answers. "# if you only have to get the monthly averages, it can be done this way > spdat$month<-sapply(strsplit(spdat$dates,"-"),"["*,2*) > spdat$year<-sapply(strsplit(spdat$dates,"-"),"[",*3*)" >

Re: [R] A question on regular expression

2019-09-13 Thread Christofer Bogaso
A quick question. Could you please explain the -- [^}]* -- part in finding the pattern? On Fri, Sep 13, 2019 at 12:19 AM Bert Gunter wrote: > > > You can't use the same regex for str_extract_all as I used for sub (or gsub, > which is what is required here)! If you do this sort of thing a lot, y

Re: [R] Query about calculating the monthly average of daily data columns

2019-09-13 Thread Jim Lemon
Hi Subhamitra, I'll try to write my answers adjacent to your questions below. On Fri, Sep 13, 2019 at 6:08 PM Subhamitra Patra wrote: > Dear Sir, > > Thank you very much for your suggestion. > > Yes, your suggested code worked. But, actually, I have data from 3rd > January 1994 to 3rd August 201

Re: [R] Query about calculating the monthly average of daily data columns

2019-09-13 Thread PIKAL Petr
Hi I may be completely wrong but reshape/aggregate should by what you want spdat dates returnA returnB 1 1-1-1994 16 13 2 2-1-1994 44 10 3 3-1-1994 24 32 . > library(reshape2) > spdat.m <- melt(spdat) Using dates as id variables > str(spdat.m) 'data.f

Re: [R] test if something was plotted on pdf device

2019-09-13 Thread PIKAL Petr
Dear Duncan Thank you for the code, I will test it or at least check what it does. I finally found probably easier solution. I stay with my original code if (dev.cur()==1) plot(ecdf(velik[,"ecd"]), main = ufil[j], col=i) else plot(ecdf(velik[,"ecd"]), add=T, col=i) After plot is finished and c

[R] Bug (?): file.copy() erases 'from' file if the "to" file already exists and is a symlinked file

2019-09-13 Thread Marc Girondot via R-help
If file.copy() is used to replace a symlinked file, it erases the original file and does not copy the file. The original file is lost. > version _ platform x86_64-apple-darwin15.6.0 arch x86_64 os darwin15.6.0 s

Re: [R] Query about calculating the monthly average of daily data columns

2019-09-13 Thread Subhamitra Patra
Dear Sir, Thank you very much for your suggestion. Yes, your suggested code worked. But, actually, I have data from 3rd January 1994 to 3rd August 2017 for very large (i.e. for 84 countries) sample. From this, I have given the example of the years up to 2000. Before applying the same code for the