0

I have two data tables as .dbf files that I want to extract values from by row and populate an empty data frame with the new values using the following equation; (tmax_08 - tmin_08)/2 - 65. This will result in values both positive and negative in which I want to separate those and square each value and take the sum of squares at the end. Below is what I have so far.

Install.packages("foreign")

library(foreign)

tmax_08<- read.dbf("E:/Adam Stuff/Daymet_Daily_UTM/1km table/tmax/tmax_2008_daymet.dbf")
tmin_08 <- read.dbf("E:/Adam Stuff/Daymet_Daily_UTM/1km table/tmin/tmin_2008_daymet.dbf")

my.df <- data.frame(matrix(0, ncol = 366, nrow = 24024))

row <- tmax_08[1,]
row2 <- tmin_08[1,]

I have as you can see been able to extract the first row and all columns from each .dbf table, however automating this would be much better as I have a lot of files this needs to be done for. Thank you in advance for any help provided!

AdamG
  • 1
  • What do you mean by automating it? Do you need to do this for multiple pairs of files like (tmax_08, tmin_08)? – Vishesh Shrivastav Jun 14 '18 at 19:46
  • Are your `tmax_08` and `tmin_08` numeric data frames with the same dimensions? If they are, you don't need to construct any kind of loop. You can just create your new data frame with your equation: `new_df <- (tmax_08 - tmin_08)/2 - 65`. In general, we'll be able to do a better job at helping you if you write your problem in a way that is reproducible. See https://stackoverflow.com/help/mcve and https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – De Novo Jun 14 '18 at 19:54
  • Yes they are numeric data frames with the same dimensions; for example tmax might read 10 20 15 32 35... and tmin would read -23 -15 -4 3 -10.... with dimensions of 24024 rows and 366 columns. yes I will keep that in mind for and additional posts, I didn't think about making it reproducible. – AdamG Jun 14 '18 at 20:02
  • @VisheshShrivastav Yes I need this for 48 files – AdamG Jun 14 '18 at 20:03

0 Answers0