[R] which() with multiple conditions

2012-10-01 Thread pdb
I hope someone can point me in the right direction please. I have a data frame with a column containing names. I want to identify the columns that contain names in a list. namestofind - c('fred','bill',a long list) If I only wanted to identify a single name I would use which(z$name ==

Re: [R] POSIXlt and daylight savings time

2012-09-05 Thread pdb
I'll rephrase the question... If you try... as.POSIXlt('2004-10-31 02:00:00') you get [1] 2004-10-31 What do I need to do to make it return [1] 2004-10-31 02:00:00 -- View this message in context: http://r.789695.n4.nabble.com/POSIXlt-and-daylight-savings-time-tp4642253p4642272.html

[R] POSIXlt and daylight savings time

2012-09-04 Thread pdb
I have a data frame that contains dates, but when I use as.POSIXlt() I lose the hours on all records. I traced this down to a particuar hour which causes the issue... as.POSIXlt('2004-10-31 02:00:00') [1] 2004-10-31 as.POSIXlt('2004-10-31 03:00:00') [1] 2004-10-31 03:00:00 How do I tell

[R] revolution foreach oddity

2012-05-07 Thread pdb
I know this is not a revolution support forum, but as anyone noticed the following? I have a foreach loop to generate random samples. If I run the exact code below in normal r (2.14.1) it works as expected, but if I run it from revolution 4.2.0 each loop returns the same numbers. The only way I

Re: [R] directory of current script

2012-04-12 Thread pdb
I found this... https://stat.ethz.ch/pipermail/r-help/2009-January/184745.html -- View this message in context: http://r.789695.n4.nabble.com/directory-of-current-script-tp4553386p4553409.html Sent from the R help mailing list archive at Nabble.com.

[R] directory of current script

2012-04-12 Thread pdb
I am running a series of scripts sequentially and they all need some global parameters. These will be included in a file in a known sub directory as the scripts themselves. The scripts need to be run by anyone without ANY editing. Question is: Is there a command to return the directory of the

[R] can this sequence be generated easier?

2011-06-17 Thread pdb
I have 'x' variables that I need to find the optimum combination of, with the constraint that the sum of all x variables needs to be exactly 100. I need to test all combinations to get the optimal mix. This is easy if I know how many variables I have - I can hard code as below. But what if I

[R] computer name

2011-06-12 Thread pdb
Is there an r function that will be able to identify the computer the code is running on? I have some common code that I run on several computers and each has a database with a different server name - although the content is identical. I need to set thisServer depending on which machine the code

[R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
I want to use caret to build a model with an algorithm that actually has no parameters to find. How do I stop it from repeatedly building the same model 25 times? library(caret) data(mdrr) LOGISTIC_model - train(mdrrDescr,mdrrClass ,method='glm'

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
Hi Max, But in this example, it says the sample size is the same as the total number of samples, so unless the sampling is done by columns, wouldn't you get exactly the same model each time for logistic regression? ps - great package btw. I'm just beginning to explore its potential now.-- View

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
Thanks for the clarification Max - I should have realised that. One final question, I like caret because it lets me pass in data to all functions in the same way. For glm I have only ever used the formula notation and did not see a way to pass in predictors and a target individually. How do I do

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
glm.fit - answered my own question by reading the manual!-- View this message in context: http://r.789695.n4.nabble.com/caret-prevent-resampling-when-no-parameters-to-find-tp3488761p3488923.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
Thanks again Max - a great time saver this is. Now just for my sanity, if I use glm.fit to build a model where I have the matrices, how do I then use the predict function without getting an error message? LOGISTIC_model1 - glm.fit(mdrrDescr,mdrrClass, family=binomial(link=logit)) Warning

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
Hi Max, I tried your suggestion but cam up with errors: fitControl-trainControl(number=1) LOGISTIC_model - train(mdrrDescr,mdrrClass ,method='glm' ,trControl = fitControl ) Fitting: parameter=none Error in if

[R] changing a specific column name

2011-04-28 Thread pdb
Hi, Can someone please tell me how to change the column name of a specific column. How do I change the name of the column 'Species'? Thanks in advance d - iris colnames(d) [1] Sepal.Length Sepal.Width Petal.Length Petal.Width Species ind - which(names(d)=='Species') ind [1] 5

[R] boxplot - how to supress groups with low counts

2011-01-28 Thread pdb
In a boxplot - how can I prevent groups where the number of cases is less than a set threshold from being plotted. set.seed(42) DF - data.frame(type=sample(LETTERS[1:5], 100, replace=TRUE), cost=rnorm(100)) count - boxplot(cost ~ type, data=DF, plot = 0) count$n ## how to only include

[R] 2 functions with same name - what to do to get the one I want

2011-01-26 Thread pdb
There seems to be 2 functions call ecdf... http://lib.stat.cmu.edu/S/Harrell/help/Hmisc/html/ecdf.html http://127.0.0.1:11885/library/stats/html/ecdf.html How do I get the one ecdf {Hmisc} to run instead of the ecdf {stats} A pointer in the right direction would be greatly appreciated.

Re: [R] 2 functions with same name - what to do to get the one I want

2011-01-26 Thread pdb
Thanks for the quick response, but that doesn't seem to help What do I need to do to get it to work? Hmisc:::ecdf(...) Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : object 'ecdf' not found -- View this message in context:

[R] removed data is still there!

2010-09-21 Thread pdb
I'm confused, hope someone can point out what is not obvious to me. I thought I was creating a new data frame by 'deleting' rows from an existing dataframe - I've tried 2 methods. But this new data frame seems to remember values from its parent - even though there are no occurences. Where

Re: [R] removed data is still there!

2010-09-21 Thread pdb
Thanks, but that was what I just discovered myself the hard way. What I really wanted to know was how to solve this issue. -- View this message in context: http://r.789695.n4.nabble.com/removed-data-is-still-there-tp2548440p2548527.html Sent from the R help mailing list archive at Nabble.com.

[R] getting a function to do something

2010-09-18 Thread pdb
Hi, I want to repeatedly do a task, so thought I could put it in a function and then just call the function. The task is just clearing all the graphics devices and then opening a new one of a specified size. Now, when I call the function below, nothing appears to happen. But when I run the 2

Re: [R] getting a function to do something

2010-09-18 Thread pdb
as, silly me. clearG() this now works! -- View this message in context: http://r.789695.n4.nabble.com/getting-a-function-to-do-something-tp2545594p2545596.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org

[R] transaction object - how to coerce this data

2010-08-31 Thread pdb
Hi, I am wanting to look at frequent item sets using the arules package. I need to transform my data into a transactions object. The data I read in from a file has 2 columns, an ID and an item. How do I convert data like this into a transactions object? I've tried class? transactions but it

[R] checking if a package is installed

2010-08-26 Thread pdb
Hi, I am writing a function that requires a specific package to be installed. Is there a way of checking if the package is installed and returning a TRUE / FALSE result so my function can return an appropriate error message and exit the function gracefully rather than just bombing out? I'm

Re: [R] Tinn R - the preferred R term was not defined

2010-08-23 Thread pdb
Ok - I found the correct forum and that this seems to be a common problem. http://sourceforge.net/projects/tinn-r/forums/forum/481900/topic/3741784 -- View this message in context: http://r.789695.n4.nabble.com/Tinn-R-the-preferred-R-term-was-not-defined-tp2334642p2334649.html Sent from the

[R] Tinn R - the preferred R term was not defined

2010-08-22 Thread pdb
I have Windows 7 64 bit and 64 bit version of R. I have installed Tinn R. Everytime I start R from within Tinn R it gives me the message The preferred R term was not defined. Do you desire to do this now I then tell Tinn R where the Rterm.exe and Rgui.exe are. Rterm works OK - I can open r

[R] finding max value in a row and reporting colum name

2010-08-01 Thread pdb
Hi, Hopefully someone can point me in the right direction on how I would go about solving the following. I have some data and need to find the column name of the maximum value in each row. This could be the data... a - data.frame(x = rnorm(4), y = rnorm(4), z = rnorm(4)) a x

[R] Lags and Differences of zoo Objects

2010-07-30 Thread pdb
Hi, I'm struggling to understand the documentation. ?lag.zoo x - a zoo object. k, lag - the number of lags (in units of observations). Note the sign of k behaves as in lag. differences - an integer indicating the order of the difference. What does the above line actually mean? I've tried

Re: [R] Lags and Differences of zoo Objects

2010-07-30 Thread pdb
Thanks for the response. I can figure out the 'lag' parameter to the function, but I dont understand the 'differences' parameter. differences - an integer indicating the order of the difference What does the 'order of the difference' mean in English? How are these numbers calculated? x -

[R] where did the column names go to?

2010-07-29 Thread pdb
I've just tried to merge 2 data sets thinking they would only keep the common columns, but noticed the column count was not adding up. I've then replicated a simple example and got the same thing happening. q1. why doesn't 'b' have a column name? q2. when I merge, why does the new column 'y'

[R] how to 'stack' data frames?

2010-07-29 Thread pdb
I have 2 data frames (A B) with some common column names. A has 10 rows. B has 20 rows. How do I combine them so I end up with a data frame with 30 rows that only contains the common columns. I was trying 'merge' (Merge two data frames by common columns .etc. ) but that is not giving me

Re: [R] how to 'stack' data frames?

2010-07-29 Thread pdb
Thanks Dennis - easy when you know how ! -- View this message in context: http://r.789695.n4.nabble.com/how-to-stack-data-frames-tp2306284p2306309.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

[R] eliminating constant variables

2010-07-10 Thread pdb
as to how I can automatically purge my data file of these useless fields. Thanks in advance, pdb train - read.csv(TrainingData.csv) library(gbm) i.gbm-gbm(TargetVariable ~ . ,data=train,distribution=bernoulli. 1: In gbm.fit(x, y, offset = offset, distribution = distribution, ... : variable 5

Re: [R] eliminating constant variables

2010-07-10 Thread pdb
, pdb -- View this message in context: http://r.789695.n4.nabble.com/eliminating-constant-variables-tp2284831p2284853.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r

Re: [R] eliminating constant variables

2010-07-10 Thread pdb
Yep - that is what I want. Cheers Jim you Legend. -- View this message in context: http://r.789695.n4.nabble.com/eliminating-constant-variables-tp2284831p2284861.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org

Re: [R] eliminating constant variables

2010-07-10 Thread pdb
Awsome! It made sense once I realised SD=standard deviation ! pdb -- View this message in context: http://r.789695.n4.nabble.com/eliminating-constant-variables-tp2284831p2284915.html Sent from the R help mailing list archive at Nabble.com. __ R

[R] r code exchange site?

2010-07-05 Thread pdb
Does there exist a site where snippets of r code examples can be deposited, such as the one that exists for matlab? http://www.mathworks.com/matlabcentral/fileexchange/ ps I also noted from the main r site http://www.r-project.org/ when you click on the nabble link under the search link, I

[R] plot focus

2010-06-30 Thread pdb
I am doing calculations in a loop and then plotting the results by adding a point to each of 2 charts at the end of the loop. Its very informative as you can see the progression through time. My problem is, if I have 2 plots, I don't know how to get the focus back to the first plot.

Re: [R] plot focus - another issue (ylim)

2010-06-30 Thread pdb
Thanks Henrique, that appeared to work, but now I have another issue. If I add a ylim to the plot then when I plot another line it gets plotted on the wrong scale. #this works as expected plot(iris[,1],col=red,ylim=c(-10,10)) #plot1 lines(iris[,4],col=black) #this does not par(mfrow=c(2,1))

[R] randomforests - how to classify

2010-05-04 Thread pdb
Hi, I'm experimenting with random forests and want to perform a binary classification task. I've tried some of the sample codes in the help files and things run, but I get a message to the effect 'you don't have very many unique values in the target - are you sure you want to do regression?'

[R] timing a function

2010-05-04 Thread pdb
Hi, I want to time how long a function takes to execute. Any clues on what to search for to achieve this? Thanks in advance. -- View this message in context: http://r.789695.n4.nabble.com/timing-a-function-tp2126319p2126319.html Sent from the R help mailing list archive at Nabble.com.