Any help on R code interpretation?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Any help on R code interpretation?

Marna Wagley
HI R user,
I was looking a r code and saw "%*%t", what does it("%*%t") mean?. The
example is given below.

For example: here is the code where "%*%t" has been used. when I run the
formula but did not run in my data.

prediction=plogis(as.matrix(mod7)%*%t(with(subset(data,site!='AB'),cbind(1,
site=='BC', site =='MM', site =='XY',Temp,Treatment=='Local'))))

Can I get the same result of above using the following code? Do both codes
give same results?

ab<-with(subset(data,site!='AB'),cbind(1,site=='BC', site =='MM', site ==
'XY',Temp,Treatment=='Local'))
prediction =plogis(as.matrix(mod7),(ab))

Thanks,

MW

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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 | Threaded
Open this post in threaded view
|

Re: Any help on R code interpretation?

Thierry Onkelinx
Dear Marna,

It's a combinations of two functions: %*% and t()
help("%*%") and help("t") will open their helpfiles.

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2016-12-22 14:08 GMT+01:00 Marna Wagley <[hidden email]>:

> HI R user,
> I was looking a r code and saw "%*%t", what does it("%*%t") mean?. The
> example is given below.
>
> For example: here is the code where "%*%t" has been used. when I run the
> formula but did not run in my data.
>
> prediction=plogis(as.matrix(mod7)%*%t(with(subset(data,
> site!='AB'),cbind(1,
> site=='BC', site =='MM', site =='XY',Temp,Treatment=='Local'))))
>
> Can I get the same result of above using the following code? Do both codes
> give same results?
>
> ab<-with(subset(data,site!='AB'),cbind(1,site=='BC', site =='MM', site ==
> 'XY',Temp,Treatment=='Local'))
> prediction =plogis(as.matrix(mod7),(ab))
>
> Thanks,
>
> MW
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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 | Threaded
Open this post in threaded view
|

Re: Any help on R code interpretation?

Ben Tupper-2
In reply to this post by Marna Wagley
Hi,

It's a bit hard to read what you have provided (don't forget that code pasted into emails on this list are best rendered if the email client is configured for plain text not html), but I suspect that it there is no %*%t. Instead, I think it should look like...

x %*% t(y)

where your x is 'mod7' and your y is all that other stuff. You might try ...

prediction = plogis( as.matrix( mod7 %*% t(ab) ) )

but that's just a guess.

Ben


> On Dec 22, 2016, at 8:08 AM, Marna Wagley <[hidden email]> wrote:
>
> HI R user,
> I was looking a r code and saw "%*%t", what does it("%*%t") mean?. The
> example is given below.
>
> For example: here is the code where "%*%t" has been used. when I run the
> formula but did not run in my data.
>
> prediction=plogis(as.matrix(mod7)%*%t(with(subset(data,site!='AB'),cbind(1,
> site=='BC', site =='MM', site =='XY',Temp,Treatment=='Local'))))
>
> Can I get the same result of above using the following code? Do both codes
> give same results?
>
> ab<-with(subset(data,site!='AB'),cbind(1,site=='BC', site =='MM', site ==
> 'XY',Temp,Treatment=='Local'))
> prediction =plogis(as.matrix(mod7),(ab))
>
> Thanks,
>
> MW
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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 | Threaded
Open this post in threaded view
|

Re: Any help on R code interpretation?

Rui Barradas
In reply to this post by Marna Wagley
Hello,

t() is the transpose function, it computes the transpose of matrix

with(subset(data,site!='AB'),cbind(1,
site=='BC', site =='MM', site =='XY',Temp,Treatment=='Local'))

then %*% is matrix multiplication. If you have doubts on the result,
compute as.matrix(mod7)%*%t(...) outside the call to plogis.

And no, the two codes do not give the same results. Read the help page
?plogis to find out the arguments to that function.

Hope this helps,

Rui Barradas

Em 22-12-2016 13:08, Marna Wagley escreveu:

> HI R user,
> I was looking a r code and saw "%*%t", what does it("%*%t") mean?. The
> example is given below.
>
> For example: here is the code where "%*%t" has been used. when I run the
> formula but did not run in my data.
>
> prediction=plogis(as.matrix(mod7)%*%t(with(subset(data,site!='AB'),cbind(1,
> site=='BC', site =='MM', site =='XY',Temp,Treatment=='Local'))))
>
> Can I get the same result of above using the following code? Do both codes
> give same results?
>
> ab<-with(subset(data,site!='AB'),cbind(1,site=='BC', site =='MM', site ==
> 'XY',Temp,Treatment=='Local'))
> prediction =plogis(as.matrix(mod7),(ab))
>
> Thanks,
>
> MW
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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 | Threaded
Open this post in threaded view
|

Re: Any help on R code interpretation?

Bert Gunter-2
In reply to this post by Marna Wagley
?"%*%"
?t

It looks like you need to spend some (more) time with an R tutorial or
two to understand basic R syntax. Please do so before posting further
here. There are many good ones on the web.

-- Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Thu, Dec 22, 2016 at 5:08 AM, Marna Wagley <[hidden email]> wrote:

> HI R user,
> I was looking a r code and saw "%*%t", what does it("%*%t") mean?. The
> example is given below.
>
> For example: here is the code where "%*%t" has been used. when I run the
> formula but did not run in my data.
>
> prediction=plogis(as.matrix(mod7)%*%t(with(subset(data,site!='AB'),cbind(1,
> site=='BC', site =='MM', site =='XY',Temp,Treatment=='Local'))))
>
> Can I get the same result of above using the following code? Do both codes
> give same results?
>
> ab<-with(subset(data,site!='AB'),cbind(1,site=='BC', site =='MM', site ==
> 'XY',Temp,Treatment=='Local'))
> prediction =plogis(as.matrix(mod7),(ab))
>
> Thanks,
>
> MW
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.