Re: [R] Adding a numeric to all values in the dataframe

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Sat, 21 May 2011 19:12:56 -0700 (PDT)

> From: David Winsemius <dwinsemius_at_comcast.net>
> Subject: Re: [R] Adding a numeric to all values in the dataframe
> To: "John Kane" <jrkrideau_at_yahoo.ca>
> Cc: Bill.Venables@csiro.au, ramya.victory@gmail.com, r-help@r-project.org
> Received: Friday, May 20, 2011, 10:11 PM
>
> On May 20, 2011, at 9:50 PM, John Kane wrote:
>
> > I didn't quite understand your first post. Was it
> intended to assure 
> > that the operation was only on numeric variables?
>
> Prezactly.

Okay that's what I suspected, thanks.

You're slurring your words BTW.

>
>
> >  Otherwise I don't see the differnce in applying
> the operation to a 
> > totally numeric data.frame and a matrix.
> >
> >
> >
> > -- On Fri, 5/20/11, Bill.Venables_at_csiro.au
> <Bill.Venables_at_csiro.au> 
>
> > wrote:
> >
> >> From: Bill.Venables_at_csiro.au
> <Bill.Venables_at_csiro.au>
> >> Subject: Re: [R] Adding a numeric to all values in
> the dataframe
> >> To: Bill.Venables_at_csiro.au,
> ramya.victory_at_gmail.com,
> r-help_at_r-project.org
> >> Received: Friday, May 20, 2011, 9:37 PM
> >> Oops
> >>
> >> The first line of my template should use
> data.matrix()
> >> rather than data.frame()
> >>
> >> data.matrix() is guaranteed to return a numerical
> matrix
> >> from a data frame, making arithmetic always
> possible.
> >>
> >> Bill Venables.
> >>
> >> ________________________________________
> >> From: Venables, Bill (CMIS, Dutton Park)
> >> Sent: 20 May 2011 14:30
> >> To: 'Ramya'; 'r-help_at_r-project.org'
> >> Subject: RE: [R] Adding a numeric to all values in
> the
> >> dataframe
> >>
> >> For that kind of operation (unusual as it is) work
> with
> >> numeric matrices.  When you are finished, if
> you still
> >> want a data frame, make it then, not before.
> >>
> >> If your data starts off as data frame to begin
> with, turn
> >> it into a matrix first.  E.g.
> >>
> >> myMatrix <- data.frame(myData)
> >> myMatrix2 <- myMatrix + 2
> >> myData2 <- data.frame(myMatrix2)
> >>
> >> Bill Venables.
> >>
> >> -----Original Message-----
> >> From: r-help-bounces_at_r-project.org
> >> [mailto:r-help-bounces_at_r-project.org]
> >> On Behalf Of Ramya
> >> Sent: Friday, 20 May 2011 1:54 PM
> >> To: r-help_at_r-project.org
> >> Subject: [R] Adding a numeric to all values in
> the
> >> dataframe
> >>
> >> Hi there
> >>
> >> I just want to add 2 to all the values in
> dataframe.
> >>
> >> I tried using sapply but it seem to die all the
> time.
> >>
> >> Any help would be appreciated.
> >>
> >> Thanks
> >> Ramya
> >>
> >> --
> >> View this message in context: http://r.789695.n4.nabble.com/Adding-a-numeric-to-all-values-in-the-dataframe-tp3537594p3537594.html
> >> Sent from the R help mailing list archive at
> Nabble.com.
> >>
> >> ______________________________________________
> >> R-help_at_r-project.org
> >> mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained,
> >> reproducible code.
> >>
> >> ______________________________________________
> >> R-help_at_r-project.org
> >> mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained,
> >> reproducible code.
> >>
> >
> > ______________________________________________
> > R-help_at_r-project.org
> mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> reproducible code.
>
> David Winsemius, MD
> West Hartford, CT
>
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 22 May 2011 - 02:20:48 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 22 May 2011 - 02:50:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive