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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:03:45+00:00 2026-06-15T07:03:45+00:00

Say I have loaded a csv file into R with two columns (column A

  • 0

Say I have loaded a csv file into R with two columns (column A and column B say) with real value entries. Call the dataframe df. Is there away of speeding up the following code:

dfm <- df[floor(A) = x & floor(B) = y,]
x <- 2
y <- 2
dfm

I am hoping there will be something akin to function e.g.

dfm <- function(x,y) {df[floor(A) = x & floor(B) = y,]}

so that I can type

Any help much appreciated.

  • 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-15T07:03:46+00:00Added an answer on June 15, 2026 at 7:03 am

    The way that’s written right now won’t work for a few reasons:

    1. You need to assign values to x and y before you assign dfm. In other words, the lines x <- 2 and y <- 2 must come before the dfm <- ... line.
    2. R doesn’t know what A and B are, even if you put them inside the brackets of the dataframe that contains them. You need to write df$A and df$B.
    3. = is the assignment operator, but you’re looking for the logical operator ==. Right now your code is saying “Assign the value x to floor(A)” (which doesn’t really make sense). You want to tell it “Only choose rows where floor(A) equals x”, or floor(A)==x.

    So what you want is:

    dfm.create <- function(x,y) {df[floor(df$A)==x & floor(df$B)==y,]}
    dfm <- dfm.create(2,2)
    

    Note that if you want the dataframe to be called dfm, you don’t want to name the function dfm, or you will have to erase the function to make the dataframe.

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

Sidebar

Related Questions

Say I have a 10mb CSV file I want to load into a JavaScript
Say I have an html file that I have loaded, I run this query:
Say I have these two variables: size_t value; size_t size; And I want to
I have created two tabs, say TAB1 and TAB2. For TAB1, i have loaded
Can EF really be this bad? Maybe... Let's say I have a fully loaded,
Say I have a file based data structure such as a B+ Tree. My
Say I have file.php with three functions and an echo statement: function one() {
I have following scenario: Lets say we have two different webparts operating on the
Say I have 2 db configs: $db['default'] $db['alternate'] And say I have loaded a
I have loaded some values into local documents in my application. When the application

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.