similar to: levels() function for a vector

Displaying 20 results from an estimated 90000 matches similar to: "levels() function for a vector"

2008 Apr 09
1
vectorized way to combine levels of a factor
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 And I want a V3 that =V2 if V2=A, and =D if V2=B or C. In other words I
2008 Mar 12
3
type of object of a variable in a data frame
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 type/inheritence of an object in general? 3. The reason I want it to be a list or vector, is that I
2008 Mar 06
2
extracting a percentage of data by random
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 better way to do this? Thanks! Karen
2010 Apr 19
2
nls minimum factor error
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 the trace, the convergence seems to have been reached. I initially thought I might
2010 Apr 19
3
nls for piecewise linear regression not converging to least square
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 following segment of code is an example, and sorry for the overly precise numbers, they are just
2005 Jul 12
3
adding a factor column based on levels of another factor
Hi R users Does anyone out there have a better/quicker way of adding a factor column to a data frame based on levels of another factor? I have a (large) data frame consisting of records for individual plants, each represented by a unique ID number. The species of each plant is indicated in the column "species", which is a factor column with many different levels (species). There are
2008 May 12
1
what kind of residuals are the ones calculated in coxph?
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 _________________________________________________________________ [[alternative HTML version deleted]]
2008 Feb 14
1
deleting certain observations in a data frame
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 b" and so on. Another way to think of it is that it's a generazation of na.rm I
2005 Oct 21
1
finite mixture model (2-component gaussian): plotting component gaussian components?
Dear Knowledgeable R Community Members, Please excuse my ignorance, I apologize in advance if this is an easy question, but I am a bit stumped and could use a little guidance. I have a finite mixture modeling problem -- for example, a 2-component gaussian mixture -- where the components have a large overlap, and I am trying to use the "mclust" package to solve this problem. I need
2008 Mar 11
1
survreg asking for parameter "special"
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 didn't provide "special"? I can't seem to find what that is in the
2008 May 05
2
rpart for survival fits
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. Thanks, Karen _________________________________________________________________ Find hidden words,
2011 Dec 22
1
large data set (matrix) using image()
When I use the image() function for a relatively small matrix it works perfectly, eg.x <- 1:100 > z <- matrix(rnorm(10^4),10^2,10^2) > image(x=x,y=x,z=z,col=rainbow(3))but when I want to plot a larger matrix, it doesn't really work. Most of the times, it just plot a few intermitent points.x <- 1:1000 z <- matrix(rnorm(10^6),10^3,10^3) image(x=x,y=x,z=z,col=rainbow(3))
2010 Aug 17
4
replacing values in a vector
Dear helpRs Does anyone have an elegant way of doing the following: For a given numeric vector, e.g. vec <- c(3,2,6,4,7) Create a series of vectors where all but 1 of the values are replaced by 0's, e.g. vec.a <- c(3,0,0,0,0) vec.b <- c(0,2,0,0,0) vec.c <- c(0,0,6,0,0) vec.d <- c(0,0,0,4,0) vec.e <- c(0,0,0,0,7) I have looked at `replace', but can't think of a
2010 Nov 04
5
Logical vectors
Hi folks, Pls help me to understand follow; An Introduction to R 2.4 Logical vectors http://cran.r-project.org/doc/manuals/R-intro.html#R-and-statistics 1) > x [1] 1 2 3 4 5 > temp <- x != 1 > temp [1] FALSE TRUE TRUE TRUE TRUE > 2) > x [1] 1 2 3 4 5 > temp <- x > 1 > temp [1] FALSE TRUE TRUE TRUE TRUE Why NOT > temp [1] TRUE FALSE FALSE FALSE
2010 Nov 04
5
Logical vectors
Hi folks, Pls help me to understand follow; An Introduction to R 2.4 Logical vectors http://cran.r-project.org/doc/manuals/R-intro.html#R-and-statistics 1) > x [1] 1 2 3 4 5 > temp <- x != 1 > temp [1] FALSE TRUE TRUE TRUE TRUE > 2) > x [1] 1 2 3 4 5 > temp <- x > 1 > temp [1] FALSE TRUE TRUE TRUE TRUE Why NOT > temp [1] TRUE FALSE FALSE FALSE
2006 Jan 05
4
Q: R 2.2.1: Memory Management Issues?
Dear Developers: I have a question about memory management in R 2.2.1 and am wondering if you would be kind enough to help me understand what is going on. (It has been a few years since I have done software development on Windows, so I apologize in advance if these are easy questions.) ------------- MY SYSTEM ------------- I am currently using R (version 2.2.1) on a PC running Windows 2000
2008 May 02
1
adjusting plot vs font size in a plot
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 think is shouldn't be a specific rpart question, but rather a general plotting technique
2008 Nov 11
1
using newdata in survfit with categorical variable
Hi R-helpers, I was trying to put gender='Male' in newdata to create a expected survival curve for a pseudo cohort by using survfit based on Cox regression. My codes are shown below: fit<- coxph(Surv(end, status2)~gender, data=wlwsn1) Summary(fit) coef exp(coef) se(coef) z p genderMale 0.204 1.23 0.0912 2.23 0.025
2019 Oct 10
1
Broken link on doc.dovecot.org
Hi again, I wanted to check in and see if you got my note about the broken link on your site. Thanks! Karen On Monday, October 7, 2019 at 5:05 PM, Karen Woodman <karen at getmailbird.co> wrote: > Hi there, > > I noticed that you have a broken link to a website called Qmail.org. That > site was first published 23 years ago (back in 1996!) but unfortunately, it > is no
2008 Mar 13
1
survival curve for only certain values of a factor
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 <- survfit(Surv(time, status) ~ x1+x2, data=aml) plot(fit) I guess because there are 2 levels