Hi,
I have  problem. In the function below (test and test2) i want the function
test not to print the variable data but i want the function test2 to use the
variable test$data.

This is the creation of the variable data:

> matrice=c(1:10)
> matrice=matrix(matrice,nrow=5,ncol=2)

This is the function test:

> test=function(data){
+ return(list(x=5,data=data))
+ }

This is the function test2:

> test2=function(list){
+ bodri=list$data
+ bodri[1,2]=bodri[2,2]+1
+ return(bodri)
+ }

Below there are the result:

> uno=test(matrice)
> due=test2(uno)
> uno
$x
[1] 5

$data
     [,1] [,2]
[1,]    1    6
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10

> due
     [,1] [,2]
[1,]    1    8
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10


What i want is:

> uno=test(matrice)
> due=test2(uno)
> uno
$x
[1] 5

> due
     [,1] [,2]
[1,]    1    8
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10

Can you help me please?
Thank you.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to