由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - pass arguments by reference in R (转载)
相关主题
question about big data大家帮我看看这个程序哪里有问题啊!!
好人难做呀,以后再也不refer中国人了 (转载)请教一个 c++ member function pointer 问题
小公司PM和BA职位referone interview question, very difficult, smart people can do
C# no output of ConsoleWriteLine Visual Studio 2013std::list如何检测环?
saint gobain refer needed (转载)攒人品:google电面面经
弱弱的问问 2sum, 3sum 的问题求教 onsite 设计题目
问一道数据结构题这题怎么做?
Part-time Mandarin teacher in Lebanon, NJ讨论做题:find kth smallest number in two sorted arrays at
相关话题的讨论汇总
话题: ahash话题: myhash话题: alist话题: length话题: reference
进入JobHunting版参与讨论
1 (共1页)
l******9
发帖数: 579
1
【 以下文字转载自 Statistics 讨论区 】
发信人: light009 (light009), 信区: Statistics
标 题: pass arguments by reference in R
发信站: BBS 未名空间站 (Fri Apr 11 14:19:03 2014, 美东)
I need to do pass by reference in R by R studio on win 7.
My code:
myfunc<-function(myhash.arg, b)
{
myhash <- myhash.arg
if (!has.key("first", myhash))
myhash["first"] <- list()
alist <- myhash["first"]
alist <- append(alist, i)
eval.parent(substitute(myhash.arg<-myhash))
return(0)
}
ahash<-hash()
for(i in 1:5)
{
myfunc(myhash.arg = ahash, b = i)
print(c("length of ahash is ", length(ahash)))
print(c("length of ahash list is ", length(ahash["first"])))
}
but, the list size is always 1, the appended elements are missed.
Any help would be appreciated.
m****r
发帖数: 120
2
能不能就用个全局变量好了。或者试试assign?总之要找到正确的环境下的变量

【在 l******9 的大作中提到】
: 【 以下文字转载自 Statistics 讨论区 】
: 发信人: light009 (light009), 信区: Statistics
: 标 题: pass arguments by reference in R
: 发信站: BBS 未名空间站 (Fri Apr 11 14:19:03 2014, 美东)
: I need to do pass by reference in R by R studio on win 7.
: My code:
: myfunc<-function(myhash.arg, b)
: {
: myhash <- myhash.arg
: if (!has.key("first", myhash))

1 (共1页)
进入JobHunting版参与讨论
相关主题
讨论做题:find kth smallest number in two sorted arrays atsaint gobain refer needed (转载)
G家电面筋弱弱的问问 2sum, 3sum 的问题
问个题?求质数问一道数据结构题
请教iterative merge sort list的代码Part-time Mandarin teacher in Lebanon, NJ
question about big data大家帮我看看这个程序哪里有问题啊!!
好人难做呀,以后再也不refer中国人了 (转载)请教一个 c++ member function pointer 问题
小公司PM和BA职位referone interview question, very difficult, smart people can do
C# no output of ConsoleWriteLine Visual Studio 2013std::list如何检测环?
相关话题的讨论汇总
话题: ahash话题: myhash话题: alist话题: length话题: reference