我正在尝试跟随错误,尝试第一次Github推送:
[rejected] master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:me/me.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'non-fast forward'
section of 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)
我该如何解决此问题并合并远程更改?
在ggplot结束时,这很好用:
+ opts(title = expression("Chart chart_title..."))
Run Code Online (Sandbox Code Playgroud)
但这不是:
chart_title = "foo"
+ opts(title = expression(chart_title))
Run Code Online (Sandbox Code Playgroud)
也不是这样
chart_title = "foo"
+ opts(title = chart_title)
Run Code Online (Sandbox Code Playgroud)
当标题是变量名时,如何向ggplot添加标题?
在Python中,我刚刚读了一个文本文件的行,我想知道如何编写代码来忽略带有#行开头的#的注释.
我认为它应该是这样的:
for
if line !contain #
then ...process line
else end for loop
Run Code Online (Sandbox Code Playgroud)
但我是Python的新手,我不知道语法
我在下面有一个示例函数,它将日期作为字符串读入并将其作为日期对象返回.如果它读取的字符串无法转换为日期,则会返回错误.
testFunction <- function (date_in) {
return(as.Date(date_in))
}
testFunction("2010-04-06") # this works fine
testFunction("foo") # this returns an error
Run Code Online (Sandbox Code Playgroud)
现在,我想使用lapply并在日期列表中应用此函数:
dates1 = c("2010-04-06", "2010-04-07", "2010-04-08")
lapply(dates1, testFunction) # this works fine
Run Code Online (Sandbox Code Playgroud)
但是,如果我想在两个好日期中间的一个字符串返回错误时将该函数应用于列表,那么处理此问题的最佳方法是什么?
dates2 = c("2010-04-06", "foo", "2010-04-08")
lapply(dates2, testFunction)
Run Code Online (Sandbox Code Playgroud)
我认为我想在那里试一试,但是有没有办法捕获"foo"字符串的错误,同时要求lapply继续阅读第三个日期?
我想产生一个变量这是两个字符的串联,例如从"p30s4""p28s4"到"p30s4 p28s4"去了.我尝试了猫和粘贴,如下所示.两者都返回空变量.我究竟做错了什么?
> blah = c("p30s4","p28s4")
> blah
[1] "p30s4" "p28s4"
> foo = cat(blah)
p30s4 p28s4
> foo
NULL
> foo = paste(cat(blah))
p30s4 p28s4
> foo
character(0)
Run Code Online (Sandbox Code Playgroud) 如何在Perl中找到我正在处理的对象类型?我尝试使用perl -d进入调试器,但我不知道该怎么做.同样,我想要一种方法来轻松查看每个对象可用的方法,如何做到这一点?
在ggplot中,我可以添加一个系列到一个情节:
ggplot(diamonds, aes(x = carat, y = price)) + geom_point()
Run Code Online (Sandbox Code Playgroud)
我如何简单地添加另一个系列,例如绘制红宝石对钻石的成本.假设钻石数据集中也有红宝石.我试图用红宝石数据覆盖顶层另一层,但它只是绘制红宝石而不是钻石/克拉.
ggplot(diamonds, aes(x = carat, y = price)) + geom_point() + aes(x = rubies, y = price)
Run Code Online (Sandbox Code Playgroud)
我可以看到,通过首先将所有数据融合在一起,准备绘制它,这是可能的,所以也许我应该沿着那条路走下去.然而,只是在这样的情节中添加另一个系列似乎不应该太难,但我无法弄清楚如何去做.
library(ggplot2)
my_title = "This is a really long title of a plot that I want to nicely wrap \n and fit onto the plot without having to manually add the backslash n, but at the moment it does not"
r <- ggplot(data = cars, aes(x = speed, y = dist))
r + geom_smooth() + #(left)
opts(title = my_title)
Run Code Online (Sandbox Code Playgroud)
我可以设置绘图标题以包围并缩小文本以适应情节吗?
Perl my ($variableName) 和my $variableNamePerl有什么区别?括号怎么办?
test1 <- as.matrix(c(1, 2, 3, 4, 5))
row.names(test1) <- c("a", "d", "c", "b", "e")
test2 <- as.matrix(c(6, 7, 8, 9, 10))
row.names(test2) <- c("e", "d", "c", "b", "a")
test1
[,1]
a 1
d 2
c 3
b 4
e 5
test2
[,1]
e 6
d 7
c 8
b 9
a 10
Run Code Online (Sandbox Code Playgroud)
如何重新排序test2以使行与test1的顺序相同?例如:
test2
[,1]
a 10
d 7
c 8
b 9
e 6
Run Code Online (Sandbox Code Playgroud)
我尝试使用重新排序函数:reorder(test1,test2)但我无法弄清楚正确的语法.我看到重新排序需要一个向量,我在这里使用矩阵.我的真实数据有一个字符向量,另一个是data.frame.我认为数据结构对于上面这个例子来说并不重要,我只需要帮助解决语法并使其适应我的实际问题.