由买买提看人间百态

topics

全部话题 - 话题: globalenv
(共0页)
a***d
发帖数: 336
1
来自主题: Statistics版 - R同名函数问题
this is what I usually do. there are probably much better ways of doing it.
your function is usually in .globalEnv unless you specify otherwise.
so to get your function, use:
fun1 <- get(funcNm, env=.GlobalEnv)
use search() to find out position of the package. if the package is the nth
package in the search path, use:
fun2 <- get(funcNm, pos=n)
a*****8
发帖数: 110
2
来自主题: Statistics版 - R-Question about attach
OK, I just start a new session.
> mydata
gender q1 q2 q3 q4
1 f 1 1 5 1
2 f 2 1 4 1
3 f 2 2 4 3
4 3 1 NA 3
5 m 3 5 2 4
6 m 5 4 5 5
7 m 5 3 4 4
8 m 4 5 5 5
> attach(mydata)
The following object(s) are masked _by_ .GlobalEnv :
gender q1 q2 q3 q4
>
What is the problem? Thanks!
d********p
发帖数: 31
3
来自主题: Statistics版 - R environment 问题
对的。好像pos和envir是redundant arguments。
x=function() {assign('c',1); print(c)}; x()
get('c') # error
x=function() {assign('c',1, envir=.GlobalEnv); print(c)}; x()
get('c')
(共0页)