Make a Table of Contents
Average and Standard Deviation for a Table or Spreadsheet
Module to find the average and std deviation of a list of values. The list above (yvalues) is essentially a table or spreadsheet - here we will find the average and std deviation for each column of data:
There is an easier way to do this : Here we sum a column
Here we sum a row:
Create a Table with Column and Row Headings
| Grade | Number | Per Cent |
| A | 25 | 14.0 |
| A- | 10 | 5.6 |
| B+ | 14 | 7.8 |
| B | 10 | 5.6 |
| B- | 13 | 7.3 |
| C+ | 12 | 6.7 |
| C | 3 | 1.7 |
| C- | 6 | 3.4 |
| D+ | 10 | 5.6 |
| D | 8 | 4.5 |
| F | 68 | 38.0 |
Create a Graph with Text for the data points
This applies different sized labels to the plot
Emulate the VLOOKUP Function from Spreadsheets
How do you sum a specific column in a table, with filter critera? Here, we find all the unique values in the first column, and sum the desired column (basically a VLOOKUP in Excel.
a = {{a1, b1}, {a2, b2}, {a2, b3}, {a2, b4}, {a3, b5}, {a3, b6}};
You can use : els = Union@Part[Transpose@a, 1]
sel[x_] := Select[a, (#[[1]] == x) &];
Map[sel[#] &, els]
Map[{#[[1, 1]], Total@Transpose[#][[2]]} &, %]
Explanation : The first line finds the different first elements (e.g.{a1, a2, a3})
The function sel[x_] selects the rows of a which have x as their first
element.Then the first Map applies this function for the different first
elements : {a1, a2, a3}
Then the second Map constructs your final matrix with the different
elements in the first column and the sum in the second column.
Calculate Number of Days between Dates
Miscellaneous Functions
Import Tab - separated Data into a Formatted Grid
Sort an Array of Arrays by Column (position)
Graphs
Create a Histogram
Another way :
Sum a Specific Column, Conditionally
Playing with Text as DataPoints, Varying Size
Tooltips and Rollovers
Select a subset of rows from a list based upon a list of criteria chosen by the user.
I'm working on a small application and I'm searching for a way to
Select a subset of rows from a list based upon a list of criteria
chosen by the user. Here is small (hypothetical) example. Say one
has a data set of consisting of a list of as follows:
{ {1,A,Blue,"Hello",10.5},{7,D,Green,"Goodbye",9.4},
{6,S,Yellow,"Hello",6.9},{3,A,Blue,"Hello",8.0}}
The user will specify a letter and a color and the program should
Select[ ] the appropriate rows, e.g., if I pick Color=Blue and Letter
= A, then it will return
{ {1,A,Blue,"Hello",10.5},{3,A,Blue,"Hello",8.0}....}, etc. Thus one
can enter Select[myData,(#[[2]]==A && #[[3]]==Blue)&] and get the
appropriate records.Note that The actual data set has about 20,000
records (lists), each with about 20 fields, and can select 7 or 8
different attributes, so the Select statements get fairly long.
My question involves an efficient way to code the Select statement if
a user wants to chose records that correspond to any value of a
particular field, e.g., All of the Color=Blue, regardless of the
Letter choice,e.g.,
Select[myData,(#[[3]]==Blue)&]
More precisely, is there a way to pass Select the user choice of any
letter using some sort of 'wildcard' value that represents any value
for the specific attribute, i.e.,
Select[myData,(#[[2]]=='Wildcard' && #[[3]]==Blue)&]
My motivation is that if I have may possible selection criteria, I
can still use a single Select statement. Hi, try MatchQ[#[[3]], Blue] if you wist to select Blue
and MatchQ[#[[3]], _] as the wildcard.And
to make it more easy
try MatchQ[#[[3]],Blue] if you wist to select Blue
and MatchQ[#[[3]],_] as the wildcard. And
to make it more easy
mypattern={_,_,_,_,_};
...
If[characterSelectedQ,mypattern[[2]]=selectedCharacter];
If[colorSelectedQ,mypattern[[3]]=selectedColor];
...
Select[lst,MatchQ[#,mypattern] &]
This works
What to do with missing values in a list
Select Rows based on Criteria - Method 1
Select Rows based on Criteria - Method 2
End
| Created by Wolfram Mathematica 6.0 (02 June 2008) |