Re: [R] source and localhost

2011-05-22 Thread John
localhost is the computer you are working at, and the ip assigned to the loob-back interface. This is normally used for testing networking interfaces. That being so, simply using the path to the file on your machine, e.g. /home/username/data/somedata.csv should work much better. JWD

[R] unwanted coercion using apply

2011-05-22 Thread Jeroen Ooms
I need to convert a dataframe to a record-structure, to be able to encode it later in JSON. Suppose this is the data: mydata - data.frame(foo=1:3, bar=c(M,M,F)); I would like to convert this to a unnamed list (json array) of key-value pairs. For example like this: apply(data.frame(foo=1:3,

[R] How to calculate confidence interval of C statistic by rcorr.cens

2011-05-22 Thread khosoda
Hi, I'm trying to calculate 95% confidence interval of C statistic of logistic regression model using rcorr.cens in rms package. I wrote a brief function for this purpose as the followings; CstatisticCI - function(x) # x is object of rcorr.cens. { se - x[S.D.]/sqrt(x[n]) Low95 - x[C

Re: [R] unwanted coercion using apply

2011-05-22 Thread Peter Ehlers
On 2011-05-21 23:11, Jeroen Ooms wrote: I need to convert a dataframe to a record-structure, to be able to encode it later in JSON. Suppose this is the data: mydata- data.frame(foo=1:3, bar=c(M,M,F)); I would like to convert this to a unnamed list (json array) of key-value pairs. For example

Re: [R] Group close numbers in a vector

2011-05-22 Thread Salih Tuna
Hi Jim, I think i sorted it out how to read and write each vector separately. Thanks a lot. It was exactly what i wanted to do. best, salih On Sat, May 21, 2011 at 11:41 PM, jim holtman jholt...@gmail.com wrote: Is this what you are after: x = c(1 ,2 ,4 ,7 ,9 ,10 ,15) # partition if the

[R] Adding dash-lines in R tables

2011-05-22 Thread Axel Urbiz
is it possible to add dash lines to tables or matrices when they are printed? An example of what I'm looking for is this: library(Design) y - sample(c(0,1),100, replace = TRUE) x - rnorm(100) summary(y ~ x) Thanks, Axel. [[alternative HTML version deleted]]

Re: [R] multilevel

2011-05-22 Thread eeecon
Thanks for your reply David. I didn't realize I could change the title of my post! Haha. I rather like the example because Table 1 actually appears in Cameron and Trivedi (potential error and all!). aperm is not the issue. I am not sure why you get different output, it should be the case. Other

Re: [R] Plots: I've deleted axes, now to delete space

2011-05-22 Thread Jannis
Hi Adele, it was not my intention to critizise you for posting your question. You are totally free to post whatever question you like and the reciepient is then free to answer it or not. I wanted, however, to demonstrate to you that it would have been easier in my opinion to research some

Re: [R] Adding dash-lines in R tables

2011-05-22 Thread David Winsemius
On May 22, 2011, at 7:47 AM, Axel Urbiz wrote: is it possible to add dash lines to tables or matrices when they are printed? An example of what I'm looking for is this: library(Design) y - sample(c(0,1),100, replace = TRUE) x - rnorm(100) summary(y ~ x) There is a method for summary on

Re: [R] How to calculate confidence interval of C statistic by rcorr.cens

2011-05-22 Thread Frank Harrell
S.D. is the standard deviation (standard error) of Dxy. It already includes the effective sample size in its computation so the sqrt(n) terms is not needed. The help file for rcorr.cens has an example where the confidence interval for C is computed. Note that you are making the strong

Re: [R] dealing with sweave.sty and pgfSweave

2011-05-22 Thread Ista Zahn
Hi Ravi, There are a couple of ways to do it. See chapter 4 of the MikTeX documentation. Best, Ista PS. List: Is there any reason why Sweave.sty should not be distributed with the major LaTeX distributions (TeXlive, MacTeX, MikTeX)? Every time I add Sweave.sty to my texmf directory I wonder

Re: [R] Shrink file size of pdf graphics

2011-05-22 Thread Layman123
Thank you very much for the tip! Using imagemagick i got an image of reasonable quality without making the file size that large. Regards Roman Von: quot;Philipp Pagel-5 [via R]quot; lt;ml-node+3537871-1637924423-125...@n4.nabble.comgt; Gesendet: 20.05.2011 09:50:42 An: Layman123

Re: [R] Adding dash-lines in R tables

2011-05-22 Thread Ista Zahn
Axel, you may also be interested in the ascii function (in the ascii package). The ascii version of David's example is library(ascii) #may need install.packages(ascii) first ascii(M) ascii(table(sample(1:10, 100, replace=TRUE))) Best, Ista On Sun, May 22, 2011 at 9:52 AM, David Winsemius

Re: [R] multilevel

2011-05-22 Thread eeecon
I see.. Row1 of Table 2 gives averages for category 3 in the group with a zero in cols 6-8 AND col 2. I wanted to averages for category 3 in the group with a zero in cols 6-8 and a 1 in col 2. I still think its suspicious that cols V1 and V2 in Table 1 are the same. -- View this message in

Re: [R] maximum likelihood convergence reproducing Anderson Blundell 1982 Econometrica R vs Stata

2011-05-22 Thread Mike Marchywka
From: marchy...@hotmail.com To: rvarad...@jhmi.edu; pda...@gmail.com; alex.ols...@gmail.com Date: Sat, 21 May 2011 20:40:44 -0400 CC: r-help@r-project.org Subject: Re: [R] maximum likelihood convergence reproducing Anderson Blundell 1982

Re: [R] How to calculate confidence interval of C statistic by rcorr.cens

2011-05-22 Thread khosoda
Thank you for your comment, Prof Harrell. I changed the function; CstatisticCI - function(x) # x is object of rcorr.cens. { se - x[S.D.]/2 Low95 - x[C Index] - 1.96*se Upper95 - x[C Index] + 1.96*se cbind(x[C Index], Low95, Upper95) }

Re: [R] Adding dash-lines in R tables

2011-05-22 Thread David Hajage
moreover: library(ascii) M - matrix(letters[1:10], 2) M [,1] [,2] [,3] [,4] [,5] [1,] a c e g i [2,] b d f h j ascii(M) | | a | c | e | g | i | b | d | f | h | j | print(ascii(M), rest) +---+---+---+---+---+ | a | c | e | g | i |

Re: [R] How to intantiate a list of data.frames?

2011-05-22 Thread Joshua Wiley
Hi Rui, data frames must have the same number of rows, but two different data frames stored within a list do not need to have the same number of rows. Can you please post the code that is giving the error? Josh On Sun, May 22, 2011 at 9:41 AM, Rui Maximo ruimax...@hotmail.com wrote: Hi Josh,

[R] using predict.lm function

2011-05-22 Thread Dave Evens
Dear all, I'm fitting a linear model with numerous lag terms of the response variable [i.e. y(t-1), y(t-2),y(t-3)...,] and other explanatory variables [x(1), x(2), x(3),]- which go into my design matrix X. I'm fitting the linear model: lm(Y ~ X, ...). I would like to use the predict.lm

Re: [R] How to intantiate a list of data.frames?

2011-05-22 Thread Rui Maximo
Hi Josh, Sorry, your examples have equal number of rows in both df and df2. In my situation they haven't. Strangely, your solution have worked only when I am copy post the code into the command line. If I use the code inside of a function I get an error at: return(ds) ERROR: arguments imply

Re: [R] A better way to do this

2011-05-22 Thread 1Rnwb
here is the data set, yes i am doing spagghetti plots for each Subject for MCP1 with respect to the Age.at.Sample.Collection, with a final of all the controls and all the cases Subject.ID sample Group Age.at.Sample.CollectionMCP1 19 00173-0 3455 control11.767282

Re: [R] Adding dash-lines in R tables

2011-05-22 Thread David Winsemius
On May 22, 2011, at 2:22 PM, David Hajage wrote: moreover: library(ascii) Seems strange that the ascii.interger function doesn't set the digits argument to 0: ascii(as.integer(c(3,4,5))) |= | 3.00 | 4.00 | 5.00 |= ascii(as.integer(c(3,4,5)),

Re: [R] Adding dash-lines in R tables

2011-05-22 Thread David Winsemius
On May 22, 2011, at 2:41 PM, David Winsemius wrote: On May 22, 2011, at 2:22 PM, David Hajage wrote: moreover: library(ascii) Seems strange that the ascii.interger function doesn't set the digits argument to 0: ascii.integer ascii(as.integer(c(3,4,5))) |= |

Re: [R] using predict.lm function

2011-05-22 Thread David Winsemius
On May 22, 2011, at 12:35 PM, Dave Evens wrote: Dear all, I'm fitting a linear model with numerous lag terms of the response variable [i.e. y(t-1), y(t-2),y(t-3)...,] and other explanatory variables [x(1), x(2), x(3),]- which go into my design matrix X. I'm fitting the linear model:

Re: [R] How to calculate confidence interval of C statistic by rcorr.cens

2011-05-22 Thread Frank Harrell
Hi Kohkichi, What we really need to figure out is how to make validate give you confidence intervals for Dxy or C while it is penalizing for overfitting. Some people have ad hoc solutions for that but nothing is nailed down yet. Frank khosoda wrote: Thank you for your comment, Prof Harrell.

Re: [R] unwanted coercion using apply

2011-05-22 Thread Jeroen Ooms
apply() operates on arrays and a data frame will be coerced to a matrix (which requires all elements to be of the same type). This is documented in ?apply. Thanks, I was not aware of that. I implicitly assumed there would be a specific apply.data.frame. This may not be elegant, but why

Re: [R] unwanted coercion using apply

2011-05-22 Thread David Winsemius
On May 22, 2011, at 3:22 PM, Jeroen Ooms wrote: apply() operates on arrays and a data frame will be coerced to a matrix (which requires all elements to be of the same type). This is documented in ?apply. Thanks, I was not aware of that. I implicitly assumed there would be a specific

Re: [R] unwanted coercion using apply

2011-05-22 Thread David Winsemius
On May 22, 2011, at 2:11 AM, Jeroen Ooms wrote: I need to convert a dataframe to a record-structure, to be able to encode it later in JSON. Suppose this is the data: mydata - data.frame(foo=1:3, bar=c(M,M,F)); I would like to convert this to a unnamed list (json array) of key- value

Re: [R] unwanted coercion using apply

2011-05-22 Thread David Winsemius
On May 22, 2011, at 3:40 PM, David Winsemius wrote: On May 22, 2011, at 2:11 AM, Jeroen Ooms wrote: I need to convert a dataframe to a record-structure, to be able to encode it later in JSON. Suppose this is the data: mydata - data.frame(foo=1:3, bar=c(M,M,F)); I would like to convert

Re: [R] How to intantiate a list of data.frames?

2011-05-22 Thread Rui Maximo
I will post the whole function, but I believe the problem is in the 3th part. The issue is that oilDF has different number of rows than oilDF2. Thank you, Rui myScan - function(dirPath, num) { #dirPath is the name of the directory where we want to apply the function. It should be called from

[R] Manipulating rownames for nMDS

2011-05-22 Thread morrokm
I am trying to plot an nMDS plot using ggplot2. My rownames are coded so that they can be broken down by Site, Species, Treatment, or Replicate based on unique separators. There are no column headers. I am having trouble coding ggplot2 to plot by Site -or- Species -or- Treatment and NOT by all

[R] tm package, makeChunks

2011-05-22 Thread Matevž Pavlič
Hi all, i have a question about a makeChunks function from tm package. I have a text with constructed with a SQL qurey consisting of several rows in a table. The texts should be around 1000 lines but is now one long line of text. My question is : Does this matter in makeChunks()

Re: [R] A better way to do this

2011-05-22 Thread Dennis Murphy
Hi: Here are a few options for making this type of plot: # ggplot2 library(ggplot2) ggplot(dd, aes(x = Age.at.Sample.Collection, y = MCP1, group = Subject.ID, colour = Subject.ID, shape = Group)) + geom_point(size = 2.5) + geom_line(size = 0.6) + labs(x = 'Age') ggplot(dd,

[R] Convert dataframe with two factors from wide to long format

2011-05-22 Thread Gang Chen
I know how to convert a simple dataframe from wide to long format with one varying factor. However, for a dataset with two factors like the following, Subj T1_Cond1 T1_Cond2 T2_Cond1 T2_Cond2 1 0.125869 4.108232 1.099392 5.556614 2 1.427940 2.170026 0.120748 1.176353 How to

Re: [R] Convert dataframe with two factors from wide to long format

2011-05-22 Thread David Winsemius
On May 22, 2011, at 5:25 PM, Gang Chen wrote: I know how to convert a simple dataframe from wide to long format with one varying factor. However, for a dataset with two factors like the following, Subj T1_Cond1 T1_Cond2 T2_Cond1 T2_Cond2 1 0.125869 4.108232 1.099392 5.556614 2

Re: [R] grep pattern

2011-05-22 Thread Kang Min
Thanks! On May 21, 7:09 am, David Winsemius dwinsem...@comcast.net wrote: On May 20, 2011, at 11:57 AM, Kang Min wrote: Hi all, I'm trying to subset a pattern in a vector. Each argument has 6 letters, and I need those that start with Z and end with Z. e.g. x - c(ZFHSJK,

Re: [R] Convert dataframe with two factors from wide to long format

2011-05-22 Thread Dennis Murphy
Hi: library(reshape2) d1 - melt(d, id = 'Subj') d1 - cbind(d1, colsplit(d1$variable, '_', c('Time', 'Cond'))) d1 - transform(d1, Time = substr(Time, 2, 2), Cond = substr(Cond, 5, 5))[c(1, 4, 5, 3)] str(d1) d1 You can decide whether to leave Time and Cond as

Re: [R] grep pattern

2011-05-22 Thread jim holtman
If you want to only match names of length 6, you will have to use this pattern: x - c(ZFHSJK, ZFHJKZ,ZIOPWE,ZLKJSD,ZKFLPZ, ZAAZ, ZAZ, + ZZAZ, ZRITEZ) # match exactly values of length 6 len6 - ^Z[[:alpha:]]{4}Z$ grep(len6, x) [1] 2 5 9 On Sun, May 22, 2011 at 5:10 PM, Kang Min

Re: [R] Convert dataframe with two factors from wide to long format

2011-05-22 Thread Gang Chen
Just learned another trick today. Thanks a lot to both of you for the kind help! Gang On Sun, May 22, 2011 at 6:04 PM, Dennis Murphy djmu...@gmail.com wrote: Hi: library(reshape2) d1 - melt(d, id = 'Subj') d1 - cbind(d1, colsplit(d1$variable, '_', c('Time', 'Cond'))) d1 - transform(d1,

Re: [R] Finding solution set of system of linear equations.

2011-05-22 Thread dslowik
Thanks Robert. That all seems to work. I also found the MASS::Null() function that gives the null space for the matrix(transpose) given as argument. I am still trying to appreciate the math behind the Moore-Penrose inverse matrix. If you have any suggestions for understanding how to use R to solve

[R] SNA query

2011-05-22 Thread Thomas Rawdon (Tom)
Hi R Users I am working with the very useful SNA package (v.2.2) in R and have a query I hope you may be able to help out with: I have been using gplot commands to plot an SNA graph. Here's the code and output: library(sna); library(network); library(RODBC) setwd(c:\\temp) x =

[R] Help with isolating and comparing data from two files.

2011-05-22 Thread ajn21
Hello, I was hoping that someone would be able to help me or at least point me in the right direction regarding a problem I am having. I am a new R user, and I've been trying to read tutorials but they haven't been much help to me so far. The problem is relatively simple as I've already created

Re: [R] How to calculate confidence interval of C statistic by rcorr.cens

2011-05-22 Thread khosoda
Dear Prof. Harrell, I'm sorry to say this, but I'm afraid I cannot understand what you write very well. Do you mean that the method to calculate confidence intervals for Dxy or C statistics in logistic model penalized for overfitting has not been established yet and what I did is wrong?