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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:32:37+00:00 2026-06-15T23:32:37+00:00

Below I have provided a snippet of some code that I have been working

  • 0

Below I have provided a snippet of some code that I have been working on. I have been sucessfully reading in string as tables. There exist some subset of my tables which I wish to use the median() function on. From what research I have done and my own experiences median() does not have defined behavior for a data.frame nor a subset of data.frame. So, wishing to fit my problem into some defined behavior, I tried to cast my desired subset into a vector. However, even after using as.vector to cast my desired subset, I still have a data.frame. When I try to call median on this I get “argument is not numeric or logical: returning NA.”

I have played this quite a bit myself and tried to find information here and elsewhere. As a note I have tried the methods listed in the accpeted solution on this thread R-friendly way to convert R data.frame column to a vector? and achieved the same results I have now. I don’t care too much how I accomplish this; feel free to suggest other methods.

Thank you for your time.

for(i in 1:length(text_array)){
    temp= read.table(textConnection(text_array[i]), sep="\t",row.names=NULL, header= FALSE,  fill=TRUE) 
    value=""
    #we are now going to process temp and add it
    cur_DS=coll_data_sets[i]
    #median is the value that we are going to insert into the result array.
    #currently the logic behind it is not implemented.
    #the value will be the median of state1 divided by the median of state2.
    t_states=vector(length=ncol(temp))
    for(j in 1:ncol(temp)){
        t_states[j]=toString(temp[2,j])

    }
    t_states=(unique(t_states))
    #this logic is current is set to reject data from more than one state.
    # It will also reject anything that appears to lack state data.
    if(length(t_states) !=  2){
        value=NA
    }else{
        s1_expr=as.vector(x=(temp[3, temp[2,]==t_states[1]]))
        s2_expr=as.vector(x=temp[3, temp[2,]==t_states[2]])
        print(class(s1_expr))
    #   med1= (median(s1_expr))
    #   med2= (median(s2_expr))
    #   if(is.na(med1[1]) || is.na(med2[1])){
    #       value=-1
        }#else{
    #       value=med1[1]/med2[1]
    #       print(value)
    #   }

    }
[1] "data.frame"
[1] "data.frame"
[1] "data.frame"

Here is an example value for ‘temp’:

         V1        V2          V3          V4
1 GSM506899 GSM506900   GSM506901   GSM506902
2 wild type wild type Zbtb20 null Zbtb20 null
3      99.3     98.24        66.2      102.42
4      55.8     20.11        22.9       16.98
5     159.6     63.46       102.5       67.17
6       166     54.73         215       49.46
  • 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-15T23:32:39+00:00Added an answer on June 15, 2026 at 11:32 pm

    Data frames are lists. Even if you select just a single row of a data, it’s still a list.

    Try unlist. (Assuming all the values in your “row” are of course numeric. If they aren’t, that you have bigger problems.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

below i have a code that runs in most of my simple programs ..
I have below snippet of code in which TestClass is extending jPanel which is
I have stumbled upon the following problem. The below code snippet does not link
Below I have a function that animates a div ( container ) either to
Below I have a line of code where it states which Session a user
Below I have written a sample program that I have written to learn about
I have below code: <a href=# id=@item.Id name=vote ><img src=/Content/images/021.png style=float:left alt= /></a> which
I have provided the test website link below: http://www.naughtyfancydress.com/html/outfit.html I am trying to integrate
It all looks good below I have provided the 3 parts the service works
I have parent window and provided a link. For now I am using below

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.