Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用RPostgreSQL从R中的数据帧创建临时表_R_Postgresql - Fatal编程技术网

使用RPostgreSQL从R中的数据帧创建临时表

使用RPostgreSQL从R中的数据帧创建临时表,r,postgresql,R,Postgresql,我有一个数据帧,需要使用RPostgreSQL包在R中编写为临时表 例如: >data(USArrests) #Assuming that we have already established a connection to the postgres db #Let conn be the postgres connection object >dbWriteTable(conn, "temp_table_data", USArrests, temp.table=TRUE) 这是

我有一个数据帧,需要使用RPostgreSQL包在R中编写为临时表

例如:

>data(USArrests)
#Assuming that we have already established a connection to the postgres db
#Let conn be the postgres connection object
>dbWriteTable(conn, "temp_table_data", USArrests, temp.table=TRUE)
这是行不通的。参数temp.table似乎被忽略


如果没有办法处理dbWriteTable,是否还需要将数据帧作为临时表写入?

我能想到的最简单方法是将数据帧作为结果集返回,并使用plpgsql编写的包装函数将其写入临时表。这意味着您必须将逻辑分解为计算层和存储层。

您可以使用参数
is.temp=TRUE
而且它是有效的

你是从哪里想到temp.table=TRUE可能会有效的?可能是从这个。但是,它注意到,对于该驱动程序,您不应该尝试这样做。如果您在这里的基本目的只是将PostgreSQL语句应用于R数据帧,那么您可以尝试sqldf。例如,这计算
USArrests
库(RPostgreSQL)中的行数;图书馆(sqldf);sqldf('select count(*)from“USArrests')
。请参见和
?sqldf
@Grothendieck:谢谢您的指针。非常感谢。我目前面临的障碍是sqldf不适用于R版本2.13.0。谢谢你