小编Ant*_*tex的帖子

日期时间转换并仅提取时间

想要将Time类更改为POSIXlt并仅提取小时分钟和秒

str(df3$Time)
chr [1:2075259] "17:24:00" "17:25:00" "17:26:00" "17:27:00" ...
Run Code Online (Sandbox Code Playgroud)

使用了strptime功能

df33$Time <- strptime(df3$Time, format = "%H:%M:%S") 
Run Code Online (Sandbox Code Playgroud)

这给出了附加的日期/时间

> str(df3$Time)
 POSIXlt[1:2075259], format: "2015-08-07 17:24:00" "2015-08-07 17:25:00" "2015-08-07 17:26:00" ...
Run Code Online (Sandbox Code Playgroud)

.

想要在不改变POSIXlt类的情况下提取时间.使用strftime函数

df3$Time <- strftime(df3$Time, format = "%H:%M:%S") 
Run Code Online (Sandbox Code Playgroud)

但是这会将类转换回"char" -

> class(df3$Time)
[1] "character"
Run Code Online (Sandbox Code Playgroud)

如何将类设置为POSIX或数字来提取时间...

datetime r strptime

17
推荐指数
5
解决办法
3万
查看次数

街道地址到地理位置lat/long

我正在考虑rChart/LeafLet为我县的房屋销售创建一个闪亮的应用程序.在任何给定的时间有几百个房子待售.想要为所有人映射街道地址到地理位置(纬度/经度)并在地图上显示它们.所以,我正在寻找可以将街道地址映射到地理位置的ar包,服务或数据库.

r geolocation leaflet rcharts

10
推荐指数
2
解决办法
2万
查看次数

R 连接到 sqlite

我无法从 R 连接到 sqlite。Sqlite3 安装在 Linux 服务器上并且能够创建/修改。但 R 未连接:

library(dplyr)
library(RSQLite)

> db <- src_sqlite("my_db.sqlite3", create = TRUE)
Error in .local(drv, ...) : Could not connect to database:
unable to open database file
Run Code Online (Sandbox Code Playgroud)

我可以从命令行连接到 SQLite:

@ubuntu:~$ sqlite3
SQLite version 3.8.2 2013-12-06 14:53:30
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> 
Run Code Online (Sandbox Code Playgroud)

这是会议信息:

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.1 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] …
Run Code Online (Sandbox Code Playgroud)

sqlite r

5
推荐指数
1
解决办法
1万
查看次数

rstudio推送“ rpostback-askpass”错误

从CLI,我可以推/拉到git。但是,从Rsudio,我只能拉而不能推。我已经为ssh / https端口打开了防火墙,但是在尝试推送时仍然出现以下错误:

error: unable to read askpass response from 'rpostback-askpass'
fatal: could not read Username for 'https://github.com': No such device or address
Run Code Online (Sandbox Code Playgroud)

Rstudio版本0.99.484。

git ssh-keys rstudio

3
推荐指数
2
解决办法
2295
查看次数

如何在ggplot2页脚上添加徽标

如何在ggplot2的绘图区域外添加图像徽标.从'grid'包中尝试了rasterGrob函数,但是它保留了绘图区域内的图像.

这是启动脚本:

library(ggplot2)
library(png)
library(gridExtra)
library(grid)

gg <- ggplot(df1, aes(x = mpg, y = wt)) + 
       theme_minimal() +
        geom_count() + 
        labs(title = "Title Goes Here", x = "", y = "")

img <- readPNG("fig/logo.png")
Run Code Online (Sandbox Code Playgroud)

这是我正在寻找的结果.

在此输入图像描述

我可以在右侧添加注释,但左侧的徽标是我受到挑战的地方.

r ggplot2

3
推荐指数
1
解决办法
4440
查看次数

根据两列条件找到平均值

foo = data.frame(V1=c(rep("A",4),"B",rep("C",3),"D","D"), 
                 V2=c(rep("1",3), rep("2",2),
                      "1", rep("3",2), rep("2",2)), 
                 V3=c(1.2,1.4,1.3,1.5,1.6,1.2,1.1,1,1.3,1.4),
                 V4=c(2.2,2.4,2.3,2.5,2.6,2.2,2.1,2,2.3,2.4),
                 V5=c(3.2,3.4,1.3,3.5,1.6,3.2,1.1,1,3.3,3.4))
Run Code Online (Sandbox Code Playgroud)

结果将保持V1和V2的独特组合以及每列V3-V5的平均值.示例平均值(1.2,1.4,1.3)= 1.3

 foo
    V1 V2  V3 V4  V5
1   A  1  1.3 2.2 3.2
2   A  2  1.5 2.5 3.5
3   B  2  1.6 2.6 1.6
4   C  1  1.2 2.2 3.2
5   C  3  1.1 2.1 1.1
6   D  2  1.3 2.3 3.3
Run Code Online (Sandbox Code Playgroud)

r lapply

2
推荐指数
1
解决办法
63
查看次数

数据表中的串扰包错误

当试图在传单/ DT之间渲染带有串扰的html应用程序时,我收到以下错误:

Error in datatable(sd, extensions = "Scroller", style = "bootstrap", class = "compact",  : 'data' must be 2-dimensional (e.g. data frame or matrix)
Run Code Online (Sandbox Code Playgroud)

数据框:

df2 <-   data.frame(
    structure(list(lat = c(-20.42, -20.62, -26, -17.97, -20.42, -19.68, 
    -11.7, -28.11, -28.74, -17.47, -21.44, -12.26, -18.54, -21, -20.7, 
    -15.94, -13.64, -17.83, -23.5, -22.63), long = c(181.62, 181.03, 
    184.1, 181.66, 181.96, 184.31, 166.1, 181.93, 181.74, 179.59, 
    180.69, 167, 182.11, 181.66, 169.92, 184.95, 165.96, 181.5, 179.78, 
    180.31), depth = c(562L, 650L, 42L, 626L, 649L, 195L, …
Run Code Online (Sandbox Code Playgroud)

r rstudio leaflet dt

2
推荐指数
1
解决办法
1218
查看次数

找不到闪亮的传单数据

对于将呈现传单地图的闪亮应用程序,我使用'ggmap'包中的"Crime"数据集.我试图实现两个输入.一个是'进攻',另一个是'月'变量.这些变量可以从闪亮的下拉菜单中获得.目标是通过攻击类型和月份的组合来过滤和显示.防爆.例如4月的抢劫......

当被解雇时,我得到了Point data not found;错误.

这是一个提取数据的代码构造.

fData <- reactive({
  data <- hustonCrime

           if (input$offenseFilter != "All"){
                  data <- subset(hustonCrime, offense %in% input$offenseFilter) 
                  }
           if (input$monthFilter != "All"){
                   data <- subset(hustonCrime, month %in% input$monthFilter) 
                 }
   })
Run Code Online (Sandbox Code Playgroud)

r leaflet

1
推荐指数
1
解决办法
115
查看次数

标签 统计

r ×7

leaflet ×3

rstudio ×2

datetime ×1

dt ×1

geolocation ×1

ggplot2 ×1

git ×1

lapply ×1

rcharts ×1

sqlite ×1

ssh-keys ×1

strptime ×1