I need to completely remove row.names from a dataframe. Are there other ways to remove them (and not anything else) besides: mydataframe<-data.frame(mydataframe, row.names=NULL) I realize that this doesn't really remove the row.names; it merely replaces the current row.names vector with the numbers 1..nrow (in quotes). ====================Dr. Marc R. Feldesman Professor and Chairman Anthropology Department Portland State University 1721 SW Broadway Portland, Oregon 97201 email: feldesmanm at pdx.edu phone: 503-725-3081 fax: 503-725-3905 http://web.pdx.edu/~h1mf PGP Key Available On Request ===================== "Anyway, no drug, not even alcohol, causes the fundamental ills of society. If we're looking for the source of our troubles, we shouldn't test people for drugs, we should test them for stupidity, ignorance, greed and love of power." P.J. O'Rourke Powered by Optiplochoerus and Windows 2000 (scary isn't it?) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Questions on histograms: 1. When I run "hist" on a data set, the histogram object produced has two variables, "$density" and "$intensities". These appear to be the same: $intensities [1] 1.7619226436 0.0360495682 0.1967705595 0.0000000000 0.0037551633 [6] 0.0000000000 0.0007510327 0.0007510327 $density [1] 1.7619226436 0.0360495682 0.1967705595 0.0000000000 0.0037551633 [6] 0.0000000000 0.0007510327 0.0007510327 Why are they the same? Are both necessary? 2. I want to plot histograms that are normalized -- that is, the sum of the intensities or density is 1.0, so the bars represent probabilities. As it's set up now, I have to do this calculation manually. Why can't R do this when it calculates the values? If I specify "probability=TRUE", I expect probabilities, not some arbitrarily scaled value. 3. What would be even nicer is to have "hist" and "density" *both* scale their outputs as probabilities, so they could be overlaid on a plot together. How difficult is this to do? -- znmeb at aracnet.com (M. Edward Borasky) http://www.aracnet.com/~znmeb If there's nothing to astrology, how come so many famous men were born on holidays? -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> Marc Feldesman writes:> I need to completely remove row.names from a dataframe. Are there other > ways to remove them (and not anything else) besides:> mydataframe<-data.frame(mydataframe, row.names=NULL)> I realize that this doesn't really remove the row.names; it merely > replaces the current row.names vector with the numbers 1..nrow (in > quotes).My understanding is that you cannot do that. By definition, data frames are lists all components of which have the same length, and have both names and row.names attributes which must have the right length and no duplicated elements. -k -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
If a data.frame formed as follows: sampled <- data.frame(sample(rnorm(100),2)) sampled The output is: sample.rnorm.100...2. 1 -0.1124964 2 -1.4590381 What I would like to have is no column titles so I get this: 1 -0.1124964 2 -1.4590381 I don't have a lot of experience with R, so excuse me if this is a stupid question. Best Regards, Dermot MacSweeney. ************************************************************** Dermot MacSweeney NMRC, Email: dsweeney at nmrc.ucc.ie Lee Maltings, Tel: +353 21 4904178 Prospect Row, Fax: +353 21 4270271 Cork, WWW: http://nmrc.ucc.ie Ireland ************************************************************** -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Date: Wed, 7 Feb 2001 11:05:05 +0000 (GMT) > From: Dermot MacSweeney <dsweeney at nmrc.ucc.ie> > Subject: Re: [R] Removing "row.names" > To: r-help at stat.math.ethz.ch > X-Virus-Scanned: by AMaViS at NMRC, Ireland > > If a data.frame formed as follows: > > sampled <- data.frame(sample(rnorm(100),2)) > > sampled > > The output is: > > sample.rnorm.100...2. > 1 -0.1124964 > 2 -1.4590381 > > What I would like to have is no column titles so I get this: > > 1 -0.1124964 > 2 -1.4590381 > > I don't have a lot of experience with R, so excuse me if this is a stupid > question.Certainly not, but there are two separate things going on you need to keep separate. 1) A data frame has row names and column names. You have sensible row names. You can get better column names by sampled <- data.frame(x = sample(rnorm(100),2)) or afterwards by names(sampled) <- "x". 2) By default, a data frame is printed with row and column names. You can change that. The simplest way is probably (for 1.2.1) zz <- as.matrix(format(sampled)) colnames(zz) <- rep("", ncol(zz)) print(zz, quote=FALSE) or use myprint <- function(df) { zz <- as.matrix(format(df)) colnames(zz) <- rep("", ncol(zz)) print(zz, quote=FALSE) invisible(df) }> myprint(sampled)1 -0.76797637 2 0.08913408 -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._