Tags down


Error in xts, as.POSIXct "'order.by' cannot contain 'NA', 'NaN', or 'Inf'"

By : user2174684
Date : October 17 2020, 08:10 AM
To fix the issue you can do Here are some lines of code with randomly generated data to help you. Just replace "db0" with your data imported from Excel (start from scratch and try to remove the Date column this time)
code :
db0 <- as.data.frame(matrix(rnorm(1*1000, mean=5, sd=2), ncol=1)) 
date <- seq(from=as.POSIXct("2011-03-12 0:30", format = "%Y-%m-%d %H:%M"), length.out = nrow(db0), by = "30 min") 
dbt <- xts(db0, date) 
# index(dbt) 
apply.weekly(dbt, FUN = "sum")

Share : facebook icon twitter icon

POSIXct: as.POSIXct("2008-03-30 02:00:00",format="%Y-%m-%d %H:%M:%S") fails is it a bug in R?

By : babichild
Date : March 29 2020, 07:55 AM
wish helps you This is the beginning of daylight savings time in Germany in 2008, see this link. That time effectively is equivalent to "2008-03-30 03:00:00" (an hour later), which should work on your system. So, yes, this is related to your locale.

Convert data.frame column from POSIXct to numeric produces: "Error in as.POSIXct.numeric(value) : 'origin' must be

By : Eddie
Date : March 29 2020, 07:55 AM
To fix the issue you can do Your problem is not the as.numeric call itself. The problem is that you are trying to write the result of that call to a column which is a POSIXct column. So, R tries to convert it to the correct format for you, and fails, because the conversion method requires an origin. If you write to a new column (or, better yet, write the for loop as a single vectorised operation to avoid the issue) then you shouldn't have a problem.
code :
# make up some dummy data for testing
AUC = data.frame(sys_value = 1:100, sys_time = as.POSIXct(Sys.time() + 1:100))

for(i in 1:length(AUC$sys_time)){
  AUC$sys_time[i] <- as.numeric(difftime(time1 = AUC$sys_time[1],
                                     time2 = AUC$sys_time[i], units = "hours"))
} # this doesn't work, because you're mixing data types in the sys_time column

for(i in 1:length(AUC$sys_time)){
  AUC$sys_time_diff[i] <- as.numeric(difftime(time1 = AUC$sys_time[1],
                                          time2 = AUC$sys_time[i], units = "hours"))
} # this works, because the numeric data isn't being added to a time column

pkgsearch: Error in as.POSIXct.default(date): do not know how to convert 'date' to class "POSIXct"

By : user2806709
Date : March 29 2020, 07:55 AM
this will help It could be an issue with the attributes of the dataset (str(PkgMYaseen208)). One option is to convert to data.frame and then select
code :
PkgMYaseen208 %>% 
  as.data.frame %>% 
#          package
#1      agriTutorial
#2         bayesammi
#3      baystability
#4  DiallelAnalysisR
#5              dmai
#6         eda4treeR
#7              gvcR
#8         PakPC2017
#9    PakPMICS2014Ch
#10   PakPMICS2014HH
#1   PakPMICS2014HL
#2   PakPMICS2014Wm
#3       ppcSpatial
#4         PSLM2015
#15            qccrs
#16             rgsp
#17        stability
#18       StroupGLMM
#19            SupMZ
#20   VetResearchLMM

Convert character date with timestamp to class "POSIXct" "POSIXt"

By : user3474203
Date : March 29 2020, 07:55 AM
Any of those help I have two data.tables I'm trying to merge via a date column, now my first data.table's date column is of class "POSIXct" "POSIXt" and has this format: , With lubridate, it can be dmy_hms
code :
DT2[, study_date := dmy_hms(study_date)]
DT2[, study_date := as.POSIXct(study_date, format = '%d%b%Y:%H:%M:%S')]

NA for 1 particular date when converting dates from "character" format to "POSIXct" with as.POSIXct

By : user3728834
Date : March 29 2020, 07:55 AM
I wish this help you We can specify the %T for time. In the format, there are minutes, seconds and millseconds. So, the %H is only matching the hour part
code :
as.POSIXct("2017-03-26 02:00:00.000",format="%Y-%m-%d %T")
[1] "2017-03-26 02:00:00 EDT"
as.POSIXct("2017-03-26 02:00:00.000",format="%Y-%m-%d %H:%M:%OS")
#[1] "2017-03-26 02:00:00 EDT"
ymd_hms("2017-03-26 02:00:00.000")
Related Posts Related Posts :
  • Get the min value of one variable greater than the observation of another variable
  • Reference previous value in data.table calculation
  • 'Can't create call to non-callable object' error while summarizing data by grouping
  • Multiplying all columns in dataframe by single column
  • Calculating Standard Deviation by each unique variable in R.
  • Fisher exact test for each gene
  • Sorting coordinates to create a polygon gives messy results
  • Merging legends in ggplot fails with certain expressions
  • Shiny modal dialog in response to multiple buttons
  • Error connecting to mongoDB using Mongolite
  • R: networkD3 sankey plot - colours not displaying
  • Merging two rows into one header using R
  • Parse JSON to dataframe returns different numbers
  • How to number by group?
  • Multinomial probit regression with mixed type explanatory variables
  • How can I make a variable in a dataset containing a vector of all numbers between two other variables?
  • How to extract the trailing digits from a string in R?
  • Select values based on other columns
  • readLines killing R in purrr::map
  • Subset rows based on "start and stop" strings
  • How to add a column to lists within a list without losing their names?
  • Plotting the means in ggplot, without using stat_summary()
  • R :Looping through each 5 rows of data frame and imputing incremental value
  • In R, is growing a list just as inefficient as growing a vector?
  • Flexdashboard, rhandsontable: how to programmatically access user updated table?
  • Creating Summary Table from R Variables
  • Average over groups and include previous groups
  • R: data.table count rows on specific columns > 0
  • Transform (shuffle) just 2 Fields in a Dataframe
  • Issue with replacing string by match in R
  • (very) Simple quantstrat trading model using logistic regression
  • R - count maximum number of consecutive dates
  • Problems using tidyr separate on "|"
  • Default value when calling a function in a for loop
  • Finding values in a matrix from list of values in R
  • count 0's in a zoo (or dataframe) object
  • Finding the first non-zero year in data frame for multiple variables using tidyverse
  • ggplot2 - how to assign geom_text with arrow icon to second yaxis scale
  • regex fails with dollar sign
  • Drop first element of list of lists, condense list of lists? Too many elements?
  • R - how to apply output of ifelse(str_detect ...) to whole group
  • caret package confusion matrix define positive case with multiple classes
  • Generating a pairwise 'distance' matrix
  • Change all R columns names using a reference file
  • In R & dabestr, how do I get grouped differences correctly?
  • Exclude or set a unique color to the bottom triangle of a correlation matrix heatmap
  • r shiny observe function clears text input
  • Split column by multiple delimiters, keeping delimiters
  • How to random search in a specified grid in caret package?
  • merge 2 data frames in a loop for each column in one of them
  • how to edit the codes for the summary of R S4 Object?
  • Remove specific rows in R
  • Flatten JSON list into data frame
  • Filtering a dataset and making a ggplot
  • Align cells vertically to be at the bottom flextable
  • R speed up sapply
  • invalid subscript type 'list' Azure Machine Learning
  • Use rollapply with xts object and an anonymous defined function
  • Isolate data frames from a spreadsheet to create a list
  • Column splitting in R
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org