Re: [R] Interpreting R -results for Bivariate Normal

2009-06-07 Thread Peter Dalgaard

beetle2 wrote:

HI Guys,
I know that this forum is not for homework but I am trying to interpret R
output code.
I was just wondering if someone might be able to help.


Well, if homework, we can only give hints.



I have been given the following.

For (X1,X2) distributed bivariate normal with parameters 

mu1 = 5.8  
mu2 = 5.3  
sd1 = sd2 = 0.2


and p = 0.6


That's Greek letter rho, not p, I expect.



The r-code and inpit/output are as follows

input

m <- 5.3 + 0.6*(6.3 - 5.8)
s  <- sqrt(0.2^2*(1-0.6^2))
q  <- seq(5.12,6.08,0.16)

print(rbind(q,pnorm(mean=m,sd=sd=s,q=q)))

output

q 5.1200  5.280   5.44   5.6 5.76 5.926.1
   0.0013  0.023   0.16   0.5 0.84 0.981

I have been asked to interpret 


E[X2|X1 = 6.3] and varE[X2|X1 = 6.3]


I take it that s<- = 0.16 is the standard variation


Standard _deviation_


So I am assuming that varE[X2|X1 = 6.3] = 0.16^2 = .0256

m <- 5.3 + 0.6*(6.3 - 5.8) = 5.6this the Expected value of E[X+Y]


What makes you think that? E[X+Y] is mu1+mu2.

The m calculation could also have been written

x1 <- 6.3
m <- 5.3 + 0.6*(x1 - 5.8)

Now go back to your text book and read up on the formulas that connect 
correlation and regression coefficients.





I see from the output that this would be correct because the probability of
5.6 = 0.5


to interpret E[X2|X1 = 6.3] I can't see it in the output.  And I'm not sure
how to find the conditional probabilty from the output.

Any help would be greatly appreciated







--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
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.


Re: [R] ridiculous behaviour printing to eps: labels all messed up!

2009-06-07 Thread Peter Dalgaard

maiya wrote:

OK, this is really weird!

here's an example code:

t1<-c(1,2,3,4)
t2<-c(4,2,4,2)
plot(t1~t2, xlab="exp1", ylab="exp2")
dev.copy2eps(file="test.eps")

that all seems fine...

until you look at the eps file created, where for some weird reason, if you
scroll down to the end, the code reads:

/Font1 findfont 12 s
0 setgray
214.02 18.72 (e) 0 ta
-0.360 (xp1) tb gr
12.96 206.44 (e) 90 ta
-0.360 (xp2) tb gr

Which means, that the labels "exp1" and "exp2" get split up!?!? 
Now visually that doesn't matter, but I use the labels to refer to them in

LaTeX using psfrag, so I have to know exactly what they are called in the
.eps file in order to reference them correctly. 


I've tried other labels and the splitting up seems completely random i.e
doesn't have anything to do with the length of the label etc. 


I am completely lost here, can someone help me figure out what is going on
here?

Maja



Look at the useKerning argument to postscript().

(AFAIR the rationale for the behaviour is that you cannot rely on having 
the output device do kerning while getting reliable string width 
calculations. I can't offhand recall the examples where it mattered, 
though.)


--
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45) 35327907

__
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.


Re: [R] ridiculous behaviour printing to eps: labels all messed up!

2009-06-07 Thread Zeljko Vrba
On Sun, Jun 07, 2009 at 05:00:18PM -0700, maiya wrote:
> 
> I am completely lost here, can someone help me figure out what is going on
> here?
> 
With an unrelated problem, someone suggested to me never to use dev.copy2eps,
but to open a new device with postscript() and draw the figure there.  Maybe it
will help with your problem too.

Alternatively, as a (temporary) kludge, why don't you use one-letter names?  Do
you have more than 26 labels in the diagram?

__
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.


Re: [R] Plotting two regression lines on one graph

2009-06-07 Thread David Winsemius
Since you have provided no executable data and not even a clear enough  
description of the data to offer advice regarding approaches or  
pitfalls, I will use the example in glm's help page:


counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)

glm.D93r <- glm(counts ~ outcome, family=poisson())
plot(x=as.numeric(as.character(outcome)), y=counts, type="p")  #need  
to convert from factor to ge points

lines(1:3, c(exp(3.045), exp(3.0445 -0.4543), exp(3.0445 -0.2930) ) )

#the default link for poisson is log, so you need to transform back to  
the original scale to predict counts.



On Jun 7, 2009, at 11:36 PM, Jo Stringer wrote:


I have fitted two glms assuming a poisson distribution which are:

fit1 <- glm(Aids ~ Year, data=aids, family=poisson())

fit2 <- glm(Aids ~ Year+I(Year^2), data=aids, family=poisson())


I am trying to work out how to represent the fitted regression  
curves of fit1 and fit2 on the one graph. I have tried:


graphics.off()

plot(Aids ~ Year, data = aids)


line(glm(Aids ~ Year, data=aids, family=poisson()))
line(glm(Aids ~ Year+I(Year^2), data=aids, family=poisson()))

but this does not work.

Can anyone help me?



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
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.


[R] Interpreting R -results for Bivariate Normal

2009-06-07 Thread beetle2

HI Guys,
I know that this forum is not for homework but I am trying to interpret R
output code.
I was just wondering if someone might be able to help.

I have been given the following.

For (X1,X2) distributed bivariate normal with parameters 

mu1 = 5.8  
mu2 = 5.3  
sd1 = sd2 = 0.2

and p = 0.6

The r-code and inpit/output are as follows

input

m <- 5.3 + 0.6*(6.3 - 5.8)
s  <- sqrt(0.2^2*(1-0.6^2))
q  <- seq(5.12,6.08,0.16)

print(rbind(q,pnorm(mean=m,sd=sd=s,q=q)))

output

q 5.1200  5.280   5.44   5.6 5.76 5.926.1
   0.0013  0.023   0.16   0.5 0.84 0.981

I have been asked to interpret 

E[X2|X1 = 6.3] and varE[X2|X1 = 6.3]


I take it that s<- = 0.16 is the standard variation

So I am assuming that varE[X2|X1 = 6.3] = 0.16^2 = .0256

m <- 5.3 + 0.6*(6.3 - 5.8) = 5.6this the Expected value of E[X+Y]


I see from the output that this would be correct because the probability of
5.6 = 0.5


to interpret E[X2|X1 = 6.3] I can't see it in the output.  And I'm not sure
how to find the conditional probabilty from the output.

Any help would be greatly appreciated




-- 
View this message in context: 
http://www.nabble.com/Interpreting-R--results-for-Bivariate-Normal-tp23916967p23916967.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


[R] ridiculous behaviour printing to eps: labels all messed up!

2009-06-07 Thread maiya

OK, this is really weird!

here's an example code:

t1<-c(1,2,3,4)
t2<-c(4,2,4,2)
plot(t1~t2, xlab="exp1", ylab="exp2")
dev.copy2eps(file="test.eps")

that all seems fine...

until you look at the eps file created, where for some weird reason, if you
scroll down to the end, the code reads:

/Font1 findfont 12 s
0 setgray
214.02 18.72 (e) 0 ta
-0.360 (xp1) tb gr
12.96 206.44 (e) 90 ta
-0.360 (xp2) tb gr

Which means, that the labels "exp1" and "exp2" get split up!?!? 
Now visually that doesn't matter, but I use the labels to refer to them in
LaTeX using psfrag, so I have to know exactly what they are called in the
.eps file in order to reference them correctly. 

I've tried other labels and the splitting up seems completely random i.e
doesn't have anything to do with the length of the label etc. 

I am completely lost here, can someone help me figure out what is going on
here?

Maja

-- 
View this message in context: 
http://www.nabble.com/ridiculous-behaviour-printing-to-eps%3A-labels-all-messed-up%21-tp23916638p23916638.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] extract rows having negative values

2009-06-07 Thread Manisha Brahmachary
Thank you Bill, your suggestion works just fine!!!

-Original Message-
From: bill.venab...@csiro.au [mailto:bill.venab...@csiro.au] 
Sent: Sunday, June 07, 2009 3:23 AM
To: Manisha Brahmachary; r-help@r-project.org
Subject: RE: extract rows having negative values

rownames(X)[apply(X, 1, function(r) any(r < 0))]

... if I understand you correctly.

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf
Of Manisha Brahmachary [mb3...@c2b2.columbia.edu]
Sent: 07 June 2009 08:54
To: r-help@r-project.org
Subject: [R] extract rows having negative values

Hello,



I have a matrix with 6 columns and 12 rows. I want to extract out those IDs
(rownames) from my matrix which have a negative values. For each ID(row) if
the negative value is even under 1 column it needs to be extracted out. I
will be grateful for any correct suggestion.





Thanks

Manisha



Here is the matrix that I am working on:





ID

A

B

C

D

E

F

1

-4.18972

-3.8946

-1.14888

-1.88406

-8.34124

10.97497

2

11.81028

11.1054

0.85112

0.115942

-4.34124

24.97497

3

-0.18972

-1.8946

1.85112

-4.88406

-17.3412

-13.025

4

-1.18972

3.105402

-0.14888

-12.8841

-15.3412

4.974967

6

-3.18972

4.105402

24.85112

0.115942

1.658762

-11.025

7

-2.18972

-10.8946

-20.1489

-1.88406

3.658762

-11.025

8

-0.18972

-7.8946

-7.14888

-9.88406

3.658762

-9.02503

9

-5.18972

-4.8946

-12.1489

0.115942

-12.3412

10.97497

10

17.81028

9.105402

-15.1489

10.11594

19.65876

9.974967

11

538.8103

335.1054

863.8511

229.1159

520.6588

143.975

12

30.81028

18.1054

30.85112

16.11594

9.658762

13.97497








[[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.

__
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.


Re: [R] Convert a lis to matrix

2009-06-07 Thread Manisha Brahmachary
Thank you, it worked.



-Original Message-
From: Bernardo Rangel Tura [mailto:t...@centroin.com.br] 
Sent: Sunday, June 07, 2009 6:14 AM
To: Manisha Brahmachary
Cc: r-help@r-project.org
Subject: Re: [R] Convert a lis to matrix

On Sun, 2009-06-07 at 00:14 -0400, Manisha Brahmachary wrote:
> Hello,
> 
>  
> 
> This is an urgent request. I want to convert a list of 3 elements into a
> matrix and I am not sure how to do it.
> 
>  
> 
> The list looks like this:
> 
> List of 3
> 
>  $ : num [1:15364, 1] 0.133 0.622 0.588 1.024 0.583 ...
> 
>   ..- attr(*, "dimnames")=List of 2
> 
>   .. ..$ : chr [1:15364] "6420681" "3610072" "2260458" "60689" ...
> 
>   .. ..$ : NULL
> 
>  $ : num [1:15364, 1] 3.159 0.265 0.522 1.912 3.380 ...
> 
>   ..- attr(*, "dimnames")=List of 2
> 
>   .. ..$ : chr [1:15364] "6420681" "3610072" "2260458" "60689" ...
> 
>   .. ..$ : NULL
> 
>  $ : num [1:15364, 1] 3.214 0.277 1.447 1.827 2.054 ...
> 
>   ..- attr(*, "dimnames")=List of 2
> 
>   .. ..$ : chr [1:15364] "6420681" "3610072" "2260458" "60689" ...
> 
>   .. ..$ : NULL

I'm not sure if understood your question, but look this code

a<-list(B=1:3,C=2:4,D=3:5)
matrix(unlist(a),ncol=3)




-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

__
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.


Re: [R] Plotting two regression lines on one graph

2009-06-07 Thread milton ruser
Hi Jo,

Next time try prepare a reproducible code.
You have several ways of do that (see Dylan Beaudette) and give a look
below.

x<-1:100
y<-7+x*(sqrt(x*runif(100)))

plot(y~x)

mod1<-glm(y~x)
mod2<-glm(y~x+I(x*x))
curve(mod1$coef[1]+mod1$coef[2]*x, col="red", add=T, lwd=3)
curve(mod2$coef[1]+mod2$coef[2]*x+mod2$coef[3]*x*x, col="green", add=T,
lwd=3)

cheers

milton

On Sun, Jun 7, 2009 at 11:36 PM, Jo Stringer  wrote:

> Hi!
>
>
> I have fitted two glms assuming a poisson distribution which are:
>
> fit1 <- glm(Aids ~ Year, data=aids, family=poisson())
>
> fit2 <- glm(Aids ~ Year+I(Year^2), data=aids, family=poisson())
>
>
> I am trying to work out how to represent the fitted regression curves of
> fit1 and fit2 on the one graph. I have tried:
>
> graphics.off()
>
> plot(Aids ~ Year, data = aids)
>
>
> line(glm(Aids ~ Year, data=aids, family=poisson()))
> line(glm(Aids ~ Year+I(Year^2), data=aids, family=poisson()))
>
> but this does not work.
>
> Can anyone help me?
>
> Thanks
>
> Jo
>
> BSES Limited Disclaimer
>
>
> 
>
> This email and any files transmitted with it are confide...{{dropped:15}}
>
> __
> 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.
>

[[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.


Re: [R] Plotting two regression lines on one graph

2009-06-07 Thread Dylan Beaudette
One approach to this is generating a representative sequence of your
x-variable(s) with seq() or expand.grid(). Next use the predict()
function to make predictions from your glm object along the sequence.
Finally, plot the predictions vs. the new sequence. Putting everything
into a dataframe helps.

# generate some data:
x <- rnorm(10)
y <- x * 2 + rnorm(10, sd=0.5)

# plot
plot(y ~ x)

# generate linear model:
l <- lm(y ~ x)

# generate sequence along x-var
# and predictions
d <- data.frame(x.new=seq(from=-1.5, to=1.2, by=0.1))
d$y.new <- predict(l, data.frame(x=d$x.new))

# add to plot:
lines(y.new ~ x.new, data=d, lwd=2)

Cheers,
Dylan


On Sun, Jun 7, 2009 at 8:36 PM, Jo Stringer wrote:
> Hi!
>
>
> I have fitted two glms assuming a poisson distribution which are:
>
> fit1 <- glm(Aids ~ Year, data=aids, family=poisson())
>
> fit2 <- glm(Aids ~ Year+I(Year^2), data=aids, family=poisson())
>
>
> I am trying to work out how to represent the fitted regression curves of fit1 
> and fit2 on the one graph. I have tried:
>
> graphics.off()
>
> plot(Aids ~ Year, data = aids)
>
>
> line(glm(Aids ~ Year, data=aids, family=poisson()))
> line(glm(Aids ~ Year+I(Year^2), data=aids, family=poisson()))
>
> but this does not work.
>
> Can anyone help me?
>
> Thanks
>
> Jo
>
> BSES Limited Disclaimer
>
> 
>
> This email and any files transmitted with it are confide...{{dropped:15}}
>
> __
> 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.
>

__
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.


[R] Plotting two regression lines on one graph

2009-06-07 Thread Jo Stringer
Hi!


I have fitted two glms assuming a poisson distribution which are:

fit1 <- glm(Aids ~ Year, data=aids, family=poisson())

fit2 <- glm(Aids ~ Year+I(Year^2), data=aids, family=poisson())


I am trying to work out how to represent the fitted regression curves of fit1 
and fit2 on the one graph. I have tried:

graphics.off()

plot(Aids ~ Year, data = aids)


line(glm(Aids ~ Year, data=aids, family=poisson()))
line(glm(Aids ~ Year+I(Year^2), data=aids, family=poisson()))

but this does not work.

Can anyone help me?

Thanks

Jo

BSES Limited Disclaimer



This email and any files transmitted with it are confide...{{dropped:15}}

__
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.


Re: [R] latex subscripts in title of a plot

2009-06-07 Thread Kingsford Jones
Hi Dajiang,

try

plot(1, main=expression(beta[1]))

and, more generally, see

?plotmath

or

demo(plotmath)



Kingsford Jones


On Sun, Jun 7, 2009 at 4:43 PM, Dajiang Jeff Liu wrote:
> Dear All,
> I want to ask how to make latex symbol \beta_1 into the title of the page.
> The usual bquote does not seem to work.
>
> Any ideas? Thanks a lot.
>
> Regards,
> Dajiang
>
>        [[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.
>

__
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.


[R] Random Forest % Variation vs Psuedo-R^2?

2009-06-07 Thread Ryan Harrigan
Hi all (and Andy!),
When running a randomForest run in R, I get the last part of an output
(with do.trace=T) that looks like this:

1993 |  0.04606   130.43 |
1994 |  0.04605   130.40 |
1995 |  0.04605   130.43 |
1996 |  0.04605   130.43 |
1997 |  0.04606   130.44 |
1998 |  0.04607   130.47 |
1999 |  0.04606   130.46 |
2000 |  0.04605   130.42 |

With the first column representing the iteration, the second column
representing the OOB MSE, and the last column representing the %Var(y). If I
calculate a "Psuedo-R^2" from these numbers, I would get;

1-(.04605/1.3042) = 0.965

Here's the question, if I look at the summary of forest.rf (this same run),
I get the following;

randomForest(formula = Prev ~ ., data = plas, ntree = 2000, importance =
TRUE, do.trace = T)
   Type of random forest: regression
 Number of trees: 2000
No. of variables tried at each split: 5

  Mean of squared residuals: 0.04605177
% Var explained: -30.42

What does that -30.42 % Var explained relate to? I find it interesting that
the %Var(y) is 130.42, and that the %Var explained is a very similar number,
but have no idea how they are related. From my calculations, it seems like I
have a good predictor set (Psuedo R^2 over 95%), but am I missing something?

Cheers,

Ryan


--
Ryan Harrigan, Ph.D.
Center for Tropical Research
Institute of the Environment
University of California, Los Angeles
La Kretz Hall, Suite 300
Box 951496
Los Angeles, CA 90095-1496
203-804-9505
ilu...@ucla.edu

__
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.


Re: [R] Excel Export in a beauty way

2009-06-07 Thread Tom Short
Another useful way to create a formatted Excel file is to write out an
HTML file, but put an XLS extension on it. When Excel reads it, it
will convert it. Users will treat it like an Excel file. This trick
allows you to add formatted titles, table footnotes, links to other
files (pdf graphs for example), and more.

To create HTML, you have several packages that can help you out:
R2HTML, Rpad, hwriter, and xtable. Not everything might convert
properly, so you may have to experiment. Data frames as tables
normally convert nicely.

- Tom

Tom Short

__
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.


Re: [R] Scrolling behavior in View()

2009-06-07 Thread Duncan Murdoch

On 07/06/2009 9:50 AM, Jose Quesada wrote:

Hi,

I've realized that the scrolling behavior in View() is unlike most other
applications. It seems that the minimum scroll size is very large for
large objects( i.e., a vector of 1M integers), and it might be that this
scroll is proportional to the size of the object.
Try this:
a = 1:100
View(a)
Click once on the scroll arrow down. It will move to item 1001.

It could be that the scroll size is 1/1000 object length.

If this is so, it's a bit of a problem, since there's no way to View say
cell 500... unless one does a View(head(a, 500)), which kind of defeats
the point of view.

Is this behavior by design? If so, wouldn't it be better to make it
optional (as it breaks GUI conventions of mostly any OS for scrolling
behavior)? An argument for view to turn this off would be great.


This should be fixed now.  Please try R-patched dated June 8 or later, 
and let me know if there are any more problems.


Duncan Murdoch

__
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.


[R] Reminder: useR Group SFBA - R Graphics Survey - Nicholas Lewin-Koh

2009-06-07 Thread Jim Porzak
All San Francisco Bay Area useRs:

This Wednesday evening Nicholas is presenting a survey of statistical
visualization best practices & corresponding methods in R.

For details see http://www.meetup.com/R-Users/calendar/9763376/

Note this is our last meeting before the summer break.

Hope to see many of you there!

Best,
Jim Porzak
www.TGN.com
San Francisco, CA
www.linkedin.com/in/jimporzak
use R! Group SF: www.meetup.com/R-Users/

[[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.


Re: [R] graphically representing frequency of words in a speech?

2009-06-07 Thread Mike Lawrence
Below are various attempts using using ggplot2
(http://had.co.nz/ggplot2/). First I try random positioning, then
random positioning with alpha, then a quasi-random position scheme in
polar coordinates:

#this demo has random number generation
# so best to set a seed to make it
# reproducible.
set.seed(1)

#generate some fake data
a = data.frame(
word = month.name
, freq = sample(1:10,12,replace=TRUE)
)

#add arbitrary location information
a$x = sample(1:12,12)
a$y = sample(1:12,12)

#load ggplot2
library(ggplot2)

#initialize a ggplot object
my_plot = ggplot()

#create an object for the text layer
my_text = geom_text(
data = a
, aes(
x = x
, y = y
, label = word
, size = freq
)
)

#create an object for the text size limits
my_size_scale = scale_size(
to = c(3,20)
)

#create an object to expand the x-axis limits
# (ensures that text isn't cropped)
my_x_scale = scale_x_continuous(
expand = c(.5, 0)
)

#ditto for the y axis
my_y_scale = scale_y_continuous(
expand = c(.5, 0)
)

#create an opts object that removes
# plot elements unnecessary in a tag cloud
my_opts = opts(
legend.position = 'none'
, panel.grid.minor = theme_blank()
, panel.grid.major = theme_blank()
, panel.background = theme_blank()
, axis.line = theme_blank()
, axis.text.x = theme_blank()
, axis.text.y = theme_blank()
, axis.ticks = theme_blank()
, axis.title.x = theme_blank()
, axis.title.y = theme_blank()
)

#show the plot
print(
my_plot+
my_text+
my_size_scale+
my_x_scale+
my_y_scale+
my_opts
)

#to aid readability amidst overlap, set alpha in
# the call to geom_text
my_text_with_alpha = geom_text(
data = a
, aes(
x = x
, y = y
, label = word
, size = freq
)
, alpha = .5
)

#show the version with alpha
print(
my_plot+
my_text_with_alpha+
my_size_scale+
my_x_scale+
my_y_scale+
my_opts
)

#alternatively, in polar coordinates,
# which maps x to angle and y to radius,
# making a nice circle
print(
my_plot+
my_text_with_alpha+
my_size_scale+
my_opts+
coord_polar()
)
#(note omission of my_y_scale &
# my_x_scale, which seem to be ignored
# when coord_polar() is called. I'll
# report this possible bug to the ggplot2
# maintainer)

#a possible way to avoid overlap is to
# map radius (y) to frequency so that
# larger text is in the periphery
# where there is more room. This
# necessitates adding some random
# noise to the frequency so that
# the low frequency words don't
# jumble in the center too badly
a$freq2 = a$freq+rnorm(12)

#now map radius (y) to freq2
my_text_with_alpha_and_freq2 = geom_text(
data = a
, aes(
x = x
, y = freq2
, label = word
, size = freq
)
, alpha = .5
)

#show the version with alpha & radius mapped to freq2
print(
my_plot+
my_text_with_alpha_and_freq2+
my_size_scale+
my_opts+
coord_polar()
)

-- 
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University

Looking to arrange a meeting? Check my public calendar:
http://tr.im/mikes_public_calendar

~ Certainty is folly... I think. ~

__
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.


[R] Must be a better way to collate sequenced data

2009-06-07 Thread Burke, Robin
I have data that looks like this

time_stamp (seconds)  user_id

The data is (partial) ordered by time - in that sometimes transactions occur at 
the same timestamp. The output I want is collated by transaction time on a per 
user basis, normalized by the maximum number of transactions per user, and 
aggregated over each day. So, if the users have 50 transactions in the first 
day and 20 transactions on the second day, and 10 transactions on the third 
day, the output would be as follows, if each transaction represents 0.01% of 
each user's total profile. (In reality, they all have different profile lengths 
so a transaction represents a different percentage for each user.)

time_since_first_transaction (days)percent_of_profile
1  
0.50
2  
0.20
3  
0.10

I have the following code that computes the right answer, but it is really 
inefficient, so I'm sure that I'm doing something wrong. Really inefficient 
means > 30 minutes for an 100 k item data frame on a 2.2 GHz machine, and my 
1-million data set has never finished. I'm no stranger to functional 
programming (Lisp programmer) but I can't figure out a way to subtract the 
first timestamp for user A from all of the other timestamps for user A without 
either (a) building a separate table of "first entries for each user", which I 
do here, or (b) re-computing the initial entry for each user with every row, 
which is what I did before and is even more inefficient. Another killer 
operation seems to be the aggregate step on the last line, which I use to 
collate the data by days. It seems very slow, but I don't know any other way to 
do this. I realize that I am living proof that one can program in C no matter 
what language one uses - so I would appreciate any enlightenment on offer. If !
 there's no better way, I'll pre-process everything in Perl, but I'd rather 
learn the "R" way to do things like this. Thanks.

# Build table of times
utime.times <<- utime.data["TIME"] %/% period;
utime.tstart <<- vector("numeric", 
length=max(utime.data["USER"]));
for (i in 1:nrow(utime.data))
{
if (as.numeric(utime.data[i, "USER_COUNT"])==1)
{
day <- utime.times[i, "TIME"];
user <- utime.data[i, "USER"];
utime.tstart[user] <<- day;
}
}

# Build table of maximum profile sizes
utime.userMax <<- aggregate(utime.data["USER_COUNT"],

utime.data["USER"],
max);

utime.atimes <<- vector("numeric", length=nrow(utime.data));
utime.aperc <<- vector("numeric", length=nrow(utime.data));
augdata <<- as.data.frame(cbind(utime.atimes, utime.aperc));
names(augdata) <<- c("TIME", "PERC");
for (i in 1:nrow(utime.data))
{
# adjust time according to user start time
augdata[i, "TIME"] <<-
utime.times[i,"TIME"] -

utime.tstart[utime.data[i,"USER"]];
# look up maximum user count
umax <- subset(utime.userMax,

USER==as.numeric(utime.data[i, "USER"]))["USER_COUNT"];
augdata[i, "PERC"] <<- 1.0/umax;
}

utime.rcount <<- aggregate(augdata, augdata["TIME"], sum);



Robin Burke
Associate Professor
School of Computer Science, Telecommunications, and
   Information Systems
DePaul University
(currently on leave at University College Dublin)

http://josquin.cti.depaul.edu/~rburke/

"The universe is made of stories, not of atoms" - Muriel Rukeyser


[[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.


[R] latex subscripts in title of a plot

2009-06-07 Thread Dajiang Jeff Liu
Dear All,
I want to ask how to make latex symbol \beta_1 into the title of the page.
The usual bquote does not seem to work.

Any ideas? Thanks a lot.

Regards,
Dajiang

[[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.


Re: [R] graphically representing frequency of words in a speech?

2009-06-07 Thread Brown, Tony Nicholas
Thank you so much Mark and Gregor. The basic information, suggestions,
and R code that you provided is most helpful. 

Tony

-Original Message-
From: Gorjanc Gregor [mailto:gregor.gorj...@bfro.uni-lj.si] 
Sent: Sunday, June 07, 2009 2:17 PM
To: Marc Schwartz; Brown, Tony Nicholas
Cc: rhelp help
Subject: RE: [R] graphically representing frequency of words in a
speech?

> The only thing that I found for R is by Gregor Gorjanc, but the
> information seems to be dated:
>
>http://www.bfro.uni-lj.si/MR/ggorjan/software/R/index.html#tagCloud

Hi,

Yes, I have tried to create a tag cloud plot in R, but I abandoned the
project
due to other things. The main obstacle was that in R we need to take
care of the fontsizes and placement of words, while this is very easy
with
say browsers, who do all the renderind. I tracked the last version of
the R file
which is pasted bellow. I must say that I do not remember the status of
the
code so use it as you wish. If anyone wishes to take this project
further, please
do so!

gg

### tagCloud.R
###-
---
### What: Tag cloud plot functions
### Time-stamp: <2006-09-10 02:53:29 ggorjan>
###-
---

tagCloud <- function(x, n=100, decreasing=TRUE,
 threshold=NULL, fontsize=c(12, 36),
 align=TRUE, expandRow=TRUE,
 justRow="bottom", title,
 textGpar=gpar(col="navy"),
 rectGpar=gpar(col="white"),
 titleGpar=gpar(), viewGpar=gpar(),
 mar=c(1, 1, 1, 1))
{
  UseMethod("tagCloud")
}

tagCloud.default <- function(x, n=100, decreasing=TRUE,
 threshold=NULL, fontsize=c(12, 36),
 align=TRUE, expandRow=TRUE,
 justRow="bottom", title,
 textGpar=gpar(col="navy"),
 rectGpar=gpar(col="white"),
 titleGpar=gpar(), viewGpar=gpar(),
 mar=c(1, 1, 1, 1))
{
  if(!is.null(dim(x))) stop("'x' must be a vector")

  tagCloud.table(table(x), n=n, decreasing=decreasing,
fontsize=fontsize,
 threshold=threshold, align=align, expandRow=expandRow,
 justRow=justRow, title=title, textGpar=textGpar,
 rectGpar=rectGpar, titleGpar=titleGpar,
viewGpar=viewGpar,
 mar=mar)
}

tagCloud.table <- function(x, n=100, decreasing=TRUE,
   threshold=NULL, fontsize=c(12, 36),
   align=TRUE, expandRow=TRUE,
   justRow="bottom", title,
   textGpar=gpar(col="navy"),
   rectGpar=gpar(col="white"),
   titleGpar=gpar(), viewGpar=gpar(),
   mar=c(1, 1, 1, 1))
{
  ## --- Check ---

  if(length(dim(x)) != 1)
stop("'x' must be one dimensional table")

  ## --- Threshold ---

  if(!is.null(threshold)) x <- x[x >= threshold]

  ## --- Number of units ---

  N <- length(x)## length of table
  if(is.null(n)) {  ## if n=NULL, plot all units
n <- N
  } else {
if(n > N) n <- N## if n is to big, decrease it
if(n < 1) n <- round(N * n) ## if n is percentage of units
  }

  fontsizeLength <- length(fontsize)
  if(fontsizeLength != 2)
stop("'fontsize' must be of length two")

  ## --- Sort and subset ---

  if(n < N) { ## only if we want to plot subset of units
tmp <- sort(x, decreasing=decreasing)
x <- x[names(x) %in% names(tmp[1:n])]
  }

  ## --- Get relative freq ---

  x <- prop.table(x)

  ## --- Fontsize ---

  fontsizeDiff <- diff(fontsize)
  xDiff <- max(x) - min(x)
  if(xDiff != 0) {
off <- ifelse(fontsizeDiff > 0, min(x), max(x))
fontsize <- (x - off) / xDiff * fontsizeDiff + min(fontsize)
  } else { ## all units have the same frequency
fontsize <- rep(min(fontsize), times=n)
  }

  ## --- Viewport and rectangle ---

  grid.newpage()
  width <- unit(1, "npc")
  height <- unit(1, "npc")
  vp <- viewport(y=unit(mar[1], "lines"), x=unit(mar[2], "lines"), ,
 width=width - unit(mar[2] + mar[4], "lines"),
 height=height - unit(mar[1] + mar[3], "lines"),
 just=c("left", "bottom"), gp=viewGpar, name="main")
  pushViewport(vp)

  if(!missing(title))
grid.text(title, y=height, gp=titleGpar, name="title")

  grid.rect(gp=rectGpar, name="cloud")

  ## --- Grobs ---

  tag <- vector(mode="list", length=4)
  names(tag) <- c("fontsize", "grob", "width", "height")
  tag[[1]] <- tag[[2]] <- tag[[3]] <- tag[[4]] <- vector(mode="list",
length=n)
  for(i in 1:n) {
tag$fontsize[[i]] <- fontsize[i]
tag$grob[[i]] <- textGrob(names(x[i]),
gp=gpar(fontsize=fontsize[i]))
tag$width[[i]] <- convertWidth(grobWidth(tag$grob[[i]]),
uni

Re: [R] graphically representing frequency of words in a speech?

2009-06-07 Thread Gorjanc Gregor
> The only thing that I found for R is by Gregor Gorjanc, but the
> information seems to be dated:
>
>http://www.bfro.uni-lj.si/MR/ggorjan/software/R/index.html#tagCloud

Hi,

Yes, I have tried to create a tag cloud plot in R, but I abandoned the project
due to other things. The main obstacle was that in R we need to take
care of the fontsizes and placement of words, while this is very easy with
say browsers, who do all the renderind. I tracked the last version of the R file
which is pasted bellow. I must say that I do not remember the status of the
code so use it as you wish. If anyone wishes to take this project further, 
please
do so!

gg

### tagCloud.R
###
### What: Tag cloud plot functions
### Time-stamp: <2006-09-10 02:53:29 ggorjan>
###

tagCloud <- function(x, n=100, decreasing=TRUE,
 threshold=NULL, fontsize=c(12, 36),
 align=TRUE, expandRow=TRUE,
 justRow="bottom", title,
 textGpar=gpar(col="navy"),
 rectGpar=gpar(col="white"),
 titleGpar=gpar(), viewGpar=gpar(),
 mar=c(1, 1, 1, 1))
{
  UseMethod("tagCloud")
}

tagCloud.default <- function(x, n=100, decreasing=TRUE,
 threshold=NULL, fontsize=c(12, 36),
 align=TRUE, expandRow=TRUE,
 justRow="bottom", title,
 textGpar=gpar(col="navy"),
 rectGpar=gpar(col="white"),
 titleGpar=gpar(), viewGpar=gpar(),
 mar=c(1, 1, 1, 1))
{
  if(!is.null(dim(x))) stop("'x' must be a vector")

  tagCloud.table(table(x), n=n, decreasing=decreasing, fontsize=fontsize,
 threshold=threshold, align=align, expandRow=expandRow,
 justRow=justRow, title=title, textGpar=textGpar,
 rectGpar=rectGpar, titleGpar=titleGpar, viewGpar=viewGpar,
 mar=mar)
}

tagCloud.table <- function(x, n=100, decreasing=TRUE,
   threshold=NULL, fontsize=c(12, 36),
   align=TRUE, expandRow=TRUE,
   justRow="bottom", title,
   textGpar=gpar(col="navy"),
   rectGpar=gpar(col="white"),
   titleGpar=gpar(), viewGpar=gpar(),
   mar=c(1, 1, 1, 1))
{
  ## --- Check ---

  if(length(dim(x)) != 1)
stop("'x' must be one dimensional table")

  ## --- Threshold ---

  if(!is.null(threshold)) x <- x[x >= threshold]

  ## --- Number of units ---

  N <- length(x)## length of table
  if(is.null(n)) {  ## if n=NULL, plot all units
n <- N
  } else {
if(n > N) n <- N## if n is to big, decrease it
if(n < 1) n <- round(N * n) ## if n is percentage of units
  }

  fontsizeLength <- length(fontsize)
  if(fontsizeLength != 2)
stop("'fontsize' must be of length two")

  ## --- Sort and subset ---

  if(n < N) { ## only if we want to plot subset of units
tmp <- sort(x, decreasing=decreasing)
x <- x[names(x) %in% names(tmp[1:n])]
  }

  ## --- Get relative freq ---

  x <- prop.table(x)

  ## --- Fontsize ---

  fontsizeDiff <- diff(fontsize)
  xDiff <- max(x) - min(x)
  if(xDiff != 0) {
off <- ifelse(fontsizeDiff > 0, min(x), max(x))
fontsize <- (x - off) / xDiff * fontsizeDiff + min(fontsize)
  } else { ## all units have the same frequency
fontsize <- rep(min(fontsize), times=n)
  }

  ## --- Viewport and rectangle ---

  grid.newpage()
  width <- unit(1, "npc")
  height <- unit(1, "npc")
  vp <- viewport(y=unit(mar[1], "lines"), x=unit(mar[2], "lines"), ,
 width=width - unit(mar[2] + mar[4], "lines"),
 height=height - unit(mar[1] + mar[3], "lines"),
 just=c("left", "bottom"), gp=viewGpar, name="main")
  pushViewport(vp)

  if(!missing(title))
grid.text(title, y=height, gp=titleGpar, name="title")

  grid.rect(gp=rectGpar, name="cloud")

  ## --- Grobs ---

  tag <- vector(mode="list", length=4)
  names(tag) <- c("fontsize", "grob", "width", "height")
  tag[[1]] <- tag[[2]] <- tag[[3]] <- tag[[4]] <- vector(mode="list", length=n)
  for(i in 1:n) {
tag$fontsize[[i]] <- fontsize[i]
tag$grob[[i]] <- textGrob(names(x[i]), gp=gpar(fontsize=fontsize[i]))
tag$width[[i]] <- convertWidth(grobWidth(tag$grob[[i]]), unitTo="npc",
   valueOnly=TRUE)
tag$height[[i]] <- convertHeight(grobHeight(tag$grob[[i]]), unitTo="npc",
 valueOnly=TRUE)
  }

  ## --- Split lines ---

  row <- colWidth <- vector(length=n)
  row[1] <- 1
  colWidth[1] <- 0
  lineWidth <- tag$width[[1]]
  j <- 1
  gapWidth <- convertWidth(stringWidth(" "), u

Re: [R] graphically representing frequency of words in a speech?

2009-06-07 Thread Marc Schwartz


On Jun 7, 2009, at 1:41 PM, Brown, Tony Nicholas wrote:


Dear all,

I recently saw a graph on television that displayed selected
words/phrases in a speech scaled in size according to their frequency.
So words/phrases that were often used appeared large and words that  
were

rarely used appeared small. The closest thing I can find on the web to
approximate what I saw can be found here:
http://stateoftheunion.onetwothree.net/ The example at that website is
more complicated but captures the general idea.

Would someone point me in the right direction in terms of replicating
such a graph.

Thanks in advance,

Tony


Tony,

What you are referring to is called a 'tag cloud'. See this page:

  http://en.wikipedia.org/wiki/Tag_cloud

They are commonly used on wikis, Twitter and so forth. For example:

  http://tweetstats.com/trends


The only thing that I found for R is by Gregor Gorjanc, but the  
information seems to be dated:


  http://www.bfro.uni-lj.si/MR/ggorjan/software/R/index.html#tagCloud

I have cc'd him here for any updates.

Otherwise, there are some links on the Wikipedia page and some other  
applications such as Wordle:


  http://www.wordle.net/

HTH,

Marc Schwartz

__
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.


[R] graphically representing frequency of words in a speech?

2009-06-07 Thread Brown, Tony Nicholas
Dear all,

 

I recently saw a graph on television that displayed selected
words/phrases in a speech scaled in size according to their frequency.
So words/phrases that were often used appeared large and words that were
rarely used appeared small. The closest thing I can find on the web to
approximate what I saw can be found here:
http://stateoftheunion.onetwothree.net/ The example at that website is
more complicated but captures the general idea.

 

Would someone point me in the right direction in terms of replicating
such a graph.

 

Thanks in advance,

Tony

 


-

Tony N. Brown, Ph.D.

Editor-Elect, American Sociological Review

Associate Professor of Sociology and Human and Organizational
Development (secondary)

Program Faculty, Effective Health Communication and African American &
Diaspora Studies

Faculty Head of Hank Ingram House, The Commons

Vanderbilt University

(615) 322-7518

(615) 322-7505 fax




[[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.


Re: [R] How do I construct a one matrix from another? (newbie)

2009-06-07 Thread Jorge Ivan Velez
Dear jonathanbriggs,
Try

x <- read.table(textConnection("CustID itemID
1a
1b
2c
3a
3c"),header=TRUE)
closeAllConnections()

with(x, tapply(CustID, itemID, paste, collapse=",") )
#   abc
# "1,3"  "1" "2,3"

with(x, tapply(itemID, CustID, paste, collapse=",") )
#   123
#"a,b"  "c" "a,c"

HTH,

Jorge


On Sun, Jun 7, 2009 at 1:26 PM, jonathanbriggs wrote:

>
> Apologies if this is an obvious question but I am teaching myself R and the
> occasional push in the right direction is much appreciated?
>
> I have a data.frame containing data that looks like this
>
> CustID itemID
> 1a
> 1b
> 2c
> 3a
> 3c
>
> I want to assemble the vector of all the items bought by a particular
> customer and can't quite see how to do it.
>
> What is the best way to represent the answers for a single customer and by
> all customers?
>
> Thanks.
> --
> View this message in context:
> http://www.nabble.com/How-do-I-construct-a-one-matrix-from-another--%28newbie%29-tp23913248p23913248.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> 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.
>

[[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.


Re: [R] How do I construct a one matrix from another? (newbie)

2009-06-07 Thread Dylan Beaudette
Hi,
some ideas:

?split
?by

library(plyr)
?ddply

Cheers,
Dylan


On Sun, Jun 7, 2009 at 10:26 AM, jonathanbriggs wrote:
>
> Apologies if this is an obvious question but I am teaching myself R and the
> occasional push in the right direction is much appreciated?
>
> I have a data.frame containing data that looks like this
>
> CustID itemID
> 1        a
> 1        b
> 2        c
> 3        a
> 3        c
>
> I want to assemble the vector of all the items bought by a particular
> customer and can't quite see how to do it.
>
> What is the best way to represent the answers for a single customer and by
> all customers?
>
> Thanks.
> --
> View this message in context: 
> http://www.nabble.com/How-do-I-construct-a-one-matrix-from-another--%28newbie%29-tp23913248p23913248.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> 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.
>

__
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.


[R] How do I construct a one matrix from another? (newbie)

2009-06-07 Thread jonathanbriggs

Apologies if this is an obvious question but I am teaching myself R and the
occasional push in the right direction is much appreciated?

I have a data.frame containing data that looks like this

CustID itemID
1a
1b
2c
3a
3c

I want to assemble the vector of all the items bought by a particular
customer and can't quite see how to do it.

What is the best way to represent the answers for a single customer and by
all customers?

Thanks.
-- 
View this message in context: 
http://www.nabble.com/How-do-I-construct-a-one-matrix-from-another--%28newbie%29-tp23913248p23913248.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] Need some help in R : value more than equals to a row.

2009-06-07 Thread Gabor Grothendieck
Try this:

t(apply(m, 1, function(x) colMeans(outer(x, x, ">="


On Sun, Jun 7, 2009 at 10:09 AM, suparna
mitra wrote:
> Hallo,
>  I was trying some code, but couldn't make one step of the code properly.
> Can anybody  please  help me?
>
> I have one matrix like this
>> values
>          [,1]       [,2]       [,3]      [,4]      [,5]
> [1,] 0.778 0.3611 0. 0.139 0.000
> [2,] 1.000 0. 0.53846154 0.000 0.5384615
> [3,] 0.520 0.4800 0.6400 0.000 0.880
> [4,] 0.8928571 1. 0. 0.8928571 0.1071429
>
>
> And I want to get some matrix like:
>> values.new
>      [,1]  [,2]  [,3]  [,4]  [,5]
> [1,] 0.2  0.4  0.6  0.8  1.0
> [2,] 0.2  1.0  0.6  1.0  0.6
> [3,] 0.6  0.8  0.4  1.0  0.2
> [4,] 0.6  0.2  1.0  0.6  0.8
>
>
> This table should be computed by taking proportion of values in the row that
> are larger or equals to the value being considered with the total no of
> objects in the row.
>
> for example
>> values[1,2]
> [1] 0.361
> and
>> values[1,]
> [1] 0.778 0.361 0.222 0.139 0.000 0.861
> So there are two numbers more than equals to values[1,2]
> So
>> values.new[1,2]= 2/length(values[1,])
>
>
>
> With best regard,
> Suparna
> 
> Ms Suparna Mitra
> Eberhard-Karls-Universität Tübingen
> Wilhelm-Schickard-Institut
> Algorithmen der Bioinformatik
> Sand 14, 72076 Tuebingen
> Germany
> Tel. ++49-7071-29 70453 (0)
> Fax ++49-7071-29 5148 (0)
> Phone: ++49-176-20361469 (M)
>            ++49-7071-1477169 (R)
> Alternative e-mail: mi...@informatik.uni-tuebingen.de
>
>        [[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.
>
>

__
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.


Re: [R] Need some help in R : value more than equals to a row.

2009-06-07 Thread Jakson Alves de Aquino
suparna mitra wrote:
> Hallo,
>  I was trying some code, but couldn't make one step of the code properly.
> Can anybody  please  help me?
> 
> I have one matrix like this
>> values
>   [,1]   [,2]   [,3]  [,4]  [,5]
> [1,] 0.778 0.3611 0. 0.139 0.000
> [2,] 1.000 0. 0.53846154 0.000 0.5384615
> [3,] 0.520 0.4800 0.6400 0.000 0.880
> [4,] 0.8928571 1. 0. 0.8928571 0.1071429
> 
> 
> And I want to get some matrix like:
>> values.new
>   [,1]  [,2]  [,3]  [,4]  [,5]
> [1,] 0.2  0.4  0.6  0.8  1.0
> [2,] 0.2  1.0  0.6  1.0  0.6
> [3,] 0.6  0.8  0.4  1.0  0.2
> [4,] 0.6  0.2  1.0  0.6  0.8
> 
> 
> This table should be computed by taking proportion of values in the row that
> are larger or equals to the value being considered with the total no of
> objects in the row.

I think the code below do what you want, but I would like to know how to
do it with one of the *apply functions:

m <- read.table(stdin(), header=F)
0.778 0.3611 0. 0.139 0.000
1.000 0. 0.53846154 0.000 0.5384615
0.520 0.4800 0.6400 0.000 0.880
0.8928571 1. 0. 0.8928571 0.1071429

m <- as.matrix(m)
bdim <- dim(m)
m2 <- m
for(i in 1:bdim[1])
  for(j in 1:bdim[2])
m2[i,j] <- sum(m[i,j] <= m[i,]) / bdim[2]
m2

__
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.


[R] Need some help in R : value more than equals to a row.

2009-06-07 Thread suparna mitra
Hallo,
 I was trying some code, but couldn't make one step of the code properly.
Can anybody  please  help me?

I have one matrix like this
> values
  [,1]   [,2]   [,3]  [,4]  [,5]
[1,] 0.778 0.3611 0. 0.139 0.000
[2,] 1.000 0. 0.53846154 0.000 0.5384615
[3,] 0.520 0.4800 0.6400 0.000 0.880
[4,] 0.8928571 1. 0. 0.8928571 0.1071429


And I want to get some matrix like:
> values.new
  [,1]  [,2]  [,3]  [,4]  [,5]
[1,] 0.2  0.4  0.6  0.8  1.0
[2,] 0.2  1.0  0.6  1.0  0.6
[3,] 0.6  0.8  0.4  1.0  0.2
[4,] 0.6  0.2  1.0  0.6  0.8


This table should be computed by taking proportion of values in the row that
are larger or equals to the value being considered with the total no of
objects in the row.

for example
> values[1,2]
[1] 0.361
and
> values[1,]
[1] 0.778 0.361 0.222 0.139 0.000 0.861
So there are two numbers more than equals to values[1,2]
So
> values.new[1,2]= 2/length(values[1,])



With best regard,
Suparna

[[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.


[R] Need some help in R : value more than equals to a row.

2009-06-07 Thread suparna mitra
Hallo,
 I was trying some code, but couldn't make one step of the code properly.
Can anybody  please  help me?

I have one matrix like this
> values
  [,1]   [,2]   [,3]  [,4]  [,5]
[1,] 0.778 0.3611 0. 0.139 0.000
[2,] 1.000 0. 0.53846154 0.000 0.5384615
[3,] 0.520 0.4800 0.6400 0.000 0.880
[4,] 0.8928571 1. 0. 0.8928571 0.1071429


And I want to get some matrix like:
> values.new
  [,1]  [,2]  [,3]  [,4]  [,5]
[1,] 0.2  0.4  0.6  0.8  1.0
[2,] 0.2  1.0  0.6  1.0  0.6
[3,] 0.6  0.8  0.4  1.0  0.2
[4,] 0.6  0.2  1.0  0.6  0.8


This table should be computed by taking proportion of values in the row that
are larger or equals to the value being considered with the total no of
objects in the row.

for example
> values[1,2]
[1] 0.361
and
> values[1,]
[1] 0.778 0.361 0.222 0.139 0.000 0.861
So there are two numbers more than equals to values[1,2]
So
> values.new[1,2]= 2/length(values[1,])



With best regard,
Suparna

Ms Suparna Mitra
Eberhard-Karls-Universität Tübingen
Wilhelm-Schickard-Institut
Algorithmen der Bioinformatik
Sand 14, 72076 Tuebingen
Germany
Tel. ++49-7071-29 70453 (0)
Fax ++49-7071-29 5148 (0)
Phone: ++49-176-20361469 (M)
++49-7071-1477169 (R)
Alternative e-mail: mi...@informatik.uni-tuebingen.de

[[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.


Re: [R] Journal Articles that Have Used R

2009-06-07 Thread Ted Harding
On 07-Jun-09 14:01:14, Ted Harding wrote:
> I think the reason Google will not find it is that, in the Journal
> website, the R files (and the names of the article directories that
> might contain them, such as journal.sjdm.org/8210/ -- see below)
> are not directly pointed to by any index.html or any
> " ... " in the website, as far as I can see. This would
> be why 'wget' cannot find them in HTTP mode, and it would prevent
> Google being led to them.
> [... ... ...]
> This all seems to be overkill, however! Much easier if the site
> would accept FTP.
> Ted.

Or, as Jonathan has now done, the R files were pointed to by links within
the web-page! :)
Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 07-Jun-09   Time: 15:41:49
-- XFMail --

__
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.


Re: [R] Scrolling behavior in View()

2009-06-07 Thread Duncan Murdoch

On 07/06/2009 9:50 AM, Jose Quesada wrote:

Hi,

I've realized that the scrolling behavior in View() is unlike most other
applications. It seems that the minimum scroll size is very large for
large objects( i.e., a vector of 1M integers), and it might be that this
scroll is proportional to the size of the object.
Try this:
a = 1:100
View(a)
Click once on the scroll arrow down. It will move to item 1001.

It could be that the scroll size is 1/1000 object length.

If this is so, it's a bit of a problem, since there's no way to View say
cell 500... unless one does a View(head(a, 500)), which kind of defeats
the point of view.

Is this behavior by design? If so, wouldn't it be better to make it
optional (as it breaks GUI conventions of mostly any OS for scrolling
behavior)? An argument for view to turn this off would be great.


You didn't say which version or platform you were using.  I see it on 
Windows 2.9.0 and R-devel.


The behaviour you describe (scrolling 1/1000 of the object) happens when 
the object has more than 1 items in it.  If I temporarily disable 
it, things are worse:  then there is no easy way I can find to get to 
the bottom of the object.   There appear to be some 16 bit overflows 
happening if you try to drag the scrollbar slider down too far.  The 
reason for this is that Windows only provides 16 bits of information in 
the scrolling message; however, there are workarounds to get 32 bit 
positions.  I'll see if I can add them to our code.


Duncan Murdoch

__
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.


Re: [R] RPostgreSQL segfault with LEFT JOIN

2009-06-07 Thread Dirk Eddelbuettel

On 7 June 2009 at 06:40, Neil Tiffin wrote:
| I am adding your note to google code issues 
(http://code.google.com/p/rpostgresql/issues/list 
| ), issue Number 1.  Normally I monitor R-SIG-DB 
(https://stat.ethz.ch/mailman/listinfo/r-sig-db 
| ).

That list seems most appropriate.
 
| Hope to look at these in the next couple of weeks.
| 
| Thanks, for the suggested changes.

Thanks from my end too. 

It does compile, and it passes the existing tests that R CMD check runs so it
looks good so far. It also passes simple

 select foofrom bar 
 select foo as fii from bar

where the second form bombed without the patch.  So thanks!!

[ Incidentally, I am having issues with googlecode.com which no longer wants
me to connect / update / initialise from home behind NAT and a simple
firewall:

e...@ron:~/svn/rpostgresql> svn up
svn: OPTIONS of 'https://rpostgresql.googlecode.com/svn/trunk': could not 
connect to server (https://rpostgresql.googlecode.com)
e...@ron:~/svn/rpostgresql>

Does anybody know what's happening there?  I can check out etc fine from
another machine somewhere else. I can connect and authenticate fine to the
https url using a browswer, it is just svn that croaks.  Ideas ? Does this
now need rpc or portmap back to me? ]

Dirk

| Neil
| 
| On Jun 6, 2009, at 11:18 PM, Joe Conway wrote:
| 
| > Dylan Beaudette wrote:
| >> After some further investigation, I see that the query works fine  
| >> if I *do not use column aliases* :
| >
| > Looks like *any* query using a column alias will segfault unless the  
| > alias exactly matches the column name (in which case why bother).  
| > The code starting at line 423 in RS-PostgreSQL.c looks like:
| >
| > 8<---
| >if(PQftablecol(my_result,j) !=0) {
| >
| >/* Code to find whether a row can be nullable or not */
| >sprintf(buff,
| >"select attnotnull from pg_attribute
| > where attrelid=%d and attname='%s'",
| >PQftable(my_result,j),(char*)PQfname(my_result,j));
| >res = PQexec (conn, buff );
| >
| >if(strcmp(PQgetvalue(res,0,0),"f")==0) {
| > 8<---
| > The crash occurs at line 430 (the strcmp()) because PQgetvalue(res, 
| > 0,0) returns NULL.
| >
| > PQfname() will return the column alias, not the actual column name,  
| > therefore the PQexec() here returns no results. At the very least,  
| > PQresultStatus(res) or perhaps PQntuples(res) should be used  
| > immediately after PQexec() to ensure you have a good result before  
| > trying to use it in strcmp().
| >
| > In any case, I think the simple fix (untested) is something like:
| >
| > 8<---
| >if(PQftablecol(my_result,j) !=0) {
| >
| >/* Code to find whether a row can be nullable or not */
| >sprintf(buff,
| >"select attnotnull from pg_attribute
| > where attrelid=%d and attnum=%d",
| >PQftable(my_result,j),PQftablecol(my_result,j));
| > 8<---
| > i.e. use the table column number and pg_attribute.attnum field.
| >
| > This is beyond what is appropriate for r-help, so I suggest any  
| > further discussion go off-list (or is there somewhere more  
| > appropriate, e.g. r-devel?)
| >
| > HTH,
| >
| > Joe
| >
| 

-- 
Three out of two people have difficulties with fractions.

__
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.


Re: [R] Journal Articles that Have Used R

2009-06-07 Thread Ted Harding
I think the reason Google will not find it is that, in the Journal
website, the R files (and the names of the article directories that
might contain them, such as journal.sjdm.org/8210/ -- see below)
are not directly pointed to by any index.html or any
" ... " in the website, as far as I can see. This would
be why 'wget' cannot find them in HTTP mode, and it would prevent
Google being led to them.

On the other hand, if one knows the name of a directory, then
a wget on that directory will assemble its list of contents into
an "index.html" file on the local machine, from which the names
of any ".R" files can be extracted with a bit of greppery.

For example,
  wget http://journal.sjdm.org/8210/
creates a local file "index.html", and then
  grep '[.]R' index.html
outputs:

probs.R09-Dec-2008 14:37
  1.0K

test.R23-May-2008 05:46
  251 

thus revealing the two R files "probs.R" and "test.R" which are there.
Then a bit of seddery (or the like) could probably extract just the
filenames, by looking for *.R between > and <.

However, the key to the whole thing is knowing what the numerical
directory names (such as "8210) are. The only way I've found to do
this automatically is to download the whole site (Linux commands):

  mkdir sjdm
  cd sjdm
  wget -r -k -np -nH http://journal.sjdm.org/

extract the numeric directory-names with (e.g.):

  find . -type d -name '[0-9]*[0-9]' -print

and then work through the results of this with directory-specific
wget's as before.

This all seems to be overkill, however! Much easier if the site
would accept FTP.
Ted.


On 07-Jun-09 11:45:19, Gabor Grothendieck wrote:
> The fact that the search did find two files suggests that
> it works but the problem may be that google has just not
> indexed those other files.  Try entering the url for one of
> them into google and google still does not find it.
> http://journal.sjdm.org/8210/test.R
> 
> 
> On Sun, Jun 7, 2009 at 7:37 AM, Ted
> Harding wrote:
>> On 07-Jun-09 10:56:25, Gabor Grothendieck wrote:
>>> Try this:
>>> site:journal.sjdm.org filetype:R
>>
>> When I enter that into Google, I got only the following two hits:
>>
>> _#
>> _#!/usr/bin/Rscript --vanilla # input is a pre-made list of files ...
>> _#!/usr/bin/Rscript --vanilla # input is a pre-made list of files
>> ending
>> _in html called ../htmlist # (see below). This is easily modified. ...
>> _journal.sjdm.org/RePEc/rss/rss.R - Cached - Similar pages
>>
>> _#
>> _#!/usr/bin/Rscript --vanilla --verbose # script to convert RePEc ...
>> _#!/usr/bin/Rscript --vanilla --verbose # script to convert
>> RePEc-style
>> _rdf files (ReDIFF) to DOAJ-type xml files # usage: oai.R [file] #
>> where
>> _[file] is a ...
>> _journal.sjdm.org/RePEc/rss/oai.R - Cached - Similar pages
>>
>> none of which is what Jonathan os looking for (and the "Similar pages"
>> links are a waste of time).
>>
>> In "regexp language", what he is looking for is
>>
>> _http://journal.sjdm.org/[0:9]+/*.R
>>
>> of which there are several instances on the site, for example
>>
>> _http://journal.sjdm.org/8210/
>>
>> shows
>>
>> _ jdm8210.html _ _13-Dec-2008 1
>> _ jdm8210.pdf _ _ 13-Dec-2008 11:18 _ _ _ 102K
>> _ jdm8210.tex _ _ 13-Dec-2008 11:18 _ _ _ 27K
>> _ jdm8210001.gif _09-Dec-2008 14:38 _ _ _ 11K
>> _ probs.R _ _ _ _ 09-Dec-2008 14:37 _ _ _ 1.0K
>> _ test.R _ _ _ _ _23-May-2008 05:46 _ _ _ 251
>> _ ttest.csv _ _ _ 22-May-2008 21:31 _ _ _ 2.6K1:18 _ _ _ _31K
>>
>> so there are two ".R"files there (8210 is the number of an article
>> in the Journal). Other similar directories mAy or may not have
>> ".R" files -- for example
>> _http://journal.sjdm.org/8816/
>> has none.
>>
>> The problem is that utilities like wget won;t work in this case,
>> since HTTP doesn't accept "wild cards", unlike FTP; but the journal
>> site doesn't accept FTP ... !!
>>
>> It's an intriguing problem, and I'm seeking advice amongst my Linux
>> acquaintances about it. I sonehow doubt that there is a solution ...
>>
>> Ted.
>>> On Sat, Jun 6, 2009 at 6:39 PM, Jonathan Baron
>>> wrote:
 I also use R to redraw figures for the journal I edit (below), when
 the authors cannot produce usable graphics (about 50% of the author
 who try).

 Unfortunately, I cannot find a way to search for just the R files.
 They are all http://journal.sjdm.org/*/*.R
 where * is the number of the article. _But Google, to my knowledge
 will not deal with wildcards like this.

 Jon
 --
 Jonathan Baron, Professor of Psychology, University of Pennsylvania
 Home page: http://www.sas.upenn.edu/~baron
 Editor: Judgment and Decision Making (http://journal.sjdm.org)

 __
 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.

>>>
>>> 

[R] Scrolling behavior in View()

2009-06-07 Thread Jose Quesada
Hi,

I've realized that the scrolling behavior in View() is unlike most other
applications. It seems that the minimum scroll size is very large for
large objects( i.e., a vector of 1M integers), and it might be that this
scroll is proportional to the size of the object.
Try this:
a = 1:100
View(a)
Click once on the scroll arrow down. It will move to item 1001.

It could be that the scroll size is 1/1000 object length.

If this is so, it's a bit of a problem, since there's no way to View say
cell 500... unless one does a View(head(a, 500)), which kind of defeats
the point of view.

Is this behavior by design? If so, wouldn't it be better to make it
optional (as it breaks GUI conventions of mostly any OS for scrolling
behavior)? An argument for view to turn this off would be great.

Thanks!

Best,
-Jose

-- 
Jose Quesada, PhD.
Max Planck Institute,
Center for Adaptive Behavior and Cognition -ABC-, 
Lentzeallee 94, office 224, 14195 Berlin
http://www.josequesada.name/

__
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.


Re: [R] One rather theoretical question about fitting algorithm

2009-06-07 Thread Bill.Venables
The glm function allows you to specify starting values for beta (start =), eta 
(etastart =) or mu (mustart =).  In your case the starting value for beta would 
seem to be the most appropriate.  You might find providing a starting value for 
mu or eta also works well, provided you can come up with a quick way of finding 
values for the new observations.



From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
useR [milicic.ma...@gmail.com]
Sent: 07 June 2009 21:20
To: r-help@r-project.org
Subject: [R] One rather theoretical question about fitting algorithm

Hi,

What I'm trying to achieve is very fast algorithm for fitting logistic
regression model. I have to estimate regression coeficients using
about 10k observations. Once I have coefficients estimated, new 100
rows of data becomes available Now I need to reestimate
coeficients using 100 newly arrived observations and removing 100
oldest observations.

So, my question is would it be possible to somehow reuse pre iusly
calculated coeficients and only adjust them cor newly arrived data? I
know it would have to be some aproximation but I suppose it will be
good enough.

I dont mind doing this in straight C because of of speed perative.
Actualy this will have to be cAlculated in a fraction of second.


Any ideas would be higly appreciated

__
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.

__
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.


Re: [R] EBImage not loading

2009-06-07 Thread Quin Wills
Hi Greg

It works! Thanks. I've noticed a lot of general Heron-unhappiness re.
ImageMagick. 'Appreciate that ImageMagick isn't really your domain, but it
might be helpful to put up a solution page somewhere.

postcript 1 - my apologies. I sent this off to the wrong list... I really
should have used the Bioconductor list. Careless clicking of 'send to'.

postscript 2 -thanks for the 2.6 spot. I am actually running 2.9. I didn't
notice that my bioconductor libraries are going into my 2.6 folder. Not sure
why that is. Presumably its only a cosmetic problem.

Q

* Quin Wills *
* DPhil candidate *

* *

* Department of Statistics
University of Oxford
1 South Parks road
Oxford
OX1 3TG
+44 (0)1865 285 394
*



2009/6/7 Gregoire Pau 

> Hi Quin,
>
> This is a well documented bug of Ubuntu 8.10 (Hardy Heron), preventing
> applications using libgomp (EBImage via ImageMagick) to work:
> https://bugs.launchpad.net/ubuntu/hardy/+source/gcc-4.2/+bug/235070
>
> The bug was fixed in the package gcc-4.2.4-3ubuntu3.
>
> Please note that your R version (2.6.2) is pretty outdated.
>
> Best regards,
>
> Greg
> ---
> Gregoire Pau
> EMBL Research officer
> http://www.ebi.ac.uk/~gpau/ 
>
>
> Quin Wills wrote:
>
>> Hello all
>>
>> I've just spent a few joyless hours trying to get EBImage to install in R.
>> I'm running Ubuntu (Hardy Heron), fully updated (including R and
>> Imagemagick). EBImage installation seems to work, but when I
>> 'library(EBImage)' I get the following:
>>
>> - - - -
>> Error in dyn.load(file, DLLpath = DLLpath, ...) :
>>  unable to load shared library '/home/qilin/R/i486-pc-linux-
>> gnu-library/2.6/EBImage/libs/EBImage.so':
>>  /usr/lib/libgomp.so.1: cannot allocate memory in static TLS block
>> Error: package/namespace load failed for 'EBImage'
>> - - - -
>>
>> Which is meaningless to me. Any help would be enormously appreciated,
>> thanks.
>>
>> Quin
>>
>> * Quin Wills *
>> * DPhil candidate *
>>
>> * *
>>
>> * Department of Statistics
>> University of Oxford
>> 1 South Parks road
>> Oxford
>> OX1 3TG
>> +44 (0)1865 285 394
>> *
>>
>>[[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.
>>
>

[[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.


Re: [R] Journal Articles that Have Used R

2009-06-07 Thread Jonathan Baron
Argh.

The reason we can't find my example R files with Google is that they
were not indexed because there were no links to them.  I've now
created a page with just these links, and a link to that page at the
very bottom of http://journal.sjdm.org/submit.htm

Google should find it all eventually.
The direct link is http://journal.sjdm.org/RX.html

I should also note that I need to set a bounding box around
everything, and here is the "bbox" script I use (based loosely on a
suggestion made by Brian Ripley a long time ago).  Sometimes I add
this to the end of the script that makes the graph, with
system("bbox fig1.eps")
or something like that.

#!/bin/bash
cat $1 | sed -r -e "s/BoundingBox:[\ ]+[0-9]+[\ ]+[0-9]+[\ ]+[0-9]+\
[\ ]+[0-9]+/`gs -sDEVICE=bbox -dBATCH -dNOPAUSE -q`/" > temp.eps
gs -sDEVICE=bbox -sNOPAUSE -q $1 $showpage -c quit 2> bb.out
sed -e"1 r bb.out" temp.eps > $1
/bin/rm bb.out
/bin/rm temp.eps

I may also created a Namazu search index for these, if I get around to
it.

Jon

On 06/07/09 07:45, Gabor Grothendieck wrote:
> The fact that the search did find two files suggests that
> it works but the problem may be that google has just not
> indexed those other files.  Try entering the url for one of
> them into google and google still does not find it.
> http://journal.sjdm.org/8210/test.R
> 
> 
> On Sun, Jun 7, 2009 at 7:37 AM, Ted Harding 
> wrote:
> > On 07-Jun-09 10:56:25, Gabor Grothendieck wrote:
> >> Try this:
> >> site:journal.sjdm.org filetype:R
> >
> > When I enter that into Google, I got only the following two hits:
-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
Editor: Judgment and Decision Making (http://journal.sjdm.org)

__
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.


Re: [R] Journal Articles that Have Used R

2009-06-07 Thread Gabor Grothendieck
The fact that the search did find two files suggests that
it works but the problem may be that google has just not
indexed those other files.  Try entering the url for one of
them into google and google still does not find it.
http://journal.sjdm.org/8210/test.R


On Sun, Jun 7, 2009 at 7:37 AM, Ted Harding wrote:
> On 07-Jun-09 10:56:25, Gabor Grothendieck wrote:
>> Try this:
>> site:journal.sjdm.org filetype:R
>
> When I enter that into Google, I got only the following two hits:
>
>  #
>  #!/usr/bin/Rscript --vanilla # input is a pre-made list of files ...
>  #!/usr/bin/Rscript --vanilla # input is a pre-made list of files ending
>  in html called ../htmlist # (see below). This is easily modified. ...
>  journal.sjdm.org/RePEc/rss/rss.R - Cached - Similar pages
>
>  #
>  #!/usr/bin/Rscript --vanilla --verbose # script to convert RePEc ...
>  #!/usr/bin/Rscript --vanilla --verbose # script to convert RePEc-style
>  rdf files (ReDIFF) to DOAJ-type xml files # usage: oai.R [file] # where
>  [file] is a ...
>  journal.sjdm.org/RePEc/rss/oai.R - Cached - Similar pages
>
> none of which is what Jonathan os looking for (and the "Similar pages"
> links are a waste of time).
>
> In "regexp language", what he is looking for is
>
>  http://journal.sjdm.org/[0:9]+/*.R
>
> of which there are several instances on the site, for example
>
>  http://journal.sjdm.org/8210/
>
> shows
>
>   jdm8210.html    13-Dec-2008 1
>   jdm8210.pdf     13-Dec-2008 11:18       102K
>   jdm8210.tex     13-Dec-2008 11:18       27K
>   jdm8210001.gif  09-Dec-2008 14:38       11K
>   probs.R         09-Dec-2008 14:37       1.0K
>   test.R          23-May-2008 05:46       251
>   ttest.csv       22-May-2008 21:31       2.6K1:18        31K
>
> so there are two ".R"files there (8210 is the number of an article
> in the Journal). Other similar directories mAy or may not have
> ".R" files -- for example
>  http://journal.sjdm.org/8816/
> has none.
>
> The problem is that utilities like wget won;t work in this case,
> since HTTP doesn't accept "wild cards", unlike FTP; but the journal
> site doesn't accept FTP ... !!
>
> It's an intriguing problem, and I'm seeking advice amongst my Linux
> acquaintances about it. I sonehow doubt that there is a solution ...
>
> Ted.
>> On Sat, Jun 6, 2009 at 6:39 PM, Jonathan Baron
>> wrote:
>>> I also use R to redraw figures for the journal I edit (below), when
>>> the authors cannot produce usable graphics (about 50% of the author
>>> who try).
>>>
>>> Unfortunately, I cannot find a way to search for just the R files.
>>> They are all http://journal.sjdm.org/*/*.R
>>> where * is the number of the article. _But Google, to my knowledge
>>> will not deal with wildcards like this.
>>>
>>> Jon
>>> --
>>> Jonathan Baron, Professor of Psychology, University of Pennsylvania
>>> Home page: http://www.sas.upenn.edu/~baron
>>> Editor: Judgment and Decision Making (http://journal.sjdm.org)
>>>
>>> __
>>> 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.
>>>
>>
>> __
>> 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.
>
> 
> E-Mail: (Ted Harding) 
> Fax-to-email: +44 (0)870 094 0861
> Date: 07-Jun-09                                       Time: 12:37:34
> -- XFMail --
>

__
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.


Re: [R] Journal Articles that Have Used R

2009-06-07 Thread Ted Harding
On 07-Jun-09 10:56:25, Gabor Grothendieck wrote:
> Try this:
> site:journal.sjdm.org filetype:R

When I enter that into Google, I got only the following two hits:

  #
  #!/usr/bin/Rscript --vanilla # input is a pre-made list of files ...
  #!/usr/bin/Rscript --vanilla # input is a pre-made list of files ending
  in html called ../htmlist # (see below). This is easily modified. ...
  journal.sjdm.org/RePEc/rss/rss.R - Cached - Similar pages

  #
  #!/usr/bin/Rscript --vanilla --verbose # script to convert RePEc ...
  #!/usr/bin/Rscript --vanilla --verbose # script to convert RePEc-style
  rdf files (ReDIFF) to DOAJ-type xml files # usage: oai.R [file] # where
  [file] is a ...
  journal.sjdm.org/RePEc/rss/oai.R - Cached - Similar pages

none of which is what Jonathan os looking for (and the "Similar pages"
links are a waste of time).

In "regexp language", what he is looking for is

  http://journal.sjdm.org/[0:9]+/*.R

of which there are several instances on the site, for example

  http://journal.sjdm.org/8210/

shows

   jdm8210.html13-Dec-2008 1
   jdm8210.pdf 13-Dec-2008 11:18   102K
   jdm8210.tex 13-Dec-2008 11:18   27K
   jdm8210001.gif  09-Dec-2008 14:38   11K
   probs.R 09-Dec-2008 14:37   1.0K
   test.R  23-May-2008 05:46   251
   ttest.csv   22-May-2008 21:31   2.6K1:1831K

so there are two ".R"files there (8210 is the number of an article
in the Journal). Other similar directories mAy or may not have
".R" files -- for example
  http://journal.sjdm.org/8816/
has none.

The problem is that utilities like wget won;t work in this case,
since HTTP doesn't accept "wild cards", unlike FTP; but the journal
site doesn't accept FTP ... !!

It's an intriguing problem, and I'm seeking advice amongst my Linux
acquaintances about it. I sonehow doubt that there is a solution ...

Ted.
> On Sat, Jun 6, 2009 at 6:39 PM, Jonathan Baron
> wrote:
>> I also use R to redraw figures for the journal I edit (below), when
>> the authors cannot produce usable graphics (about 50% of the author
>> who try).
>>
>> Unfortunately, I cannot find a way to search for just the R files.
>> They are all http://journal.sjdm.org/*/*.R
>> where * is the number of the article. _But Google, to my knowledge
>> will not deal with wildcards like this.
>>
>> Jon
>> --
>> Jonathan Baron, Professor of Psychology, University of Pennsylvania
>> Home page: http://www.sas.upenn.edu/~baron
>> Editor: Judgment and Decision Making (http://journal.sjdm.org)
>>
>> __
>> 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.
>>
> 
> __
> 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.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 07-Jun-09   Time: 12:37:34
-- XFMail --

__
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.


[R] One rather theoretical question about fitting algorithm

2009-06-07 Thread useR
Hi,

What I'm trying to achieve is very fast algorithm for fitting logistic
regression model. I have to estimate regression coeficients using
about 10k observations. Once I have coefficients estimated, new 100
rows of data becomes available Now I need to reestimate
coeficients using 100 newly arrived observations and removing 100
oldest observations.

So, my question is would it be possible to somehow reuse pre iusly
calculated coeficients and only adjust them cor newly arrived data? I
know it would have to be some aproximation but I suppose it will be
good enough.

I dont mind doing this in straight C because of of speed perative.
Actualy this will have to be cAlculated in a fraction of second.


Any ideas would be higly appreciated

__
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.


[R] writing a panel function in coplot for displaying a non-linear regression model graphically

2009-06-07 Thread Marion Dumas
Hello,I am a little bit struggling with the following:
I would like to draw a coplot and in each panel draw the curve and display
the coefficients of the regression model y~a*x^b.
I thought of running nls(y~a*x^b,...) in panel=function(x,y...){} when
calling coplot. How can I do this?
Alternatively,  I could do the regression before graphing with coplot and
just use the panel function to draw the resulting curve and print the
formula. Again, how to write the part panel=function(x,y...) to implement
this in coplot?
Thank you very much!!!
Marion

[[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.


Re: [R] Journal Articles that Have Used R

2009-06-07 Thread Gabor Grothendieck
Try this:

site:journal.sjdm.org filetype:R

On Sat, Jun 6, 2009 at 6:39 PM, Jonathan Baron wrote:
> I also use R to redraw figures for the journal I edit (below), when
> the authors cannot produce usable graphics (about 50% of the author
> who try).
>
> Unfortunately, I cannot find a way to search for just the R files.
> They are all http://journal.sjdm.org/*/*.R
> where * is the number of the article.  But Google, to my knowledge
> will not deal with wildcards like this.
>
> Jon
> --
> Jonathan Baron, Professor of Psychology, University of Pennsylvania
> Home page: http://www.sas.upenn.edu/~baron
> Editor: Judgment and Decision Making (http://journal.sjdm.org)
>
> __
> 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.
>

__
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.


[R] Inf in nnet final value for validation data

2009-06-07 Thread Andrea Weidacher
Hi,

I use nnet for my classification problem and have a problem concerning the 
calculation of the final value for my validation data.(nnet only calculates the 
final value for the training data). I made my own final value formula (for the 
training data I get the same value as nnet):
  
# prob-matrix
pmatrix <- cat*fittedValues
tmp <- rowSums(pmatrix) 

# -log likelihood
finalValue <- sum(-log(tmp))

# add penalty term
finalValue + sum(decay * weights^2)
  
where cat is a matrix with cols for each possible category and a row for each 
data record. The values are 1 for the target categories of a data record and 0 
otherwise.

My problem is, that I get Inf-values for some validation data records, because 
the rowsum of cat*fittedValues gets 0 and the log gets Inf.

Has anyone an idea how to deal with that problem properly? How does nnet?

I´m thinking of a penalty value for those values. That means if 
cat*fittedValues == 0 not to calculate the log but add e.g. 100 instead of 
"-log(tmp)" to the finalValue-sum??
But how to determine the penalty value???

I´m looking forwar for all suggestions,

Andrea.


  
[[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.


Re: [R] Convert a lis to matrix

2009-06-07 Thread Bernardo Rangel Tura
On Sun, 2009-06-07 at 00:14 -0400, Manisha Brahmachary wrote:
> Hello,
> 
>  
> 
> This is an urgent request. I want to convert a list of 3 elements into a
> matrix and I am not sure how to do it.
> 
>  
> 
> The list looks like this:
> 
> List of 3
> 
>  $ : num [1:15364, 1] 0.133 0.622 0.588 1.024 0.583 ...
> 
>   ..- attr(*, "dimnames")=List of 2
> 
>   .. ..$ : chr [1:15364] "6420681" "3610072" "2260458" "60689" ...
> 
>   .. ..$ : NULL
> 
>  $ : num [1:15364, 1] 3.159 0.265 0.522 1.912 3.380 ...
> 
>   ..- attr(*, "dimnames")=List of 2
> 
>   .. ..$ : chr [1:15364] "6420681" "3610072" "2260458" "60689" ...
> 
>   .. ..$ : NULL
> 
>  $ : num [1:15364, 1] 3.214 0.277 1.447 1.827 2.054 ...
> 
>   ..- attr(*, "dimnames")=List of 2
> 
>   .. ..$ : chr [1:15364] "6420681" "3610072" "2260458" "60689" ...
> 
>   .. ..$ : NULL

I'm not sure if understood your question, but look this code

a<-list(B=1:3,C=2:4,D=3:5)
matrix(unlist(a),ncol=3)




-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

__
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.


Re: [R] EBImage not loading

2009-06-07 Thread Gregoire Pau

Hi Quin,

This is a well documented bug of Ubuntu 8.10 (Hardy Heron), preventing 
applications using libgomp (EBImage via ImageMagick) to work:

https://bugs.launchpad.net/ubuntu/hardy/+source/gcc-4.2/+bug/235070

The bug was fixed in the package gcc-4.2.4-3ubuntu3.

Please note that your R version (2.6.2) is pretty outdated.

Best regards,

Greg
---
Gregoire Pau
EMBL Research officer
http://www.ebi.ac.uk/~gpau/


Quin Wills wrote:

Hello all

I've just spent a few joyless hours trying to get EBImage to install in R.
I'm running Ubuntu (Hardy Heron), fully updated (including R and
Imagemagick). EBImage installation seems to work, but when I
'library(EBImage)' I get the following:

- - - -
Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared library '/home/qilin/R/i486-pc-linux-
gnu-library/2.6/EBImage/libs/EBImage.so':
  /usr/lib/libgomp.so.1: cannot allocate memory in static TLS block
Error: package/namespace load failed for 'EBImage'
- - - -

Which is meaningless to me. Any help would be enormously appreciated,
thanks.

Quin

* Quin Wills *
* DPhil candidate *

* *

* Department of Statistics
University of Oxford
1 South Parks road
Oxford
OX1 3TG
+44 (0)1865 285 394
*

[[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.


__
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.


Re: [R] extract rows having negative values

2009-06-07 Thread Bill.Venables
rownames(X)[apply(X, 1, function(r) any(r < 0))]

... if I understand you correctly.

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Manisha Brahmachary [mb3...@c2b2.columbia.edu]
Sent: 07 June 2009 08:54
To: r-help@r-project.org
Subject: [R] extract rows having negative values

Hello,



I have a matrix with 6 columns and 12 rows. I want to extract out those IDs
(rownames) from my matrix which have a negative values. For each ID(row) if
the negative value is even under 1 column it needs to be extracted out. I
will be grateful for any correct suggestion.





Thanks

Manisha



Here is the matrix that I am working on:





ID

A

B

C

D

E

F

1

-4.18972

-3.8946

-1.14888

-1.88406

-8.34124

10.97497

2

11.81028

11.1054

0.85112

0.115942

-4.34124

24.97497

3

-0.18972

-1.8946

1.85112

-4.88406

-17.3412

-13.025

4

-1.18972

3.105402

-0.14888

-12.8841

-15.3412

4.974967

6

-3.18972

4.105402

24.85112

0.115942

1.658762

-11.025

7

-2.18972

-10.8946

-20.1489

-1.88406

3.658762

-11.025

8

-0.18972

-7.8946

-7.14888

-9.88406

3.658762

-9.02503

9

-5.18972

-4.8946

-12.1489

0.115942

-12.3412

10.97497

10

17.81028

9.105402

-15.1489

10.11594

19.65876

9.974967

11

538.8103

335.1054

863.8511

229.1159

520.6588

143.975

12

30.81028

18.1054

30.85112

16.11594

9.658762

13.97497








[[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.

__
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.