title: How do I predict new rows from a data frame?
body: <p>This is open data. Please have a look at both the data and my code and try to tell me what I am doing wrong. Here is the data- <a href="https://drive.google.com/open?id=0BzGPJ4-xoC1oUURaQXVrSFVJUkk" rel="nofollow">https://drive.google.com/open?id=0BzGPJ4-xoC1oUURaQXVrSFVJUkk</a></p>
  
  <p>I'm just trying to predict the next 10 or so rows from that data but I keep getting errors.</p>
  
  <p>Here is my code so far-</p>
  
  <pre><code>df=read.csv(file="sampledata.csv", header=FALSE, row.names=NULL)
  
  df &lt;- df[-c(21),]
  
  start &lt;- length(df) *.2
  
  train = df[,start:length(df)]
  test = df[,1:start]
  #df &lt;- data.frame(t(df))
  
  train &lt;- data.frame(t(train))
  test &lt;- data.frame(t(test))
  
  #library(rpart)
  #fit &lt;- rpart(X1 ~ ., method='anova', data=df)
  
  #View(df)
  
  #predict(fit, type="prob")
  
  #df$Prediction &lt;- predict(lm(X1~., data=df))
  
  fit &lt;- lm(V1~., data=data.frame(t(train)))
  #test &lt;- data.frame(t(test))
  
  #predictions &lt;- data.frame(matrix(nrow=length(test), ncol=20))
  #predictions &lt;- as.matrix(predictions)
  #predictions &lt;- as.integer(predictions)
  #dim(predictions) &lt;- c(length(test), 20)
  #test &lt;- data.frame(t(test))
  #predictions &lt;- data.frame(predictions)
  
  predict(fit, newdata=test)
  </code></pre>
  
  <p>I think that the problem may be in the <code>fit &lt;- lm</code> part. I don't know how to fit the lm with a row. It only seems to work with columns.</p>
  
  <p>Please show me how to make use of pattern recognition or something sophisticated enough to be dynamic and not just to have it print out something like the following (these are statistically the most likely numbers given <code>df</code>)-</p>
  
  <pre><code>[1] 24.849651%
  [5] 11.065672%
  [9] 8.293240%
  [15] 6.753669%
  [17] 6.621362%
  [23] 5.995911%
  [26] 5.845562%
  [30] 5.424585%
  [36] 5.298292%
  [39] 5.460669%
  [44] 5.376473%
  [48] 5.502766%
  [51] 5.635073%
  [56] 5.629059%
  [59] 6.038008%
  [64] 6.735627%
  [68] 7.258841%
  [72] 8.197017% 
  [76] 11.179937% 
  [80] 25.174405%
  </code></pre>
  
  <p>Note that what it prints out won't look like the above. I structured that data manually. I need 3 to 10 rows of 20 predicted values that aren't the same and I need to see the probabilities for the numbers predicted as well.</p>
  
  <p>Good luck and thank you!</p>