Re: [R] Retrieving Factors with Levels Ordered

2010-12-31 Thread Berwin A Turlach
G'day H.T. On Sat, 1 Jan 2011 00:41:10 -0500 (EST) "H. T. Reynolds" wrote: > When I create a factor with labels in the order I want, write the > data as a text file, and then retrieve them, the factor levels are no > longer in the proper order. Not surprisingly. :) [..big snip..] > testdf <-

[R] Retrieving Factors with Levels Ordered

2010-12-31 Thread H. T. Reynolds
Hello (and Happy New Year), When I create a factor with labels in the order I want, write the data as a text file, and then retrieve them, the factor levels are no longer in the proper order. Here is what I do (I tried many variations): # educ is a numeric vector with 1,001 observations. # The

Re: [R] Silhouette function problem

2010-12-31 Thread ADias
Hello, thank you all. I have been able to solve my problem with your help. The problem I am trying to solve is: I am working on a clustering method to group a data base. At the moment I am using the clustering hierarchical method and trying to get to the best K group value via the silhouette fu

Re: [R] Sweave for "big" data analysis

2010-12-31 Thread Ben Bolker
Duncan Murdoch gmail.com> writes: > As others have said, there are packages that provide caching. > > I haven't used them, because I like to keep my projects as > self-contained as possible: adding a dependency on one of those > packages is undesirable[1]. What I do in the case where there a

Re: [R] Changing column names

2010-12-31 Thread Bill.Venables
You don't give us much to go on, but some variant of country <- c("US", "France", "UK", "NewZealand", "Germany", "Austria", "Italy", "Canada") result <- read.csv("result.csv", header = FALSE) names(result) <- country should do what you want. From: r-hel

Re: [R] python-like dictionary for R

2010-12-31 Thread Martin Morgan
On 12/30/2010 02:30 PM, Paul Rigor wrote: > Thanks gang, > I'll work with named vectors and concatenate as needed. This might be ok for small problems, but concatenation is an inefficient R pattern -- the objects being concatenated are copied in full, so becomes longer, and the concatenation slowe

Re: [R] Sweave for "big" data analysis

2010-12-31 Thread Duncan Murdoch
On 31/12/2010 3:35 PM, Lars Bishop wrote: Hi, Maybe I'm missing the point here...but let's suppose you are working with "large" data sets and using functions that take a significant amount of time to run in R. I woulnd't like to run these functions every time I call Sweave("myfile.Rnw") within R

Re: [R] Sweave for "big" data analysis

2010-12-31 Thread Yihui Xie
I still recommend the pgfSweave package (as usual) -- you can cache both data objects (using cacheSweave) and graphics (using pgf). Regards, Yihui -- Yihui Xie Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Fri, Dec 31

Re: [R] Sweave for "big" data analysis

2010-12-31 Thread Sarah Goslee
My very simple approach is to check if the output file exists (within the Sweave file), and run the time-consuming bits only if it does not. As Uwe says, there are more sophisticated approaches too. Sarah On Fri, Dec 31, 2010 at 3:35 PM, Lars Bishop wrote: > Hi, > > Maybe I'm missing the point

Re: [R] Error using sos

2010-12-31 Thread Uwe Ligges
On 31.12.2010 11:02, Paolo Rossi wrote: I am trying to use sos but I get the message below My PC's spec is: MS XP Version 2002 SP 3 Intel Celeron E3300 @ 2.50Ghz Is the error below related to a firewall or something? Are you able to connect to that side via your favorite internet browser?

Re: [R] Sweave for "big" data analysis

2010-12-31 Thread Uwe Ligges
Google for "cache" and "Sweave" and you will find more than one package that extend Sweave and provide kinds of caching, i.e. roughly what you have in mind anyway. Best, Uwe Ligges On 31.12.2010 21:35, Lars Bishop wrote: Hi, Maybe I'm missing the point here...but let's suppose you are work

[R] Sweave for "big" data analysis

2010-12-31 Thread Lars Bishop
Hi, Maybe I'm missing the point here...but let's suppose you are working with "large" data sets and using functions that take a significant amount of time to run in R. I woulnd't like to run these functions every time I call Sweave("myfile.Rnw") within R. What is the "common" practice to use Sweav

Re: [R] Class "coef.mer" into a data.frame?

2010-12-31 Thread David Winsemius
On Dec 31, 2010, at 2:49 AM, Jukka Koskela wrote: Hello, Could somebody please tell me what am I doing wrong in following? I try extract coefficients (using arm-package) from the lmer frunction, but I get the following warning: a<-data.frame(coef(res)) Error in as.data.frame.default(x[[i]]

Re: [R] Repeated Indexing / Sequence Operation

2010-12-31 Thread Charles C. Berry
On Fri, 31 Dec 2010, Paolo Rossi wrote: Hi Everyone, quick question before the end of the year. I have soem indices to select data from a bigger sample. I want to select n days before each index and n days after the index. Any clever way to do it. For heavy duty applications involving interv

Re: [R] Repeated Indexing / Sequence Operation

2010-12-31 Thread Gabor Grothendieck
On Fri, Dec 31, 2010 at 1:03 PM, Paolo Rossi wrote: > Hi Everyone, > > quick question before the end of the year. > > I have soem indices to select data from a bigger sample. I want to select n > days before each index and n days after the index. Any clever way to do it. > A for loop would do but

Re: [R] Repeated Indexing / Sequence Operation

2010-12-31 Thread Duncan Murdoch
On 31/12/2010 1:03 PM, Paolo Rossi wrote: Hi Everyone, quick question before the end of the year. I have soem indices to select data from a bigger sample. I want to select n days before each index and n days after the index. Any clever way to do it. A for loop would do but I wanted to know if t

Re: [R] Analysing Character Strings for subsequent frequency analysis

2010-12-31 Thread bob stoner
Marc/Gabor many thanks for your responses which have helped me to proceed. Sometimes doing your homework before asking can appear quite obvious but to newbies it is also quite difficult to get the correct question; therefore I appreciate your valued responses. Happy New Year to you all Bob O

Re: [R] Repeated Indexing / Sequence Operation

2010-12-31 Thread Paolo Rossi
in my pevious message the line with SampleWidth should be SampleWidth = 5 Paolo On 31 December 2010 18:03, Paolo Rossi wrote: > Hi Everyone, > > quick question before the end of the year. > > I have soem indices to select data from a bigger sample. I want to select n > days before each index and

[R] Repeated Indexing / Sequence Operation

2010-12-31 Thread Paolo Rossi
Hi Everyone, quick question before the end of the year. I have soem indices to select data from a bigger sample. I want to select n days before each index and n days after the index. Any clever way to do it. A for loop would do but I wanted to know if there is a moreR-friendly way to approach thi

Re: [R] optim and singularity

2010-12-31 Thread emorway
Thanks Berend, setting lower=c(0,0.01) seems to have solved the problem. I have a dataset with 200+ cropped fields with associated data and wanted to generate each plot in a way that minimized the visual residuals between the green squares and blue circles. I have inserted a resulting plot so yo

Re: [R] Silhouette function problem

2010-12-31 Thread jim holtman
Is this what you want: > library(cluster) > d<-hclust(dist(iris[,-5])) > > avgs<-sapply(1:20,function(x) + summary(silhouette(cutree(d,x), + + dist(iris[,-5] > # str(avgs) > > # print out the average widths > for (i in 2:length(avgs)){ # ignore first item + cat('i=', i, 'average=', avgs[[

Re: [R] Silhouette function problem

2010-12-31 Thread David Winsemius
On Dec 31, 2010, at 10:34 AM, ADias wrote: ADias wrote: Hi, I am using the code below to get a plot that will show me on the X axis the number of clusters and on the Y axis the cluster average widths. However I am getting this error: Error in summary(silhouette(cutree(d, x), dist(iris[

Re: [R] survexp - example produces error

2010-12-31 Thread Heinz Tuechler
Follow up: The critical line seems to be in survexp around line 97 rdata <- data.frame(eval(rcall, m)) If changed to: old.stringsAsFactors <- options()$stringsAsFactors options(stringsAsFactors=TRUE) rdata <- data.frame(eval(rcall, m)) ### <- seems to be critical options(stringsAsFactors=old.

Re: [R] dataframe, simulating data

2010-12-31 Thread Petr Savicky
On Fri, Dec 31, 2010 at 05:05:08AM -0800, Sarah wrote: > > I'm sorry, I don't think I've made myself clear enough. > > Cases have been randomly assigned to one of the two groups, with certain > probabilities (based on other variables). > So, if there are too many people (i.e., more than 34) assig

Re: [R] Silhouette function problem

2010-12-31 Thread ADias
ADias wrote: > > Hi, > > I am using the code below to get a plot that will show me on the X axis > the number of clusters and on the Y axis the cluster average widths. > However I am getting this error: > > Error in summary(silhouette(cutree(d, x), dist(iris[, -5])))$si.summary : > $ operat

Re: [R] Changing column names

2010-12-31 Thread Jason Edgecombe
Try: df1 = read.csv('result.csv', header=TRUE) df1 Jason On 12/31/2010 03:19 AM, Amy Milano wrote: Please read - http://127.0.0.1:24408/library/base/html/colnames.html I am trying to give an example. I am not a programmer and I am sure the R stalwarts will have better ways to do it. # Supp

[R] Help with ROracle

2010-12-31 Thread Sébastien Bihorel
Dear R-users, I am working with a colleague on extracting and processing data from our Oracle database using R scripts. We performed some initial testing using functions available in the ROracle package. Overall, our tests were successful and encouraging. There are however a couple of questions/pr

Re: [R] survexp - example produces error

2010-12-31 Thread Heinz Tuechler
Dear Peter, Dear All, a further attempt led me to an answer. If I set options(stringsAsFactors=TRUE), which I usually have set to FALSE, no error occurs. I am, however not happy with this solution. Heinz Thank you, Peter after setting options(error=recover), see the output below, once for

Re: [R] survexp - example produces error

2010-12-31 Thread Heinz Tuechler
Thank you, Peter after setting options(error=recover), see the output below, once for frame number 2, which I suspect to be the problem, once for frame number 1. Heinz > expect <- + survexp(futime ~ ratetable(age=(accept.dt - birth.dt), + sex=1,year=accept.dt,ra

Re: [R] dataframe, simulating data

2010-12-31 Thread David Winsemius
On Dec 31, 2010, at 8:32 AM, David Winsemius wrote: On Dec 31, 2010, at 8:05 AM, Sarah wrote: I'm sorry, I don't think I've made myself clear enough. Cases have been randomly assigned to one of the two groups, with certain probabilities (based on other variables). So, if there are too m

Re: [R] dataframe, simulating data

2010-12-31 Thread David Winsemius
On Dec 31, 2010, at 8:05 AM, Sarah wrote: I'm sorry, I don't think I've made myself clear enough. Cases have been randomly assigned to one of the two groups, with certain probabilities (based on other variables). So, if there are too many people (i.e., more than 34) assigned to group 0,

Re: [R] dataframe, simulating data

2010-12-31 Thread Sarah
I'm sorry, I don't think I've made myself clear enough. Cases have been randomly assigned to one of the two groups, with certain probabilities (based on other variables). So, if there are too many people (i.e., more than 34) assigned to group 0, I would like to sample 34 cases from group 0, and g

Re: [R] survexp - example produces error

2010-12-31 Thread peter dalgaard
On Dec 31, 2010, at 10:21 , Heinz Tuechler wrote: > Dear All, > > reposting, because I did not find a solution, maybe someone could check the > example below. > > It's taken from the help page of survdiff. Executing it, gives the error > > "Error in floor(temp) : Non-numeric argument to mathe

Re: [R] optim and singularity

2010-12-31 Thread Berend Hasselman
The error occurs in the x <- solve(A,RHS) statement. In a certain iteration ylim_2 passed by optim to your function is c(0,0) That give a zero column of matrix A ==> exactly singular. If I set lower=c(0,0.01) in the call of optim and use the na.approx then the result is ylim_2=c(0, 4.63) with th

Re: [R] dataframe, simulating data

2010-12-31 Thread Petr Savicky
On Fri, Dec 31, 2010 at 01:51:18AM -0800, Sarah wrote: > > Dear all, > > I'm having trouble with my dataframe, and I hope someone can help me out... > I have data from 40 subjects, displayed in a dataframe. I have randomly > assigned subjects to group 1 or 0 (mar.y==0 or mar.y==1, with probabilit

Re: [R] dataframe, simulating data

2010-12-31 Thread Jim Lemon
On 12/31/2010 08:51 PM, Sarah wrote: Dear all, I'm having trouble with my dataframe, and I hope someone can help me out... I have data from 40 subjects, displayed in a dataframe. I have randomly assigned subjects to group 1 or 0 (mar.y==0 or mar.y==1, with probabilities used). In the end, I wan

[R] Error using sos

2010-12-31 Thread Paolo Rossi
I am trying to use sos but I get the message below My PC's spec is: MS XP Version 2002 SP 3 Intel Celeron E3300 @ 2.50Ghz Is the error below related to a firewall or something? Thanks and Happy New Year Paolo Error in readLines(link) : cannot open the connection In addition: Warning message:

[R] dataframe, simulating data

2010-12-31 Thread Sarah
Dear all, I'm having trouble with my dataframe, and I hope someone can help me out... I have data from 40 subjects, displayed in a dataframe. I have randomly assigned subjects to group 1 or 0 (mar.y==0 or mar.y==1, with probabilities used). In the end, I want 34 cases assigned to group 0, with th

[R] survexp - example produces error

2010-12-31 Thread Heinz Tuechler
Dear All, reposting, because I did not find a solution, maybe someone could check the example below. It's taken from the help page of survdiff. Executing it, gives the error "Error in floor(temp) : Non-numeric argument to mathematical function" best regards, Heinz library(survival) ## Exa

Re: [R] Changing column names

2010-12-31 Thread Amy Milano
Please read - http://127.0.0.1:24408/library/base/html/colnames.html I am trying to give an example. I am not a programmer and I am sure the R stalwarts will have better ways to do it. # Suppose df1 = read.csv('result.csv') where (say e.g.) result.csv is as follows result.csv var1   var

Re: [R] help me

2010-12-31 Thread Petr Savicky
On Thu, Dec 30, 2010 at 11:01:47PM -0800, Sintayehu Aynalem wrote: > I nanna subscribe to r-help. > > Can you please guide me... Start at http://www.r-project.org/ Click on "Mailing lists". Find section "R-help". Click on "web interface". Find section "Subscribing to R-help" and follow the desc