R package arules: read.transactions file format

Multi tool use
Multi tool use












0















I have a .csv file with the following type of data:



Day Item
1 12,19,24,31,48,
1 1,19,
1 16,28,32,45,
1 19,36,41,43,44,
1 7,24,27,
1 21,31,33,41,
1 46
1 50
2 12,31,36,48,
2 17,29,47,
2 2,18,20,29,38,39,40,41
2 17,29,47,


And I can't get the read.transactions to read it properly.



The data set is based on several item selection for each day (more than one time per day, if necessary). For instance, the third selection on day 1, returned items 16,28,32, and 45.



Shouldn't this be enough?



library(arules)
dataset <- read.transactions("file.csv", format = 'basket')









share|improve this question

























  • I think you need to specify the sep

    – akrun
    Dec 30 '18 at 20:38











  • What happens when you try the code? An error? What error?

    – IceCreamToucan
    Dec 30 '18 at 20:38











  • @akrun, thanks for your comment. However, I already tried to specify sep="," or even revome the commas from the CSV but the dataset analysis isn't done properly

    – Paulos
    Dec 30 '18 at 20:39






  • 1





    You have a quote missing in basket. If i do read.transactions("file.csv", format = 'basket', sep=",")# transactions in sparse format with 13 transactions (rows) and 32 items (columns)

    – akrun
    Dec 30 '18 at 20:40













  • @IceCreamToucan the dataset isn't analyzed properly. For instance, it is saying that all rows have only 2 elements (it must be using only the first two numbers). Instead, it should be detecting the first as a class and the following (separeted by commas), as the elements.

    – Paulos
    Dec 30 '18 at 20:41
















0















I have a .csv file with the following type of data:



Day Item
1 12,19,24,31,48,
1 1,19,
1 16,28,32,45,
1 19,36,41,43,44,
1 7,24,27,
1 21,31,33,41,
1 46
1 50
2 12,31,36,48,
2 17,29,47,
2 2,18,20,29,38,39,40,41
2 17,29,47,


And I can't get the read.transactions to read it properly.



The data set is based on several item selection for each day (more than one time per day, if necessary). For instance, the third selection on day 1, returned items 16,28,32, and 45.



Shouldn't this be enough?



library(arules)
dataset <- read.transactions("file.csv", format = 'basket')









share|improve this question

























  • I think you need to specify the sep

    – akrun
    Dec 30 '18 at 20:38











  • What happens when you try the code? An error? What error?

    – IceCreamToucan
    Dec 30 '18 at 20:38











  • @akrun, thanks for your comment. However, I already tried to specify sep="," or even revome the commas from the CSV but the dataset analysis isn't done properly

    – Paulos
    Dec 30 '18 at 20:39






  • 1





    You have a quote missing in basket. If i do read.transactions("file.csv", format = 'basket', sep=",")# transactions in sparse format with 13 transactions (rows) and 32 items (columns)

    – akrun
    Dec 30 '18 at 20:40













  • @IceCreamToucan the dataset isn't analyzed properly. For instance, it is saying that all rows have only 2 elements (it must be using only the first two numbers). Instead, it should be detecting the first as a class and the following (separeted by commas), as the elements.

    – Paulos
    Dec 30 '18 at 20:41














0












0








0








I have a .csv file with the following type of data:



Day Item
1 12,19,24,31,48,
1 1,19,
1 16,28,32,45,
1 19,36,41,43,44,
1 7,24,27,
1 21,31,33,41,
1 46
1 50
2 12,31,36,48,
2 17,29,47,
2 2,18,20,29,38,39,40,41
2 17,29,47,


And I can't get the read.transactions to read it properly.



The data set is based on several item selection for each day (more than one time per day, if necessary). For instance, the third selection on day 1, returned items 16,28,32, and 45.



Shouldn't this be enough?



library(arules)
dataset <- read.transactions("file.csv", format = 'basket')









share|improve this question
















I have a .csv file with the following type of data:



Day Item
1 12,19,24,31,48,
1 1,19,
1 16,28,32,45,
1 19,36,41,43,44,
1 7,24,27,
1 21,31,33,41,
1 46
1 50
2 12,31,36,48,
2 17,29,47,
2 2,18,20,29,38,39,40,41
2 17,29,47,


And I can't get the read.transactions to read it properly.



The data set is based on several item selection for each day (more than one time per day, if necessary). For instance, the third selection on day 1, returned items 16,28,32, and 45.



Shouldn't this be enough?



library(arules)
dataset <- read.transactions("file.csv", format = 'basket')






r arules






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 30 '18 at 20:47







Paulos

















asked Dec 30 '18 at 20:34









PaulosPaulos

235




235













  • I think you need to specify the sep

    – akrun
    Dec 30 '18 at 20:38











  • What happens when you try the code? An error? What error?

    – IceCreamToucan
    Dec 30 '18 at 20:38











  • @akrun, thanks for your comment. However, I already tried to specify sep="," or even revome the commas from the CSV but the dataset analysis isn't done properly

    – Paulos
    Dec 30 '18 at 20:39






  • 1





    You have a quote missing in basket. If i do read.transactions("file.csv", format = 'basket', sep=",")# transactions in sparse format with 13 transactions (rows) and 32 items (columns)

    – akrun
    Dec 30 '18 at 20:40













  • @IceCreamToucan the dataset isn't analyzed properly. For instance, it is saying that all rows have only 2 elements (it must be using only the first two numbers). Instead, it should be detecting the first as a class and the following (separeted by commas), as the elements.

    – Paulos
    Dec 30 '18 at 20:41



















  • I think you need to specify the sep

    – akrun
    Dec 30 '18 at 20:38











  • What happens when you try the code? An error? What error?

    – IceCreamToucan
    Dec 30 '18 at 20:38











  • @akrun, thanks for your comment. However, I already tried to specify sep="," or even revome the commas from the CSV but the dataset analysis isn't done properly

    – Paulos
    Dec 30 '18 at 20:39






  • 1





    You have a quote missing in basket. If i do read.transactions("file.csv", format = 'basket', sep=",")# transactions in sparse format with 13 transactions (rows) and 32 items (columns)

    – akrun
    Dec 30 '18 at 20:40













  • @IceCreamToucan the dataset isn't analyzed properly. For instance, it is saying that all rows have only 2 elements (it must be using only the first two numbers). Instead, it should be detecting the first as a class and the following (separeted by commas), as the elements.

    – Paulos
    Dec 30 '18 at 20:41

















I think you need to specify the sep

– akrun
Dec 30 '18 at 20:38





I think you need to specify the sep

– akrun
Dec 30 '18 at 20:38













What happens when you try the code? An error? What error?

– IceCreamToucan
Dec 30 '18 at 20:38





What happens when you try the code? An error? What error?

– IceCreamToucan
Dec 30 '18 at 20:38













@akrun, thanks for your comment. However, I already tried to specify sep="," or even revome the commas from the CSV but the dataset analysis isn't done properly

– Paulos
Dec 30 '18 at 20:39





@akrun, thanks for your comment. However, I already tried to specify sep="," or even revome the commas from the CSV but the dataset analysis isn't done properly

– Paulos
Dec 30 '18 at 20:39




1




1





You have a quote missing in basket. If i do read.transactions("file.csv", format = 'basket', sep=",")# transactions in sparse format with 13 transactions (rows) and 32 items (columns)

– akrun
Dec 30 '18 at 20:40







You have a quote missing in basket. If i do read.transactions("file.csv", format = 'basket', sep=",")# transactions in sparse format with 13 transactions (rows) and 32 items (columns)

– akrun
Dec 30 '18 at 20:40















@IceCreamToucan the dataset isn't analyzed properly. For instance, it is saying that all rows have only 2 elements (it must be using only the first two numbers). Instead, it should be detecting the first as a class and the following (separeted by commas), as the elements.

– Paulos
Dec 30 '18 at 20:41





@IceCreamToucan the dataset isn't analyzed properly. For instance, it is saying that all rows have only 2 elements (it must be using only the first two numbers). Instead, it should be detecting the first as a class and the following (separeted by commas), as the elements.

– Paulos
Dec 30 '18 at 20:41












1 Answer
1






active

oldest

votes


















0














I have tried to create a sample data using data provided by you



data <- read.table(text="Day Item
1 12,19,24,31,48,
1 1,19,
1 16,28,32,45,
1 19,36,41,43,44,
1 7,24,27,
1 21,31,33,41,
1 46
1 50
2 12,31,36,48,
2 17,29,47,
2 2,18,20,29,38,39,40,41
2 17,29,47",header = T)

data <- as(data[-1], "transactions") ##removing 1st header column for the transactional data

inspect(data)

## apply apriori algorithm ###

rules <- apriori(data, parameter = list(supp = 0.001, conf = 0.80))


### Arrange top 10 rules by lift ####

inspect(rules[1:10])


Please try this method hope it helps






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%2f53981209%2fr-package-arules-read-transactions-file-format%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









    0














    I have tried to create a sample data using data provided by you



    data <- read.table(text="Day Item
    1 12,19,24,31,48,
    1 1,19,
    1 16,28,32,45,
    1 19,36,41,43,44,
    1 7,24,27,
    1 21,31,33,41,
    1 46
    1 50
    2 12,31,36,48,
    2 17,29,47,
    2 2,18,20,29,38,39,40,41
    2 17,29,47",header = T)

    data <- as(data[-1], "transactions") ##removing 1st header column for the transactional data

    inspect(data)

    ## apply apriori algorithm ###

    rules <- apriori(data, parameter = list(supp = 0.001, conf = 0.80))


    ### Arrange top 10 rules by lift ####

    inspect(rules[1:10])


    Please try this method hope it helps






    share|improve this answer




























      0














      I have tried to create a sample data using data provided by you



      data <- read.table(text="Day Item
      1 12,19,24,31,48,
      1 1,19,
      1 16,28,32,45,
      1 19,36,41,43,44,
      1 7,24,27,
      1 21,31,33,41,
      1 46
      1 50
      2 12,31,36,48,
      2 17,29,47,
      2 2,18,20,29,38,39,40,41
      2 17,29,47",header = T)

      data <- as(data[-1], "transactions") ##removing 1st header column for the transactional data

      inspect(data)

      ## apply apriori algorithm ###

      rules <- apriori(data, parameter = list(supp = 0.001, conf = 0.80))


      ### Arrange top 10 rules by lift ####

      inspect(rules[1:10])


      Please try this method hope it helps






      share|improve this answer


























        0












        0








        0







        I have tried to create a sample data using data provided by you



        data <- read.table(text="Day Item
        1 12,19,24,31,48,
        1 1,19,
        1 16,28,32,45,
        1 19,36,41,43,44,
        1 7,24,27,
        1 21,31,33,41,
        1 46
        1 50
        2 12,31,36,48,
        2 17,29,47,
        2 2,18,20,29,38,39,40,41
        2 17,29,47",header = T)

        data <- as(data[-1], "transactions") ##removing 1st header column for the transactional data

        inspect(data)

        ## apply apriori algorithm ###

        rules <- apriori(data, parameter = list(supp = 0.001, conf = 0.80))


        ### Arrange top 10 rules by lift ####

        inspect(rules[1:10])


        Please try this method hope it helps






        share|improve this answer













        I have tried to create a sample data using data provided by you



        data <- read.table(text="Day Item
        1 12,19,24,31,48,
        1 1,19,
        1 16,28,32,45,
        1 19,36,41,43,44,
        1 7,24,27,
        1 21,31,33,41,
        1 46
        1 50
        2 12,31,36,48,
        2 17,29,47,
        2 2,18,20,29,38,39,40,41
        2 17,29,47",header = T)

        data <- as(data[-1], "transactions") ##removing 1st header column for the transactional data

        inspect(data)

        ## apply apriori algorithm ###

        rules <- apriori(data, parameter = list(supp = 0.001, conf = 0.80))


        ### Arrange top 10 rules by lift ####

        inspect(rules[1:10])


        Please try this method hope it helps







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 31 '18 at 4:18









        HunaidkhanHunaidkhan

        821114




        821114






























            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%2f53981209%2fr-package-arules-read-transactions-file-format%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







            2M ThxektB 22nUl72bTL
            YGSsEPJ16dx6eeSBUAyH,XJiHyRKzGmkmSwSg iJv58oMzDJnAn6i5aJGnaOVD hBEJOsakS7xWd

            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas