3

I'm trying to clean a dataset of unnecessary variables but I constantly get an error when doing so.

Following an example where:

rawDataDiamonds = «dataSetDiamonds»;
dataDiamondsTemp = Delete[Transpose[rawDataDiamonds][[All,1]][[All,{1,2}]],1]

gives an output where only Price and Weight is shown, I tried to apply this for:

dataBundesliga = {{
  "Football Club", "Marketvalue_2011", "Marketvalue_2012", 
   "Final Placement_2011", "Points_2011", "Mid_Season_Points_2011", 
   "Mid_Season_Points_2012"}, {
  "FC Bayern München", 333000000, 415950000, 2, 73, 37, 42}, {
  "Borussia Dortmund", 158000000, 229250000, 1, 81, 34, 30}, {
  "FC Schalke 04", 130000000, 163250000, 3, 64, 34, 25}, {
  "Bayer 04 Leverkusen", 138000000, 163900000, 5, 54, 26, 33}, {
  "VfL Wolfsburg", 110000000, 132200000, 8, 44, 20, 19}, {
  "Hamburger SV", 100000000, 104300000, 15, 36, 19, 24}, {
  "VfB Stuttgart", 94000000, 91900000, 6, 53, 22, 25}, {
  "Borussia Mönchengladbach", 67000000, 88350000, 4, 60, 33, 25}, {
  "SV Werder Bremen", 113000000, 82150000, 9, 42, 29, 22}, {
  "TSG 1899 Hoffenheim", 90000000, 77650000, 11, 41, 22, 12}, {
  "Hannover 96", 65000000, 78650000, 7, 48, 23, 23}, {
  "SC Freiburg", 55000000, 46650000, 12, 40, 13, 26}, {
  "1.FSV Mainz 05", 50000000, 46000000, 13, 39, 18, 26}, {
  "Eintracht Frankfurt", 46000000, 49400000, 999, 0, 0, 30}, {
  "1.FC Nürnberg", 41000000, 41500000, 10, 42, 18, 20}, {
  "FC Augsburg", 29000000, 39250000, 14, 38, 15, 9}, {
  "SpVgg Greuther Fürth", 21000000, 30100000, 999, 0, 0, 9}, {
  "Fortuna Düsseldorf", 22000000, 26850000, 999, 0, 0, 21}, {
  "1.FC Köln", 59750000, 22950000, 17, 30, 21, 0}, {
  "1.FC Kaiserslautern", 41900000, 26725000, 18, 23, 16, 0}, {
  "Hertha Berlin", 45000000, 34850000, 16, 31, 20, 0}}

dataBundesligaTemp = 
 Delete[Transpose[dataBundesliga][[All, 1]][[All, {2, 5}]], 1]

But when doing so, I get the error

Part::partd: Part specification {Football Club,Marketvalue_2011,Marketvalue_2012,Final Placement_2011,Points_2011,Mid_Season_Points_2011,Mid_Season_Points_2012}[[All,{2,5}]] is longer than depth of object. >> Part::partd: Part specification All[[{2,5}]] is longer than depth of object. >>

Can someone help me please to understand what I'm doing wrong?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Malganas
  • 133
  • 1
  • 4
  • Please explain what you want to achieve in words. Which columns do you want to delete? – C. E. Nov 09 '13 at 14:55
  • Hello, I want to only have the values for Marketvalue_2011 (hence 2) and Points_2011 (hence 5). This should ultimately enable me to do a regression model based on these two values. – Malganas Nov 09 '13 at 15:21
  • 1
    Like dataBundesliga[[All, {2, 5}]]? – ssch Nov 09 '13 at 15:33
  • For some reason writing just dataBundesliga[[All, {2, 5}]] gave me the output I wanted, but I couldnt plot this without the step bellow. – Malganas Nov 09 '13 at 17:33

1 Answers1

5

It's simpler than you think. Try this:

twoCols = dataBundesliga[[All, {2, 5}]]
{{"Marketvalue_2011", "Points_2011"}, 
 {333000000, 73}, 
 {158000000, 81}, 
 {130000000, 64}, 
 {138000000, 54}, 
 {110000000, 44}, 
 {100000000, 36}, 
 {94000000, 53}, 
 {67000000, 60}, 
 {113000000, 42}, 
 {90000000, 41}, 
 {65000000, 48}, 
 {55000000, 40}, 
 {50000000, 39}, 
 {46000000, 0}, 
 {41000000, 42}, 
 {29000000, 38}, 
 {21000000, 0}, 
 {22000000, 0}, 
 {59750000, 30}, 
 {41900000, 23}, 
 {45000000, 31}}

Then, if you want to transpose this into rows:

Transpose[twoCols]
{{"Marketvalue_2011", 333000000, 158000000, 130000000, 138000000, 
  110000000, 100000000, 94000000, 67000000, 113000000, 90000000, 
  65000000, 55000000, 50000000, 46000000, 41000000, 29000000, 21000000, 
  22000000, 59750000, 41900000, 45000000}, 
 {"Points_2011", 73, 81, 64, 54, 44, 36, 53, 60, 42, 41, 48, 40, 39, 0, 
  42, 38, 0, 0,30, 23, 31}}
m_goldberg
  • 107,779
  • 16
  • 103
  • 257