[R] How use a matrix method?

2009-04-19 Thread Grześ
Why when I want to find my value from matrix I get: 2,3,4,1,2? I think that I should get: 1,2,3,4,7,8. macierz=matrix(1:4,7,8) macierz[[2]] [1] 2 macierz[[3]] [1] 3 macierz[[4]] [1] 4 macierz[[5]] [1] 1 macierz[[6]] [1] 2 This is a similar situation: macierz=matrix(9,8,7,6)

Re: [R] Binomial simulation

2009-04-19 Thread beetle2
Thank you for your help! Yes you are right the probabilities are for the values 0 through 12. I been asked to compare the simulated values to that of dbinom() once again thanks! Ranjan Maitra wrote: This sounds like a potential homework problem. You don't quite need to simulate anything

Re: [R] Binomial simulation

2009-04-19 Thread beetle2
Sorry guys one quick question I've graphed the histogram with hist(rbinom(n = 1000, size = 10, prob = 0.25)) How to I sum the individual values 0 to 12? regards Brendan beetle2 wrote: Hi Guy's I was wondering if someone could point me in the right direction. dbinom(10,1,0.25) I am

Re: [R] Can't read table encoded in Unicode (R-2.8.1)

2009-04-19 Thread Hilmar Berger
Hi Duncan, Thanks, this solves my problem. Regards, Hilmar Duncan Murdoch schrieb: On 18/04/2009 1:18 PM, Hilmar Berger wrote: Hi all, I have problems reading Unicode (UTF-16) coded tables in R 2.8.1 under Windows Vista. Imagine the following table: abcd X1,21,31,4

Re: [R] Binomial simulation

2009-04-19 Thread beetle2
I'm thinking I will just use: results - rbinom(1000, 10, .25) d = sum(results == 0 ) df = (d/1000) df And do each individually beetle2 wrote: Hi Guy's I was wondering if someone could point me in the right direction. dbinom(10,1,0.25) I am using dbinom(10,1,0.25) to calculate the

[R] Question about rpart(sth~.,database)

2009-04-19 Thread Grześ
I have a standard database - HouseVotes84 For example: Class V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 1 republicann y ny y y n n n y NA y y y ny 2 republicann y ny y y n n n nn y y y n NA 3 democrat NA y y NA

Re: [R] Binomial simulation

2009-04-19 Thread beetle2
I've done some study. And made a couple of loops to compare the dbinom() and rbinom() Here are the results: The instructor only asked for 1000 trials so its not that accurate. but its close to it. for(x in c(1:10)) + {print(dbinom(x,10,.25)) } [1] 0.1877117 [1] 0.2815676 [1] 0.2502823 [1]

Re: [R] How use a matrix method?

2009-04-19 Thread Peter Dalgaard
Grześ wrote: Why when I want to find my value from matrix I get: 2,3,4,1,2? I think that I should get: 1,2,3,4,7,8. macierz=matrix(1:4,7,8) That's matrix(data=1:4, nrow=7, ncol=8) a 7x8 matrix with the numbers 1 to 4 repeated columnwise. You probably want something like matrix(c(1:4, 7,

Re: [R] explicit documentation (was: get() versus getAnywhere())

2009-04-19 Thread Patrick Burns
Rolf Turner wrote: On 17/04/2009, at 10:21 PM, Duncan Murdoch wrote: Benjamin Tyner wrote: Many thanks Duncan. Perhaps this merits a more explicit note in the documentation? The quote I gave is from the documentation. How could it be more explicit? This is unfortunately typical of the

Re: [R] get() versus getAnywhere()

2009-04-19 Thread Duncan Murdoch
On 18/04/2009 8:47 PM, Rolf Turner wrote: On 17/04/2009, at 10:21 PM, Duncan Murdoch wrote: Benjamin Tyner wrote: Many thanks Duncan. Perhaps this merits a more explicit note in the documentation? The quote I gave is from the documentation. How could it be more explicit? This is

Re: [R] How use a matrix method?

2009-04-19 Thread Grześ
Peter Dalgaard wrote: Grześ wrote: Why when I want to find my value from matrix I get: 2,3,4,1,2? I think that I should get: 1,2,3,4,7,8. macierz=matrix(1:4,7,8) That's matrix(data=1:4, nrow=7, ncol=8) a 7x8 matrix with the numbers 1 to 4 repeated columnwise. You probably

[R] Sweave: Changing the background color, adding a border

2009-04-19 Thread Christophe Genolini
Hi all, I am using Sweave to produce a document. Unfortunately, I have to print several copies and I can't print them in color. So I would like to change the way of printing the code. I would like to print the code in a box with a black borderline and a grey background (quite classic). Is it

Re: [R] Sweave: Changing the background color, adding a border

2009-04-19 Thread Duncan Murdoch
On 19/04/2009 6:03 AM, Christophe Genolini wrote: Hi all, I am using Sweave to produce a document. Unfortunately, I have to print several copies and I can't print them in color. So I would like to change the way of printing the code. I would like to print the code in a box with a black

[R] tcltk2 treectrl

2009-04-19 Thread _
Hi all, I loaded the treectrl widget, but i can not add any elements oder styles. Has anybody a little code snippet, please. Thank you ! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] Sweave: Changing the background color, adding a border

2009-04-19 Thread Romain Francois
Christophe Genolini wrote: Hi all, I am using Sweave to produce a document. Unfortunately, I have to print several copies and I can't print them in color. So I would like to change the way of printing the code. I would like to print the code in a box with a black borderline and a grey

Re: [R] Question about rpart(sth~.,database)

2009-04-19 Thread Gavin Simpson
Grześ wrote: I have a standard database - HouseVotes84 For example: Class V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 1 republicann y ny y y n n n y NA y y y ny 2 republicann y ny y y n n n nn y y y n NA 3

[R] importing spreadsheet data - linera regression - panel data

2009-04-19 Thread Cecilia Carmo
Hi everyone and thank you for the help you could give me. My data is in a spreadsheet. The 1st column identifies the firm (with the fiscal number), the columns 2 to 11 have the variable value for 11 years. I have many variables (files like this). Each file has about 40.000 firms (rows). I

Re: [R] dynlm question: How to predefine formula for call to dynlm(formula) call

2009-04-19 Thread Achim Zeileis
On Sat, 18 Apr 2009, Ron Burns wrote: I want to set up a model with a formula and then run dynlm(formula) because I ultimately want to loop over a set of formulas (see end of post) R form - gas~price R dynlm(form) Time series regression with ts data: Start = 1959(1), End = 1990(4) snip

[R] creating a package in R

2009-04-19 Thread Antonio.Gasparrini
Dear R users, I created some functions I want to convert in a package under Windows (Vista or XP). I carefully read both Writing R extensions by the R Development Core Team and Creating R packages: a tutorial by Friedrich Leisch. I've also installed Rtools as suggested. These tutorials are

Re: [R] creating a package in R

2009-04-19 Thread Duncan Murdoch
On 19/04/2009 9:02 AM, antonio.gasparr...@lshtm.ac.uk wrote: Dear R users, I created some functions I want to convert in a package under Windows (Vista or XP). I carefully read both Writing R extensions by the R Development Core Team and Creating R packages: a tutorial by Friedrich Leisch.

Re: [R] importing spreadsheet data - linera regression - panel data

2009-04-19 Thread Stefan Grosse
Cecilia Carmo schrieb: The objective of my work is to do linear regressions with the variables in the files or with other variables that I can obtain from those by doing some mathematical operations. I’ve already tried to import this information to an array in R, but I’ve seen that the

Re: [R] AICs from lmer different with summary and anova

2009-04-19 Thread Michael Dewey
At 16:22 15/04/2009, Jonathan Williams wrote: Dear R Helpers, I have noticed that when I use lmer to analyse data, the summary function gives different values for the AIC, BIC and log-likelihood compared with the anova function. I do not think I have seen a reply to this. What happens if you

[R] (senza oggetto)

2009-04-19 Thread giuseppef...@libero.it
Dear all, excuse me for my simple questions: i had imported with read table a database with x, y,value and i must do variogram with gstat. can someone tell me how to do it? I read the help but I could not to obtain variogram, __ R-help@r-project.org

Re: [R] Binomial simulation

2009-04-19 Thread Ranjan Maitra
With due respect, and in all fairness, you should inform your instructor that you took help from R's mailing list for doing homework. This mailing list (or any other general mailing list for that matter) is not for doing your (or anyone else's) homework. If the instructor allowed that, that is a

Re: [R] AICs from lmer different with summary and anova

2009-04-19 Thread hadley wickham
Am I doing something wrong, here? If not, which are the real AIC and logLik values for the different models? I don't think it's reasonable to expect that the log-likelihood computed by different functions be should comparable. Are the constant terms included or dropped? Hadley --

[R] drawing data structures

2009-04-19 Thread rajesh j
Hi, I need to represent data structures in a figure.stuff like trees with nodes and pointers etc.can someone guide me to a package that does this? -- Rajesh.J [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] help with this code

2009-04-19 Thread li li
Hi, can anyone help me with the following code? Thanks! library(mvtnorm) f2 - function(n, rho) { var - matrix(c(1,rho,rho,1), nrow=2, ncol=2, byrow=T) beta - seq(0, 1, length.out=n+1) alpha - sort (sapply(1-beta, qnorm)) x - array(0, dim=c(n, n)) for (s in 1:n) { for (t in 1:n){ if

[R] covariance

2009-04-19 Thread Benny Chain
Does anyone know a way to calculate the covariances between two arrays/matrices x and y, row by row. i.e. var(x[n,],y[n,]) for all n ? Benjamin Chain Division of Infection and Immunity Windeyer Building UCL, 46 Cleveland St. London W1T 4JF Fax 00 44 20 7679 9301

Re: [R] covariance

2009-04-19 Thread Gábor Csárdi
sapply(seq_len(nrow(x)), function(i) var(x[i,], y[i,])) Gabor On Sun, Apr 19, 2009 at 7:12 PM, Benny Chain b.ch...@ucl.ac.uk wrote: Does anyone know a way to calculate the covariances between two arrays/matrices x and y, row by row. i.e. var(x[n,],y[n,]) for all n ? Benjamin Chain Division

Re: [R] covariance

2009-04-19 Thread Jorge Ivan Velez
Dear Benny, Here is something that could get you a hint: # Some data set.seed(123) X - matrix(rnorm(100),ncol=10) Y - matrix(rnorm(100,2,4),ncol=10) # Number of rows n-nrow(X) # Covariances sapply(1:n,function(i) cov(X[i,],Y[i,])) # [1] 0.23396819 0.51455839 1.13851842 -4.30551345

Re: [R] covariance

2009-04-19 Thread Marc Schwartz
Depending upon the size of the matrix, using: diag(cov(t(x), t(y))) might be notably faster. On smaller matrices the time savings is negligible. Using Jorge's example below: diag(cov(t(X), t(Y))) [1] 0.23396819 0.51455839 1.13851842 -4.30551345 -2.60720372 [6] -0.06834326

Re: [R] AICs from lmer different with summary and anova

2009-04-19 Thread Ben Bolker
hadley wrote: Am I doing something wrong, here? If not, which are the real AIC and logLik values for the different models? The difference here is that summary() is using REML=TRUE and anova() is using REML=FALSE. It makes sense that anova (which is typically being used to compare

Re: [R] Sweave: Changing the background color, adding a border

2009-04-19 Thread Christophe Genolini
Duncan Murdoch a écrit : On 19/04/2009 6:03 AM, Christophe Genolini wrote: Hi all, I am using Sweave to produce a document. Unfortunately, I have to print several copies and I can't print them in color. So I would like to change the way of printing the code. I would like to print the code

[R] flip certain bits in vector

2009-04-19 Thread Esmail
I have a string of binary values, and I would like to flip certain bits in a set of positions. Let's say the vector p contains position [1, 3, 5, 7] vector b contains bits [1, 0, 1, 0, 1, 0, 1, 0, 1, 0] result r should be [0, 1, 0, 0, 0, 0, 0, 0, 1, 0] in pseudo code this would be

Re: [R] flip certain bits in vector

2009-04-19 Thread David Winsemius
I do not think your wetware processed the inputs correctly. The second bit should not have been flipped: Try this loop free index based solution: b - c( 1, 0, 1, 0, 1, 0, 1, 0, 1, 0) r - b r[p] - 0 + !r[p] # adding 0 converts logical TRUE/FALSE to 0/1 r [1] 0 0 0 0 0 0 0 0 1 0 The if

Re: [R] flip certain bits in vector

2009-04-19 Thread jim holtman
try this: b - c(1, 0, 1, 0, 1, 0, 1, 0, 1, 0) p - c(1, 3, 5, 7) b[p] - ifelse(b[p] == 0, 1, 0) b [1] 0 0 0 0 0 0 0 0 1 0 On Sun, Apr 19, 2009 at 3:24 PM, Esmail esmail...@gmail.com wrote: I have a string of binary values, and I would like to flip certain bits in a set of positions.

Re: [R] Binomial simulation

2009-04-19 Thread Johannes Huesing
beetle2 samandbren...@aapt.net.au [Sun, Apr 19, 2009 at 03:01:43AM CEST]: I'm thinking I will just use: results - rbinom(1000, 10, .25) d = sum(results == 0 ) df = (d/1000) df And do each individually ok, at least you are trying some things out for yourself. In fact, along with reading

Re: [R] flip certain bits in vector

2009-04-19 Thread Esmail
David Winsemius wrote: I do not think your wetware processed the inputs correctly. The second bit should not have been flipped: Ooops .. yes you are right! Try this loop free index based solution: b - c( 1, 0, 1, 0, 1, 0, 1, 0, 1, 0) r - b r[p] - 0 + !r[p] # adding 0 converts logical

Re: [R] flip certain bits in vector

2009-04-19 Thread Esmail
jim holtman wrote: try this: b - c(1, 0, 1, 0, 1, 0, 1, 0, 1, 0) p - c(1, 3, 5, 7) b[p] - ifelse(b[p] == 0, 1, 0) I'll have to look up the ifelse operator, looks like the ternary operator used in C b[p] = b[p]==0?1:0 Cool - thanks! Esmail __

Re: [R] get() versus getAnywhere()

2009-04-19 Thread Rolf Turner
On 19/04/2009, at 9:45 PM, Duncan Murdoch wrote: On 18/04/2009 8:47 PM, Rolf Turner wrote: On 17/04/2009, at 10:21 PM, Duncan Murdoch wrote: Benjamin Tyner wrote: Many thanks Duncan. Perhaps this merits a more explicit note in the documentation? The quote I gave is from the

Re: [R] explicit documentation (was: get() versus getAnywhere())

2009-04-19 Thread Rolf Turner
On 19/04/2009, at 8:59 PM, Patrick Burns wrote: Rolf Turner wrote: On 17/04/2009, at 10:21 PM, Duncan Murdoch wrote: Benjamin Tyner wrote: Many thanks Duncan. Perhaps this merits a more explicit note in the documentation? The quote I gave is from the documentation. How could it be

Re: [R] explicit documentation

2009-04-19 Thread Peter Dalgaard
Rolf Turner wrote: On 19/04/2009, at 8:59 PM, Patrick Burns wrote: I think this unfairly blames R-core for being human. Why is this unfair? R-core is supposed to be superhuman! :-) Aiming for the fortune file again, eh? -- O__ Peter Dalgaard Øster Farimagsgade

Re: [R] get() versus getAnywhere()

2009-04-19 Thread Johannes Huesing
Rolf Turner r.tur...@auckland.ac.nz [Sun, Apr 19, 2009 at 10:01:34PM CEST]: On 19/04/2009, at 9:45 PM, Duncan Murdoch wrote: On 18/04/2009 8:47 PM, Rolf Turner wrote: On 17/04/2009, at 10:21 PM, Duncan Murdoch wrote: Benjamin Tyner wrote: Many thanks Duncan. Perhaps this merits a more

[R] Sweave: Howto write real TeX formula in plot

2009-04-19 Thread Jonas Stein
Hi, i use Sweave to put plots in my .tex Documents. (pdflatex) Is there a nice solution for this: a) get a real LaTeX formula in the plot area. I have only found very complicate solutions. Is there sth. like \formula{x^2 = \oint f} b) how can i format axis and legend to get exact the same

Re: [R] Sweave: Howto write real TeX formula in plot

2009-04-19 Thread baptiste auguie
Perhaps try the pgfSweave package on r-forge? http://r-forge.r-project.org/projects/pgfsweave/ HTH, baptiste On 19 Apr 2009, at 22:15, Jonas Stein wrote: Hi, i use Sweave to put plots in my .tex Documents. (pdflatex) Is there a nice solution for this: a) get a real LaTeX formula in the

Re: [R] get() versus getAnywhere()

2009-04-19 Thread Duncan Murdoch
On 19/04/2009 4:01 PM, Rolf Turner wrote: On 19/04/2009, at 9:45 PM, Duncan Murdoch wrote: On 18/04/2009 8:47 PM, Rolf Turner wrote: On 17/04/2009, at 10:21 PM, Duncan Murdoch wrote: Benjamin Tyner wrote: Many thanks Duncan. Perhaps this merits a more explicit note in the documentation?

[R] Including a vector element in an if statement

2009-04-19 Thread Enda Hargaden
Hi all, I've searched high and low on this and found nothing of help. I'm using v2.6.2 and trying to write a function that will count how many people from a dataset fall under a poverty line of 50% of the mean income. a9 is my 100-element vector of incomes. I want pa9 to be my vector that counts

Re: [R] Binomial simulation

2009-04-19 Thread beetle2
Hi All, Thank you for all your help. In future I will state if it's homework related. regards Brendan beetle2 wrote: Hi Guy's I was wondering if someone could point me in the right direction. dbinom(10,1,0.25) I am using dbinom(10,1,0.25) to calculate the probabilty of 10 judges

Re: [R] Question about rpart(sth~.,database)

2009-04-19 Thread Grześ
Gavin Simpson wrote: Grześ wrote: I have a standard database - HouseVotes84 For example: Class V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 1 republicann y ny y y n n n y NA y y y ny 2 republicann y ny y y n n n nn

[R] data$ID - I always get a NULL

2009-04-19 Thread Grześ
I have database write as .csv file. When I want to get sth from my database I get NULL, but I know that there is sth! For example: data$ID NULL data$kod NULL but command like below is always recognize by R data[2,3] [1] '082' In my opinion this problem is also connect with my attempt to

[R] package installation error

2009-04-19 Thread Joseph P Gray
After installing 2.9.0 I tried loading packages, but keep getting the following error. package 'robustbase' successfully unpacked and MD5 sums checked Error in normalizePath(path) : path[1]=C:\Program Files\R\R-2.9.0\library/robustbase: The system cannot find the file specified I've tried

Re: [R] Including a vector element in an if statement

2009-04-19 Thread jim holtman
If all you want is a count, then you can construct a logical vector and count the TRUEs: sum(a9 (mean(a9) / 2)) On Sun, Apr 19, 2009 at 5:58 PM, Enda Hargaden endaharga...@gmail.com wrote: Hi all, I've searched high and low on this and found nothing of help. I'm using v2.6.2 and trying to

Re: [R] package installation error

2009-04-19 Thread Joseph P Gray
No, this is on Windows-Xp. From: Erin Hodgess erinm.hodg...@gmail.com To: Joseph P. Gray jpg...@uwm.edu Sent: Sun, 19 Apr 2009 19:17:34 -0500 (CDT) Subject: Re: [R] package installation error Hi Pat! Are you using Windows Vista by any chance, please? If so, try running as administrator. It

Re: [R] Presenting R Results in Webpages

2009-04-19 Thread robert denham
On Fri, Apr 17, 2009 at 3:36 AM, Jason Rupert jasonkrup...@yahoo.comwrote: I apologize in advance that this question is not specific to R, but I thought some R users may be using this in their work process flow. I would like to be able to have a tool (prefer scriptable) that will take two

[R] plotCI (plotrix) problem

2009-04-19 Thread Derek Ogle
I am attempting to create a plot with intervals stretched in the x-direction using plotCI() in the plotrix package. The same data provides an appropriate set of intervals when stretched in the y-direction but I only get a lower interval when stretched in the x-direction. The data are as

Re: [R] Including a vector element in an if statement

2009-04-19 Thread David Winsemius
On Apr 19, 2009, at 5:58 PM, Enda Hargaden wrote: Hi all, I've searched high and low on this and found nothing of help. I'm using v2.6.2 and trying to write a function that will count how many people from a dataset fall under a poverty line of 50% of the mean income. a9 is my

Re: [R] data$ID - I always get a NULL

2009-04-19 Thread David Winsemius
On Apr 19, 2009, at 6:45 PM, Grześ wrote: I have database write as .csv file. The external sorage format is not likely to be relevant. What might be informative would be to produce the code that reads this file. When I want to get sth from my database I get NULL, but I know that there

Re: [R] explicit documentation (was: get() versus getAnywhere())

2009-04-19 Thread ronggui
It is always unfair to complain about volunteer work, and what you should do is to make contributions. 2009/4/20 Rolf Turner r.tur...@auckland.ac.nz: On 19/04/2009, at 8:59 PM, Patrick Burns wrote: Rolf Turner wrote: On 17/04/2009, at 10:21 PM, Duncan Murdoch wrote: Benjamin Tyner wrote:

[R] PCA and automatic determination of the number of components

2009-04-19 Thread nikolay12
Hi all, I have relatively small dataset on which I would like to perform a PCA. I am interested about a package that would also combine a method for determining the number of components (I know there are plenty of approaches to this problem). Any suggestions about a package/function? thanks,

Re: [R] Sweave: Howto write real TeX formula in plot

2009-04-19 Thread cls59
Bugzilla from n...@jonasstein.de wrote: Hi, i use Sweave to put plots in my .tex Documents. (pdflatex) Is there a nice solution for this: a) get a real LaTeX formula in the plot area. I have only found very complicate solutions. Is there sth. like \formula{x^2 = \oint f} b) how

Re: [R] Modelling an incomplete Poisson distribution ?

2009-04-19 Thread Emmanuel Charpentier
Dear Ben, Le samedi 18 avril 2009 à 23:37 +, Ben Bolker a écrit : Emmanuel Charpentier charpent at bacbuc.dyndns.org writes: I forgot to add that yes, I've done my homework, and that it seems to me that answers pointing to zero-inflated Poisson (and negative binomial) are

Re: [R] plotCI (plotrix) problem

2009-04-19 Thread Dieter Menne
Derek Ogle DOgle at northland.edu writes: I am attempting to create a plot with intervals stretched in the x-direction using plotCI() in the plotrix package. The same data provides an appropriate set of intervals when stretched in the y-direction but I only get a lower interval when