[R] deleting certain observations in a data frame

2008-02-14 Thread Chang Liu
Hi, I'm wondering what the fastest way is to delete certain data points (observations) in a data frame. I have a vector of the indices/row.names I would like to delete. I have tried replacing list by list, but it always complains about different lengths, replacing list of length a with length

Re: [R] deleting certain observations in a data frame

2008-02-25 Thread Chang Liu
the minus sign: yourData[-indicesToBeDeleted,] For rownames, negate %in%: yourData[!rownames(yourData)%in%namesToBeDeleted,] HTH Peter Alspach -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chang Liu Sent: Friday, 15 February 2008 9:50 a.m

[R] extracting a percentage of data by random

2008-03-05 Thread Chang Liu
Hello Gurus: If I have a dataframe with one of the variables called age for example, and I want to extract a random 10% of the observations from each age group of the entire data frame. Do I have to double loop to split the data and then loop again to assign random numbers? Or is there a

Re: [R] extracting a percentage of data by random

2008-03-05 Thread Chang Liu
://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chang Liu Sent: Thursday, 6 March 2008 10:50 AM To: r-help@r-project.org Subject: [R] extracting a percentage of data by random Hello Gurus: If I have a dataframe with one

[R] survreg asking for parameter special

2008-03-10 Thread Chang Liu
Hello Gurus: I'm using basic survival analysis, and trying to use survreg, and I provided the parameter formula= and data=, but I got an error saying: Error in terms.default(formula, special, data = data) : no terms component I'm wondering what it's trying to say. Is it because I

[R] levels() function for a vector

2008-03-10 Thread Chang Liu
Hello: I'm trying to use levels function, but I don't know why it's returning NULL. For example: temp[1] 3 5 5 NA levels(temp)NULL Also, I've tried: list(temp)[[1]][1] 3 5 5 NA levels(list(temp))NULL Is there a specific requirement on the parameter? Karen

[R] type of object of a variable in a data frame

2008-03-12 Thread Chang Liu
Hello! I have used read.csv to read in a data frame, and there are a few variables in it, however, when I tried is.list(data$V1) FALSE In fact, I have tried, they are not vectors either. I'm wondering: 1. What objects are these lists of data? 2. How could I find out about the

[R] survival curve for only certain values of a factor

2008-03-12 Thread Chang Liu
Hello: Using the built-in dataset aml as an example: data(aml) If I use instead dummy variables: aml$x1 = (aml$x==maintained)aml$x2 = (aml$x==unmaintained) and I want to plot the survival curve using x1, x2, and I just want the 2 levels, rather than 4 curves from: fit -

[R] vectorized way to combine levels of a factor

2008-04-09 Thread Chang Liu
Hi Gurus: If I have a large dataset of the form of: x - data.frame(V1 = runif(10), V2 = sample(c('A','B','C'),10,T)) x V1 V21 0.2691580 A2 0.8711267 B3 0.2674728 C4 0.3278876 A5 0.1809152 A6 0.2499651 C7 0.9155174 A8 0.8004974 B9 0.7885516 A10 0.9301630 A

[R] plot size vs. text size

2008-05-02 Thread Chang Liu
Hello: I am using plot() in rpart, making a decision tree plot. I use plot() first, then text() followed, but I think due to the figure vs. text size, the bottom of the text always gets cut off. I can only “see” the text of the bottom of the tree if I make the font size REALLY small. I

[R] rpart for survival fits

2008-05-05 Thread Chang Liu
Hello Gurus: When I plot a survival fit using rpart for the classification tree, for each node, there is a decimal based number above the event/total. I tried to see if it's the exponential ratio or logrithmics, neither seem to be the case. I'm wondering if anyone knows what they are.

[R] what kind of residuals are the ones calculated in coxph?

2008-05-12 Thread Chang Liu
Hi Gurus: In the coxph() objects in Survival package, there is an attribute called residuals. Usually, there are several kinds for censored survival data. I can't seem to find in the documentation as to which one this is calculating. Anyone knows? Karen

[R] nls for piecewise linear regression not converging to least square

2010-04-19 Thread Karen Chang Liu
Hi R experts, I'm trying to use nls() for a piecewise linear regression with the first slope constrained to 0. There are 10 data points and when it does converge the second slope is almost always over estimated for some reason. I have many sets of these 10-point datasets that I need to do. The

[R] nls minimum factor error

2010-04-19 Thread Karen Chang Liu
Hi, I have a small dataset that I'm fitting a segmented regression using nls on. I get a step below minimum factor error, which I presume is because residual sum of square is still not small enough when steps in the parameter space is already below specified/default value. However, when I look at

Re: [R] nls minimum factor error

2010-04-19 Thread Karen Chang Liu
right with weights, but I may have done something wrong, have you tried it with weights before? Karen On Mon, Apr 19, 2010 at 3:59 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: On Mon, Apr 19, 2010 at 8:38 AM, Karen Chang Liu kare...@uw.edu wrote: Hi, I have a small dataset that I'm