[R] Assign and cmpfun

2012-01-06 Thread Michael Pearmain
Hi All, I've just recently discovered the cmpfun function, and was wanting to to create a function to assign this to all the functions i have created, but without explicitly naming them. I've achieved this with: foo - function(x) { print(x)} bar - function(x) { print(x + 1)} foo - function(x)

[R] missing value where TRUE/FALSE needed

2011-12-23 Thread Michael Pearmain
Merry Xmas to all, I am writing a function and curiously this runs sometimes on one data set and fails on another and i cannot figure out why. Any help much appreciated. If i run the code below with data - iris[ ,1:4] The code runs fine, but if i run on a large dataset i get the following error

Re: [R] missing value where TRUE/FALSE needed

2011-12-23 Thread Michael Pearmain
the following command: options(error=utils::recover) and then learn how to use the 'browser' to examine variables when the error occurs. On Fri, Dec 23, 2011 at 5:44 AM, Michael Pearmain michael.pearm...@gmail.com wrote: Merry Xmas to all, I am writing a function and curiously this runs

[R] Convert ragged list to structured matrix efficiently

2011-12-20 Thread Michael Pearmain
Hi All, I'm wanting to convert a ragged list of values into a structured matrix for further analysis later on, i have a solution to this problem (below) but i'm dealing with datasets upto 1GB in size, (i have 24GB of memory so can load it) but it takes a LONG time to run the code on a large

[R] R code for OptiGrid Clustering

2011-08-26 Thread Michael Pearmain
Hi All, Has anyone coded up the OptiGrid clustering algorithm for high dimensional space? If so is anyone willing to share? Many thanks in Advance Mike [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] Using Match in a lookup table

2011-06-28 Thread Michael Pearmain
Hi All, I'm having a few problems using match and a lookup table, previous Googling show numerous solutions to matching a lookup table to a dataset, My situation is slightly different as i have multiple lookup tables, (that i cannot merge - for integrity reasons) that i wish to match against my

Re: [R] Using Match in a lookup table

2011-06-28 Thread Michael Pearmain
, Michael Pearmain wrote: Hi All, I'm having a few problems using match and a lookup table, previous Googling show numerous solutions to matching a lookup table to a dataset, My situation is slightly different as i have multiple lookup tables, (that i cannot merge - for integrity reasons

[R] Loading List data into R with scan()

2011-06-23 Thread Michael Pearmain
Hi All, I've been given a data file of the form: 1: 3,4,5,6 2:1,2,3 43: 5,7,8,9,5 and i want to read this data in as a list to create the form: (guessing final look) my.list [[1]] [1] 3 4 5 6 [[2]] [1] 1 2 3 [[43]] [1] 5 7 8 9 5 I can get to a stage using scan: scan(my.data, what =

Re: [R] Loading List data into R with scan()

2011-06-23 Thread Michael Pearmain
Thanks Uwe, The list elements was a mistake on my part, i just wanted everything before the : to be the name of the element. Thanks for the help, i can play around with this to get what i want. M 2011/6/23 Uwe Ligges lig...@statistik.tu-dortmund.de On 23.06.2011 16:39, Michael Pearmain

Re: [R] Loading List data into R with scan()

2011-06-23 Thread Michael Pearmain
Thanks All, Henrique, gave me the solution is was looking for, the indexing was a mistake on my part. Thanks again On 23 June 2011 16:37, David Winsemius dwinsem...@comcast.net wrote: On Jun 23, 2011, at 11:19 AM, Uwe Ligges wrote: On 23.06.2011 16:39, Michael Pearmain wrote: Hi All

[R] Passing Arguments in a function

2011-02-15 Thread Michael Pearmain
Hi All, I'm having some trouble assigning arguments inside a function to produce a plot from a model Can anyone help me? Below I've outlined the situation and examples of failing and working code. Regards Mike ## data ## decay.data - ... behaviors lift reach.uu

[R] Passing function arguments

2011-02-11 Thread Michael Pearmain
Hi All, Im looking for some help passing function arguments and referencing them, I've made a replica, less complicated function to show my problem, and how i've made a work around for this. However i suspect there is a _FAR_ better way of doing this. If i do: BuildDecayModel - function(x =

[R] Title splitting function

2010-01-22 Thread Michael Pearmain
Hi All, I'm trying to write a function to automatically split long strings so they will appear nicely in a chart i'm trying to create, Say i have a string title - some variety of words that are descriptive In this instance i want to place carriage return where there is a space just prior to a

[R] Numeric formatting question

2009-11-10 Thread Michael Pearmain
Hi All, I have am using Sweave and the \Sexpr{} to place some numeric variables in my tex document. I want to format the number prior to entry so they read slightly more elegantly. Say i have the following numbers x - 0.00487324 y - 0.00432 z - 0.567 I would like to have the numbers

[R] List mappings and variable creation

2009-10-12 Thread Michael Pearmain
combinedd 3 countertrue combinede 1 So i dont have to create the dummy variables. does this make sense? Many thanks in advance Mike -- Michael Pearmain I abhor averages. I like the individual case. A man may have

[R] Viewing Function Code

2009-09-15 Thread Michael Pearmain
function (height, ...) UseMethod(barplot2) environment: namespace:gplots 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

[R] Help with nls and error messages singular gradient

2009-08-25 Thread Michael Pearmain
= 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 Belgrave House 76 Buckingham Palace

[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)

[R] t.test in a loop

2009-01-28 Thread Michael Pearmain
(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$power, : variable channel.data.train$News~channel.data.train$power was not found -- Michael Pearmain Senior Analytics Research

[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 =

[R] Loop swith String replacement

2008-12-05 Thread Michael Pearmain
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 London SW1W 9TQ United Kingdom t

[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

[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
-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 Road London SW1W 9TQ United Kingdom t +44 (0

[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] 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] 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] 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
Exposure_2 y 5 2 Exposure_2 y 7 1 Exposure_3 y cbind(Unique=tapply(y$ID, y$ID, length)) Unique 1 3 2 2 3 1 On Tue, Aug 5, 2008 at 9:21 AM, Michael Pearmain [EMAIL PROTECTED] wrote: Hi All, i have a dataset that i want to dynamically inspect

[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

Re: [R] Problems with basic loop

2008-06-20 Thread Michael Pearmain
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'm having trouble creating a looping variable and i can't see wher ethe problem arises from any hep gratfully appreciated

[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,

[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
[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 however i want to find out what the sig. value is based on n1,n2,p1,p2 and this package doesn't

[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 anyone

[R] Merging two dataframes

2008-06-06 Thread Michael Pearmain
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' field Can anyone advise please? -- Michael Pearmain [[alternative HTML version deleted