Kirsten M Barrett
2008-Oct-31 19:17 UTC
[R] replace() error: new columns would leave holes after existing columns
Hello, I have a problem with using replace() to convert a vector of dates from yyyy-mm-dd to julian date. For example, I type replace(x,2004-05-14,134) and I receive an error: Error in `[<-.data.frame`(`*tmp*`, list, value = 134) : new columns would leave holes after existing columns If I can successfully convert, I have a script that will convert all of the dates in the vector (i.e., the same line repeated with the next yyyy-mm-dd and corresponding julian day). Any help would be much appreciated. Thank you, Kirsten Kirsten Barrett Mendenhall Postdoctoral Fellow, USGS Alaska Science Center 4210 University Drive Anchorage, AK [[alternative HTML version deleted]]
Kellie Wills
2008-Oct-31 23:39 UTC
[R] replace() error: new columns would leave holes after existing columns
Hi Kirsten, The second argument of replace() is actually an index, so it's trying to replace element number 2004-5-14 = 1985 with 134! See ?replace. I would need more of your code to understand your error exactly. I think you would be better off converting your dates to date format (?Date) and then using the julian() function to convert them to Julian. -- Kellie Wills Engineering Service Manager REvolution Computing On Fri, Oct 31, 2008 at 12:17 PM, Kirsten M Barrett <kbarrett@usgs.gov>wrote:> Hello, I have a problem with using replace() to convert a vector of dates > from yyyy-mm-dd to julian date. > > For example, I type > > replace(x,2004-05-14,134) > > and I receive an error: > > Error in `[<-.data.frame`(`*tmp*`, list, value = 134) : > new columns would leave holes after existing columns > > If I can successfully convert, I have a script that will convert all of > the dates in the vector (i.e., the same line repeated with the next > yyyy-mm-dd and corresponding julian day). Any help would be much > appreciated. > > Thank you, > Kirsten > > Kirsten Barrett > Mendenhall Postdoctoral Fellow, USGS > Alaska Science Center > 4210 University Drive > Anchorage, AK > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]