Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7550103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:07:39+00:00 2026-05-30T10:07:39+00:00

I have a data set, and I would like to apply an equation to

  • 0

I have a data set, and I would like to apply an equation to groups of my values. Specifically I would like to apply

sqrt(X^2+Y^2+Z^2)

to all values within a specific time and variable

Looking at the data below I would like to group my values by unique time (TS) and Bins (Bin), and grab the square root of the sum of squares for each of the X Y and Z components.

    id  D      Bin  value   Month Day Year Hour Minute Second                  TS
    1   X       V1   -0.320     1  30 2012   13     59     50 2012-01-30 13:59:50
    1   Y       V1   -0.088     1  30 2012   13     59     50 2012-01-30 13:59:50
    1   Z       V1    0.171     1  30 2012   13     59     50 2012-01-30 13:59:50
    1   X       V2    0.368     1  30 2012   13     59     50 2012-01-30 13:59:50
    1   Y       V2   -0.104     1  30 2012   13     59     50 2012-01-30 13:59:50
    1   Z       V2    0.008     1  30 2012   13     59     50 2012-01-30 13:59:50
    2   X       V1   -0.052     1  30 2012   14      0     50 2012-01-30 14:00:50
    2   Y       V1    0.278     1  30 2012   14      0     50 2012-01-30 14:00:50
    2   Z       V1   -0.086     1  30 2012   14      0     50 2012-01-30 14:00:50
    2   X       V2   -0.214     1  30 2012   14      0     50 2012-01-30 14:00:50
    2   Y       V2    0.118     1  30 2012   14      0     50 2012-01-30 14:00:50
    2   Z       V2   -0.030     1  30 2012   14      0                        

So up first would be V1 at 13:59:50

sqrt(-0.320^2 + -0.088^2 + 0.171^2)

and then for V2 at t13:59:50

sqrt(0.368^2 +-0.104^2  + 0,008^2)

and so on

I had tried to use this formula (Data is called “V”)

 V=aggregate(value~TS+variable,data=V,sqrt((if(V$D=="X")V$value^2)+(if(V$D=="Y")V$value^2))+(if(V$D=="Z")V$value^2))

But obviously that does not work. So does anyone have a better way to first index unique groups in a data set, and than apply an equation to said group?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:07:40+00:00Added an answer on May 30, 2026 at 10:07 am

    Assuming you always have one X, one Y, and one Z for each combination of (TS, Bin), I would try this:

    aggregate(value ~ TS + Bin, data = V, FUN = function(x)sqrt(sum(x^2)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of controls bound to data, on which I would like
I have a data set that looks like this: 000 100 200 300 010
I have created a DataTemplateSelector class. I would like to apply it to a
I have a data set whose elements are displayed as rows in a DataGrid.
I have a data set that is organized in the following manner: Timestamp|A0001|A0002|A0003|A0004|B0001|B0002|B0003|B0004 ...
I have a data set with over 50,000 geocoded points (lat-long). Each point has
I have a data set which consists of an ID and a matrix (n
I have a data set that is around 700 rows with eight columns of
I have the following data set that I am trying to plot with ggplot2,
Interpolating Large Datasets I have a large data set of about 0.5million records representing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.