Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.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
R 将Excel值从列存储到中的变量_R_Excel - Fatal编程技术网

R 将Excel值从列存储到中的变量

R 将Excel值从列存储到中的变量,r,excel,R,Excel,我目前正在尝试在Excel中使用BERT控制台,但在将数据集Iris中的值存储到变量中的简单功能方面遇到了问题。我使用的是bert的示例脚本,如下所示: # # Here's an example of using the Excel scripting interface # (paste this code into the shell). # # For more information, see # # https://bert-toolkit.com/excel-scripting

我目前正在尝试在Excel中使用BERT控制台,但在将数据集Iris中的值存储到变量中的简单功能方面遇到了问题。我使用的是bert的示例脚本,如下所示:

#
# Here's an example of using the Excel scripting interface
# (paste this code into the shell). 
# 
# For more information, see
#
# https://bert-toolkit.com/excel-scripting-interface-in-r
#

#
# get a reference to the workbook
#
wb <- EXCEL$Application$get_ActiveWorkbook();

#
# add a sheet
#
new.sheet <- wb$get_Sheets()$Add();

# 
# change the name of the new sheet. note that this will
# fail if a sheet with this name already exists. 
#
new.sheet$put_Name( "R Data Set" );

#
# add some data. use matrices.
#
range <- new.sheet$get_Range( "B3:F152" );
range$put_Value( as.matrix( iris ));

#
# add column headers
#
header.range <- new.sheet$get_Range( "B2:F2" );
header.range$put_Value( t( colnames( iris )));

# 
# resize columns to fit
#
range$get_EntireColumn()$AutoFit();

#
# example of using constants: add border (underline) to headers
#
borders <- header.range$get_Borders();
border <- borders$get_Item( EXCEL$XlBordersIndex$xlEdgeBottom );
border$put_Weight( EXCEL$XlBorderWeight$xlThin );
#
#下面是一个使用Excel脚本界面的示例
#(将此代码粘贴到shell中)。
# 
#有关详细信息,请参阅
#
# https://bert-toolkit.com/excel-scripting-interface-in-r
#
#
#获取对工作簿的引用
#

wb给定运行第一个代码块后的设置,此代码将数据从B列复制到G列:


我问这个问题已经有一段时间了,但这个答案是正确的:)
col.B <- list("B3:B152");
test.input <- new.sheet$get_Range( "G3:G152" );
test.input$put_Value();
da_ta <- new.sheet$get_Range("B3:B152")$get_Value()
new.sheet$get_Range("G3:G152")$put_Value(da_ta)