[R] problem when extacting columns of a data frame in a new data frame

2008-01-08 Thread Delphine Fontaine
Dear R-users, I would like to create a new data frame composed of 2 columns of another data frame. But it does not give me what I want... casesCNST[1:10,] case X1 X2 X3 X4 expected 1A1 0 0 0 0E 2A2 0 0 0 1C 3A3 0 0 0 2C 4A4 0 0 0 3

Re: [R] Orientation of labels on axes

2008-01-08 Thread Jim Lemon
mika03 wrote: http://www.nabble.com/file/p14664173/at-modality.png I created the above image with R and I have one problem left: Some of the labels of the axes do not show up, probably because there's not enough space. I use the following code to create the plot: modality -

Re: [R] problem when extacting columns of a data frame in a new data frame

2008-01-08 Thread Dieter Menne
Delphine Fontaine delphine.fontaine at genexion.com writes: I would like to create a new data frame composed of 2 columns of another data frame. But it does not give me what I want... casesCNST[1:10,] case X1 X2 X3 X4 expected 1A1 0 0 0 0E 2A2 0 0 0 1C

[R] correlation matrix - large dataset

2008-01-08 Thread suman Duvvuru
Hello, I have a dataset with 20,000 variables.and I would like to compute a pearson correlation matrix which will be 2*2. The cor() function doesnt work in this case due to memory problem. If you have any ideas regarding a feasible way to compute correlations on such a huge dataset,

[R] recode() function results in logical output, not factor output

2008-01-08 Thread Thomas MacFarland
Dear R Users: I have race-ethnicity groups identified in the factor variable Ethnic_G. I need to collapse Ethnic_G into a new variable with only two factors, 1 (White, non-Hispanic) and 2 (Minority). As seen in the code and output below, the recoded race-ethnicity variable is put into

[R] Is there a multinomial exact goodness of fit test in R?

2008-01-08 Thread Rong Jian
Dear all: I have very small observed values and would like to do a goodness-of-fit test. Is there a multinomial exact goodness of fit test in R? Thank you very much! Sincerely, Jian - [[alternative HTML version deleted]]

[R] How to rearrange lattice graphics output?

2008-01-08 Thread Weidong Gu
My question arises when I use levelplot graphics. For example, levelplot(z~x*y|fg) where fg is a factor with three levels of 'a','b','c'. The panels come out in a default order. I would like to rearrange the panels in a manner of 'c','b','a'. I used fg-ordered(fg, levels=c('c','b','a'))

Re: [R] GAM, GLM, Logit, infinite or missing values in 'x'

2008-01-08 Thread Simon Wood
Anders, A very flexible logistic regression model is quite often able to predict some subset of the data `perfectly' with the unfurtunate consequence that the corresponding linear predictor is not well defined. My guess would be that the extra flexibility of the gam is what is causing slightly

[R] Error cannot allocate vector of size...

2008-01-08 Thread Rod
Hello, I have a memory problem when I run package WinBUGS with R (2.6.1). Until now I have been using a Pentium IV 3.2Ghz computer with 512Mb of RAM memory (with Windows XP Pro SP2), and I hadn't had any problem. Now I have a new computer with the following characteristics: Intel Core 2 duo

Re: [R] recode() function results in logical output, not factor output

2008-01-08 Thread Chuck Cleland
On 1/7/2008 3:32 PM, Thomas MacFarland wrote: Dear R Users: I have race-ethnicity groups identified in the factor variable Ethnic_G. I need to collapse Ethnic_G into a new variable with only two factors, 1 (White, non-Hispanic) and 2 (Minority). As seen in the code and output below,

Re: [R] Importing data

2008-01-08 Thread Michael Dewey
At 11:46 06/01/2008, Simo Vundla wrote: Hi, I'm trying to import categorical data from SPSS to R using the script: xxx -spss.get(xxx.por, use.value.labels=TRUE) but unfortunately am getting an error message 'error reading portable-file dictionary'. I have successfully imported data in the past.

Re: [R] problem when extacting columns of a data frame in a new data frame

2008-01-08 Thread Emmanuel Charpentier
Delphine Fontaine a écrit : Dear R-users, I would like to create a new data frame composed of 2 columns of another data frame. But it does not give me what I want... casesCNST[1:10,] case X1 X2 X3 X4 expected 1A1 0 0 0 0E 2A2 0 0 0 1C 3A3 0 0

Re: [R] A question on chisq.test

2008-01-08 Thread Peter Dalgaard
Rong Jian wrote: Dear all, I would like to do a goodness-of-fit test on my data to see if they follow a mixture of 2 poisson distributions. I have small numbers for observed values. Most of them 5. The chisq.test gives warning message: Chi-squared approximation may be incorrect in:

Re: [R] Range of circular data

2008-01-08 Thread Richard . Cotton
I want to get the minimum arc (in degrees) needed to include a set of compass directions. I would like to use the range.circular() function of the package circular, because that package understands a compass-type of angle convention, but it gives results I don't understand. Howver, I can

Re: [R] Is there a multinomial exact goodness of fit test in R?

2008-01-08 Thread Prof Brian Ripley
On Mon, 7 Jan 2008, Rong Jian wrote: Dear all: I have very small observed values and would like to do a goodness-of-fit test. Is there a multinomial exact goodness of fit test in R? Thank you very much! chisq.test(simulate.p.value = TRUE) for some senses of 'exact'. Sincerely, Jian

Re: [R] How to rearrange lattice graphics output?

2008-01-08 Thread Felix Andrews
It works for me. fg - ordered(letters[1:3]) levelplot(1:3 ~ 1:3 * 1:3 | fg) # (panels a, b, c) fg - ordered(fg, levels=c('c','b','a')) levelplot(1:3 ~ 1:3 * 1:3 | fg) # (panels c, b, a) packageDescription(lattice)$Version [1] 0.17-2 On Jan 8, 2008 4:43 AM, Weidong Gu [EMAIL PROTECTED] wrote:

Re: [R] recode() function results in logical output, not factor output

2008-01-08 Thread John Fox
Dear Chuck and Thomas, Thanks, Chuck, for answering Thomas's question. A small point: If Thomas recode()s the factor directly, as you suggest, then as.factor.result=TRUE is the default. Regards, John John Fox, Professor Department of Sociology McMaster

[R] the woes of NA

2008-01-08 Thread Professor Brian Ripley
Jan Galkowski wrote I'm adapting a FORTRAN 77 package for use with R. Pretty straightforward. Except for a glitch it took me some time to figure out. This existing package has subroutines which have parameters called NA. So, I called subroutines like bnodes - function(n, lst, lptr,

Re: [R] Problems with modifying data in a MySQL database

2008-01-08 Thread Duncan Murdoch
On 1/8/2008 7:11 AM, Marcus Wurzer wrote: Using the package /RMySQL/ I have established a connection ('con1') to a MySQL-Database called 'mc'. This database contains a table called 'mc_2000' which has 20 observations on several variables. One of these variables is called 'B5' (type

Re: [R] storing matrices in a list or vector and preserve dimensions

2008-01-08 Thread Gabor Csardi
Bram, On Tue, Jan 08, 2008 at 03:11:07PM +0100, Bram Kuijper wrote: Hi all, As an R newbie, I wonder how I can store multiple matrices in a list() or vector() object without losing their structure. I should be able to retrieve the matrix from the list later on. If I just append() the

[R] storing matrices in a list or vector and preserve dimensions

2008-01-08 Thread Bram Kuijper
Hi all, As an R newbie, I wonder how I can store multiple matrices in a list() or vector() object without losing their structure. I should be able to retrieve the matrix from the list later on. If I just append() the matrices to a list() object, they automatically lose their dimensions,

[R] splitting the column

2008-01-08 Thread mohamed nur anisah
Hi, I have a matrix data with 21 rows and 6 columns. Below and attach with is my matrix data. My problem is to split the column into 3 subcolumns (except for column 3 and 4) . I want my new matrix data to have 14 columns and 21 rows. Kindly help is highly appreciated. [,1]

Re: [R] Error cannot allocate vector of size...

2008-01-08 Thread Duncan Murdoch
On 1/8/2008 8:49 AM, Rod wrote: On Jan 8, 2008 12:41 PM, Duncan Murdoch [EMAIL PROTECTED] wrote: Rod wrote: Hello, I have a memory problem when I run package WinBUGS with R (2.6.1). Until now I have been using a Pentium IV 3.2Ghz computer with 512Mb of RAM memory (with Windows XP Pro

Re: [R] I need arguments pro-S-PLUS and against SAS...

2008-01-08 Thread bogdan romocea
John Sorkin wrote: The difference is not so much the language as the end users. S-Plus, R, SAS, etc. are all similar in that they are all tools to an end and not an end in themselves. Try to find one user who: 1. is familiar with both SAS and R/S-Plus; 2. has to do real data analysis

Re: [R] splitting the column

2008-01-08 Thread Gabor Grothendieck
If mat is your matrix then this will produce a 14 column data frame: DF - read.table(textConnection(apply(mat, 1, paste, collapse = ))) On Jan 8, 2008 9:36 AM, mohamed nur anisah [EMAIL PROTECTED] wrote: Hi, I have a matrix data with 21 rows and 6 columns. Below and attach with is my

Re: [R] splitting the column

2008-01-08 Thread Henrique Dallazuanna
Try this also: do.call(rbind, lapply(apply(df, 1, paste, collapse= ), function(.x)read.table(textConnection(.x On 08/01/2008, mohamed nur anisah [EMAIL PROTECTED] wrote: Hi, I have a matrix data with 21 rows and 6 columns. Below and attach with is my matrix data. My problem is to

Re: [R] correlation matrix - large dataset

2008-01-08 Thread Douglas Bates
On Jan 8, 2008 12:34 AM, suman Duvvuru [EMAIL PROTECTED] wrote: Hello, I have a dataset with 20,000 variables.and I would like to compute a pearson correlation matrix which will be 2*2. The cor() function doesnt work in this case due to memory problem. If you have any ideas regarding

[R] Odp: splitting the column

2008-01-08 Thread Petr PIKAL
Hi Do you have a source data available. Maybe you could try to read it in such manner that you will get desired result without further adjustment. See all options in read.* functions. If you really wanted to split already imported data you will need to use regular expressions and I am not an

[R] Oracle connectivity

2008-01-08 Thread Tudor Bodea
Dear useRs, I would like to access a remote Oracle database through R but I just cannot find sufficient online information to do so. As a result, I am wondering if you can provide me with a link to a document that details the steps I need to undertake to successfuly complete the task (e.g.,

[R] cursor position on image

2008-01-08 Thread Peter Hietz
Hi, I am using the EBImage package for image display and analysis and want to read the cursor (mouse) position on the image. The function locator() would be ideal, but this appears to work only on plots, not images. a - Image((0:(w^2))/w^2, c(w,w)) if ( interactive() ) display(a) locator(n

Re: [R] Create a new dataframe from an existing dataframe

2008-01-08 Thread Gang Chen
Yes, this works well. Also 'table' suggested by Bert Gunter also works perfectly. Thank all who've helped me on this. Gang On Jan 7, 2008, at 7:39 PM, jim holtman wrote: Does this do what you want? x - read.table(textConnection(AB C D + A1 B1 C1 D1 + A1 B2 C1 D1 + A1 B1 C1

Re: [R] cursor position on image

2008-01-08 Thread Prof Brian Ripley
On Tue, 8 Jan 2008, Peter Hietz wrote: Hi, I am using the EBImage package for image display and analysis and want to read the cursor (mouse) position on the image. The function locator() would be ideal, but this appears to work only on plots, not images. a - Image((0:(w^2))/w^2,

[R] mle

2008-01-08 Thread Antonio Gasparrini
Hello, I'm trying to obtain a maximum likelyhood estimate of a gaussian model by the MLE command, as I did with a Poisson model: x - rep(1:2,each=500) y - rnorm(length(x), mean=10+3*x, sd=1) glm1 - glm(y ~ x , family=gaussian()) library(stats4) func1 - function(alfa=10, beta=3, sigma=1)

Re: [R] I need arguments pro-S-PLUS and against SAS...

2008-01-08 Thread Lucke, Joseph F
A good summary of the differences between S-PLUS and SAS, along with their respective advantages and disadvantages, is given in Section 1.6 of http://lib.stat.cmu.edu/S/Harrell/doc/splusp.pdf. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bogdan

Re: [R] using lapply()

2008-01-08 Thread Dimitris Rizopoulos
try the following: delta - c(2.5, 2.5, 1) v - list( matrix(round(rnorm(70, 2), 2), 5, 14), matrix(round(rnorm(70, 2), 2), 5, 14), matrix(round(rnorm(70, 2), 1), 5, 14) ) v mapply(function(x, y){ x[x y] - NA; x }, v, delta, SIMPLIFY = FALSE) I hope it helps. Best, Dimitris

[R] using lapply()

2008-01-08 Thread dxc13
useR's, I am trying to find a quick way to change some values in a list that are subject to a condition to be NA. Consider the 3x1 matrix: delta - matrix(c(2.5,2.5,1), nrow = 1) And consider the list named v that has 3 elements v v[[1]] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]

[R] retaining POSIXct formatting when using apply(muff, FUN=MAX) on POSIXct dataframe?

2008-01-08 Thread Thomas Pujol
How do I retain POSIXct formatting when using apply, with FUN=max? #example: mydata - rep(Sys.time(), 10) mydf - data.frame(matrix(data=mydata, nrow=2, ncol=length(mydata) ) ) for(i in seq(mydf))class(mydf[[i]]) - class(mydata) str(mydf) maxdates - apply(mydf,2,max,na.rm=T) str(maxdates)

Re: [R] Problem in anova with coxph object

2008-01-08 Thread Peter Dalgaard
Matthias Gondan wrote: Dear R users, I noticed a problem in the anova command when applied on a single coxph object if there are missing observations in the data: This example code was run on R-2.6.1: library(survival) data(colon) colondeath = colon[colon$etype==2, ] m =

[R] Problem in anova with coxph object

2008-01-08 Thread Matthias Gondan
Dear R users, I noticed a problem in the anova command when applied on a single coxph object if there are missing observations in the data: This example code was run on R-2.6.1: library(survival) data(colon) colondeath = colon[colon$etype==2, ] m = coxph(Surv(time, status) ~ rx + sex +

Re: [R] using lapply()

2008-01-08 Thread dxc13
Thank you, this works perfectly! Dimitris Rizopoulos wrote: try the following: delta - c(2.5, 2.5, 1) v - list( matrix(round(rnorm(70, 2), 2), 5, 14), matrix(round(rnorm(70, 2), 2), 5, 14), matrix(round(rnorm(70, 2), 1), 5, 14) ) v mapply(function(x, y){ x[x y] -

[R] Using aggregate() and apply() on circular data

2008-01-08 Thread Waichler, Scott R
I would like to use aggregate.ts() and apply() on circular data, but I can't figure out how to get the circular data components to pass through: library(circular) x - circular(c(20, 30, 355, 5, 345, 25), units = degrees) % I want to get the mean angle for each successive pair; answer should be

[R] plotting help needed

2008-01-08 Thread bunny , lautloscrew.com
Dear all, i need some help with plotting. the specific problem is the following: #FYI a=100 b=95 d=94.5 e=70 all=c(a,b) all2=c(d,e) plot(all,type=b,col=blue,xlim=c(1,4),ylim=c(20,150)) lines(all2,type=o,col=yellow) this does work so far, but ... i´d like to have 4 intersects, just named by

[R] Installing R on BSD

2008-01-08 Thread Kitty Lee
Dear users, I try to follow the instruction on this page to install R on 4.4BSD network. http://cran.r-project.org/doc/manuals/R-admin.html#Using-make I can unpack the file but the system can't recognize the command: ./configure make Any ideas what should be the right command? Thanks!!

Re: [R] choose the intercept from glm and lm

2008-01-08 Thread Chuck Cleland
On 1/8/2008 2:48 PM, Knut Krueger wrote: Hi to all, Is there a possibility to choose which value is used for the intercept or does in not make any sense? f.e I would like to use outcome2 for the intercept ## Dobson (1990) Page 93: Randomized Controlled Trial : counts -

[R] choose the intercept from glm and lm

2008-01-08 Thread Knut Krueger
Hi to all, Is there a possibility to choose which value is used for the intercept or does in not make any sense? f.e I would like to use outcome2 for the intercept ## Dobson (1990) Page 93: Randomized Controlled Trial : counts - c(18,17,15,20,10,20,25,13,12) outcome - gl(3,1,9) treatment -

Re: [R] Installing R on BSD

2008-01-08 Thread Saeed Abu Nimeh
add_pkg -r R Kitty Lee wrote: Dear users, I try to follow the instruction on this page to install R on 4.4BSD network. http://cran.r-project.org/doc/manuals/R-admin.html#Using-make I can unpack the file but the system can't recognize the command: ./configure make Any ideas

[R] using mapply()

2008-01-08 Thread dxc13
useR's, This is a follow up question to one I previously asked. Consider the 3-element list below res [[1]] [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [1,] NA NA NA 1.25 0.25 0.75 NA NA NANANANA 1.25 0.25 [2,] 1.25 0.25

Re: [R] using mapply()

2008-01-08 Thread Dimitris Rizopoulos
do you mean the following?: out - rowMeans(matrix(unlist(res), ncol = length(res))) dim(out) - dim(res[[1]]) out Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel:

Re: [R] mle

2008-01-08 Thread Peter Dalgaard
Antonio Gasparrini wrote: Hello, I'm trying to obtain a maximum likelyhood estimate of a gaussian model by the MLE command, as I did with a Poisson model: x - rep(1:2,each=500) y - rnorm(length(x), mean=10+3*x, sd=1) glm1 - glm(y ~ x , family=gaussian()) library(stats4)

Re: [R] using mapply()

2008-01-08 Thread dxc13
Yes, that's it. Thank you again! Dimitris Rizopoulos wrote: do you mean the following?: out - rowMeans(matrix(unlist(res), ncol = length(res))) dim(out) - dim(res[[1]]) out Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health

Re: [R] plotting help request II

2008-01-08 Thread Greg Snow
?par look at xaxt ?axis -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of bunny , lautloscrew.com Sent: Tuesday, January 08, 2008

[R] plotting help request II

2008-01-08 Thread bunny , lautloscrew.com
Dear all, meanwhile i found out how to handle the coordinate thing and plot the lines like i like. the remaining problem is, i need something like names.arg does in barplot for my plot. my plot connects several dots with several lines. and now i like characters as the names of the

[R] using sub with wildcards, e.g. sub(\\*.., , test.a..34)

2008-01-08 Thread Thomas Pujol
I have a text string test.a..34 I wish to extract the text that comes after .. (e.g. 34), and the text that comes before .. (e.g. test.a). What is a good way to do this? Also, can you help me understand how to use wildcards such as * with sub, etc? #This seems to work, but

[R] Invoking R on BSD

2008-01-08 Thread Kitty Lee
Thanks to Saeed Abu Nimeh. I used pkg_add to install R package on 4.4BSD. My directory now has the following: BUILDDIRMakefrag.cc_lo config.log m4 tests MakeconfMakefrag.cxxconfig.status po tools MakefileR-2.6.1 doc

Re: [R] using sub with wildcards, e.g. sub(\\*.., , test.a..34)

2008-01-08 Thread jim holtman
This will work: sub(.*\\.\\., , test.a..34) [1] 34 This say match all characters upto and including the two periods. You have to escape the periods since they have special meaning in regular expression (match a character). On Jan 8, 2008 6:08 PM, Charilaos Skiadas [EMAIL PROTECTED] wrote:

Re: [R] retaining POSIXct formatting when using apply(muff, FUN=MAX) on POSIXct dataframe?

2008-01-08 Thread jim holtman
It all depends on what you are doing. Take a look at 'apply'; it says: If X is not an array but has a dimension attribute, apply attempts to coerce it to an array via as.matrix if it is two-dimensional (e.g., data frames) or via as.array. Now take a look at what happens when you convert your

Re: [R] using sub with wildcards, e.g. sub(\\*.., , test.a..34)

2008-01-08 Thread Charilaos Skiadas
If this is really the case you are dealing with, wouldn't strsplit do the job more easily? On Jan 8, 2008, at 5:47 PM, Thomas Pujol wrote: I have a text string test.a..34 I wish to extract the text that comes after .. (e.g. 34), and the text that comes before .. (e.g. test.a). What

Re: [R] retaining POSIXct formatting when using apply(muff, FUN=MAX) on POSIXct dataframe?

2008-01-08 Thread Peter Dalgaard
jim holtman wrote: Now take a look at what happens when you convert your dataframe to a matrix: x - as.matrix(mydf) str(x) It is a character matrix. This is a bit confusing (but deliberate; as.matrix.data.frame explicitly counts POSIXct as non-numeric):

[R] loading igraph package on Solaris

2008-01-08 Thread Peter McMahan
Hello, I'm having trouble getting the igraph package to load on Solaris. I can get igraph to compile and install from a local directory without issues using simply R CMD INSTALL igraph, however library(igraph) from within R gives the following errors: Error in dyn.load(x, as.logical(local),

[R] Constrained minimization solver for nonlinear programming

2008-01-08 Thread tom soyer
Hi, I noticed that R has a few bound-constrained nonlinear min and max solvers, such as optim, nlm, etc. But I could not find a constrained min and max solver that is not LP. Does this mean R do not have this capability? It is hard to believe that R may not be as advanced as Excel in certain

Re: [R] Invoking R on BSD

2008-01-08 Thread Saeed Abu Nimeh
when you do pkg_add -r R it should install R and you will not need to run make. To invoke R, you just need to type R in your prompt. Here is what I have on my FreeBSD: FreeBSD 7.0-PRERELEASE (GENERIC2) #0: Sat Jan 5 21:27:47 CST 2008 Welcome to %R R version 2.6.0 (2007-10-03) Copyright