我试图在RStudio中运行rWBclimate包.我从ROpenSci复制了以下代码并粘贴在RStudio中.但我得到错误说'不知道如何自动选择类型列表对象的比例.默认为连续错误:geom_point需要以下缺失的美学:y
gbr.dat.t <- get_ensemble_temp("GBR", "annualavg", 1900, 2100)
## Loading required package: rjson
### Subset to just the median percentile
gbr.dat.t <- subset(gbr.dat.t, gbr.dat.t$percentile == 50)
## Plot and note the past is the same for each scenario
ggplot(gbr.dat.t,aes(x=fromYear,y=data,group=scenario,colour=scenario))
+ geom_point() +
geom_path() +
theme_bw() +
xlab("Year") +
ylab("Annual Average Temperature in 20 year increments")
Run Code Online (Sandbox Code Playgroud)
我也尝试以下列方式使用geom_point(stat ="identity")但不起作用:
ggplot(gbr.dat.t,aes(x=fromYear,y=data,group=scenario,colour=scenario))
+ geom_point(stat="identity") +
geom_path() +
theme_bw() +
xlab("Year") +
ylab("Annual Average Temperature in 20 year increments")
Run Code Online (Sandbox Code Playgroud)
我仍然得到相同的消息"不知道如何自动选择类型列表对象的比例.默认为连续错误:geom_point需要以下缺少美学:y"
另外,str(gbr.dat.t)的结果如下:
> str(gbr.dat.t)
'data.frame': …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 SQLAlchemy 中的两个表填充数据库。我已经创建了数据库 test_database,现在我尝试在其中创建 2 个表。我已经检查过该数据库是否已使用 成功创建\l。以下是文件 create.py 的代码,它创建一个包含两个表的数据库:
import os
from flask import Flask, render_template, request
from models import *
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = 'postgresql://shammun:my_password@localhost:5432/test_database.db'
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
# db = SQLAlchemy()
db.init_app(app)
def main():
db.create_all()
if __name__ == "__main__":
with app.app_context():
main()
Run Code Online (Sandbox Code Playgroud)
这个文件create.py导入了model.py,生成了两个表,其代码如下:
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class Flight(db.Model):
__tablename__ = "flights"
id = db.Column(db.Integer, primary_key=True)
origin = db.Column(db.String, nullable=False)
destination = db.Column(db.String, nullable=False)
duration = db.Column(db.Integer, nullable=False) …Run Code Online (Sandbox Code Playgroud) 我有两个向量X和Y。因此,我想按升序对X进行排序,并将X与对应的Y配对。这里X和Y具有相同数量的元素。
有什么帮助吗?谢谢。