Error In As Date Origin Must Be Supplied
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or
Error In As Date Numeric Value Origin Must Be Supplied
posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss origin must be supplied r Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes
As Posixct Origin Must Be Supplied
a minute: Sign up Strange behavior involving dates - “origin must be supplied” up vote 0 down vote favorite I have a data.table like so dt <- data.table(x=as.Date(c("2014-1-1", "2015-1-1", "2016-1-1")), y=as.Date(c(NA, "2015-6-1", NA))) dt x y 1: 2014-01-01
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and
Error In As.date.numeric(value) 'origin' Must Be Supplied Rbind
policies of this site About Us Learn more about Stack Overflow the ggplot2 error in as.date.numeric(value) : 'origin' must be supplied company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags
Excel Date Origin
Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only http://stackoverflow.com/questions/31274536/strange-behavior-involving-dates-origin-must-be-supplied takes a minute: Sign up “Origin” must be supplied issue with the function in r: possibly environment/namespace issue up vote 3 down vote favorite 1 I have a function that produces the first date of each month: firstDayNextMonth <- function(x) # # Wrapper for the function above - applies the firstDayNextMonth to the vector # { return(as.Date(sapply(x, fDNM))) } where fDNM http://stackoverflow.com/questions/22599701/origin-must-be-supplied-issue-with-the-function-in-r-possibly-environment-nam is fDNM <- function(x) # # Computes the date of the first day of the next month # { if (as.numeric(format(x,format="%m"))==12) { nextMonth = 1 Yr = as.numeric(format(x,format="%Y"))+1 }else{ nextMonth = as.numeric(format(x,format="%m"))+1 Yr = as.numeric(format(x,format="%Y")) } y = as.Date(paste(Yr, nextMonth, '01', sep='-'), format = "%Y-%m-%d") return(y) } everything works well when I apply this function to an index. However, when I include this function to a custom package I get Error in as.Date.numeric(sapply(x, fDNM)) : 'origin' must be supplied What could cause this? Thanks! r xts share|improve this question edited Mar 24 '14 at 12:13 tonytonov 12.5k123762 asked Mar 24 '14 at 1:41 user29514 1813 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted Notice that the Usage section of ?as.Date has clues if you have learned how to read that section.: ## S3 method for class 'character' as.Date(x, format = "", ...) ## S3 method for class 'numeric' as.Date(x, origin, ...) ## S3 method for class 'POSIXct' as.Date(x, tz = "UTC", ...) The 'origin' parameter for as.Date.numeric does not have a default value, w
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow http://stackoverflow.com/questions/19449307/how-to-solve-error-in-as-posixct-numericx2l-origin-must-be-supp the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of http://grokbase.com/p/r/r-help/1237sh5t1x/r-convert-numeric-20090101-to-date 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to solve: “Error in as.POSIXct.numeric(X[[2L]], …) : 'origin' must be supplied” up vote 0 down vote favorite must be we have created the following loop to plot the different parts of the data (with the package "latticeExtra"). library("latticeExtra") All_dates<-unique(fad$Meet_date) for (i in 1:11) { Date.i <- All_dates[i] layoutno <- unique(fad[fad$Meet_date == Date.i,28] ) Data.i <- fad[fad$Meet_date == Date.i, ] Data.i$newtime <- as.POSIXct(Data.i$DateTime) prop <- with(Data.i,tapply(newtime,klasse, max))-with(Data.i,tapply(newtime,klasse, min)) png(paste(Date.i, ".png", sep = ""), height = 20, width = 30, units = "cm", res = 400) dog <- xyplot(Ratio ~ Meet_times |as.factor(klasse), data must be supplied = Data.i, main = paste(Date.i), layout = c(layoutno,1), scales = list(x = list(relation = "free",format = "%H:%M")), xlab = "Time of measurement", ylab = "Ratio CH4/CO2") print(resizePanels(dog,w = prop)) dev.off() } However, we get this: Error in as.POSIXct.numeric(X[[2L]], ...) : 'origin' must be supplied.. I am a big noob with R, so I have no idea where this problem could lie.. My collegue also seems to be lost.. I know it is a big code, but I kinda hoped someone sees the problem rigthaway.. I tried several searches on this website and on Google, but this did not get me anything useful. Please, help? Thanks a lot in advance! r loops time share|improve this question asked Oct 18 '13 at 12:07 Jalalala 1171312 The error tells you exactly where the problem lies, and help("as.POSIXct.numeric") has examples of how to solve it. –Joshua Ulrich Oct 18 '13 at 12:16 1 Yeah, so I filled in a wrong column number as a reference point, that's what went wrong. We forgot that we added a column earlier in the script, so instead of using the 28th column, it needed to use the 29th.. The difference between these columns was that one is numeric and the other is POSIXlt.. Probably, that's why I got that error..
for:format(x, format = "%d-%m-%Y")[1] "01-01-2009"I don't think that was quite what was asked for. Original question was to convert something read as numeric to a date. For that, you need to first convert to a character string by throwing an as.character into the mix:as.Date(20091231, format="%Y%m%d")Error in as.Date.numeric(20091231, format = "%Y%m%d") :'origin' must be suppliedas.Date(as.character(20091231), format="%Y%m%d")[1] "2009-12-31"format(as.Date(as.character(20091231), format="%Y%m%d"),"%d-%m-%Y")[1] "31-12-2009"(For other date formats, you may have to tackle leading zeros as well.)A better idea could be to tell read.fwf to read the column as character (use colClasses).(AFAIK, with SAS you also get to jump through a few hoops to convert dates that was accidentally read as numbers. The effective way is to specify a format when reading data.)On Tue, Mar 6, 2012 at 8:40 PM, jim holtman wrote:try this:x <- as.POSIXct("20090101", format = "%Y%m%d")x[1] "2009-01-01 EST"On Tue, Mar 6, 2012 at 7:38 PM, RHelpPlease wrote:Hi there,Does it exist where R can convert a numeric date (20090101) to a "proper"date format? (Ideally dd-mm-yyyy)Original data (in this case) is in .DAT format. I read the multi-columndata with the read.fwf function, where I specified the column width for theeight digit date (example above). After the .DAT data is read-in &formatted in R, it is to be exported to Excel.I understand that with the as.Date function, 20090101 is understood as thenumber of days from the R origin date.I read that SAS has the capability to convert 20090101 to a date, so I'mhoping R does as well. Conversion to a date in Excel does not work.Help in this matter is most appreciated!--View this message in context: http://r.789695.n4.nabble.com/Convert-Numeric-20090101-to-Date-tp4451859p4451859.htmlSent from the R help mailing list archive at Nabble.com.______________________________________________R-help at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self