3

My question is regarding How do you adjust/control the scale in a treemap (using the 'portfolio' library) in R?.

I modified seq(-1,0 to seq(0,1 as recommended in one of the answers. I then copied and pasted the entire map.market function into R, but am unable to call the modified version that I just pasted. When I type map.market, the original definition of the function "portfolio" is printed within the R editor window. How can I run the version that I just pasted?

Community
  • 1
  • 1
user3152437
  • 31
  • 1
  • 2

1 Answers1

6

If you just copy and paste, the function is not really saved in your session. You need to assign it to an object in R. When you type the name of the function map.market, you get the code:

function(...)
{
# all
# the code 
# of the function
}
<bytecode: 0x0000000007dd9aa0>
<environment: namespace:portfolio>

So, you have to copy everything before <bytecode> and <environment> lines, modify and save it to an object

map.market2 = function(...)
{
# all
# the code 
# of the function (with modifications)
}

Now, you can use the new modified function map.market2 as desired. You can name it map.market if you want, but check that doesn't break the rest of your code. For example, if you have used the original function before, because the new modified function will have precedence over the original one.

Ricardo Oliveros-Ramos
  • 4,322
  • 2
  • 25
  • 42