3 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
source | link

I am trying to make my own package based on the code from this QuestionQuestion. The following is the code from that page:

BeginPackage["SelectData`"];
select::usage = "select[data,where,condition]";
Begin["`Private`"]

    ClearAll[select, where];
    SetAttributes[where, HoldAll];
    select[table : {colNames_List, rows__List}, w : (where[condition_] | None) : None,
         cols : (columns[varNames__] | All) : All] :=
      With[{namingRules = Dispatch[Thread[colNames -> Thread[Slot[Range[Length[colNames]]]]]]}, 
        With[{cl = {varNames} /. namingRules /. Verbatim[Slot][n_] :> n},
          If[cols === All, #, #[[All, cl]]] &@
            If[w === None,
               {rows},
               (* else *)
               With[{selF = Apply[Function, Hold[condition] /. namingRules]},
                  Select[{rows}, selF @@ # &]
               ]
            ]
        ]
      ]; 

End[]
EndPackage[]

Then, on my notebook, use the following data as input:

table = List[{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 
   0}, {"Beta", 1, 1}, {"Alpha", 0, 0}]

Call the package, Needs["SelectData`"]

Evaluating, select[table, columns["Variable 1"]]

the output is as follows:

select[{{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 0}, {"Beta", 
   1, 1}, {"Alpha", 0, 0}}, columns["Variable 1"]]

I think I have done something wrong when creating my package, but I can't find it. Could anyone give me suggestions?

I am trying to make my own package based on the code from this Question. The following is the code from that page:

BeginPackage["SelectData`"];
select::usage = "select[data,where,condition]";
Begin["`Private`"]

    ClearAll[select, where];
    SetAttributes[where, HoldAll];
    select[table : {colNames_List, rows__List}, w : (where[condition_] | None) : None,
         cols : (columns[varNames__] | All) : All] :=
      With[{namingRules = Dispatch[Thread[colNames -> Thread[Slot[Range[Length[colNames]]]]]]}, 
        With[{cl = {varNames} /. namingRules /. Verbatim[Slot][n_] :> n},
          If[cols === All, #, #[[All, cl]]] &@
            If[w === None,
               {rows},
               (* else *)
               With[{selF = Apply[Function, Hold[condition] /. namingRules]},
                  Select[{rows}, selF @@ # &]
               ]
            ]
        ]
      ]; 

End[]
EndPackage[]

Then, on my notebook, use the following data as input:

table = List[{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 
   0}, {"Beta", 1, 1}, {"Alpha", 0, 0}]

Call the package, Needs["SelectData`"]

Evaluating, select[table, columns["Variable 1"]]

the output is as follows:

select[{{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 0}, {"Beta", 
   1, 1}, {"Alpha", 0, 0}}, columns["Variable 1"]]

I think I have done something wrong when creating my package, but I can't find it. Could anyone give me suggestions?

I am trying to make my own package based on the code from this Question. The following is the code from that page:

BeginPackage["SelectData`"];
select::usage = "select[data,where,condition]";
Begin["`Private`"]

    ClearAll[select, where];
    SetAttributes[where, HoldAll];
    select[table : {colNames_List, rows__List}, w : (where[condition_] | None) : None,
         cols : (columns[varNames__] | All) : All] :=
      With[{namingRules = Dispatch[Thread[colNames -> Thread[Slot[Range[Length[colNames]]]]]]}, 
        With[{cl = {varNames} /. namingRules /. Verbatim[Slot][n_] :> n},
          If[cols === All, #, #[[All, cl]]] &@
            If[w === None,
               {rows},
               (* else *)
               With[{selF = Apply[Function, Hold[condition] /. namingRules]},
                  Select[{rows}, selF @@ # &]
               ]
            ]
        ]
      ]; 

End[]
EndPackage[]

Then, on my notebook, use the following data as input:

table = List[{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 
   0}, {"Beta", 1, 1}, {"Alpha", 0, 0}]

Call the package, Needs["SelectData`"]

Evaluating, select[table, columns["Variable 1"]]

the output is as follows:

select[{{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 0}, {"Beta", 
   1, 1}, {"Alpha", 0, 0}}, columns["Variable 1"]]

I think I have done something wrong when creating my package, but I can't find it. Could anyone give me suggestions?

    Tweeted twitter.com/#!/StackMma/status/433640558956150785
2 deleted 2 characters in body
source | link

I am trying to make my own package based on the code from this Question. The following is the code from that page:

BeginPackage["SelectData`"];
select::usage = "select[data,where,condition]";
Begin["`Private`"]

    ClearAll[select, where];
    SetAttributes[where, HoldAll];
    select[table : {colNames_List, rows__List}, w : (where[condition_] | None) : None,
         cols : (columns[varNames__] | All) : All] :=
      With[{namingRules = Dispatch[Thread[colNames -> Thread[Slot[Range[Length[colNames]]]]]]}, 
        With[{cl = {varNames} /. namingRules /. Verbatim[Slot][n_] :> n},
          If[cols === All, #, #[[All, cl]]] &@
            If[w === None,
               {rows},
               (* else *)
               With[{selF = Apply[Function, Hold[condition] /. namingRules]},
                  Select[{rows}, selF @@ # &]
               ]
            ]
        ]
      ]; 

End[]
EndPackage[]

Then, on my notebook, use the following data as input:

table = List[{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 
   0}, {"Beta", 1, 1}, {"Alpha", 0, 0}]

Call the package, Needs["SelectData"]`Needs["SelectData`"]

Evaluating, select[table, columns["Variable 1"]]

the output is as follows:

select[{{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 0}, {"Beta", 
   1, 1}, {"Alpha", 0, 0}}, columns["Variable 1"]]

I think I have done something wrong when creating my package, but I can't find it. Could anyone give me suggestions?

I am trying to make my own package based on the code from this Question. The following is the code from that page:

BeginPackage["SelectData`"];
select::usage = "select[data,where,condition]";
Begin["`Private`"]

    ClearAll[select, where];
    SetAttributes[where, HoldAll];
    select[table : {colNames_List, rows__List}, w : (where[condition_] | None) : None,
         cols : (columns[varNames__] | All) : All] :=
      With[{namingRules = Dispatch[Thread[colNames -> Thread[Slot[Range[Length[colNames]]]]]]}, 
        With[{cl = {varNames} /. namingRules /. Verbatim[Slot][n_] :> n},
          If[cols === All, #, #[[All, cl]]] &@
            If[w === None,
               {rows},
               (* else *)
               With[{selF = Apply[Function, Hold[condition] /. namingRules]},
                  Select[{rows}, selF @@ # &]
               ]
            ]
        ]
      ]; 

End[]
EndPackage[]

Then, on my notebook, use the following data as input:

table = List[{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 
   0}, {"Beta", 1, 1}, {"Alpha", 0, 0}]

Call the package, Needs["SelectData"]`

Evaluating, select[table, columns["Variable 1"]]

the output is as follows:

select[{{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 0}, {"Beta", 
   1, 1}, {"Alpha", 0, 0}}, columns["Variable 1"]]

I think I have done something wrong when creating my package, but I can't find it. Could anyone give me suggestions?

I am trying to make my own package based on the code from this Question. The following is the code from that page:

BeginPackage["SelectData`"];
select::usage = "select[data,where,condition]";
Begin["`Private`"]

    ClearAll[select, where];
    SetAttributes[where, HoldAll];
    select[table : {colNames_List, rows__List}, w : (where[condition_] | None) : None,
         cols : (columns[varNames__] | All) : All] :=
      With[{namingRules = Dispatch[Thread[colNames -> Thread[Slot[Range[Length[colNames]]]]]]}, 
        With[{cl = {varNames} /. namingRules /. Verbatim[Slot][n_] :> n},
          If[cols === All, #, #[[All, cl]]] &@
            If[w === None,
               {rows},
               (* else *)
               With[{selF = Apply[Function, Hold[condition] /. namingRules]},
                  Select[{rows}, selF @@ # &]
               ]
            ]
        ]
      ]; 

End[]
EndPackage[]

Then, on my notebook, use the following data as input:

table = List[{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 
   0}, {"Beta", 1, 1}, {"Alpha", 0, 0}]

Call the package, Needs["SelectData`"]

Evaluating, select[table, columns["Variable 1"]]

the output is as follows:

select[{{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 0}, {"Beta", 
   1, 1}, {"Alpha", 0, 0}}, columns["Variable 1"]]

I think I have done something wrong when creating my package, but I can't find it. Could anyone give me suggestions?

1
source | link

Error When Creating Package

I am trying to make my own package based on the code from this Question. The following is the code from that page:

BeginPackage["SelectData`"];
select::usage = "select[data,where,condition]";
Begin["`Private`"]

    ClearAll[select, where];
    SetAttributes[where, HoldAll];
    select[table : {colNames_List, rows__List}, w : (where[condition_] | None) : None,
         cols : (columns[varNames__] | All) : All] :=
      With[{namingRules = Dispatch[Thread[colNames -> Thread[Slot[Range[Length[colNames]]]]]]}, 
        With[{cl = {varNames} /. namingRules /. Verbatim[Slot][n_] :> n},
          If[cols === All, #, #[[All, cl]]] &@
            If[w === None,
               {rows},
               (* else *)
               With[{selF = Apply[Function, Hold[condition] /. namingRules]},
                  Select[{rows}, selF @@ # &]
               ]
            ]
        ]
      ]; 

End[]
EndPackage[]

Then, on my notebook, use the following data as input:

table = List[{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 
   0}, {"Beta", 1, 1}, {"Alpha", 0, 0}]

Call the package, Needs["SelectData"]`

Evaluating, select[table, columns["Variable 1"]]

the output is as follows:

select[{{"ID", "Variable 1", "Variable 2"}, {"Alpha", 1, 0}, {"Beta", 
   1, 1}, {"Alpha", 0, 0}}, columns["Variable 1"]]

I think I have done something wrong when creating my package, but I can't find it. Could anyone give me suggestions?