我有两个数据框,它们都包含纬度和经度坐标。第一个数据帧是对事件的观察,其中记录了位置和时间。第二个数据框是地理要素,其中记录了该要素的位置和信息。
my_df_1 <- structure(list(START_LAT = c(-33.15, -35.6, -34.08333, -34.13333,
-34.31667, -47.38333, -47.53333, -34.08333, -47.38333, -47.15
), START_LONG = c(163, 165.18333, 162.88333, 162.58333, 162.76667,
148.98333, 148.66667, 162.9, 148.98333, 148.71667)), row.names = c(1175L,
528L, 1328L, 870L, 672L, 707L, 506L, 981L, 756L, 210L), class = "data.frame", .Names = c("START_LAT",
"START_LONG"))
my_df_2 <- structure(list(latitude = c(-42.7984, -34.195, -49.81, -35.417,
-28.1487, -44.657, -42.7898, -36.245, -39.1335, -31.8482), longitude = c(179.9874,
179.526, -176.68, 178.765, -168.0314, 174.695, -179.9873, 177.7873,
-170.0583, 173.2424), depth_top = c(935L, 2204L, 869L, 1973L,
4750L, …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个可以在像 Github Actions 这样的无头环境中运行的 R 包。使用 httr,您可以使用以下代码在交互式会话中通过 Spotify API 进行身份验证(从 窃取spotifyr)
get_spotify_authorization_code <- function(
client_id = Sys.getenv("SPOTIFY_CLIENT_ID"),
client_secret = Sys.getenv("SPOTIFY_CLIENT_SECRET"),
scope = get_scopes()
) {
endpoint <- oauth_endpoint(authorize = 'https://accounts.spotify.com/authorize',
access = 'https://accounts.spotify.com/api/token')
app <- oauth_app('spotty', client_id, client_secret)
token <- safely(.f=oauth2.0_token)(
endpoint = endpoint,
app = app,
scope = scope)
if (!is.null(token$error)) {
token$error
} else {
token$result
}
}
Run Code Online (Sandbox Code Playgroud)
当您第一次运行它时,它会弹出一个浏览器窗口进行身份验证。这只需要完成一次,然后从那时起使用刷新令牌。
有没有一种方法可以调整它,以便它不使用web-application-flow并使用可以无头运行的其他类型的身份验证。我知道存在“客户端凭据流”,但它不允许访问用户资源,并且我希望能够访问已保存的播放列表等内容(即me 端点,'https://api.spotify.com/v1/me/tracks/')
我有一个闪亮的应用程序,它需要一个数据帧,并group_by从dplyr. 我可以让它接受单个组,但我希望它selectInput接受多个分组变量。
selectInput我可以通过添加另一个,然后将其传递给语句来解决这个问题group_by,但我希望它扩展到任意数量的变量。因此我需要单个参数selectInput来接受多个参数。
仅添加multiple = TRUE不会以可以理解的方式传递变量group_by,并且我现在无法适应这个答案group_by_,该答案已被弃用
笔记,
此应用程序的完整版本使用fileInput,而不是硬编码数据集,因此调用renderUI、 和reactive
library(shiny)
library(DT)
library(dplyr)
ui <- fluidPage(
titlePanel("app"),
sidebarLayout(
sidebarPanel(
uiOutput("groups")
),
mainPanel(
DT::dataTableOutput("summary")
)
)
)
server <- function(input, output) {
mydata <- reactive({structure(list(School = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 1L, 1L, 2L, 2L), .Label = c("School1", "School2"), class = "factor"),
Town = structure(c(1L, 1L, …Run Code Online (Sandbox Code Playgroud) 我对 gganimate 比较陌生,我正在尝试在 R studio 上创建一个简单的多项式时间序列图。
x <- 1:100
f <- function (x){
return(-(x)^2)
}
df <- data.frame(x, y= -(x)^2)
ggplot(df, aes(x, y)) +
geom_line() +
stat_function(fun=f) +
transition_states(x, transition_length = 1, state_length = 2 )
Run Code Online (Sandbox Code Playgroud)
我的错误显示:
" Error in transform_path(all_frames, next_state, ease, params$transition_length[i], :
transformr is required to tween paths and lines "
Run Code Online (Sandbox Code Playgroud)
我想知道 transition_state() 中是否缺少某些东西?它作为静态图看起来不错,但我想让它成为一个时间序列图。
感谢任何建议/帮助!谢谢 !