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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:42:56+00:00 2026-06-07T21:42:56+00:00

I have a column in a data frame that looks something like this: [1]

  • 0

I have a column in a data frame that looks something like this:

[1] [0.50 .. 0.52] [0.52 .. 0.54] [0.54 .. 0.56] [0.56 .. 0.58]
[5] [0.58 .. 0.60] [0.60 .. 0.62] [0.62 .. 0.64] [0.64 .. 0.66]
[9] [0.66 .. 0.68] [0.68 .. 0.70] [0.70 .. 0.72] [0.72 .. 0.74]
[13] [0.74 .. 0.76] [0.76 .. 0.78] [0.78 .. 0.80] [0.80 .. 0.82]

I would like to take the average of the two numbers in this column. However, I don’t know how to go about this. I tried using gsub() to replace the ” .. ” but I cannot remove the brackets, and I cannot seem to find a way to just extract the numbers. What would be the best way to just get the average of these numbers?

  • 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-07T21:42:58+00:00Added an answer on June 7, 2026 at 9:42 pm

    Use gsub to take out the brackets (remembering to double escape for them), then use strsplit to separate the numbers, and sapply to work on the resulting list with mean and as.numeric:

    x <- c("[0.52 .. 0.54]", "[0.54 .. 0.56]")
    
    sapply(strsplit(gsub("[\\[\\]]","",x,perl=T)," .. "),function(x) mean(as.numeric(x)))
    [1] 0.53 0.55
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data frame that looks like this, with two key columns and
I have a data.frame that looks like this > head(df) Memory Memory Memory Memory
I have a single column in a data frame in R that looks something
I have a data frame that looks like this: user1,product1,0 user1,product2,2 user1,product3,1 user1,product4,2 user2,product3,0
I have an R data frame that looks like this: z = as.data.frame(list(Col1=c(a,c,e,g),Col2=c(b,d,f,h),Col3=c(1,2,5,3,5,7,9,8,1))) >
I have a factored time series that looks like this: df <- data.frame(a=c(11-JUL-2004, 11-JUL-2005,
I have two data frames that look like something like the following: df1 <-
I have data frame that looks like the following models cores time 1 4
I have a large data frame that looks similar to this: df <- data.frame(dive
I have a data set which looks something like data<-c(0,1,2,3,4,2,3,1,4,3,2,4,0,1,2,0,2,1,2,0,4) frame<-as.data.frame(data) I now want

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.