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 8050911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:11:19+00:00 2026-06-05T07:11:19+00:00

Given a data set with a time stamp and several columns of data following

  • 0

Given a data set with a time stamp and several columns of data following it

data=
           hour          V1           V2          V3
1 2012-01-19 08:00:00  0.04551064  0.002851064  0.01842553
2 2012-01-19 09:00:00 -0.05305000 -0.052266667 -0.07455000
3 2012-01-19 10:00:00 -0.07518333 -0.101333333 -0.10670000
4 2012-01-19 11:00:00 -0.09195000 -0.099383333 -0.11176667
5 2012-01-19 12:00:00 -0.07743333 -0.074000000 -0.09106667
6 2012-01-19 13:00:00 -0.10978333 -0.096200000 -0.11343333

I would like to square the columns V1-V3 giving me this

data_sq=
         hour                V1           V2           V3
1    2012-01-19 08:00:00  0.002071218 8.128565e-06 0.0003395002
2    2012-01-19 09:00:00  0.002814303 2.731804e-03 0.0055577025
3    2012-01-19 10:00:00  0.005652534 1.026844e-02 0.0113848900
4    2012-01-19 11:00:00  0.008454803 9.877047e-03 0.0124917878
5    2012-01-19 12:00:00  0.005995921 5.476000e-03 0.0082931378
6    2012-01-19 13:00:00  0.012052380 9.254440e-03 0.0128671211

As for right now I just use

data_sq<-data^2

to get the square root. But it destroys the time stamp so I have to put it back in with something really awkward like

data_sqd<-cbind(data_sq,data$hour)

I tried

data_sq<-(data[,c(2:4)]^2

but I loose the time stamp as well

So how do I keep my time stamp column intact and specify which columns I want to square? My apologies for the lack of reproducible data, but I am hoping this is a simple enough question I can get away with it 🙂

  • 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-06-05T07:11:20+00:00Added an answer on June 5, 2026 at 7:11 am
    data_sq <- data # try not to use data, it's a function in base
    data_sq[,2:4] <- data[,2:4]^2 # subsetting was off but you were close!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, given a data set in plain text such as the following: ==Events==
Given a data set like this; +-----+---------------------+--------+ | id | date | result |
Given a simple data set, I would like to be able to calculate a
Given data values of some real-time physical process (e.g. network traffic) it is to
Given a table (TableA) that contains the following data; Id Date Status RecordId 1
I have a data set consisting of time-stamped values, and absolute (meter) values. Sometimes
Currently I did a FFT of a set of data which gives me a
I am trying to sample a data frame from a given data frame such
Another stupid question here regarding a SQL scenario. Given data such as: FieldKey DocumentKey
Given a data stream of continuously arriving items containing a timestamp and text (e.g.

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.