-1

I am doing a project about wind turbines where I test whether it is possible to heat a house only with energi from the wind turbine. So I made this R code. The code can predict the inside temperature. I have dataset in Excel that contains the outside temperature and windspeed every hour in january 2009.

R <- 5 This is the isolation of the wall

C <- 4 This is heat capacity of the wall

Ta <- rep(3,24) constant outside temperature in 24 hour 

Ph <- rep(2,24) constant effect of the wind turbine in kW in 24 hour

Ti0 <- 20 This is the beginning temperature in the house 

a <- -1/(R*C)

for(k in 2:24) {
  Ti[k] <- Ta[k] + exp(a) * (Ti[k-1] - Ta[k]) + R * (1-exp(a)) * Ph[k]
}

My question is. How can I load my Excel dataset into R so R can predict the inside temperatur with changing temperature in 24 hour and changing effect in 24 hour, instead of holding these constant

talat
  • 68,970
  • 21
  • 126
  • 157
Alim Teacher
  • 111
  • 1

1 Answers1

1

Use this to load Excel data:

data = read.xls("excelfile.xls")

This will get the data from the first worksheet in your Excel file and save it in a dataset. (Just make sure the file is in the working directory).

Just in case this doesn't work, try loading the gdata package before importing from the Excel file:

library(gdata)
kRiZ
  • 2,320
  • 4
  • 28
  • 39
  • In the console or in the editor – Alim Teacher Dec 28 '14 at 23:31
  • Should work either way. You could start by testing in the console. Just read in the file and print it to see what you got. – kRiZ Dec 28 '14 at 23:33
  • if you have `.*xlsx` files `library(openxlsx); read.xlsx("file.xlsx")` is another easy way. http://cran.r-project.org/web/packages/openxlsx/ – ckluss Dec 29 '14 at 14:37