[R] Calculating Weeks Since Last Event

2017-09-15 Thread Abhinaba Roy
Hi, I have an input data > dput (input) structure(list(ScanDate = structure(c(16433, 16440, 16447, 16454, 16461, 16468, 16475, 16482, 16489, 16496, 16503, 16510, 16517, 16524, 16531, 16538, 16545, 16552, 16559, 16566, 16573, 16580, 16587, 16594, 16601, 16608, 16615, 16622), class = "Date"), OnPr

[R] Extracting first number after * in a character vector

2017-01-23 Thread Abhinaba Roy
Hi, How do I extract the first number after '*' in a vector? The vector is given below > dput(out[1:10]) c(" 1 X[0,SMITH] * 0 0 1 ", " 2 X[0,JOHNSON] * 0 0 1 ", " 3 X[0,WILLIAMS]", "*

[R] JSON to Dataframe

2016-10-18 Thread Abhinaba Roy
Hi R helpers, I have json inputs from an app which I want to convert to dataframes. Below are the two inputs. Can someone help me in converting these to dataframes *Input1* {"booking":{"id":"54092","createdOn":"2016-10-06T06:29:00.000+","bookingDateTime":"2016-10-08T06:45:00.000+

[R] Portfolio Optimization

2016-09-17 Thread Abhinaba Roy
Hi, Has anybody worked on portfolio optimization using Genetic Algorithm in R? Could you please share the code and some references on this topic? Really appreciate your help. Thanks, Abhinaba [[alternative HTML version deleted]] __ R-help@r-

[R] Calculate mileage at each 'faildate'

2016-08-10 Thread Abhinaba Roy
Hi R-helpers, - I have a dataframe similar to 'simD'. > dput(simD) structure(list(ID = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("A", "B"), class = "factor"), PRODDATE = structure(c(14655, 14655, 14655, 14655, 14664, 14664, 14664, 14664, 14664, 14664 ), class = "Date"),

[R] Changing column names by unique factor levels

2015-12-19 Thread Abhinaba Roy
Hi R helpers, I am stuck with a very strange problem. My input data is structure(list(Date = structure(c(1447007400, 1447007400, 1447093800, 1447093800), tzone = "", class = c("POSIXct", "POSIXt")), Prod = c("Colg", "P&G", "Colg", "P&G"), Amt = c(57, 11, 62, 77), Amt1 = c(86, 72, 20, 23), Amt2 =

Re: [R] Extracting part of alpha numeric string

2015-11-30 Thread Abhinaba Roy
e69", > "00966654-0dea-4899-b8cf-26e8300b262d") > sub("^([0-9]*).*$", "\\1", fields) > > Best, > > Philippe Grosjean > > > On 30 Nov 2015, at 11:39, Abhinaba Roy wrote: > > > > Hi, > > > > I have a field

[R] Extracting part of alpha numeric string

2015-11-30 Thread Abhinaba Roy
Hi, I have a field with alpha numeric codes like, 2154333b-3208-4519-8b76-acaef5b5a479 980958a0-103b-4ba9-afaf-27b2f5c24e69 00966654-0dea-4899-b8cf-26e8300b262d I want a derived field which will contain ONLY the numeric part before the first alphabet and the first '-', for example the derived fi

[R] getURL not working in loop

2015-07-21 Thread Abhinaba Roy
Hi R helpers, I am trying to extract customer feedback from an e-commerce site and subsequently use it for creating a word cloud. Below is the code I have #web-crawling library(RCurl) library(XML) library(rvest) #web-crawling init=" http://www.flipkart.com/moto-g-2nd-generation/product-reviews/I

[R] Web crawling amazon website using R

2015-06-30 Thread Abhinaba Roy
/ref=dpx_acr_txt?showViewpoints=1 How do I achieve this using R? Regards, Abhinaba Roy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help

[R] Counting consecutive events in R

2015-05-14 Thread Abhinaba Roy
Hi, I have the following dataframe structure(list(Type = c("QRS", "QRS", "QRS", "QRS", "QRS", "QRS", "QRS", "QRS", "QRS", "QRS", "QRS", "QRS", "RR", "RR", "RR", "PP", "PP", "PP", "PP", "PP", "PP", "PP", "PP", "PP", "QTc", "QTc", "QTc", "QTc", "QTc", "QTc", "QTc", "QTc", "QTc", "QTc", "QTc", "QTc"

[R] Conversion of Matlab code to an R code

2015-03-23 Thread Abhinaba Roy
Hi, Can a Matlab code be converted to R code? I am finding it difficult to do so. Could you please help me out with it. Your help will be highly appreciated. Here comes the Matlab code ## if ~isvector(ecg) error('ecg must be a row or column vector'); end if nargin < 3 gr =

[R] Identification of QRS complex from ECG data

2015-03-18 Thread Abhinaba Roy
Hi R helpers, I was going through some documents, which explains a few algorithms (e.g., Pan Tomkins algo) for identification of QRS complex and how it is implemented in R. Also the logic used is not very clear. Could you please provide me with an R code to identify the QRS complex? Any help is

[R] Passing object value in command line

2014-10-15 Thread Abhinaba Roy
Hi R-helpers, I have a R script (mainCall.R) which takes the value of an object *'Mon'* as '31-may-2014' or '31-aug-2014' . How can I run the R script by passing the value of Mon from the command prompt? Any help will be appreciated Regards, Abhinaba [[alternative HTML version deleted]

Re: [R] Count number of Fridays

2014-10-10 Thread Abhinaba Roy
fri, '\n') > Fri this month: 5 Fri last month: 4 > > sign(first_fri - prev_fri) # will do the 'ifelse'-type test you want > [1] 1 > > > > Jim Holtman > Data Munger Guru > > What is the problem that you are trying to solve? > Tell me what you

Re: [R] Count number of Fridays in a month

2014-10-10 Thread Abhinaba Roy
Hi Duncan, I have converted the string to a POSIXIt object using > strptime('31-may-2014',format="%d-%b-%Y") But could not figure out the way forward. Could you please elaborate a bit? On Fri, Oct 10, 2014 at 5:14 PM, Duncan Murdoch wrote: > On 10/10/2014, 7

[R] Count number of Fridays in a month

2014-10-10 Thread Abhinaba Roy
Hi R helpers, I want to write a function which will 1. Count the number of fridays in the current month ( to extract month from given date) and also the number of fridays in the preceeding month 2. Calculate the ratio of the number of fridays in current month to the number of fridays in the prec

[R] Logging and writing error messages to a dataframe

2014-09-19 Thread Abhinaba Roy
Hi R-helpers, I intend to record the errors in my R code while calling functions in a dataframe (ERR_LOG, say). I want to use 'try' to identify errors while calling a function,if any.The dataframe(ERR_LOG) will have the following columns : Time : The time at which the function was called (Sys.tim

Re: [R] DATA SUMMARIZING and REPORTING

2014-07-30 Thread Abhinaba Roy
ard to a solution to the problem. Thank you Regards On Wed, Jul 30, 2014 at 7:31 PM, PIKAL Petr wrote: > Hi > > Maybe > > ?aggregate > > Use dput for data presentation and no HTML as everything gets scrambled > with it. > > Regards > Petr > > &

[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

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

2014-07-30 Thread Abhinaba Roy
is be done in R? Regards, Abhinaba Roy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide

[R] Multiple Correspondence Analysis

2014-07-14 Thread Abhinaba Roy
d levels as the plot is not clear? -- Regards, Abhinaba Roy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org

Re: [R] Decision Tree

2014-07-10 Thread Abhinaba Roy
the prp() function in the rpart.plot package. If you look at > the help for prp(), you should be able to see how to change the color. > > library(rpart.plot) > ?prp > > Jean > > > > On Thu, Jul 10, 2014 at 12:34 AM, Abhinaba Roy > wrote: > >> Hi R

[R] Decision Tree

2014-07-09 Thread Abhinaba Roy
Hi R-helpers, Is it possible to change the color of the boxes when plotting decision trees using 'fancyRpartPlot()' from rpart.plot package ? -- Regards, Abhinaba Roy [[alternative HTML version deleted]] __ R-help@r-project.org ma

Re: [R] Problem in compiling a function

2014-07-03 Thread Abhinaba Roy
> On Thu, Jul 3, 2014 at 4:03 PM, Abhinaba Roy > wrote: > > Hi, > > > > The 'if' statement closes > > CA$IND_COLLECTION[CA$TOT_PAID= > > =0] <- 5L} > > > > > > > > On Thu, Jul 3, 2014 at 12:12 PM, Pascal Oettli wrote: > >&g

Re: [R] Problem in compiling a function

2014-07-03 Thread Abhinaba Roy
Hi, The 'if' statement closes CA$IND_COLLECTION[CA$TOT_PAID= =0] <- 5L} On Thu, Jul 3, 2014 at 12:12 PM, Pascal Oettli wrote: > Hi, > > At the 3rd line, a bracket is missing, to close the "if" statement. > > HTH > Pascal > > On Thu, Jul 3, 2

[R] Problem in compiling a function

2014-07-02 Thread Abhinaba Roy
Hi R-helpers, Can someone help me with this function prepArr <- function(CA) { if(CA$CD_ACCRUAL_FLAG == 'AY' ){ if(!is.na(CA_AMT_PAYBACK ){ CA$IND_COLLECTION[(CA$TOT_PAID>=CA$TOT_ARREAR_BEG| CA$TOT_PAID>=CA_AMT_PAYBACK)] <- 1L CA$I

[R] Basket Analysis in R: extract rules

2014-06-26 Thread Abhinaba Roy
of 0 variables ..@ quality:'data.frame': 16 obs. of 3 variables: .. ..$ support : num [1:16] 0.16 0.16 0.169 0.169 0.321 ... .. ..$ confidence: num [1:16] 0.619 0.244 0.654 0.242 0.661 ... .. ..$ lift : num [1:16] 0.943 0.943 0.935 0.935 1.007 ... ..@ info :List

Re: [R] Generating Patient Data

2014-06-24 Thread Abhinaba Roy
Hi David, I was thinking something like this: ID Disease 1 A 2 B 3 A 1C 2D 5A 4B 3D 2A .... How can this be done? On Wed, Jun 25, 2014 at 11:34 AM, David Winsemius wrote: > > On Jun 24, 2014, at 10:14 PM, Abhinaba Roy wrote: > > >

[R] Generating Patient Data

2014-06-24 Thread Abhinaba Roy
e two columns 'ID' and 'Disease'. I want to do a basket analysis with this data, where ID will be the identifier and we will establish rules based on the 'Disease' column. How can I generate this type of data in R? -- Regards Abhinaba Roy

[R] Manipulating dataframes

2014-05-15 Thread Abhinaba Roy
Y to N and vice-verse) for 'ATT_1' in the previous month (i.e., in YEARMONTH_LAG1) 3. ATT2_CHNG is the number of times the level has changed (i.e., from 0 to 1 and vice-verse) for ATT_2 in the previous month How can this be done in R? -- Regards Abhinaba Roy [[alternative

Re: [R] Merging data.table and data.frame

2014-05-13 Thread Abhinaba Roy
2014 at 7:13 PM, peter dalgaard wrote: > > On 13 May 2014, at 14:34 , Abhinaba Roy wrote: > > > Hi R-helpers, > > > > I am trying the following code in R > > > > > merge(x=Master1,y=demo_dtls,by.x=c("ID_CASE","ts"),by.y=c("

[R] Merging data.table and data.frame

2014-05-13 Thread Abhinaba Roy
o automatically determine appropriate `by` parameter. Please set `by` value explicitly. Why am I getting this error? Any help will be appreciated -- Regards Abhinaba Roy [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] Lag in dataframe

2014-05-12 Thread Abhinaba Roy
(df,.(ID_CASE),transform, Lag_1 <- c(NA,Month[-nrow(df)])) But this does not give me the desired output for Lag_1. And how can this be done if I have a *date-time* object instead of an *int*column 'Month' as in the current example? Any help on this will be appreciated. -- Rega

[R] Capture change in variable in R

2014-05-08 Thread Abhinaba Roy
; Note: I have 5000 unique ID in the data and this has to be done for each ID and the data is sorted by Yr_Mnth. Please find attached the csv file for reference. How can it be done in R? -- Regards Abhinaba Roy __ R-help@r-project.org mailing list https:

[R] Summary to data frame in R!!

2014-05-07 Thread Abhinaba Roy
:472.0 I want a dataframe as mpgdisp Min. 10.40 71.1 1st Qu. 15.43 120.8 Median 19.20 196.3 Mean20.09 230.7 3rd Qu. 22.80 326.0 Max. 33.90 472.0 How can it be done in R? -- Regards Abhinaba Roy [[altern