Skip to content

Really a newbe Q about data.frames

10 messages · Brian Ripley, Fredrik Karlsson, Jens Nieschulze +4 more

#
On Mon, 4 Feb 2002, Fredrik Karlsson wrote:

            
via names:

DF <- data.frame(a=1, b=2)
names(DF)[2] <- "bb"
DF
  a bb
1 1  2

(Actually, that does make a copy internally).
#
Hi all (again)

Sorry to bother you with this lame question, but since I have not been
able to find the answer in the manuals..
How do I change the name of a variable in a data.frame??
(Without copying hte entire fram to another one of course..)


/Fredrik
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Is there a simple way of removing variables from a dataframe?

- rm(dataframe$VAR) doesn't seem to work
- Copying all but the unwanted variables into a new data frame is awkward
when there are a lot of variables.
- I haven't found any references to this in the help files.


Stuart
Dr Stuart Leask MA MRCPsych, Clinical Lecturer in Psychiatry
University of Nottingham Dept of Psychiatry, Duncan Macmillan House
Porchester Road, Nottingham. NG3 6AA. UK
http://www.nottingham.ac.uk/psychiatry/staff/sjl.html

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Mon, 4 Feb 2002, Stuart Leask wrote:
%Is there a simple way of removing variables from a dataframe?
%
%- rm(dataframe$VAR) doesn't seem to work
%- Copying all but the unwanted variables into a new data frame is awkward
%when there are a lot of variables.
%- I haven't found any references to this in the help files.

dataframe$VAR<-NULL

%
%
%Stuart
%Dr Stuart Leask MA MRCPsych, Clinical Lecturer in Psychiatry
%University of Nottingham Dept of Psychiatry, Duncan Macmillan House
%Porchester Road, Nottingham. NG3 6AA. UK
%http://www.nottingham.ac.uk/psychiatry/staff/sjl.html
%
%-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
%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
%_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
%

***********************************************************************
Jens Nieschulze

Institute for Forest Biometrics &	Phone: ++49-551-39-12107
Applied Computer Science		Fax  : ++49-551-39-3465
Buesgenweg 4
37077 Goettingen		E-mail: jniesch at uni-forst.gwdg.de
GERMANY				http://www.uni-forst.gwdg.de/~jniesch

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Hello there.

I have a script (see below) that runs in Rv1.4.0  for windows, but not in
Rv1.4.0 for linux (not the current versions, I know, but close).

In the linux version, the script is interrupted by a prompt
"Display all 101 possibilities? (y or n)"
that stops the script working properly. This prompt doesn't appear when
running the script in R for windows.

Is there some way of turning this prompt off so that I can run this script
in the linux version?

Stuart

Dr Stuart Leask MA MRCPsych, Clinical Lecturer in Psychiatry
University of Nottingham Dept of Psychiatry, Duncan Macmillan House
Porchester Road, Nottingham. NG3 6AA. UK
http://www.nottingham.ac.uk/psychiatry/staff/sjl.html

Linux version console:

...
+ Ri<-lag(R,i)
+ L0<-lag(L,0)
+ M<-as.data.frame(ts.intersect(Ri,L0))
+ cor.i<-cor(M$Ri,M$L0)
+ if(abs(cor.i)<0.01)
+ {
+ RBi<-100*(M$Ri-M$L0)/M$Ri+M$L0)
+
Display all 101 possibilities? (y or n)
+ es(lowess(RBi,M$Ri))
+ }
+ i<-i+1
+ }
Error: couldn't find function "es"
...

Windows version console (no prompt, so all runs smoothly):

...
+  Ri<-lag(R,i)
+  L0<-lag(L,0)
+  M<-as.data.frame(ts.intersect(Ri,L0))
+  cor.i<-cor(M$Ri,M$L0)
+  if(abs(cor.i)<0.01)
+  {
+  RBi<-100*(M$Ri-M$L0)/(M$Ri+M$L0)
+   lines(lowess(RBi,M$Ri))
+  }
+  i<-i+1
+ }
...

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Mon, 4 Feb 2002, Stuart Leask wrote:

            
dataframe$VAR <- NULL

G?ran

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Fredrik Karlsson <fredrik.karlsson at ling.umu.se> writes:
Use names().

Mark

--
Mark Myatt


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
"Stuart Leask" <stuart.leask at nottingham.ac.uk> writes:
Either source() the file in or remove the TAB character that is
confusing readline.
#
Thanks, Peter. It was that extra tab. I was baffled as to what could differ
between the two versions.

Stuart

----- Original Message -----
From: Peter Dalgaard BSA <p.dalgaard at biostat.ku.dk>
To: Stuart Leask <stuart.leask at nottingham.ac.uk>
Cc: r-help-request Mailing List <r-help at r-project.org>
Sent: Monday, February 04, 2002 11:28 AM
Subject: Re: [R] Script that runs under R(win) failing under R(linux)
in
script
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Thanks to G?ran and Jens.

dataframe$VAR <- NULL

completely removes the variable.

Stuart

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._