我有以下问题:我获得的数据中的日期列包含由于夏令时而不存在的日期.(例如2015-03-29 02:00在中欧时间不存在,因为时钟从01:59直接设置为03:00因为DST在这一天生效)
是否有一种简单可靠的方法来确定日期在夏令时方面是否有效?
由于datetime类的属性,这并非易事.
# generating the invalid time as POSIXlt object
test <- strptime("2015-03-29 02:00", format="%Y-%m-%d %H:%M", tz="CET")
# the object seems to represent something at least partially reasonable, notice the missing timezone specification though
test
# [1] "2015-03-29 02:00:00"
# strangely enough this object is regarded as NA by is.na
is.na(test)
# [1] TRUE
# which is no surprise if you consider:
is.na.POSIXlt
# function (x)
# is.na(as.POSIXct(x))
as.POSIXct(test)
# [1] NA
# inspecting the interior of my …Run Code Online (Sandbox Code Playgroud) 如何取消选择...自写函数参数中给出的列.(我还需要在另一个点选择列,所以只使用-in 指定列...不能解决我的问题.)
任何解决方案都是apreciated,select-helpers,manipulating quosures或expression,......
# very simple example data
test <- data.frame(a=1:3, b=1:3, c=1:3)
# function skeleton
testfun <- function(x, ...){
y <- select(x, ...)
z <- select(x, -...) # does of course not work like this
return(list(y, z)) # just as an example
}
# calling the function to select different columns
testfun(test, a)
testfun(test, a, b)
Run Code Online (Sandbox Code Playgroud) 我有办法在 Windows 上的 Rstudio 中更改控制台编码吗?
这不是关于以特定编码读取文件或获取脚本,而是关于更改控制台编码(编码 Sys.getlocale 产生)。
这通常不是什么大问题,但我尝试创建一个包,并且我在某些字符串和符号中使用了德语变音符号。编码roxygen2效果最好,UTF-8但covr如果源文件不在控制台/系统编码中,则会出现错误。
(如果有解决方法roxygen2和covr问题,这也会有所帮助。附加信息:我covr::package_coverage从控制台调用,我roxygen2通过 Rstudios Build 命令调用。)
和会话信息:
sessionInfo()
# R version 3.4.2 (2017-09-28)
# Platform: x86_64-w64-mingw32/x64 (64-bit)
# Running under: Windows >= 8 x64 (build 9200)
#
# Matrix products: default
#
# locale:
# [1] LC_COLLATE=German_Austria.1252 LC_CTYPE=German_Austria.1252 LC_MONETARY=German_Austria.1252 LC_NUMERIC=C LC_TIME=German_Austria.1252
Run Code Online (Sandbox Code Playgroud)
更新:通过 Rstudio 中的文件获取出错的函数,加载devtools::load_all(".")和 RStudio gui 给出错误/错误的编码。
是否有可能在 rstanarm 中提取用于 MCMC 采样的 stan 代码?
我想将我自己的模型参数化和先前选择与 rstanarm 中使用的参数化进行比较。
(如何)是否可以在具有 d3/透视视图的地球上绘制地理数据 \xe2\x80\x93 例如多边形层 \xe2\x80\x93 ,类似于此图形?
\n我想要一个带有sf和 的解决方案ggplot但欢迎任何解决方案。
(我问这个主要是出于好奇,但由于我经常看到这样的图形,我想这个问题可能有用)
\n