我正在使用2个输入进行闪亮的vizualization。
资料集:
> est_popai <- data.frame(concat = c("A_1","B_1","C_1","A_2","B_2","C_2","A_1","B_1","C_1","A_2","B_2","C_2","A_1","B_1","C_1","A_2","B_2","C_2","A_1","B_1","C_1","A_2","B_2","C_2"),
variables = c("quantity","quantity","quantity","quantity","quantity","quantity","price","price","price","price","price","price","quality","quality","quality","quality","quality","quality","size","size","size","size","size","size"),
values = round(runif(24, 5.0, 7.5),2)
)
Run Code Online (Sandbox Code Playgroud)
用户界面:
> ui <- fluidPage(
headerPanel(
h1("Combinacao de atributos")
),
sidebarPanel(
selectInput("xcol"," Variavel X", unique(est_popai$variable),
selected = 'price'),
selectInput("ycol"," Variavel y", unique(est_popai$variable),
selected = 'size')
),
mainPanel(
plotOutput("plot1")
)
)
Run Code Online (Sandbox Code Playgroud)
服务器:
> server <- function(input, output) {
selectData <- reactive ({
est_popai[est_popai$variable == input$xcol | est_popai$variable == input$ycol,] %>%
unique() %>%
spread(variable,value)
})
output$plot1 <- renderPlot({
ggplot(data = selectData, aes(x = input$xcol, y …Run Code Online (Sandbox Code Playgroud) 我正在尝试为 R H2O 中某个因子的水平设置一个顺序。例子x: factor w/5 levels "3" "4" "5" "1" "2"。df是数据框。
我尝试了这个:使用h2o.setLevels(df$x, levels = c("1", "2", "3", "4", "5")),我可以将级别重新排列为“1”、“2”、“3”、“4”、“5”,但不能设置我需要的顺序,其中 1 为最低,5 为最高。任何帮助,将不胜感激!谢谢
我正在尝试从此表中提取所有玩家链接:
https://www.footballdb.com/players/players.html?letter=A
这是我的代码的样子:
library(rvest)
url <- "https://www.footballdb.com/players/players.html?letter=A"
webpage <- read_html(url)
webpage %>%
html_nodes("table") %>%
html_attr("href")
Run Code Online (Sandbox Code Playgroud)
这将返回一个 NA。我看过其他有类似问题的帖子,但我未能很好地理解答案以将它们应用于这个问题。任何解决方案和/或指导将不胜感激。谢谢。
我正在尝试通过此链接重现传单包上 Rstudio 示例的结果。它一直工作到第 5 节。当我尝试使用具有完全相同设置的 AddMarkers 命令时:
##### Location Names
Location <- c("Atlanta ","Los Angeles","Chicago","New York","Dallas","Baltimore","Phoenix","Charlotte","Houston","San Antonio", "Seattle" )
#### Latitude and Longitude values for each of the above location
Lat <- c(33.74401,33.82377,41.78798,40.767309,32.88153,39.148492,33.45444,35.2406,29.935842,29.44838,47.714965 )
Lon <- c(-84.56032,-118.2668,-87.7738,-73.978308,-96.64601,-76.796211,-112.32401,-81.04028,-95.398436,-98.39908,-122.127166 )
#### Some hypothetical number of orders shipped out of each location
Orders <- c(1992,2500,3600,2252,3650,3450,4145,3945,5050,4300,1987)
#### Let us create some hypothetical class flags for the cities
Type <- c(rep("Yoda",5),rep("Vader",6))
### Create data set from the above vectors
df <- data.frame(Location, Lat,Lon,Orders,Type)
mymap …Run Code Online (Sandbox Code Playgroud)