我想复制这个
与R ggplot.我有完全相同的数据:
browsers<-structure(list(browser = structure(c(3L, 3L, 3L, 3L, 2L, 2L,
2L, 1L, 5L, 5L, 4L), .Label = c("Chrome", "Firefox", "MSIE",
"Opera", "Safari"), class = "factor"), version = structure(c(5L,
6L, 7L, 8L, 2L, 3L, 4L, 1L, 10L, 11L, 9L), .Label = c("Chrome 10.0",
"Firefox 3.5", "Firefox 3.6", "Firefox 4.0", "MSIE 6.0", "MSIE 7.0",
"MSIE 8.0", "MSIE 9.0", "Opera 11.x", "Safari 4.0", "Safari 5.0"
), class = "factor"), share = c(10.85, 7.35, 33.06, 2.81, 1.58,
13.12, 5.43, 9.91, 1.42, 4.55, 1.65), …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的字符串:
str<-"a\f\r"
Run Code Online (Sandbox Code Playgroud)
我正在尝试删除反斜杠但没有任何作用:
gsub("\","",str, fixed=TRUE)
gsub("\\","",str)
gsub("(\)","",str)
gsub("([\])","",str)
Run Code Online (Sandbox Code Playgroud)
...基本上你可以想象的所有变化.我甚至尝试过这个string_replace_all功能.任何帮助?
我正在使用R版本3.1.1; Mac OSX 10.7; 将dput在我的琴弦的矢量一个字符串给出:
dput(line)
"ud83d\ude21\ud83d\udd2b"
Run Code Online (Sandbox Code Playgroud)
我使用readLines标准
.txt文件导入
文件.该文件的内容类似于:
got an engineer booked for this afternoon \ud83d\udc4d all now hopefully sorted\ud83d\ude0a I m going to go insane ud83d\ude21\ud83d\udd2b in utf8towcs …
谢谢.
我知道这听起来很基本,但现在一直在寻找超过一个小时但没有成功.我只是尝试使用'ggplot2'包在'R'中绘制3D条形图.我的数据框看起来像这样:
x y z
t1 5 high
t1 2 low
t1 4 med
t2 8 high
t2 1 low
t2 3 med
t3 50 high
t3 12 med
t3 35 low
Run Code Online (Sandbox Code Playgroud)
我想在上面绘制这样的东西:

任何帮助都超过赞赏!!
我正在使用Paul Bleicher的calenderHeat.R代码绘制日历热图,这是我的情节:

我想知道如何在情节中添加日期,而不是空白网格.这是我的示例数据:
structure(list(Date = c("2014-10-01", "2014-09-30", "2014-09-29",
"2014-09-26", "2014-09-25", "2014-09-24", "2014-09-23", "2014-09-22",
"2014-09-19", "2014-09-18", "2014-09-17", "2014-09-16", "2014-09-15",
"2014-09-12", "2014-09-11", "2014-09-10", "2014-09-09", "2014-09-08",
"2014-09-05", "2014-09-04", "2014-09-03", "2014-09-02", "2014-08-29",
"2014-08-28", "2014-08-27", "2014-08-26", "2014-08-25", "2014-08-22",
"2014-08-21", "2014-08-20", "2014-08-19", "2014-08-18", "2014-08-15",
"2014-08-14", "2014-08-13", "2014-08-12", "2014-08-11", "2014-08-08",
"2014-08-07", "2014-08-06", "2014-08-05", "2014-08-04", "2014-08-01",
"2014-07-31", "2014-07-30", "2014-07-29", "2014-07-28", "2014-07-25",
"2014-07-24", "2014-07-23", "2014-07-22", "2014-07-21", "2014-07-18",
"2014-07-17", "2014-07-16", "2014-07-15", "2014-07-14", "2014-07-11",
"2014-07-10", "2014-07-09", "2014-07-08", "2014-07-07", "2014-07-03",
"2014-07-02", "2014-07-01", "2014-06-30", "2014-06-27", "2014-06-26",
"2014-06-25", "2014-06-24", "2014-06-23", "2014-06-20", "2014-06-19", …Run Code Online (Sandbox Code Playgroud) 我有一个字符串向量myStrings- 在R中看起来像:
[1] download file from `http://example.com`
[2] this is the link to my website `another url`
[3] go to `another url` from more info.
Run Code Online (Sandbox Code Playgroud)
哪里another url是有效的http网址,但stackoverflow不会让我插入多个网址,这就是我写作的原因another url.我想删除所有的网址myStrings,如下所示:
[1] download file from
[2] this is the link to my website
[3] go to from more info.
Run Code Online (Sandbox Code Playgroud)
我在stringr包中尝试了很多功能,但没有任何作用.
我正在使用一个API,它提供一个名为tokenvalue 的HTTP标头12abc3,我的网址是https://example.com/view/quote.有没有办法我可以将标题作为参数添加到网址中,以便我可以直接在浏览器的地址栏中输入它而不是使用cURL或Hurl.it?
我正在尝试创建一个ShinyApp.用户界面UI.R看起来很好,但我遇到了问题server.R.基本上我想要一个不同的绘图输出,具体取决于radio用户选择的选项.
用户可以选择的选项A,B或C.我想绘制直方图,如果用户选择选项A,条形图B和饼图选项,C但我不知道如何编码条件?这是一个if-else声明吗?我已经挣扎了几个小时!这是我的代码示例:
output$plots <- renderPlot({
if selection == 'A'
# plot histogram
if selection == 'B'
# plot bar chart
if selection == 'C'
# plot pie chart
})
Run Code Online (Sandbox Code Playgroud)
谢谢!
几个小时我一直在苦苦挣扎.我Shiny App应该在R环境中显示一些变量.它的工作正常但是当我将它部署到网络时,我得到的错误如下:
Error: object 'df1' not found
Run Code Online (Sandbox Code Playgroud)
如何添加df1和我的其他数据框,以便它们可以作为Shiny App部署时的一部分打包?
请帮忙.这是我的示例代码:
server.R
library(shiny)
shinyServer(function(input,output){
output$datasets <- renderTable({
switch(input$choice,
"1" = as.data.frame(df1)
"2" = as.data.frame(df2) })
}))
Run Code Online (Sandbox Code Playgroud)
UI.R
shinyUI(
fluidPage(theme = "bootstrap.css",
sidebarPanel(
conditionalPanel(
condition = "input.theTab == 'datasets' ",
h3('Display Sample Data'),
selectInput("choice", "Selection", choices = c("Group1"=1,"Group2"=2)),
)),
mainPanel(
tabsetPanel(
tabPanel( "datasets", tableOutput("datasets"), value = 'datasets'),
id = "theTab"))
)
Run Code Online (Sandbox Code Playgroud) 我有一个字符串向量,看起来像:
str <- c("bills slashed for poor families today", "your calls are charged", "complaints dept awaiting refund")
Run Code Online (Sandbox Code Playgroud)
我希望得到所有以字母结尾的单词s并删除s.我试过了:
gsub("s$","",str)
Run Code Online (Sandbox Code Playgroud)
但它不起作用,因为它试图匹配以s而不是单词结束的字符串.我试图得到一个看起来像的输出:
[1] bill slashed for poor familie today
[2] your call are charged
[3] complaint dept awaiting refund
Run Code Online (Sandbox Code Playgroud)
有关如何做到这一点的任何指示?谢谢
我在R中用代码创建了一个词云:
wordcloud(words$term, words$freq, random.order=FALSE, colors=colorRampPalette(brewer.pal(9,"Blues"))(32), scale=c(5, .5))
Run Code Online (Sandbox Code Playgroud)
它的工作原理只是它以这样的方式对术语进行着色,使得最常见的颜色出现在最暗的颜色中,而最浅的则出现在最浅的颜色中.但我希望它反过来.有什么指针吗?谢谢.