apply a function of package moonsun in R -


I am trying to apply a function in all 334 rows of data frame M, which contains time and location data And gets one value for each line Instead, I get a list of 334 values ​​for each row. How can I get one value per line from the calculations of variables in the same line?

These heads and data are frame ties M:

  d Mo y long long 5 6 2007 no NA 6 6 2007 no 7 7 7 2007 no 8 6 2007 26.8 9 15.53 9 6 2007 28.00 15.73 10 6 2007 22.41 14.93 ... 26 4 2008 23.86 14.05 27 2008 2008 24.12 14.34 28 2008 2008 27.75 12.87 29 2008 2008 27.28 10.91 30 2008 2008 24.17 14.44 1 5 2008 NA   

My code:

  f1 = function (x) {option (latitude = m $ latitude, longitude = m $ long); As.lt (moon.rst (jday = jd (M $ y, M $ mo, M $ d))) M $ rs & lt; Apply <- (M, 1, F1)   <(D, MO, Y, LAT, Long) {Option (latitude = latitude, latitude = latitude), 
< Div class = "post-text" itemprop = "text">
  f1 & lt; Longitude = long) as.lt (moon.rst (jday = jd (y, mo, d)) data $ rs & lt; - do.call (f1, data) warning message: if (year   

Function is a warning from jd () because Have Vectors (in this case, year ) are passing as an argument, but in spite of this, I hope you want the result.

Edit: Apply < Using / code>, another version without any warning, but using the index and it seemed to me that do.call is fast. < Pre> f1 & lt; -function (m) {option (latitude = m [4], longitude = m [5]); (As in.lt (d., 'D', 'mo', 'y') (as in.lt (mo., Rst (jday = jd (m [3], m [2], m [1])) , 'Late', 'long']], 1, f1) [1]] growth transit set 2005-06-08 6 d2 meter 30 to 13 c8m 3 to 20b12m 51s [2]] increase Transit set 2005-06-09 6 d 55 m 34 s 14 h 1 m 26 s 21 h 4 m 44 s [3]] growth transit set 2005-06-10 8 h 7 m 41 s 14 h 57 m 7 s 21 H 43 M 36S

Comments