write.table of posterior probabilities error
1
0
Entering edit mode
rbronste ▴ 60
@rbronste-12189
Last seen 5.0 years ago

Hi,

I am trying to write a table of posterior probabilities from a Centipede function and having some trouble. Basically want to write.table of the results of the following command:

sum(fit$PostPr == 1)

Which gives me a certain number of sites with PostPr of 1, and I would like to write those specific sites to a TAB delimited file. Any ideas on how to go about doing this? I have tried the following:

write.table(Sox3_BTTP_peripheral_fit$PostPr = 1, "Sox3_BTTP_peripheral_fit", sep="\t")

but getting this error: Error: unexpected '=' in "write.table(Sox3_BTTP_peripheral_fit$PostPr ="

Thanks!

R centipede • 974 views
ADD COMMENT
1
Entering edit mode
@james-w-macdonald-5106
Last seen 1 day ago
United States

This is a basic error in subsetting. If this is tripping you up, you should really read An Introduction to R

There is a difference between '=' and '=='. One is an assignment operator, and the other is a comparison operator. In addition, the comparison operator returns a boolean vector, which seems not to be what you want.

ADD COMMENT
0
Entering edit mode

Thanks. Any suggestions on how to correct the mistake? 

ADD REPLY
0
Entering edit mode

I already gave you a suggestion. Read An Introduction to R. In addition, I gave you like 75% of the answer. You need to re-read what I said, and if that doesn't make sense, then you really need to read An Introduction to R. You are getting tripped up by one of the most basic operations in R, and if you can't do the basics, you probably shouldn't be doing the more advanced stuff yet.

ADD REPLY
0
Entering edit mode

Thanks for you help.

ADD REPLY

Login before adding your answer.

Traffic: 543 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6