Why dplyr filter do not accepts integer data frame? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceDrop factor levels in a subsetted data frameHow to join (merge) data frames (inner, outer, left, right)Convert a list of data frames into one data frameR - list to data frameDrop data frame columns by nameHow to drop columns by name in a data frameChanging column names of a data frameFiltering a data frame by values in a columnExtracting specific columns from a data frameFiltering row which contains a certain string using dplyr

Can withdrawing asylum be illegal?

I could not break this equation. Please help me

Can a novice safely splice in wire to lengthen 5V charging cable?

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

How are presidential pardons supposed to be used?

Are spiders unable to hurt humans, especially very small spiders?

Do working physicists consider Newtonian mechanics to be "falsified"?

Why is superheterodyning better than direct conversion?

A pet rabbit called Belle

Can undead you have reanimated wait inside a portable hole?

How do I add random spotting to the same face in cycles?

Would an alien lifeform be able to achieve space travel if lacking in vision?

Relations between two reciprocal partial derivatives?

Arduino Pro Micro - switch off LEDs

When did F become S in typeography, and why?

What information about me do stores get via my credit card?

University's motivation for having tenure-track positions

Can the DM override racial traits?

How does ice melt when immersed in water

Can the prologue be the backstory of your main character?

Does Parliament hold absolute power in the UK?

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

Did God make two great lights or did He make the great light two?

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?



Why dplyr filter do not accepts integer data frame?



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceDrop factor levels in a subsetted data frameHow to join (merge) data frames (inner, outer, left, right)Convert a list of data frames into one data frameR - list to data frameDrop data frame columns by nameHow to drop columns by name in a data frameChanging column names of a data frameFiltering a data frame by values in a columnExtracting specific columns from a data frameFiltering row which contains a certain string using dplyr



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I ran the following code on data, which has 12 integer variable:



calculate_winnings <- function(data, time_durations) 
require("data.table")

calculate_winnings_loop_body <- function(i)
require("dplyr")

beg <- time_durations[i]
end <- time_durations[i + 1]

these_games <- filter(data, gameDuration >= beg & gameDuration < end)

team1_wins <- filter(these_games, winner == 1) %>% sum
team2_wins <- filter(these_games, winner == 2) %>% sum

data.frame(team1 = team1_wins, team2 = team2_wins)


i <- 1
Samples <- length(time_durations) - 1

l <- lapply(1 : Samples, calculate_winnings_loop_body)
rbindlist(l)


double_max <- .Machine["double.xmax"]
winnings <- calculate_winnings(data, c(180, 1200, 1500, 1800, 2100, double_max))


And errors:



Error in FUN(X[[i]], ...) : 
only defined on a data frame with all
numeric variables
In addition: Warning message:
NAs introduced by coercion to integer range


I tried tracback():



15: stop("only defined on a data frame w
ith all numeric variables")
14: FUN(X[[i]], ...)
13: lapply(args, function(x)
x <- as.matrix(x)
if (!is.numeric(x) && !is.comple
x(x))
stop("only defined on a data
frame with all numeric variables")
x
)
12: Summary.data.frame(list(gameDuration = integer(0), winner = integer(0),
firstBlood = integer(0), firstTower = integer(0),
firstBaron = integer(0), firstDragon = integer(0),
t1_towerKills = integer(0), t1_baronKills = integer(0),
t1_dragonKills = integer(0), t2_towerKills = integer(0),
t2_baronKills = integer(0), t2_dragonKills = integer(0)),
na.rm = FALSE)
11: function_list[[k]](value)
10: withVisible(function_list[[k]](value))
9: freduce(value, `_function_list`)
8: `_fseq`(`_lhs`)
7: eval(quote(`_fseq`(`_lhs`)), env, env)
6: eval(quote(`_fseq`(`_lhs`)), env, env)
5: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
4: filter(these_games, winner == 1) %>% sum at debug.R.tmp.R#18
3: FUN(X[[i]], ...)
2: lapply(1:Samples, calculate_winnings_loop_body) at debug.R.tmp.R#34
1: calculate_winnings(data, c(180, 1200, 1500, 1800, 2100, double_max))


But I cannot understand why this happens.



Edit:



The data is downloaded from kaggle and then processed by:



comb <- function(vec1, vec2, sep = "") 
ret <- c()

for (str1 in vec1)
for (str2 in vec2)
ret <- c(ret, paste(str1, str2, sep = sep))

ret


data <- read.csv("data/1_games.csv")
data <- data[, c("gameDuration", "winner",
comb(c("first"), c("Blood", "Tower", "Baron", "Dragon")),
comb(c("t1_", "t2_"), c("towerKills", "baronKills", "dragonKills"))
)]
data <- data[data$gameDuration > 240, ]
data <- data[data$firstTower != 0, ]









share|improve this question
























  • Please share sample data.

    – Sonny
    Mar 22 at 6:38











  • @Sonny The source of the data and the R script used to process it is shared.

    – JiaHao Xu
    Mar 22 at 6:43


















0















I ran the following code on data, which has 12 integer variable:



calculate_winnings <- function(data, time_durations) 
require("data.table")

calculate_winnings_loop_body <- function(i)
require("dplyr")

beg <- time_durations[i]
end <- time_durations[i + 1]

these_games <- filter(data, gameDuration >= beg & gameDuration < end)

team1_wins <- filter(these_games, winner == 1) %>% sum
team2_wins <- filter(these_games, winner == 2) %>% sum

data.frame(team1 = team1_wins, team2 = team2_wins)


i <- 1
Samples <- length(time_durations) - 1

l <- lapply(1 : Samples, calculate_winnings_loop_body)
rbindlist(l)


double_max <- .Machine["double.xmax"]
winnings <- calculate_winnings(data, c(180, 1200, 1500, 1800, 2100, double_max))


And errors:



Error in FUN(X[[i]], ...) : 
only defined on a data frame with all
numeric variables
In addition: Warning message:
NAs introduced by coercion to integer range


I tried tracback():



15: stop("only defined on a data frame w
ith all numeric variables")
14: FUN(X[[i]], ...)
13: lapply(args, function(x)
x <- as.matrix(x)
if (!is.numeric(x) && !is.comple
x(x))
stop("only defined on a data
frame with all numeric variables")
x
)
12: Summary.data.frame(list(gameDuration = integer(0), winner = integer(0),
firstBlood = integer(0), firstTower = integer(0),
firstBaron = integer(0), firstDragon = integer(0),
t1_towerKills = integer(0), t1_baronKills = integer(0),
t1_dragonKills = integer(0), t2_towerKills = integer(0),
t2_baronKills = integer(0), t2_dragonKills = integer(0)),
na.rm = FALSE)
11: function_list[[k]](value)
10: withVisible(function_list[[k]](value))
9: freduce(value, `_function_list`)
8: `_fseq`(`_lhs`)
7: eval(quote(`_fseq`(`_lhs`)), env, env)
6: eval(quote(`_fseq`(`_lhs`)), env, env)
5: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
4: filter(these_games, winner == 1) %>% sum at debug.R.tmp.R#18
3: FUN(X[[i]], ...)
2: lapply(1:Samples, calculate_winnings_loop_body) at debug.R.tmp.R#34
1: calculate_winnings(data, c(180, 1200, 1500, 1800, 2100, double_max))


But I cannot understand why this happens.



Edit:



The data is downloaded from kaggle and then processed by:



comb <- function(vec1, vec2, sep = "") 
ret <- c()

for (str1 in vec1)
for (str2 in vec2)
ret <- c(ret, paste(str1, str2, sep = sep))

ret


data <- read.csv("data/1_games.csv")
data <- data[, c("gameDuration", "winner",
comb(c("first"), c("Blood", "Tower", "Baron", "Dragon")),
comb(c("t1_", "t2_"), c("towerKills", "baronKills", "dragonKills"))
)]
data <- data[data$gameDuration > 240, ]
data <- data[data$firstTower != 0, ]









share|improve this question
























  • Please share sample data.

    – Sonny
    Mar 22 at 6:38











  • @Sonny The source of the data and the R script used to process it is shared.

    – JiaHao Xu
    Mar 22 at 6:43














0












0








0








I ran the following code on data, which has 12 integer variable:



calculate_winnings <- function(data, time_durations) 
require("data.table")

calculate_winnings_loop_body <- function(i)
require("dplyr")

beg <- time_durations[i]
end <- time_durations[i + 1]

these_games <- filter(data, gameDuration >= beg & gameDuration < end)

team1_wins <- filter(these_games, winner == 1) %>% sum
team2_wins <- filter(these_games, winner == 2) %>% sum

data.frame(team1 = team1_wins, team2 = team2_wins)


i <- 1
Samples <- length(time_durations) - 1

l <- lapply(1 : Samples, calculate_winnings_loop_body)
rbindlist(l)


double_max <- .Machine["double.xmax"]
winnings <- calculate_winnings(data, c(180, 1200, 1500, 1800, 2100, double_max))


And errors:



Error in FUN(X[[i]], ...) : 
only defined on a data frame with all
numeric variables
In addition: Warning message:
NAs introduced by coercion to integer range


I tried tracback():



15: stop("only defined on a data frame w
ith all numeric variables")
14: FUN(X[[i]], ...)
13: lapply(args, function(x)
x <- as.matrix(x)
if (!is.numeric(x) && !is.comple
x(x))
stop("only defined on a data
frame with all numeric variables")
x
)
12: Summary.data.frame(list(gameDuration = integer(0), winner = integer(0),
firstBlood = integer(0), firstTower = integer(0),
firstBaron = integer(0), firstDragon = integer(0),
t1_towerKills = integer(0), t1_baronKills = integer(0),
t1_dragonKills = integer(0), t2_towerKills = integer(0),
t2_baronKills = integer(0), t2_dragonKills = integer(0)),
na.rm = FALSE)
11: function_list[[k]](value)
10: withVisible(function_list[[k]](value))
9: freduce(value, `_function_list`)
8: `_fseq`(`_lhs`)
7: eval(quote(`_fseq`(`_lhs`)), env, env)
6: eval(quote(`_fseq`(`_lhs`)), env, env)
5: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
4: filter(these_games, winner == 1) %>% sum at debug.R.tmp.R#18
3: FUN(X[[i]], ...)
2: lapply(1:Samples, calculate_winnings_loop_body) at debug.R.tmp.R#34
1: calculate_winnings(data, c(180, 1200, 1500, 1800, 2100, double_max))


But I cannot understand why this happens.



Edit:



The data is downloaded from kaggle and then processed by:



comb <- function(vec1, vec2, sep = "") 
ret <- c()

for (str1 in vec1)
for (str2 in vec2)
ret <- c(ret, paste(str1, str2, sep = sep))

ret


data <- read.csv("data/1_games.csv")
data <- data[, c("gameDuration", "winner",
comb(c("first"), c("Blood", "Tower", "Baron", "Dragon")),
comb(c("t1_", "t2_"), c("towerKills", "baronKills", "dragonKills"))
)]
data <- data[data$gameDuration > 240, ]
data <- data[data$firstTower != 0, ]









share|improve this question
















I ran the following code on data, which has 12 integer variable:



calculate_winnings <- function(data, time_durations) 
require("data.table")

calculate_winnings_loop_body <- function(i)
require("dplyr")

beg <- time_durations[i]
end <- time_durations[i + 1]

these_games <- filter(data, gameDuration >= beg & gameDuration < end)

team1_wins <- filter(these_games, winner == 1) %>% sum
team2_wins <- filter(these_games, winner == 2) %>% sum

data.frame(team1 = team1_wins, team2 = team2_wins)


i <- 1
Samples <- length(time_durations) - 1

l <- lapply(1 : Samples, calculate_winnings_loop_body)
rbindlist(l)


double_max <- .Machine["double.xmax"]
winnings <- calculate_winnings(data, c(180, 1200, 1500, 1800, 2100, double_max))


And errors:



Error in FUN(X[[i]], ...) : 
only defined on a data frame with all
numeric variables
In addition: Warning message:
NAs introduced by coercion to integer range


I tried tracback():



15: stop("only defined on a data frame w
ith all numeric variables")
14: FUN(X[[i]], ...)
13: lapply(args, function(x)
x <- as.matrix(x)
if (!is.numeric(x) && !is.comple
x(x))
stop("only defined on a data
frame with all numeric variables")
x
)
12: Summary.data.frame(list(gameDuration = integer(0), winner = integer(0),
firstBlood = integer(0), firstTower = integer(0),
firstBaron = integer(0), firstDragon = integer(0),
t1_towerKills = integer(0), t1_baronKills = integer(0),
t1_dragonKills = integer(0), t2_towerKills = integer(0),
t2_baronKills = integer(0), t2_dragonKills = integer(0)),
na.rm = FALSE)
11: function_list[[k]](value)
10: withVisible(function_list[[k]](value))
9: freduce(value, `_function_list`)
8: `_fseq`(`_lhs`)
7: eval(quote(`_fseq`(`_lhs`)), env, env)
6: eval(quote(`_fseq`(`_lhs`)), env, env)
5: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
4: filter(these_games, winner == 1) %>% sum at debug.R.tmp.R#18
3: FUN(X[[i]], ...)
2: lapply(1:Samples, calculate_winnings_loop_body) at debug.R.tmp.R#34
1: calculate_winnings(data, c(180, 1200, 1500, 1800, 2100, double_max))


But I cannot understand why this happens.



Edit:



The data is downloaded from kaggle and then processed by:



comb <- function(vec1, vec2, sep = "") 
ret <- c()

for (str1 in vec1)
for (str2 in vec2)
ret <- c(ret, paste(str1, str2, sep = sep))

ret


data <- read.csv("data/1_games.csv")
data <- data[, c("gameDuration", "winner",
comb(c("first"), c("Blood", "Tower", "Baron", "Dragon")),
comb(c("t1_", "t2_"), c("towerKills", "baronKills", "dragonKills"))
)]
data <- data[data$gameDuration > 240, ]
data <- data[data$firstTower != 0, ]






r dataframe filter dplyr int






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 6:40







JiaHao Xu

















asked Mar 22 at 6:36









JiaHao XuJiaHao Xu

696316




696316












  • Please share sample data.

    – Sonny
    Mar 22 at 6:38











  • @Sonny The source of the data and the R script used to process it is shared.

    – JiaHao Xu
    Mar 22 at 6:43


















  • Please share sample data.

    – Sonny
    Mar 22 at 6:38











  • @Sonny The source of the data and the R script used to process it is shared.

    – JiaHao Xu
    Mar 22 at 6:43

















Please share sample data.

– Sonny
Mar 22 at 6:38





Please share sample data.

– Sonny
Mar 22 at 6:38













@Sonny The source of the data and the R script used to process it is shared.

– JiaHao Xu
Mar 22 at 6:43






@Sonny The source of the data and the R script used to process it is shared.

– JiaHao Xu
Mar 22 at 6:43













1 Answer
1






active

oldest

votes


















1














Your double_max variable is a list and it is creating problems downstream.
If you want that, convert into numeric and rest of your code should work



double_max <- as.numeric(.Machine["double.xmax"])


Please check



Suggestion: Please move require outside of function






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55294124%2fwhy-dplyr-filter-do-not-accepts-integer-data-frame%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Your double_max variable is a list and it is creating problems downstream.
    If you want that, convert into numeric and rest of your code should work



    double_max <- as.numeric(.Machine["double.xmax"])


    Please check



    Suggestion: Please move require outside of function






    share|improve this answer





























      1














      Your double_max variable is a list and it is creating problems downstream.
      If you want that, convert into numeric and rest of your code should work



      double_max <- as.numeric(.Machine["double.xmax"])


      Please check



      Suggestion: Please move require outside of function






      share|improve this answer



























        1












        1








        1







        Your double_max variable is a list and it is creating problems downstream.
        If you want that, convert into numeric and rest of your code should work



        double_max <- as.numeric(.Machine["double.xmax"])


        Please check



        Suggestion: Please move require outside of function






        share|improve this answer















        Your double_max variable is a list and it is creating problems downstream.
        If you want that, convert into numeric and rest of your code should work



        double_max <- as.numeric(.Machine["double.xmax"])


        Please check



        Suggestion: Please move require outside of function







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 22 at 6:59

























        answered Mar 22 at 6:51









        SonnySonny

        2,1111516




        2,1111516





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55294124%2fwhy-dplyr-filter-do-not-accepts-integer-data-frame%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript