[R] Problems with basic loop

2008-06-20 Thread Michael Pearmain
I'm having trouble creating a looping variable and i can't see wher ethe problem arises from any hep gratfully appreciated First create a table x<-table(SURVEY$n_0,exposed) > x exposed False True Under 16241 16-19 689 20-24 190 37 25-34 5

Re: [R] Problems with basic loop

2008-06-20 Thread Michael Pearmain
> to look at z-tests for proportions to check for post-hoc differences > > Any advise on other methods would be gratefully taken > > > > On Fri, Jun 20, 2008 at 11:14 AM, Peter Dalgaard <[EMAIL PROTECTED]> > wrote: > >> Michael Pearmain wrote: >> > I&#

[R] Selecting Variables

2008-08-05 Thread Michael Pearmain
Hi All, i have a dataset that i want to dynamically inspect for the number of variables that start with "Exposure_" and then for these count the entries across each case i.e ID Exposure_1 Exposure_2 Exposure_3 1y yy 2y y

Re: [R] Selecting Variables

2008-08-05 Thread Michael Pearmain
of NAs > > y <- y[complete.cases(y),] > > y > ID variable value > 1 1 Exposure_1 y > 2 2 Exposure_1 y > 3 3 Exposure_1 y > 4 1 Exposure_2 y > 5 2 Exposure_2 y > 7 1 Exposure_3 y > > cbind(Unique=tapply(y$ID, y$ID, length)) > U

[R] Flag variable

2008-08-13 Thread Michael Pearmain
Hi All, I have 4000 case which have string variables in them, i want to do some fuzzy matching and create a new variable that is of the same length with 0 or 1's if i use the code test<- agrep("web Klick",ETC$Exposure.Type , max = 2, ignore.case = TRUE) it works but i get > length(test) [1] 3127

[R] Deleting multiple variables

2008-09-22 Thread Michael Pearmain
Hi All, i have searched the web for a simple solution but have been unable to find one. Can anyone recommend a neat way of deleting multiple variable? I see, i need to use dataframe$VAR<-NULL to get rid of one variable, In my situation i need to delete all vars between two points. I've used the '

[R] Contional

2008-09-23 Thread Michael Pearmain
Hi All, I'm having trouble selecting rows to delete, that i can't seem to overcome. Below is some sample data, i am trying to dedup the data based on each user, and simultaneously the timestamp (at the side i have highlighted expected row to be removed) I've looked at the lag function but can't

[R] Help with aggregation

2008-10-02 Thread Michael Pearmain
Hi All, I seem to be having a few troubles with aggregating data back onto the the dataframe, I want to take the max value of a user, and then apply this max value back against all id's that match (i.e a one to many matching) Can anyone offer any advice? is there a better way of doing this? Dummy

[R] Time conversion

2008-10-02 Thread Michael Pearmain
07-07-2008-13:39:55 timestamp<-strptime(timestamp,"%d-%m-%y-%H:%M:%S") ## then filter on the datetime time<-ifelse(timestamp> "07-08-2008-00:00:00", TRUE, FALSE) -- Michael Pearmain Senior Statistical Analyst Google UK Ltd Belgrave House 76 Buckingham Palace Ro

[R] Paste in a FOR loop

2008-12-31 Thread Michael Pearmain
Hi All, I've been having a little trouble using R2HTML and a loop, but can't figure out where the problem lies, any hints gratefully received. My code at the minute, (Which does work) is in the following: library(R2HTML) HTMLStart(outdir = file.path("C://Example_work","R_projects","Dynamic_creati

[R] t.test in a loop

2009-01-28 Thread Michael Pearmain
ot; "power" [28] "tt" > for(i in names(channel.data.train[,c(1:16)])){ + t.test(get(paste("channel.data.train$",i,"~channel.data.train$power",sep=""))) + } Error in get(paste("channel.data.train$", i, "~channel.data.train

[R] Merging two dataframes

2008-06-06 Thread Michael Pearmain
have 1800 cases while the ETC data file only has 67 and the SURVEY file only has 28. (Reading the help it looks as if it merges 1 case with all cases in the other file, which is not what i want) The matching variables fields are the 'ord' field and the 'uid

[R] Missing Data and applying

2008-06-09 Thread Michael Pearmain
Hi All, Newbie question that i'm sure is easy, but i can't seem to apply properly I read in a datafram from a CSV file and i want to tell R that from coloum "n_0" to "n_32" the value "-1" is missing data i was looking at the is.na(xx) <- c(..,...,) idea but i can't seem to apply it properly, can

[R] Calling functions

2008-06-17 Thread Michael Pearmain
Another newbie question. I've written a function and saved the file as Xtabs.R, in a central place on a network so others will be able ot use the function, My question is how do i call this function? I've tried to chance the working directory, and tried to load it via; > library(Xtabs, lib.loc="/

[R] Z test and proportions

2008-06-17 Thread Michael Pearmain
Hi All, I have a table based on ordial data and i want to compare proportions and i've seen in the pwr package i can use power.prop.test however i want to find out what the sig. value is based on n1,n2,p1,p2 and this package doesn't contain this.. Does anyone know of a package that does or is it

Re: [R] Z test and proportions

2008-06-17 Thread Michael Pearmain
t 5:13 PM, Peter Dalgaard <[EMAIL PROTECTED]> wrote: > Michael Pearmain wrote: > > Hi All, > > > > I have a table based on ordial data and i want to compare proportions and > > i've seen in the pwr package i can use > > power.prop.test > > >

[R] Timestamps and manipulations

2008-10-13 Thread Michael Pearmain
Hi All, I've a couple of questions i've been struggling with using the time features, can anyone help? sample data Timestampuser_id 27/05/08 22:57 763830873067 27/05/08 23:00 763830873067 27/05/08 23:01 763830873067 27/05/08 23:01 763830873067 05/06/08 11:34 763830

[R] comparing with lead function

2008-10-15 Thread Michael Pearmain
Hi All, I've been trying to compare if the previous value in a variable is equal to a binary value..(i.e i want to check if the last event was a yes or no) i've been trying to write some code for this, but it seems overly elaborate, can anyone suggest a better / shorter / neater way? The below doe

[R] Loop swith String replacement

2008-12-05 Thread Michael Pearmain
2212 1.7443 0 2 14 Chrome 6012 0.2253 0 2 15 Chrome 2414 4.3348 1 3 -- Michael Pearmain Senior Analytics Research Specialist Google UK Ltd Belgrave House 76 Buckingham Palace Road

[R] Forecasting with dlm

2009-03-11 Thread Michael Pearmain
Hi All, I have a problem trying to forecast using the dlm package, can anyone offer any advise? I setup my problem as follows, (following the manual as much as possible) data for example to run code CostUSD <- c(27.24031,32.97051, 38.72474, 22.78394, 28.58938, 49.85973, 42.93949, 35.92468) libra

[R] Help with nls and error messages singular gradient

2009-08-25 Thread Michael Pearmain
data = mydata, start = list(beta1 = 3, : singular gradient Can anyone offer any advice? Thanks in advance Mike -- Michael Pearmain Senior Analytics Research Specialist “Statistics are like women; mirrors of purest virtue and truth, or like whores to use as one pleases” Google UK Ltd

[R] Viewing Function Code

2009-09-15 Thread Michael Pearmain
> barplot2 function (height, ...) UseMethod("barplot2") Mike -- Michael Pearmain Senior Analytics Research Specialist "I abhor averages. I like the individual case. A man may have six meals one day and none the next, making an average of three meals per day, but that is no