Re: [R] More elegant multiplication or division of a data frame with avector

From: Tribo Laboy <tribolaboy_at_gmail.com>
Date: Sun, 23 Mar 2008 08:26:00 +0000

Hi Gabor and Greg,

I thought there might be a more ?intuitive way to it, but any of those will just work fine.

Thanks a lot,
TL

On Sat, Mar 22, 2008 at 3:06 PM, Greg Snow <Greg.Snow_at_imail.org> wrote:
>
>
>
> > sweep( rawdata, 2, sens, '/' )
>
> hope this helps,
>
>
> ________________________________
>
> From: r-help-bounces_at_r-project.org on behalf of Tribo Laboy
> Sent: Sat 3/22/2008 8:21 AM
> To: r-help_at_r-project.org
> Subject: [R] More elegant multiplication or division of a data frame with
> avector
>
>
>
>
>
> Hello,
>
> I am importing some raw voltage multichannel measurements into an R
> data frame. I need to scale each column with the respective
> sensitivity for that channel. I figured how to do it, but I am curious
> if there isn't a more elegant way.
>
> Now I start with something like this:
>
> rawdata <- data.frame(rbind(c(1,2,3), c(4,5,6)))
> sens <- c(2,4,6)
>
>
> and I do this:
> data <- as.data.frame(t(t(rawdata)/sens))
>
> Any suggestions?
>
> Cheers,
>
> TL
>
> ______________________________________________
> 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. Received on Sun 23 Mar 2008 - 08:29:39 GMT

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 23 Mar 2008 - 11:30:23 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