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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:29:00+00:00 2026-06-09T23:29:00+00:00

I am trying to write code that takes values from one column of each

  • 0

I am trying to write code that takes values from one column of each of many files and prints out a list of the values of a different column depending on the values found in the first. If that makes sense. I have read the files in, but I am having trouble managing the table. I would like to limit the table to just those two columns, because the files are very large, cumbersome and unnecessary. In my attempt to do so I had this line:

tmp<-stack(lapply(inputFiles,function(x) x[,3]))

But ideally I would like to include two columns (3 and 1), not just one, so that I may use a line, such as these ones:

search<-tmp[tmp$values < 100, "Target"]
write(search, file = "Five", ncolumns = 2)

But I am not sure how. I am almost certain that stack is not going to work for more than one column. I tried some different things, similar to this:

tmp<-stack(lapply(inputFiles,function(x) x[,3], x[,1]))

But of course that didn’t work.

But I don’t know where to look. Does anyone have any suggestions?

  • 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-09T23:29:01+00:00Added an answer on June 9, 2026 at 11:29 pm

    The taRifx package has a list method for stack that will do what you want. It stacks lists of data.frames.

    Untested code:

    library(taRifx)
    tmp<-stack(lapply(inputFiles,function(x) x[,c(1,3)]))
    

    But you didn’t change anything! Why does this work?

    lapply() returns a list. In your case, it returns a list where each element is a data.frame.

    Base R does not have a special method for stacking lists. So when you call stack() on your list of data.frames, it calls stack.default, which doesn’t work.

    Loading the taRifx library loads a method of stack that deals specifically with lists of data.frames. So everything works fine since stack() now knows how to properly handle a list of data.frames.

    Tested example:

    dat <- replicate(10, data.frame(x=runif(2),y=rnorm(2)), simplify=FALSE)
    str(dat)
    stack(dat)
    
                x           y
    1  0.42692948  0.32023455
    2  0.75388820  0.24154125
    3  0.64035957  1.96580059
    4  0.47690790 -1.89772855
    5  0.41668993  0.78083412
    6  0.12643784  0.38029833
    7  0.01656855  0.51225268
    8  0.40653094  1.09408159
    9  0.94236491 -0.13410923
    10 0.05578115  1.12475364
    11 0.75651062 -0.65441493
    12 0.48210444  1.67325343
    13 0.95348755  0.04828449
    14 0.02315498 -0.28481193
    15 0.27370762  0.43927826
    16 0.83045889  0.75880763
    17 0.40049367  0.06945058
    18 0.86212662  1.49918712
    19 0.97611629  0.13959291
    20 0.29107186  0.64483646
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write some code that will generate accurate .proto files from
I'm trying to generate code that takes a StringBuilder, and writes the values of
I'm trying to write a piece of code that takes in a two digit
I'm trying to write code that will load an image from a resource, and
I am trying to create a UDF that takes the values from 4 selected
I m trying write code that after reset set up rrpmax as 3000. It
I've been trying to write code that loads a .png file, attaches hotspot information,
I'm trying to write a code that adds a class to a div for
I'm trying to write a code that could print something like this -xv -xvv
I am trying to write some code that that will draw the line which

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.