Re: [R] Drop matching lines from readLines

2010-10-14 Thread Santosh Srinivas
I guess invert does the trick.
For recording ... example .. 
file - grep(Repurchase Price,file, fixed = TRUE, invert = TRUE)


-Original Message-
From: Santosh Srinivas [mailto:santosh.srini...@gmail.com] 
Sent: 14 October 2010 11:28
To: 'r-help'
Subject: Drop matching lines from readLines

Dear R-group,

I have some noise in my text file (coding issues!) ...  I imported a 200 MB
text file using readlines
Used grep to find the lines with the error?

What is the easiest way to drop those lines? I plan to write back the
cleaned data set to my base file.

Thanks.

__
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 by Group

2010-10-14 Thread Dieter Menne


Ado wrote:
 
 
 My data:
 
 XYSpecies Group
 0   0A1
 .. A1
 .. A1
 I want to plot X vs Y for each species onto the same plot, using lines. 
 In other words, I need 30 different lines each plotted between 0 and  1 on
 the x axis and 0 and 100 on the y, but they need to be grouped by the
 Species, otherwise the lines return from  100 to 0 at the end of the data
 from each species.
 
 
Probably not exactly what you want, but some permutations of group and
|Species should work.

Dieter

library(lattice)
n= 200
dat = data.frame(X=sample(1:99,n,TRUE), Y=sample(0:1,n,TRUE),
   
Species=sample(c(A,B),n,TRUE),Group=as.factor(sample(1:3,n,TRUE)))
# avoid criss-cross by ordering
dat = dat[with(dat,order(X,Y,Species,Group)),] 
xyplot(X~Y|Species, group=Group,data=dat,type=l)


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Plotting-by-Group-tp2994780p2994867.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] R and Oracle

2010-10-14 Thread siddharth . garg85
Hi

Can someone please help me with connecting to oracle via R. I have been trying 
to use ROracle but its giving me a lot of trouble because of pro*c.

ThanksRegards
Siddharth
Sent on my BlackBerry® from Vodafone
__
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] GridR error

2010-10-14 Thread Elizabeth Purdom

Hi,
I am trying to use 'GridR' package for the first time, and I'm running 
into a strange error from grid.check:


 grid.check(gridFun)
Error in exists(add) : invalid first argument

After playing around in recover mode, I see that this because the 
variable 'add' created by grid.check is blank:


Browse[1] split[[1]][k]
[1]  : 
Browse[1] add
[1] 

The problem appears to be that my grid.input.Parameters (shown in full 
below) has components that look like this:

'anonymous : anonymous'
so when it is split by 'anonymous' I get add that is , and this 
gives me an error in 'exists(add)'. I have no real idea what this 
function is doing, but is there a work around for what ever is going on?


My function is quite complicated and calls a lot of local variables 
which are themselves quite intricate, so I don't really know what other 
information I can give. Any help is appreciated!


 sessionInfo()
R version 2.11.1 (2010-05-31)
x86_64-unknown-linux-gnu

locale:
[1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8   LC_NAME=C
[9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] GridR_0.9.1   codetools_0.2-2   multicore_0.1-3
[4] Rsamtools_1.0.7   Biostrings_2.16.9 GenomicFeatures_1.0.6
[7] GenomicRanges_1.0.7   IRanges_1.6.11projectManager_1.0
[10] XML_3.1-0

loaded via a namespace (and not attached):
[1] Biobase_2.8.0 biomaRt_2.4.0 BSgenome_1.16.5   DBI_0.2-5
[5] RCurl_1.4-3   RSQLite_0.9-2 rtracklayer_1.8.1 tools_2.11.1


Thanks,
Elizabeth

The full grid.input.Parameters:

Browse[1] grid.input.Parameters
[1]  anonymous: no visible global function definition for 
âmyreadPairedAlignmentsâ\n anonymous: no visible global function 
definition for âScanBamParamâ\n anonymous: no visible global function 
definition for âscanBamFlagâ\n anonymous: no visible global function 
definition for âmatchBamToNamesâ\n anonymous: no visible binding for 
global variable âGRangesListâ\n anonymous: no visible binding for 
global variable âalign2GRangesâ\n anonymous: no visible binding for 
global variable âGRangesListâ\n anonymous: no visible binding for 
global variable âalign2GRangesâ\n anonymous: no visible binding for 
global variable âalign2GRangesâ\n anonymous: no visible binding for 
global variable âalign2GRangesâ\n anonymous: no visible global 
function definition for âvaluesâ\n anonymous: no visible global 
function definition for âgetTxIdsByGeneâ\n anonymous: no visible 
global function definition for âexonsByâ\n anonymous: no visible 
global function definition for âendoapplyâ\n anonymous: no visible 
binding for global variable âreduceâ\n anonymous : anonymous: no 
visible global function definition for âalignPairs2Txâ\n anonymous: no 
visible global function definition for âseqnamesâ\n anonymous : 
anonymous : anonymous: no visible global function definition for 
âalignPairs2Txâ\n anonymous : anonymous: no visible global function 
definition for âalignPairs2Exâ\n anonymous: no visible global function 
definition for âseqnamesâ\n anonymous : anonymous : anonymous: no 
visible global function definition for âalignPairs2Exâ\n anonymous: no 
visible global function definition for âmclapplyâ\n anonymous: no 
visible binding for global variable â.tabulateReadsâ\n anonymous: no 
visible binding for global variable â.tabulateReadsâ\n


--
-
Elizabeth Purdom
Assistant Professor
Department of Statistics
UC, Berkeley

Office: 433 Evans Hall
(510) 642-6154 (office)
(510) 642-7892 (fax)
Mailing: 367 Evans Hall Berkeley, CA 94720-3860
epur...@stat.berkeley.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] Boxplot has only one whisker

2010-10-14 Thread tom


  You should provide raw data to boxplot(), not summary stats.
If you want to input summary stats, there was a post some time ago on that:
http://finzi.psych.upenn.edu/Rhelp10/2010-September/251674.html
\quoate

Overwriting $stats did the job for me. I wanted to show the effect of using
different quantile computation methods. 

Thanks a lot to everybody for the quick answers!

Tom

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Boxplot-has-only-one-whisker-tp2993262p2994962.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] Replacing N.A values in a data frame

2010-10-14 Thread Santosh Srinivas
Hello,  I have a data frame as below ... in cases where I have N.A. I want
to use an average of the past date and next date .. any help?

13/10/2010  A   23
13/10/2010  B   12
13/10/2010  C   124
14/10/2010  A   43
14/10/2010  B   54
14/10/2010  C   65
15/10/2010  A   43
15/10/2010  B   N.A.
15/10/2010  C   65


--
Thanks R-Helpers.

__
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] robust standard errors for panel data - corrigendum

2010-10-14 Thread Millo Giovanni
Hello again Max. A correction to my response from yesterday. Things were better 
than they seemed.

I thought it over, checked Arellano's panel book and Driscoll and Kraay (Rev. 
Econ. Stud. 1998) and finally realized that vcovSCC does what you want: in 
fact, despite being born primarily for dealing with cross-sectional 
correlation, 'SCC' standard errors are robust to both contemporaneous and 
lagged cross-sectional correlation, of which serial correlation is a special 
case (lagged correlation of u_is with u_jt for i=j). 

From Driscoll and Kraay's simulations, you need T20-25 at a minimum but N can 
be arbitrarily large. The bandwidth of the smoother is your choice, just as in 
Newey-West, defaults to a reasonable value etc. etc., please see ?vcovSCC. A 
nice explanation (in a Stata context) in Hoechle (2007) on the Stata journal, 
also here: http://fmwww.bc.edu/repec/bocode/x/xtscc_paper.pdf

I still believe my home-made panel-Newey-West from yesterday would work, but 
you can use vcovSCC{plm} and get cross-sectional robustness as well!
PS a couple of experts on the subject are bc/c-ed, please correct me if I'm 
wrong.

Best,
Giovanni

-Messaggio originale-
Da: Millo Giovanni 
Inviato: mercoledì 13 ottobre 2010 14:16
A: 'Achim Zeileis'; Max Brown
Cc: r-h...@stat.math.ethz.ch; yves.croiss...@univ-reunion.fr
Oggetto: R: [R] robust standard errors for panel data

Hello.
In principle Achim is right, by default vcovHC.plm does things the Arellano 
way, clustering by group and therefore giving SEs which are robust to general 
heteroskedasticity and serial correlation. The problem with your data, though, 
is that this estimator is N-consistent, so it is inappropriate for your 
setting. The other way round, on the converse (cluster=time) would yield a 
T-consistent estimator, robust to cross-sectional correlation: there's no 
escape, because the big dimension is always used to get robustness along the 
small one.

Therefore the road to go to have robustness along the big dimension is some 
sort of nonparametric truncation. So:

** 1st (possible) solution **

In my opinion, you would actually need a panel implementation of Newey-West, 
which is not implemented in 'plm' yet. It might well be feasible by applying 
vcovHAC{sandwich} to the time-demeaned data but I'm not sure; in this case, 
vcovHAC should be applied this way (here: the famous Munnell data, see 
example(plm))


 library(plm)
 fm-log(gsp)~log(pcap)+log(pc)+log(emp)+unemp
 data(Produc)
 ## est. FE model
 femod-plm(fm, Produc)
 ## extract time-demeaned data
 demy-pmodel.response(femod, model=within) demX-model.matrix(femod, 
 model=within) ## estimate lm model on demeaned data ## (equivalent 
 to FE, but makes a 'lm' object)
 demod-lm(demy~demX-1)
 library(sandwich)
 library(lmtest)
 ## apply HAC covariance, e.g., to t-tests coeftest(demod, 
 vcov=vcovHAC)

t test of coefficients:

Estimate Std. Error t value  Pr(|t|)
demXlog(pcap) -0.0261497  0.0485168 -0.5390   0.59005
demXlog(pc)0.2920069  0.0496912  5.8764 6.116e-09 ***
demXlog(emp)   0.7681595  0.0677258 11.3422  2.2e-16 ***
demXunemp -0.0052977  0.0018648 -2.8410   0.00461 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

 ## same goes for waldtest(), lht() etc.

but beware, things are probably complicated by the serial correlation induced 
by demeaning: see the references in the serial correlation tests section of the 
package vignette. Caveat emptor.

** 2nd solution **
Another possible strategy is screening for serial correlation first: again, see 
?pbgtest, ?pdwtest and be aware of all the caveats detailed in the 
abovementioned section of the vignette regarding use on FE models.

** 3rd solution **
Another thing you could do (Hendry and friends would say should do!) to get 
rid of serial correlation is a dynamic FE panel, as the Nickell bias is of 
order 1/T and so might well be negligible in your case.

Anyway, thanks for motivating me: I thought we'd provided robust covariances 
all over the place, but there was one direction left ;^) Giovanni

-Messaggio originale-
Da: Achim Zeileis [mailto:achim.zeil...@uibk.ac.at]
Inviato: mercoledì 13 ottobre 2010 12:06
A: Max Brown
Cc: r-h...@stat.math.ethz.ch; yves.croiss...@univ-reunion.fr; Millo Giovanni
Oggetto: Re: [R] robust standard errors for panel data

On Wed, 13 Oct 2010, Max Brown wrote:

 Hi,

 I would like to estimate a panel model (small N large T, fixed 
 effects), but would need robust standard errors for that. In 
 particular, I am worried about potential serial correlation for a 
 given individual (not so much about correlation in the cross section).

 From the documentation, it looks as if the vcovHC that comes with plm
 does not seem to do autocorrelation,

My understanding is that it does, in fact. The details say

  Observations may be clustered by 'group' ('time') to account
  for serial (cross-sectional) correlation.

Thus, the default appears to 

[R] Adding legend to lda-plot, using the MASS-package

2010-10-14 Thread Arve Lynghammar

Hi everyone!
I'm going to analyze the attached data set, but I'm not able to add the
correct legend. In other words, I can't see which species is which.

http://r.789695.n4.nabble.com/file/n2994991/test_discriminant_anal_alle.xls
test_discriminant_anal_alle.xls 

This is my commands:

data- read.table(clipboard,header=TRUE)
library(MASS)
output-lda(Species~., data)
scores=predict(output, data)$x
plot(scores, col=rainbow(4)[data$Species], asp=1)

Is there a quick way to add a legend to the plot with the corresponding
colours?

It's probably an easy way to do it, but now I've used too many days on
this...

Thank you in advance, 

Arve L.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Adding-legend-to-lda-plot-using-the-MASS-package-tp2994991p2994991.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] Data Gaps

2010-10-14 Thread dpender

Thanks Dennis.

 

One more thing if you don't mind.  How to I abstract the individual H and T
“arrays” from f(m,o,l) so as I can combine them with a date/time array and
write to a file?


Sorry if it’s a simple question but I’m completely new to R.

 

Cheers,

 

Doug

 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Data-Gaps-tp2993317p2994997.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] spatial partition

2010-10-14 Thread ogbos okike
Hi everybody,
I have a huge  longitude and latitude data. I have used raster package to
get the since of its global distribution. But I wish to display the
information using a few points on the world map.

The data is of the form:
95.2156 0.8312
-65.3236 -3.3851
-65.2364 -3.2696
-65.2349 -3.2679
164.7025 -17.6404
148.8214 -4.8285
-67.6568 2.6477
-73.4833 -0.2350
40.9587 -16.8655
-61.6474 8.1179
93.3401 -0.2755
119.9011 -17.1733
-69.7640 1.1245
-149.3088 -20.0035
177.8753 -3.4200
-67.5590 3.0133
-21.9331 15.4684
120.2656 -17.6166
165.9368 -17.3888
164.7335 -17.6953
-74.0017 -1.8623
-71.1195 -3.3562
130.1496 -11.5775


I am thinking of a way of handling that data in such a way that they can be
represented by fewer points when plotted on the map. I have tried using
factor method but didn't get any way.

Thank you for any idea
Best
Ogbos

[[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] (no subject)

2010-10-14 Thread Michael Bedward
Hello Julia,

I'm afraid your code had multiple problems: variables declared but not
used, incorrect or unnecessary use of the c function, out-of-bounds
subscripts and overwriting of result objects.

Rather than point them all out in detail I've modified your code so
that it works (see below). Please study this code and compare it to
your original code. This will help you to understand how to do things
more simply and reliably in R. Don't be discouraged - it takes
practice :)

Note, I didn't know whether you really wanted to retain the resultx
and resultb matrices. I've left them in there just in case.

Michael


bidding.simulation - function(nsim=10, N=200, I=5) {
  set.seed(180185)

  tau - seq(0.48, 0.52, 0.001)
  tau.mid - which(tau == 0.5)

  Ntau - length(tau)

  mresultx - matrix(-99, nrow=I*N, ncol=nsim)
  mresultb - matrix(-99, nrow=I*N, ncol=nsim)

  h - seq(0.001, 0.020, 0.001)

  Mb0 - matrix(0, nrow=nsim, ncol=Ntau)
  Mb1 - matrix(0, nrow=nsim, ncol=Ntau)
  colnames(Mb1) - colnames(Mb0) - paste(tau, tau, sep=.)

  Mhb0 - matrix(0, nrow=nsim, ncol=tau.mid - 1)
  Mhb1 - matrix(0, nrow=nsim, ncol=tau.mid - 1)
  colnames(Mhb1) - colnames(Mhb0) - paste(width, tau[(tau.mid -
1):1] - tau[(tau.mid + 1):Ntau], sep=.)

  for (i in 1:nsim){
mu - runif(I*N)
mx - rep(runif(N), I)
b0 - rep(1, I*N)

#function for private cost
cost - b0+b0*mx+mu

#bidding strategy
bid - mx+((I+1)/I)+((I-1)/I)*mu
mresultb[,i] - bid
mresultx[,i] - mx

qf - rq(formula = bid ~ mx, tau = tau)
coefs - coef(qf)

Mb0[i, ] - coefs[1, ]
Mb1[i, ] - coefs[2, ]
Mhb0[i, ] - coefs[1, (tau.mid - 1):1] - coefs[1, (tau.mid+1):Ntau]
Mhb1[i, ] - coefs[2, (tau.mid - 1):1] - coefs[2, (tau.mid+1):Ntau]
  }

  # return results as a list
  list(Mb0=Mb0, Mb1=Mb1, Mhb0=Mhb0, Mhb1=Mhb1, mresultx=mresultx,
mresultb=mresultb)
}




On 14 October 2010 05:37, Julia Lira julia.l...@hotmail.co.uk wrote:

 Dear all,



 I have just sent an email with my problem, but I think no one can see the red 
 part, beacuse it is black. So, i am writing again the codes:



 rm(list=ls()) #remove almost everything in the memory

 set.seed(180185)
 nsim - 10
 mresultx - matrix(-99, nrow=1000, ncol=nsim)
 mresultb - matrix(-99, nrow=1000, ncol=nsim)
 N - 200
 I - 5
 taus - c(0.480:0.520)
 h - c(1:20/1000)
 alpha1 - c(1:82)
 aeven1 - alpha[2 * 1:41]
 aodd1 - alpha[-2 * 1:41]
 alpha2 - c(1:40)
 aeven2 - alpha2[2 * 1:20]
 #Create an object to hold results.
 M - matrix(0, ncol=82, nrow=nsim)
 Mhb0 - matrix(0, ncol=20, nrow=nsim)
 Mhb1 - matrix(0, ncol=20, nrow=nsim)
 Mchb0 - matrix(0, ncol=20, nrow=nsim)
 Mchb1 - matrix(0, ncol=20, nrow=nsim)
 for (i in 1:nsim){
 # make a matrix with 5 cols of N random uniform values
 u - replicate( 5, runif(N, 0, 1) )
 # fit matrix u in another matrix of 1 column
 mu - matrix(u, nrow=1000, ncol=1)
 # make auction-specific covariate
 x - runif(N, 0, 1)
 mx - matrix(rep(x,5), nrow=1000, ncol=1)
 b0 - matrix(rep(c(1),1000), nrow=1000, ncol=1)
 #function for private cost
 cost - b0+b0*mx+mu
 #bidding strategy
 bid - mx+((I+1)/I)+((I-1)/I)*mu
 mresultb[,i] - bid
 mresultx[,i] - mx
 qf - rq(formula = mresultb[,i] ~ mresultx[,i], tau= 480:520/1000)
 # Storing result and does not overwrite prior values
 M[i, ] - coef(qf)
 QI - (1-0.5)/(I-1)
 M50b0 - M[,41]
 M50b1 - M[,42]
 Mb0 - matrix(M[,aodd1], nrow=nsim, ncol=20)
 Mb1 - matrix(M[,aeven1], nrow=nsim, ncol=20)
  for (t in aeven2){
  Mhb0[,t] - M[,(41+t)]-M[,(41-t)]
  Mhb1[,t] - M[,(42+t)]-M[,(42-t)]
  }
 }



 The problem is in the part:

 for (t in aeven2){
  Mhb0[,t] - M[,(41+t)]-M[,(41-t)]
  Mhb1[,t] - M[,(42+t)]-M[,(42-t)]
  }


 Since I want the software to subtract from column (41+t) of matrix called M 
 the column (41-t), in such a way that the matrix Mhb0 will show me the result 
 for each t organized by columns.



 Does anybody know what exactly I am doing wrong?



 Thanks in advance!



 Julia

        [[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] Data Gaps

2010-10-14 Thread Dennis Murphy
Hi:

The essential problem is that after you append items, the result is a list
with possibly unequal lengths. Trying to convert that into a data frame by
the 'usual' methods (do.call(rbind, ...) or ldply() in plyr) didn't work (as
anticipated). One approach is to initialize a maximum size matrix with NAs
and then replace the NAs by the contents of each component of the list. The
following function is far from elegant, but the idea is to output a data
frame by 'NA filling' the shorter vectors in the list and doing the
equivalent of do.call(rbind, list).

 listNAfill - function(l) {
   # input argument l is a list with numeric component vectors
   lengths - sapply(l, length)
   m - matrix(NA, nrow = length(l), ncol = max(lengths))
   for(i in seq_len(length(l))) m[i, ] - replace(m[i, ], 1:lengths[i],
l[[i]])
   as.data.frame(m)
   }

# From the previous mail:
u - f(m, o, l)
 u
[[1]]
[1] 0.88 0.72 0.89 1.20 1.40 0.93 1.23 0.86

[[2]]
[1] 7.14 7.14 1.60 7.49 8.14 7.14 7.32
 listNAfill(u)
V1   V2   V3   V4   V5   V6   V7   V8
1 0.88 0.72 0.89 1.20 1.40 0.93 1.23 0.86
2 7.14 7.14 1.60 7.49 8.14 7.14 7.32   NA

The result of listNAfill is a data frame, so you could cbind or otherwise
attach the date-time info and then use write.table() or some other
appropriate write function.

I'm sure there is some built-in way to NA fill the list components so that
they all have equal length, but I couldn't find it. The rbind.fill()
function from plyr works with data frame inputs, not lists. A quick search
of the archives on 'NA fill' didn't turn up anything I could use, either,
but I didn't look very hard. This seems to work as expected on the simple
example I used.

Better approaches are welcomed...

HTH,
Dennis

On Thu, Oct 14, 2010 at 1:34 AM, dpender d.pen...@civil.gla.ac.uk wrote:


 Thanks Dennis.



 One more thing if you don't mind.  How to I abstract the individual H and T
 “arrays” from f(m,o,l) so as I can combine them with a date/time array and
 write to a file?


 Sorry if it’s a simple question but I’m completely new to R.



 Cheers,



 Doug



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Data-Gaps-tp2993317p2994997.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.


[R] rounding issues

2010-10-14 Thread Federico Calboli
Hi All,

I'm running the now almost-to-be upgraded R 2.11.1 on a Intel Mac, and on a 
Ubuntu machine, but the problem I see is the same. I noticed the following 
behaviour:

407585.91 * 0.8 
[1] 326068.7  -- the right asnwer is 326068.728
round(407585.91 * 0.8, 2)
[1] 326068.7 -- same issue
407585.91/100
[1] 4075.859 -- the right answer is 4075.8591

I have no saved .Rwhatever in my environment, and I never set any option to 
have such strange rounding. I'm obviously missing something, and I'd appreciate 
suggestions.

Best,

Federico


--
Federico C. F. Calboli
Department of Epidemiology and Biostatistics
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.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] spatial partition

2010-10-14 Thread Michael Bedward
Some quick ideas...

One very easy way would be to round them all to integer degrees and
remove the duplicates - or even just let the duplicates overwrite each
other in the plot.

A step up from that would be to create a matrix at some resolution
(e.g. 180 x 360 for a 1 degree global grid) and count the number of
points that fall into each matrix cell. Then plot those points with
symbol color or size to represent frequency categories.

If you want to get fancy and look for natural spatial clusters of
points in your data there are a number of packages that can help you:
http://cran.r-project.org/web/views/Spatial.html

Hope this helps.
Michael


On 14 October 2010 19:32, ogbos okike ogbos.ok...@gmail.com wrote:
 Hi everybody,
 I have a huge  longitude and latitude data. I have used raster package to
 get the since of its global distribution. But I wish to display the
 information using a few points on the world map.

 The data is of the form:
 95.2156 0.8312
 -65.3236 -3.3851
 -65.2364 -3.2696
 -65.2349 -3.2679
 164.7025 -17.6404
 148.8214 -4.8285
 -67.6568 2.6477
 -73.4833 -0.2350
 40.9587 -16.8655
 -61.6474 8.1179
 93.3401 -0.2755
 119.9011 -17.1733
 -69.7640 1.1245
 -149.3088 -20.0035
 177.8753 -3.4200
 -67.5590 3.0133
 -21.9331 15.4684
 120.2656 -17.6166
 165.9368 -17.3888
 164.7335 -17.6953
 -74.0017 -1.8623
 -71.1195 -3.3562
 130.1496 -11.5775


 I am thinking of a way of handling that data in such a way that they can be
 represented by fewer points when plotted on the map. I have tried using
 factor method but didn't get any way.

 Thank you for any idea
 Best
 Ogbos

        [[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] rounding issues

2010-10-14 Thread Ted Harding
On 14-Oct-10 09:43:53, Federico Calboli wrote:
 Hi All,
 
 I'm running the now almost-to-be upgraded R 2.11.1 on a Intel Mac, and
 on a Ubuntu machine, but the problem I see is the same. I noticed the
 following behaviour:
 
 407585.91 * 0.8 
 [1] 326068.7  -- the right asnwer is 326068.728

You need to keep in mind the distinction between the result
that R displays, and the result that it has in internal storage.
Compare your result above with:

  print(407585.91 * 0.8,7)
  # [1] 326068.7
  print(407585.91 * 0.8,8)
  # [1] 326068.73
  print(407585.91 * 0.8,9)
  # [1] 326068.728
  print(407585.91 * 0.8,10)
  # [1] 326068.728
  print(407585.91 * 0.8,11)
  # [1] 326068.728

all being the correct answer provided you print() to sufficiently
many digits (at least 9 in this case). Without the requirement
to print to enough digits, the default (see '?print.default')
is what is returned by 'getOption(digits)', which again by
default is 7 (though you can change the digits option if you
want a different value to apply globally).

 round(407585.91 * 0.8, 2)
 [1] 326068.7 -- same issue
 407585.91/100
 [1] 4075.859 -- the right answer is 4075.8591

And this has the same explanation:

  print(round(407585.91 * 0.8, 2),8)
  # [1] 326068.73
  print(round(407585.91 * 0.8, 2),9)
  # [1] 326068.73
  print(round(407585.91 * 0.8, 2),10)
  # [1] 326068.73

'round(407585.91 * 0.8, 2)' has 8 digits, but by default will
be displayed to 7 digits. Provided you print() to at least 8
digits, the result will be fully correct.

Similarly:

  print(407585.91/100,8)
  # [1] 4075.8591

 I have no saved .Rwhatever in my environment, and I never set
 any option to have such strange rounding. I'm obviously missing
 something, and I'd appreciate suggestions.
 
 Best,
 Federico

The rounding you observe is carried out when R prepares what
is to be displayed on screen and, as illustrated above, this
has a default value of 7 digits -- though this only applies to
rounding of the fractional part: the integer part is always
displayed in full:

  1234567891/10
  # [1] 123456789
  print(1234567891/10,10)
  # [1] 123456789.1

  print(1234567891/10,4)
  # [1] 123456789

The internally stored value is always stored to the full available
precision.

Hoping this helps,
Ted.


E-Mail: (Ted Harding) ted.hard...@wlandres.net
Fax-to-email: +44 (0)870 094 0861
Date: 14-Oct-10   Time: 11:10:01
-- 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] Hash fuctions library for R?

2010-10-14 Thread Uwe Ziegenhagen
Hi,

I would like to calculate various hash sums for given string but haven't
found a suitable package, yet.

I found tools::md5sum which works only for files, however I would like to
avoid putting my string in a file before calculating the hash.

Thanks,

Uwe

-- 
Uwe Ziegenhagen
http://www.uweziegenhagen.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] robust standard errors for panel data - corrigendum

2010-10-14 Thread max . e . brown
Hi Giovanni,

thanks! This seems to be exactly what I was looking for!

Max

__
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] Drop matching lines from readLines

2010-10-14 Thread Mike Marchywka







 From: santosh.srini...@gmail.com
 To: r-help@r-project.org
 Date: Thu, 14 Oct 2010 11:27:57 +0530
 Subject: [R] Drop matching lines from readLines

 Dear R-group,

 I have some noise in my text file (coding issues!) ... I imported a 200 MB
 text file using readlines
 Used grep to find the lines with the error?

 What is the easiest way to drop those lines? I plan to write back the
 cleaned data set to my base file.

Generally for text processing, I've been using utilities external to R
although there may be R alternatives that work better for you. You
mention grep, I've suggested sed as a general way to fix formatting things,
there is also something called uniq on linux or cygwin.
I have gotten into the habit of using these for a variety of data
manipulation tasks, only feed clean data into R.

$ echo -e a bc\\na bc
a bc
a bc

$ echo -e a bc\\na bc | uniq
a bc

$ uniq --help
Usage: uniq [OPTION]... [INPUT [OUTPUT]]
Filter adjacent matching lines from INPUT (or standard input),
writing to OUTPUT (or standard output).

With no options, matching lines are merged to the first occurrence.

Mandatory arguments to long options are mandatory for short options too.
  -c, --count   prefix lines by the number of occurrences
  -d, --repeated    only print duplicate lines
  -D, --all-repeated[=delimit-method]  print all duplicate lines
    delimit-method={none(default),prepend,separate}
    Delimiting is done with blank lines
  -f, --skip-fields=N   avoid comparing the first N fields
  -i, --ignore-case ignore differences in case when comparing
  -s, --skip-chars=N    avoid comparing the first N characters
  -u, --unique  only print unique lines
  -z, --zero-terminated  end lines with 0 byte, not newline
  -w, --check-chars=N   compare no more than N characters in lines
  --help display this help and exit
  --version  output version information and exit

A field is a run of blanks (usually spaces and/or TABs), then non-blank
characters.  Fields are skipped before chars.

Note: 'uniq' does not detect repeated lines unless they are adjacent.
You may want to sort the input first, or use `sort -u' without `uniq'.
Also, comparisons honor the rules specified by `LC_COLLATE'.











 Thanks.

  
__
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] Memory not mapped when using .C, problem in Mac but not in Linux

2010-10-14 Thread David
Thank you, William and Berend, for your thorough replies. I have still the
habit of setting long int variables because, when I first learnt C, the
manual said that int could be up to around 3.2e4. But I suppose that, in
systems from 32 bits, an int number can be much larger, isn't it?

- which version of Mac OS X?


10.6.4


 - Which version of R? (version, architecture)


The version is 2.11.1 (although I had the same problem with the previous
version). I downloaded the binary for Mac from r-project. In the
Applications menu, I can see R and R64. Nevertheless, I start R in the
command line: like this, I suppose it is the 64 bits version which starts,
isn't it?


 - Officially provided R or compiled by you? Official R is compiled with
 Apple gcc.


The official one.


 - if R was compiled with Apple compiler, who knows what can happen if you
 link with code compiled with a non Apple gcc?


It is the official. Nevertheless, my code C for R works in Linux whether I
compile my C functions with gcc or with icc.


 - if the code runs ok on your supervisors iMac: did he use Apple compiler?


I do not think he compiled it himself. For the architecture, he does not
remember well, he has said that he thinks that he is using a version of R
that was compiled in 32 bits.


 if so I wouldn't be surprised if your Macports compiler is a possible cause
 of your troubles.


I do not think so. Both R and the default gcc did not come from Macports.
The default gcc came with Xcode in the extras' cd (by the way, how can gcc
in Mac be upgraded?).


 - on 64bit Mac OS X long int is 64bits and int is 32bits; on 32bit Mac OSX
 both are 32 bits.


Thank you. As I said, chaging from unsigned long int to int seemed to
solve the problem.

David
Can you please Cc to me any replies, just in case I may miss any of them
among the whole amount of emails :-) ?

[[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] Hash fuctions library for R?

2010-10-14 Thread Hans W Borchers
Uwe Ziegenhagen ziegenhagen at gmail.com writes:
 
 Hi,
 
 I would like to calculate various hash sums for given string but haven't
 found a suitable package, yet.
 
 I found tools::md5sum which works only for files, however I would like to
 avoid putting my string in a file before calculating the hash.

See the 'digest' package.

Hans Werner

__
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] R and Oracle

2010-10-14 Thread Marc Schwartz
On Oct 14, 2010, at 12:45 AM, siddharth.gar...@gmail.com wrote:

 Hi
 
 Can someone please help me with connecting to oracle via R. I have been 
 trying to use ROracle but its giving me a lot of trouble because of pro*c.
 
 ThanksRegards
 Siddharth


You have not provided sufficient information (OS, error messages, what you have 
done so far, etc.) to enable us to help you. Review the Posting Guide:

  http://www.R-project.org/posting-guide.html

To start, be sure to read:

  http://cran.r-project.org/web/packages/ROracle/INSTALL

I would also recommend searching the list archives, using one of the R search 
tools such as:

  http://www.rseek.org/

using ROracle as a keyword.

Depending upon your platform, you may wish to consider using the RODBC package 
instead, which I have used on Linux and OSX to connect to Oracle servers.

Finally, there is the R-SIG-DB list, which is focused on R and database 
connectivity/usage. More information is here:

  https://stat.ethz.ch/mailman/listinfo/r-sig-db

I would recommend subscribing to that list and re-posting your query there, 
with additional details, once you have reviewed the above resources.

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.


Re: [R] Replacing N.A values in a data frame

2010-10-14 Thread Henrique Dallazuanna
If I understand you can use approxfun:

DF - read.table(textConnection(
13/10/2010  A   23
13/10/2010  B   12
13/10/2010  C   124
14/10/2010  A   43
14/10/2010  B   54
14/10/2010  C   65
15/10/2010  A   43
15/10/2010  B   N.A.
15/10/2010  C   65), na.strings = N.A.)

f - approxfun(1:nrow(DF), DF$V3)
DF$V4 - sapply(seq(nrow(DF)), f)


On Thu, Oct 14, 2010 at 5:17 AM, Santosh Srinivas 
santosh.srini...@gmail.com wrote:

 Hello,  I have a data frame as below ... in cases where I have N.A. I want
 to use an average of the past date and next date .. any help?

 13/10/2010  A   23
 13/10/2010  B   12
 13/10/2010  C   124
 14/10/2010  A   43
 14/10/2010  B   54
 14/10/2010  C   65
 15/10/2010  A   43
 15/10/2010  B   N.A.
 15/10/2010  C   65


 
 --
 Thanks R-Helpers.

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




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[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] Building ragged dataframe (was Re: Data Gaps)

2010-10-14 Thread dpender


The H and T values come form the same recording so the gaps that require
filling in H are the same as those in T.  Therefore the lists will never be
of unequal lengths and I can abstract the list to an array using
array(unlist(H)) which is a lot simpler.  My fault for not clarifying!

 

Finally, the actually dataset that needs filled will have multiple gaps like
the one below:

 

H - c(0.88, 0.72, 0.89, 0.93, 1.23, 0.86, 0.98, 0.85, 1.23)

 

T - c(7.14, 7.14, 7.49, 8.14, 7.14, 7.32, 7.14, 7.14, 7.14)

 

O - c(0, 0, 0, 2, 0, 0, 0, 2, 0)

 

Can you advise how to create multiple input lists from this so that I can
incorporate that into the function that you defined?

 

Thanks,

 

Doug

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Data-Gaps-tp2993317p2995263.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] Replacing N.A values in a data frame

2010-10-14 Thread Gabor Grothendieck
On Thu, Oct 14, 2010 at 4:17 AM, Santosh Srinivas
santosh.srini...@gmail.com wrote:
 Hello,  I have a data frame as below ... in cases where I have N.A. I want
 to use an average of the past date and next date .. any help?

 13/10/2010      A       23
 13/10/2010      B       12
 13/10/2010      C       124
 14/10/2010      A       43
 14/10/2010      B       54
 14/10/2010      C       65
 15/10/2010      A       43
 15/10/2010      B       N.A.
 15/10/2010      C       65

Assuming A, B and C refer to separate time series you can use
na.approx in zoo.

Lines - 13/10/2010  A   23
13/10/2010  B   12
13/10/2010  C   124
14/10/2010  A   43
14/10/2010  B   54
14/10/2010  C   65
15/10/2010  A   43
15/10/2010  B   N.A.
15/10/2010  C   65

library(zoo)

# z - read.zoo(myfile.dat, format = %d/%m/%Y, split = 2,
na.strings = N.A.)
z - read.zoo(textConnection(Lines), format = %d/%m/%Y, split = 2,
na.strings = N.A.)

na.approx(z)  # or na.approx(z, rule = 2)

which gives this multivariate time series in zoo:

 na.approx(z)
A  B   C
2010-10-13 23 12 124
2010-10-14 43 54  65
2010-10-15 43 NA  65

 # or
 na.approx(z, rule = 2)
A  B   C
2010-10-13 23 12 124
2010-10-14 43 54  65
2010-10-15 43 54  65





-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] Poisson Regression

2010-10-14 Thread Michael Friendly

On 10/13/2010 4:50 PM, Antonio Paredes wrote:

Hello everyone,

I wanted to ask if there is an R-package to fit the following Poisson
regression model

log(\lambda_{ijk}) = \phi_{i} + \alpha_{j} + \beta_{k}
i=1,\cdots,N (subjects)
j=0,1 (two levels)
k=0,1 (two levels)

treating the \phi_{i} as nuinsance parameters.

Thank you very much


You can use the gnm() function in the gnm package with eliminate= to get 
rid of parameters for each subject.

Something like

gnm( lambda ~ Row + Col, eliminate = Subject, family=poisson, data=myData)

where Row, Col, Subject are suitable *factors*.  This is equivalent to

gnm( lambda ~ -1 + Subject Row + Col, family=poisson)
except that Subject parameters aren't estimated explicitly.  See 
vignette(gnmOverview)



--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
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] Replacing N.A values in a data frame

2010-10-14 Thread Santosh Srinivas
Wow! That’s Amazing! Many thanks!

When I do the below ... why do the column names get thrown off? Ticker is a
factor / character ... I tried both

 temp - head(MF_Data_Sub)
 temp
Date Ticker   Price
1 2008-04-01 106270 10.3287
2 2008-04-01 106269 10.3287
3 2008-04-01 102767 12.6832
4 2008-04-01 102766 10.5396
5 2008-04-01 102855  9.7833
6 2008-04-01 102856 12.1485
 tZoo - read.zoo(temp,split=2)
 tZoo
   X102766 X102767 X102855 X102856 X106269 X106270
2008-04-01 10.5396 12.6832  9.7833 12.1485 10.3287 10.3287


Also, is there an easy way to do a return profile on the data below after it
is transformed?

Thanks very much!
S



-Original Message-
From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] 
Sent: 14 October 2010 18:22
To: Santosh Srinivas
Cc: r-help
Subject: Re: [R] Replacing N.A values in a data frame

On Thu, Oct 14, 2010 at 4:17 AM, Santosh Srinivas
santosh.srini...@gmail.com wrote:
 Hello,  I have a data frame as below ... in cases where I have N.A. I want
 to use an average of the past date and next date .. any help?

 13/10/2010      A       23
 13/10/2010      B       12
 13/10/2010      C       124
 14/10/2010      A       43
 14/10/2010      B       54
 14/10/2010      C       65
 15/10/2010      A       43
 15/10/2010      B       N.A.
 15/10/2010      C       65

Assuming A, B and C refer to separate time series you can use
na.approx in zoo.

Lines - 13/10/2010  A   23
13/10/2010  B   12
13/10/2010  C   124
14/10/2010  A   43
14/10/2010  B   54
14/10/2010  C   65
15/10/2010  A   43
15/10/2010  B   N.A.
15/10/2010  C   65

library(zoo)

# z - read.zoo(myfile.dat, format = %d/%m/%Y, split = 2,
na.strings = N.A.)
z - read.zoo(textConnection(Lines), format = %d/%m/%Y, split = 2,
na.strings = N.A.)

na.approx(z)  # or na.approx(z, rule = 2)

which gives this multivariate time series in zoo:

 na.approx(z)
A  B   C
2010-10-13 23 12 124
2010-10-14 43 54  65
2010-10-15 43 NA  65

 # or
 na.approx(z, rule = 2)
A  B   C
2010-10-13 23 12 124
2010-10-14 43 54  65
2010-10-15 43 54  65





-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] installing grid package

2010-10-14 Thread ogbos okike
Hi all,

I can't understand why grid package failed to installed on my machine. Can
anybody have a look and advice on where I am missing it.

 My R version is 2.9.2. After untarring:  tar xzvf grid_0.7-4.tar.gz, I
tried to configure or make but none worked, 'no such files'. I have also
tried using : sudo R CMD INSTALL /home/ogbos/Desktop/goo/grid_0.7-4.tar.gz
which also resulted in the error below.
* Installing to library '/home/ogbos/R/i486-pc-linux-gnu-library/2.8'
* Installing *source* package 'grid' ...
Error: Invalid DESCRIPTION file

Invalid package name.
This is the name of a base package.

Execution halted
ERROR: installing package DESCRIPTION failed

Thanks for any advice.
Ogbos

[[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] rbind ing matrices and resetting column numbers

2010-10-14 Thread Maas James Dr (MED)
Sorry for the verbose example.  I want to row bind two matrices, and all works 
except I want the column labelled row to be sequential in the new matrix, 
shown as mat3 here, i.e. needs to be 1:6 and not 1:3 repeated twice.  Any 
suggestions?

Thanks

J

 colnm1 - c(row,ti,counti)
 colnm2 - c(row,tj,countj)
 mat1 - matrix(c(1,7,9,2,8,5,3,7,9),byrow=T,nrow=3)
 colnames(mat1) - colnm1
 mat1
 row ti counti
[1,]   1  7  9
[2,]   2  8  5
[3,]   3  7  9
 mat2 - matrix(c(1,5,3,2,6,8,3,3,7),byrow=T,nrow=3)
 colnames(mat2) - colnm2
 mat2
 row tj countj
[1,]   1  5  3
[2,]   2  6  8
[3,]   3  3  7
 mat3 - rbind(mat1,mat2)
 mat3
 row ti counti
[1,]   1  7  9
[2,]   2  8  5
[3,]   3  7  9
[4,]   1  5  3
[5,]   2  6  8
[6,]   3  3  7


===
Dr. Jim Maas
University of East Anglia


[[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] rbind ing matrices and resetting column numbers

2010-10-14 Thread David Winsemius


On Oct 14, 2010, at 10:31 AM, Maas James Dr (MED) wrote:

Sorry for the verbose example.  I want to row bind two matrices, and  
all works except I want the column labelled row to be sequential  
in the new matrix, shown as mat3 here, i.e. needs to be 1:6 and  
not 1:3 repeated twice.  Any suggestions?


cbind( row=1:sum(nrow(mat1),nrow(mat2)),
   rbind(mat1[ ,-1],mat2[ ,-1])
  )

--
David.


Thanks

J


colnm1 - c(row,ti,counti)
colnm2 - c(row,tj,countj)
mat1 - matrix(c(1,7,9,2,8,5,3,7,9),byrow=T,nrow=3)
colnames(mat1) - colnm1
mat1

row ti counti
[1,]   1  7  9
[2,]   2  8  5
[3,]   3  7  9

mat2 - matrix(c(1,5,3,2,6,8,3,3,7),byrow=T,nrow=3)
colnames(mat2) - colnm2
mat2

row tj countj
[1,]   1  5  3
[2,]   2  6  8
[3,]   3  3  7

mat3 - rbind(mat1,mat2)
mat3

row ti counti
[1,]   1  7  9
[2,]   2  8  5
[3,]   3  7  9
[4,]   1  5  3
[5,]   2  6  8
[6,]   3  3  7


===
Dr. Jim Maas
University of East Anglia


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


David Winsemius, MD
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] R functions in Java

2010-10-14 Thread lord12

Suppose I have a function in R called foo.

foo = function(x)
{
   print(x);
}

When I create the Rengine re and do re.eval(foo(1)) I get the output 1. 
However, if I create a string variable in java String num = 1 and do
re.eval(foo(num)), I get an error saying that num cannot be found. How can
I fix this problem.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-functions-in-Java-tp2995428p2995428.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] rbind ing matrices and resetting column numbers

2010-10-14 Thread David Winsemius


On Oct 14, 2010, at 10:40 AM, David Winsemius wrote:



On Oct 14, 2010, at 10:31 AM, Maas James Dr (MED) wrote:

Sorry for the verbose example.  I want to row bind two matrices,  
and all works except I want the column labelled row to be  
sequential in the new matrix, shown as mat3 here, i.e. needs to  
be 1:6 and not 1:3 repeated twice.  Any suggestions?


cbind( row=1:sum(nrow(mat1),nrow(mat2)),
  rbind(mat1[ ,-1],mat2[ ,-1])
 )


NOte that using row as a column name could be a bit confusing down the  
line for two reason: a) it's actually a column, and b) row is the  
name of a useful function. In fact, that function could be used to  
solve your request using your mat3 constructed below:


 mat3[ , 1] - row(mat3)[ , 1]
 mat3
 row ti counti
[1,]   1  7  9
[2,]   2  8  5
[3,]   3  7  9
[4,]   4  5  3
[5,]   5  6  8
[6,]   6  3  7


--
David.


Thanks

J


colnm1 - c(row,ti,counti)
colnm2 - c(row,tj,countj)
mat1 - matrix(c(1,7,9,2,8,5,3,7,9),byrow=T,nrow=3)
colnames(mat1) - colnm1
mat1

   row ti counti
[1,]   1  7  9
[2,]   2  8  5
[3,]   3  7  9

mat2 - matrix(c(1,5,3,2,6,8,3,3,7),byrow=T,nrow=3)
colnames(mat2) - colnm2
mat2

   row tj countj
[1,]   1  5  3
[2,]   2  6  8
[3,]   3  3  7

mat3 - rbind(mat1,mat2)
mat3

   row ti counti
[1,]   1  7  9
[2,]   2  8  5
[3,]   3  7  9
[4,]   1  5  3
[5,]   2  6  8
[6,]   3  3  7


===
Dr. Jim Maas
University of East Anglia


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


David Winsemius, MD
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.


David Winsemius, MD
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.


Re: [R] R functions in Java

2010-10-14 Thread lord12

Any advice?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-functions-in-Java-tp2995428p2995490.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] declaring GPL license

2010-10-14 Thread Stacey Wood
Hi all,

I'm currently writing an R package and want to declare a GPL2 license.
According to the license agreement, I'm supposed to display:

  This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation ... See the
   GNU General Public License for more details.

When I add this statement to the description file, the package cannot be
processed.  Where should I add this statement to appropriately cite the
license?

Thanks,
Stacey

[[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] bwplot change whiskers position to percentile 5 and P95

2010-10-14 Thread David Winsemius


On Oct 14, 2010, at 11:07 AM, Christophe Bouffioux wrote:


Hi,

I have tried your proposition, and it works properly on the  
simulated data, but not on my real data, and I do not see any  
explanations, this is weird, i have no more ideas to explore the  
problem


You should:
a) provide the code that you used to call boxplot
b) offer str(sasdata03_a) ,  since summary will often obscure  
class-related problems

c) consider running:
sasdata03_a$Cat_F - factor(sasdata03_a$Cat_F) # to get rid of the  
empty factor level





so here i give some information on my data, nothing special actually,

Christophe

 summary(sasdata03_a)
   jaar   Cat_F  montant_oa 
nombre_casmontant_i
 2006:36854   a  :22591Min.   :  -112.8Min.   :
-5.0   Min.   :   33.22
 2007:36538   h  :220561st Qu.:  1465.5 1st Qu.:   
104.01st Qu.:   37.80
 2008:36579   i  :21844 Median :  4251.5 Median :   
307.0   Median :   50.00
k  :21485 Mean   : 13400.0Mean   :   
557.5Mean   : 1172.17
g  :16217 3rd Qu.: 13648.53rd Qu.:   
748.03rd Qu.:  458.67
d  : 5778  Max.   : 534655.6Max.   : 
13492.0   Max.   :17306.73

(Other):0
nombre_i
 Min.   :  1.00
 1st Qu.:  1.00
 Median :  5.00
 Mean   : 44.87
 3rd Qu.: 29.00
 Max.   :689.00

 is.data.frame(sasdata03_a)
[1] TRUE

The code of the function:

boxplot2.stats -  function (x, coef = 1.5, do.conf = TRUE, do.out =  
TRUE)

{
if (coef  0)
stop('coef' must not be negative)
nna - !is.na(x)
n - sum(nna)
stats - stats::fivenum(x, na.rm = TRUE)
stats[c(1,5)]- quantile(x, probs=c(0.05, 0.95))
iqr - diff(stats[c(2, 4)])
if (coef == 0)
do.out - FALSE
else {
out - if (!is.na(iqr)) {
x  (stats[2L] - coef * iqr) | x  (stats[4L] + coef *
iqr)
}
else !is.finite(x)
if (any(out[nna], na.rm = TRUE))
stats[c(1, 5)] - range(x[!out], na.rm = TRUE)
}
conf - if (do.conf)
stats[3L] + c(-1.58, 1.58) * iqr/sqrt(n)
list(stats = stats, n = n, conf = conf, out = if (do.out) x[out 
nna] else numeric(0L))
}


On Wed, Oct 13, 2010 at 5:13 PM, David Winsemius dwinsem...@comcast.net 
 wrote:


On Oct 13, 2010, at 10:05 AM, Christophe Bouffioux wrote:

Dear R-community,

Using bwplot, how can I put the whiskers at percentile 5 and  
percentile 95,

in place of the default position coef=1.5??

Using panel=panel.bwstrip, whiskerpos=0.05, from the package  
agsemisc gives
satisfaction, but changes the appearance of my boxplot and works  
with an old

version of R, what I don’t want, and I didn’t find the option in
box.umbrella parameters

Nope, you won't find it even if you search harder, but you do have a  
lattice path forward. Just as base function boxplot() does the  
calculations and then plots with bxp(), by default panel.bwplot  
sends the data to boxplot.stats, but panel.bwplot also allows you to  
specify an alternate function that returns plotting parameters  
differently as long as those conforms to the requirements for  
structure. You can look at boxplot.stats (it's not that big)  and  
then construct an alternative. The line you would need to alter  
would be the one starting with:  stats-stats::fivenum(...), since  
you are changing the values returned by fivenum(). You might get  
away with just changing stats[1] and stats[5] to your revised  
specifications, although it has occurred to me that you might get  
some of those out dots inside your whiskers. (Fixing that would  
not be too hard once you are inside boxplot.stats().


Seemed to work for me with your data (at least the extent of  
plotting a nice 3 x 2 panel display. All I did was redefine an  
nboxplot.stats by inserting this line after the line cited above:


stats[c(1,5)]- quantile(x, probs=c(0.05, 0.95))

and then added an argument  ..., stats=nboxplot.stats)  inside your  
panel.bwplot.


--
David.


Many thanks
Christophe

Here is the code:

library(lattice)
ex - data.frame(v1 = log(abs(rt(180, 3)) + 1),
   v2 = rep(c(2007, 2006, 2005), 60),
   z  = rep(c(a, b, c, d, e, f), e = 30))

ex2 - data.frame(v1b = log(abs(rt(18, 3)) + 1),
   v2 = rep(c(2007, 2006, 2005), 6),
   z  = rep(c(a, b, c, d, e, f), e = 3))
ex3 - merge(ex, ex2, by=c(v2,z))
D2007 - ex3[ex3$z==d  ex3$v2==2007, ]
D2006 - ex3[ex3$z==d  ex3$v2==2006, ]
C2007 - ex3[ex3$z==c  ex3$v2==2007, ]


quantile(D2007$v1, probs = c(0.05, 0.95))
quantile(D2006$v1, probs = c(0.05, 0.95))
quantile(C2007$v1, probs = c(0.05, 0.95))

bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), X = ex3$v1b,
pch = |,
par.settings = list(
plot.symbol = list(alpha = 1, col = transparent,cex = 1,pch = 20)),
panel = function(x, y, ..., X, subscripts){
panel.grid(v = -1, h = 0)
panel.bwplot(x, y, ..., 

Re: [R] declaring GPL license

2010-10-14 Thread Dirk Eddelbuettel

On 14 October 2010 at 11:06, Stacey Wood wrote:
| Hi all,
| 
| I'm currently writing an R package and want to declare a GPL2 license.
| According to the license agreement, I'm supposed to display:
| 
|   This program is free software; you can redistribute it and/or modify
|it under the terms of the GNU General Public License as published by
|the Free Software Foundation ... See the
|GNU General Public License for more details.
| 
| When I add this statement to the description file, the package cannot be
| processed.  Where should I add this statement to appropriately cite the
| license?

I suggested you do these two steps:

  1)  In the file DESCRIPTION, set the License: field accordingly.

  2)  In the top-level directory of your sources, include the file COPYING.

That should do.

Dirk, not a lawyer and not playing one on TV either

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.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] Putting the same array into a matrix

2010-10-14 Thread Desmond Lim
Hi,

I have an array and I want to put in into a matrix x number of times. Currently 
I doing this

matrix - cbind(array, array, array).

Is there a more elegant way of doing this?

I've tried

matrix - cbind(rep(array, times=x)) and matrix - rep(cbind(array), times = 5)

but it didn't work.

Thanks.
__
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] bwplot change whiskers position to percentile 5 and P95

2010-10-14 Thread Christophe Bouffioux
Hi,

I have tried your proposition, and it works properly on the simulated
data, but not on my real data, and I do not see any explanations, this is
weird, i have no more ideas to explore the problem


so here i give some information on my data, nothing special actually,

Christophe

 summary(sasdata03_a)
   jaar   Cat_F  montant_oanombre_cas
montant_i
 2006:36854   a  :22591Min.   :  -112.8Min.   :   -5.0
Min.   :   33.22
 2007:36538   h  :220561st Qu.:  1465.5 1st Qu.:  104.01st
Qu.:   37.80
 2008:36579   i  :21844 Median :  4251.5 Median :  307.0
Median :   50.00
k  :21485 Mean   : 13400.0Mean   :  557.5
Mean   : 1172.17
g  :16217 3rd Qu.: 13648.53rd Qu.:  748.0
3rd Qu.:  458.67
d  : 5778  Max.   : 534655.6Max.
:13492.0   Max.   :17306.73
(Other):
0
nombre_i
 Min.   :  1.00
 1st Qu.:  1.00
 Median :  5.00
 Mean   : 44.87
 3rd Qu.: 29.00
 Max.   :689.00

 is.data.frame(sasdata03_a)
[1] TRUE

The code of the function:

boxplot2.stats -  function (x, coef = 1.5, do.conf = TRUE, do.out = TRUE)
{
if (coef  0)
stop('coef' must not be negative)
nna - !is.na(x)
n - sum(nna)
stats - stats::fivenum(x, na.rm = TRUE)
stats[c(1,5)]- quantile(x, probs=c(0.05, 0.95))
iqr - diff(stats[c(2, 4)])
if (coef == 0)
do.out - FALSE
else {
out - if (!is.na(iqr)) {
x  (stats[2L] - coef * iqr) | x  (stats[4L] + coef *
iqr)
}
else !is.finite(x)
if (any(out[nna], na.rm = TRUE))
stats[c(1, 5)] - range(x[!out], na.rm = TRUE)
}
conf - if (do.conf)
stats[3L] + c(-1.58, 1.58) * iqr/sqrt(n)
list(stats = stats, n = n, conf = conf, out = if (do.out) x[out 
nna] else numeric(0L))
}


On Wed, Oct 13, 2010 at 5:13 PM, David Winsemius dwinsem...@comcast.netwrote:


 On Oct 13, 2010, at 10:05 AM, Christophe Bouffioux wrote:

 Dear R-community,

 Using bwplot, how can I put the whiskers at percentile 5 and percentile
 95,
 in place of the default position coef=1.5??

 Using panel=panel.bwstrip, whiskerpos=0.05, from the package agsemisc
 gives
 satisfaction, but changes the appearance of my boxplot and works with an
 old
 version of R, what I don’t want, and I didn’t find the option in
 box.umbrella parameters


 Nope, you won't find it even if you search harder, but you do have a
 lattice path forward. Just as base function boxplot() does the calculations
 and then plots with bxp(), by default panel.bwplot sends the data to
 boxplot.stats, but panel.bwplot also allows you to specify an alternate
 function that returns plotting parameters differently as long as those
 conforms to the requirements for structure. You can look at boxplot.stats
 (it's not that big)  and then construct an alternative. The line you would
 need to alter would be the one starting with:  stats-stats::fivenum(...),
 since you are changing the values returned by fivenum(). You might get away
 with just changing stats[1] and stats[5] to your revised specifications,
 although it has occurred to me that you might get some of those out dots
 inside your whiskers. (Fixing that would not be too hard once you are inside
 boxplot.stats().

 Seemed to work for me with your data (at least the extent of plotting a
 nice 3 x 2 panel display. All I did was redefine an nboxplot.stats by
 inserting this line after the line cited above:

 stats[c(1,5)]- quantile(x, probs=c(0.05, 0.95))

 and then added an argument  ..., stats=nboxplot.stats)  inside your
 panel.bwplot.

 --
 David.


 Many thanks
 Christophe

 Here is the code:

 library(lattice)
 ex - data.frame(v1 = log(abs(rt(180, 3)) + 1),
v2 = rep(c(2007, 2006, 2005), 60),
z  = rep(c(a, b, c, d, e, f), e = 30))

 ex2 - data.frame(v1b = log(abs(rt(18, 3)) + 1),
v2 = rep(c(2007, 2006, 2005), 6),
z  = rep(c(a, b, c, d, e, f), e = 3))
 ex3 - merge(ex, ex2, by=c(v2,z))
 D2007 - ex3[ex3$z==d  ex3$v2==2007, ]
 D2006 - ex3[ex3$z==d  ex3$v2==2006, ]
 C2007 - ex3[ex3$z==c  ex3$v2==2007, ]



   quantile(D2007$v1, probs = c(0.05, 0.95))
 quantile(D2006$v1, probs = c(0.05, 0.95))
 quantile(C2007$v1, probs = c(0.05, 0.95))

 bwplot(v2 ~ v1 | z, data = ex3, layout=c(3,2), X = ex3$v1b,
 pch = |,
 par.settings = list(
 plot.symbol = list(alpha = 1, col = transparent,cex = 1,pch = 20)),
 panel = function(x, y, ..., X, subscripts){
 panel.grid(v = -1, h = 0)
 panel.bwplot(x, y, ..., subscripts = subscripts)
 X - X[subscripts]
 xmax =max(x)
 X - tapply(X, y, unique)
 Y - tapply(y, y, unique)
 tg - table(y)
 panel.points(X, Y, cex=3, pch =| , col = red)
 #vcount - tapply(v1, v2, length)
 panel.text((xmax-0.2), (Y-0.15), labels = paste(N=, tg))
 })

[[alternative HTML version deleted]]

 __
 

Re: [R] declaring GPL license

2010-10-14 Thread Marc Schwartz
On Oct 14, 2010, at 10:06 AM, Stacey Wood wrote:

 Hi all,
 
 I'm currently writing an R package and want to declare a GPL2 license.
 According to the license agreement, I'm supposed to display:
 
  This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation ... See the
   GNU General Public License for more details.
 
 When I add this statement to the description file, the package cannot be
 processed.  Where should I add this statement to appropriately cite the
 license?
 
 Thanks,
 Stacey


Stacey,

Read the Package Structure section of the Writing R Extensions manual:

  http://cran.r-project.org/doc/manuals/R-exts.html#Package-structure

where you can see an example of the DESCRIPTION file, including the License 
field.

If you want (and you should), create and include a file called COPYING in the 
'inst' folder in the package, so that it gets copied to the main package 
directory upon installation. The content for that file (the GPL 2 license) is 
at:

  http://www.gnu.org/licenses/gpl-2.0.txt

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] Using Rscript to read from a file

2010-10-14 Thread Saptarshi Guha
Hello,
I have this script which will be invoked as

Rscript a.r  a.r

a.r follows

#!/usr/bin/Rscript --vanilla
f=file(stdin)
while(TRUE){
y=readLines(f,n=1,warn=TRUE)
  if(length(y)==0) break else print(y)
}


But it only reads one line from a.r
How can I read line by line from standard input?

Thank you
Saptarshi

__
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] Drop matching lines from readLines

2010-10-14 Thread Bert Gunter
If I understand correctly, the poster knows what regex error pattern
to look for, in which case (mod memory capacity -- but 200 mb should
not be a problem, I think) is not merely

cleanData - dirtyData[!grepl(errorPatternregex,dirtyData)]

sufficient?

Cheers,
Bert

On Thu, Oct 14, 2010 at 4:05 AM, Mike Marchywka marchy...@hotmail.com wrote:






 
 From: santosh.srini...@gmail.com
 To: r-help@r-project.org
 Date: Thu, 14 Oct 2010 11:27:57 +0530
 Subject: [R] Drop matching lines from readLines

 Dear R-group,

 I have some noise in my text file (coding issues!) ... I imported a 200 MB
 text file using readlines
 Used grep to find the lines with the error?

 What is the easiest way to drop those lines? I plan to write back the
 cleaned data set to my base file.

 Generally for text processing, I've been using utilities external to R
 although there may be R alternatives that work better for you. You
 mention grep, I've suggested sed as a general way to fix formatting things,
 there is also something called uniq on linux or cygwin.
 I have gotten into the habit of using these for a variety of data
 manipulation tasks, only feed clean data into R.

 $ echo -e a bc\\na bc
 a bc
 a bc

 $ echo -e a bc\\na bc | uniq
 a bc

 $ uniq --help
 Usage: uniq [OPTION]... [INPUT [OUTPUT]]
 Filter adjacent matching lines from INPUT (or standard input),
 writing to OUTPUT (or standard output).

 With no options, matching lines are merged to the first occurrence.

 Mandatory arguments to long options are mandatory for short options too.
   -c, --count   prefix lines by the number of occurrences
   -d, --repeated    only print duplicate lines
   -D, --all-repeated[=delimit-method]  print all duplicate lines
     delimit-method={none(default),prepend,separate}
     Delimiting is done with blank lines
   -f, --skip-fields=N   avoid comparing the first N fields
   -i, --ignore-case ignore differences in case when comparing
   -s, --skip-chars=N    avoid comparing the first N characters
   -u, --unique  only print unique lines
   -z, --zero-terminated  end lines with 0 byte, not newline
   -w, --check-chars=N   compare no more than N characters in lines
   --help display this help and exit
   --version  output version information and exit

 A field is a run of blanks (usually spaces and/or TABs), then non-blank
 characters.  Fields are skipped before chars.

 Note: 'uniq' does not detect repeated lines unless they are adjacent.
 You may want to sort the input first, or use `sort -u' without `uniq'.
 Also, comparisons honor the rules specified by `LC_COLLATE'.











 Thanks.


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




-- 
Bert Gunter
Genentech Nonclinical Biostatistics

__
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] Drop matching lines from readLines

2010-10-14 Thread Santosh Srinivas
Yes, thanks ... that works.

-Original Message-
From: Bert Gunter [mailto:gunter.ber...@gene.com] 
Sent: 14 October 2010 21:26
To: Mike Marchywka
Cc: santosh.srini...@gmail.com; r-help@r-project.org
Subject: Re: [R] Drop matching lines from readLines

If I understand correctly, the poster knows what regex error pattern
to look for, in which case (mod memory capacity -- but 200 mb should
not be a problem, I think) is not merely

cleanData - dirtyData[!grepl(errorPatternregex,dirtyData)]

sufficient?

Cheers,
Bert

On Thu, Oct 14, 2010 at 4:05 AM, Mike Marchywka marchy...@hotmail.com
wrote:






 
 From: santosh.srini...@gmail.com
 To: r-help@r-project.org
 Date: Thu, 14 Oct 2010 11:27:57 +0530
 Subject: [R] Drop matching lines from readLines

 Dear R-group,

 I have some noise in my text file (coding issues!) ... I imported a 200
MB
 text file using readlines
 Used grep to find the lines with the error?

 What is the easiest way to drop those lines? I plan to write back the
 cleaned data set to my base file.

 Generally for text processing, I've been using utilities external to R
 although there may be R alternatives that work better for you. You
 mention grep, I've suggested sed as a general way to fix formatting
things,
 there is also something called uniq on linux or cygwin.
 I have gotten into the habit of using these for a variety of data
 manipulation tasks, only feed clean data into R.

 $ echo -e a bc\\na bc
 a bc
 a bc

 $ echo -e a bc\\na bc | uniq
 a bc

 $ uniq --help
 Usage: uniq [OPTION]... [INPUT [OUTPUT]]
 Filter adjacent matching lines from INPUT (or standard input),
 writing to OUTPUT (or standard output).

 With no options, matching lines are merged to the first occurrence.

 Mandatory arguments to long options are mandatory for short options too.
   -c, --count   prefix lines by the number of occurrences
   -d, --repeated    only print duplicate lines
   -D, --all-repeated[=delimit-method]  print all duplicate lines
     delimit-method={none(default),prepend,separate}
     Delimiting is done with blank lines
   -f, --skip-fields=N   avoid comparing the first N fields
   -i, --ignore-case ignore differences in case when comparing
   -s, --skip-chars=N    avoid comparing the first N characters
   -u, --unique  only print unique lines
   -z, --zero-terminated  end lines with 0 byte, not newline
   -w, --check-chars=N   compare no more than N characters in lines
   --help display this help and exit
   --version  output version information and exit

 A field is a run of blanks (usually spaces and/or TABs), then non-blank
 characters.  Fields are skipped before chars.

 Note: 'uniq' does not detect repeated lines unless they are adjacent.
 You may want to sort the input first, or use `sort -u' without `uniq'.
 Also, comparisons honor the rules specified by `LC_COLLATE'.











 Thanks.


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




-- 
Bert Gunter
Genentech Nonclinical Biostatistics

__
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] Putting the same array into a matrix

2010-10-14 Thread Charles C. Berry

On Thu, 14 Oct 2010, Desmond Lim wrote:


Hi,

I have an array and I want to put in into a matrix x number of times. Currently 
I doing this

matrix - cbind(array, array, array).

Is there a more elegant way of doing this?


Fortunately!

If 'array' really is a matrix (bad choice of names here, Bub!), then

a.matrix - matrix( rep( array, 3 ), nc = ncol( array )* 3 )

But this will work too:

a.matrix - do.call( cbind, rep( list( array ), 3) )

even if 'array' is a data.frame

HTH,

Chuck




I've tried

matrix - cbind(rep(array, times=x)) and matrix - rep(cbind(array), times = 5)

but it didn't work.

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



Charles C. Berry(858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu   UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

__
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] running a long R process on Linux using putty - best practice to disconnect

2010-10-14 Thread Martin Tomko

Dear all,
I am sure this has been solved before, googling did not help much,. 
Warning, I am not great with putty/linux servers


Situation: I have been given access to an R installation on a Linux 
server to do some larger number crunching that was killing my machine. I 
use putty to connect, and then go R, source(myscript) and all is fine

But this will take potentially days, and I would like to disconnect

What is the best practice? Someone mentionne nohup, but this would 
require starting the R script with an argument to R, I think. Is this 
doable?


Another option was using screen, btu that is not available on the server.
Any help is welcome.

Thanks
Martin

__
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] Python's string translate in R?

2010-10-14 Thread Saptarshi Guha
Hello,

Would one use gsub to perform pythons translate?

in python

table = string.maketrans(abc,xyz)
abc.translate(table)
xyz

how does one do this in R?

Thank you
Saptarshi

__
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] declaring GPL license

2010-10-14 Thread Berwin A Turlach
G'day Marc,

On Thu, 14 Oct 2010 10:46:39 -0500
Marc Schwartz marc_schwa...@me.com wrote:

 If you want (and you should), create and include a file called
 COPYING in the 'inst' folder in the package, so that it gets copied
 to the main package directory upon installation. [...]

But that would be against the wishes of R core, from the Writing R
Extension manual:

Whereas you should feel free to include a license file in your
source distribution, please do not arrange to @emph{install} yet
another copy of the @acronym{GNU} @file{COPYING} or
@file{COPYING.LIB} files but refer to the copies on
@url{http://www.r-project.org/Licenses/} and included in the
@R{} distribution (in directory @file{share/licenses}).

:)

Cheers,

Berwin

__
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] running a long R process on Linux using putty - best practice to disconnect

2010-10-14 Thread Mike Marchywka








 Date: Thu, 14 Oct 2010 18:07:02 +0200
 From: martin.to...@geo.uzh.ch
 To: r-help@r-project.org
 Subject: [R] running a long R process on Linux using putty - best practice to 
 disconnect

 Dear all,
 I am sure this has been solved before, googling did not help much,.
 Warning, I am not great with putty/linux servers

 Situation: I have been given access to an R installation on a Linux
 server to do some larger number crunching that was killing my machine. I
 use putty to connect, and then go R, source(myscript) and all is fine
 But this will take potentially days, and I would like to disconnect

 What is the best practice? Someone mentionne nohup, but this would
 require starting the R script with an argument to R, I think. Is this
 doable?

In short, I think R CMD BATCH script  does what you want.
I routinely run R from scripts and use nohup, the two should work well
together AFAIK. I have encapsulated R stuff into a script ( myR) 
and have something like this ,

if [ $1 == -run ]
then
echo running $2
$R CMD BATCH $2
shift ; shift
fi


if [ $1 == -go ]
then
echo starting R with no params
$R
shift



 Another option was using screen, btu that is not available on the server.
 Any help is welcome.

 Thanks
 Martin

 __
 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] execute a script in command line

2010-10-14 Thread Benoit Wastine

 Dear all,
I'm running R on Linux OS. I want to execute a programme toto.R in 
command line. Is it possible ??

Thanks
Benoit

--
Benoit Wastine
Laboratoire des Sciences du Climat et de l’Environnement (LSCE/IPSL)
CEA-CNRS-UVSQ
CE Saclay
Orme des merisiers
Bât 703 - Pte 13A
91191 Gif sur Yvette Cedex
France

Tel : 33 (0)1 69 08 21 97
Fax : 33 (0)1 69 08 77 16

__
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] compare histograms

2010-10-14 Thread Rainer M Krug
On Thu, Oct 14, 2010 at 3:15 AM, Michael Bedward
michael.bedw...@gmail.comwrote:

 Hi Juan,

 Yes, you can use EMD to quantify the difference between any pair of
 histograms regardless of their shape. The only constraint, at least
 the way that I've done it previously, is to have compatible bins. The
 original application of EMD was to compare images based on colour
 histograms which could have all sorts of shapes.

 I looked at the package that Dennis alerted me to on RForge but
 unfortunately it seems to be inactive


No - well, it depends how you define inactive: the functionality we wanted
to include is included, therefore no further development was necessary.


 and the nightly builds are broken. I've downloaded the source code and will
 have a look at it
 sometime in the next few days.


Thanks for alerting us - we will look into that. But just don't use the
nightly builds, as they are not different to the last release. Just download
the package for your system (I assume Windows or mac, as I just installed
from source without problems under Linux).

Let me know if it doesn't work,

Cheers,

Rainer




 Meanwhile, let me know if you want a copy of my own code. It uses the
 lpSolve package.

 Michael

 On 14 October 2010 08:46, Juan Pablo Fededa jpfed...@gmail.com wrote:
  Hi Michael,
 
 
  I have the same challenge, can you use this earth movers distance it to
  compare bimodal distributions?
  Thanks  cheers,
 
 
  Juan
 
 
  On Wed, Oct 13, 2010 at 4:39 AM, Michael Bedward 
 michael.bedw...@gmail.com
  wrote:
 
  Just to add to Greg's comments: I've previously used 'Earth Movers
  Distance' to compare histograms. Note, this is a distance metric
  rather than a parametric statistic (ie. not a test) but it at least
  provides a consistent way of quantifying similarity.
 
  It's relatively easy to implement the metric in R (formulating it as a
  linear programming problem). Happy to dig out the code if needed.
 
  Michael
 
  On 13 October 2010 02:44, Greg Snow greg.s...@imail.org wrote:
   That depends a lot on what you mean by the histograms being
 equivalent.
  
   You could just plot them and compare visually.  It may be easier to
   compare them if you plot density estimates rather than histograms.
  Even
   better would be to do a qqplot comparing the 2 sets of data rather
 than the
   histograms.
  
   If you want a formal test then the ks.test function can compare 2
   datasets.  Note that the null hypothesis is that they come from the
 same
   distribution, a significant result means that they are likely
 different (but
   the difference may not be of practical importance), but a
 non-significant
   test could mean they are the same, or that you just do not have enough
 power
   to find the difference (or the difference is hard for the ks test to
 see).
You could also use a chi-squared test to compare this way.
  
   Another approach would be to use the vis.test function from the
   TeachingDemos package.  Write a small function that will either plot
 your 2
   histograms (density plots), or permute the data between the 2 groups
 and
   plot the equivalent histograms.  The vis.test function then presents
 you
   with an array of plots, one of which is the original data and the rest
 based
   on permutations.  If there is a clear meaningful difference in the
 groups
   you will be able to spot the plot that does not match the rest,
 otherwise it
   will just be guessing (might be best to have a fresh set of eyes that
 have
   not seen the data before see if they can pick out the real plot).
  
   --
   Gregory (Greg) L. Snow Ph.D.
   Statistical Data Center
   Intermountain Healthcare
   greg.s...@imail.org
   801.408.8111
  
  
   -Original Message-
   From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
   project.org] On Behalf Of solafah bh
   Sent: Monday, October 11, 2010 4:02 PM
   To: R help mailing list
   Subject: [R] compare histograms
  
   Hello
   How to compare  two statistical histograms? How i can know if these
   histograms are equivalent or not??
  
   Regards
  
  
  
 [[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-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 

Re: [R] declaring GPL license

2010-10-14 Thread Marc Schwartz
On Oct 14, 2010, at 11:13 AM, Berwin A Turlach wrote:

 G'day Marc,
 
 On Thu, 14 Oct 2010 10:46:39 -0500
 Marc Schwartz marc_schwa...@me.com wrote:
 
 If you want (and you should), create and include a file called
 COPYING in the 'inst' folder in the package, so that it gets copied
 to the main package directory upon installation. [...]
 
 But that would be against the wishes of R core, from the Writing R
 Extension manual:
 
   Whereas you should feel free to include a license file in your
   source distribution, please do not arrange to @emph{install} yet
   another copy of the @acronym{GNU} @file{COPYING} or
   @file{COPYING.LIB} files but refer to the copies on
   @url{http://www.r-project.org/Licenses/} and included in the
   @R{} distribution (in directory @file{share/licenses}).
 
 :)
 
 Cheers,
 
   Berwin


Yep. I stand corrected on that point. :-)

Thanks also to Prof. Ripley, who noted my error as well.

Regards,

Marc

__
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] drilling down data on charts

2010-10-14 Thread Greg Snow
It is not clear what exactly you want.  Try looking at the functions TkPredict, 
TkSpline, and TkApprox in the TeachingDemos package to see if any of those do 
what you want.

If not, give a bit more of a description and include some sample data.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of sachinthaka.abeyward...@allianz.com.au
 Sent: Wednesday, October 13, 2010 5:00 PM
 To: r-help@r-project.org
 Subject: [R] drilling down data on charts
 
 
 Hey all,
 
 Suppose a=b^2 for starters. I want to be able to create a graph that
 displays a initially and if i was to click on 'a' to show 'b' on the
 chart
 itself. Does anyone know if this is possible in R?
 
 Also as an extension (not necessary as yet) to output the above into a
 'html' file.
 
 Thanks,
 Sachin
 
 --- Please consider the environment before printing this email ---
 
 Allianz - General Insurance Company of the Year 2009+
 + Australia and New Zealand Insurance Industry Awards
 
 This email and any attachments has been sent by Allianz Australia
 Insurance Limited (ABN 15 000 122 850) and is intended solely for the
 addressee. It is confidential, may contain personal information and may
 be subject to legal professional privilege. Unauthorised use is
 strictly prohibited and may be unlawful. If you have received this by
 mistake, confidentiality and any legal privilege are not waived or lost
 and we ask that you contact the sender and delete and destroy this and
 any other copies. In relation to any legal use you may make of the
 contents of this email, you must ensure that you comply with the
 Privacy Act (Cth) 1988 and you should note that the contents may be
 subject to copyright and therefore may not be reproduced, communicated
 or adapted without the express consent of the owner of the copyright.
 Allianz will not be liable in connection with any data corruption,
 interruption, delay, computer virus or unauthorised access or amendment
 to the contents of this email. If this email is a commercial electronic
 message and you would prefer not to receive further commercial
 electronic messages from Allianz, please forward a copy of this email
 to unsubscr...@allianz.com.au with the word unsubscribe in the subject
 header.
 
 __
 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] Using Rscript to read from a file

2010-10-14 Thread Dirk Eddelbuettel

On 14 October 2010 at 08:49, Saptarshi Guha wrote:
| Hello,
| I have this script which will be invoked as
| 
| Rscript a.r  a.r
| 
| a.r follows
| 
| #!/usr/bin/Rscript --vanilla
| f=file(stdin)
| while(TRUE){
| y=readLines(f,n=1,warn=TRUE)
|   if(length(y)==0) break else print(y)
| }
| 
| 
| But it only reads one line from a.r
| How can I read line by line from standard input?

If you can substitute in r (from littler) for Rscript, then you get proper
behaviour.  Here is an old example from littler:

   $ ls -l /usr/bin | awk '!/^total/ {print $5}' | \
   r -e 'fsizes - as.integer(readLines()); print(summary(fsizes))' | \
   tail -2
Min.  1st Qu.   Median Mean  3rd Qu. Max.
   1 172010900   10800039200 1110
   $

This uses awk to get the file size from ls, and then runs R's summary() over
it.  For some reason, readLines() now echos back to the screen which is why I
added the 'tail -2' at the end.

Dirk

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.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] execute a script in command line

2010-10-14 Thread Jim Hargreaves

Hi Benoit,

Have a look at 'man R'. You want something like 'R CMD BATCH toto.R' 
(case sensitive).


Hope this helps,

Jim Hargreaves

On 10/14/2010 05:15 PM, Benoit Wastine wrote:

 Dear all,
I'm running R on Linux OS. I want to execute a programme toto.R in 
command line. Is it possible ??

Thanks
Benoit



__
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] Matrix subscripting to wrap around from end to start of row

2010-10-14 Thread Greg Snow
You might have better luck reformatting your data as time series, then you can 
still print it in a matrix like form, but access it serially without worrying 
about wrapping around rows.

Another option would be to transpose the matrix so that months go down the 
columns, then use the %% and %/% operators to find the vector indexes of the 
elements and just access them directly rather than as matrix elements (a matrix 
is just a vector that knows its dimensions).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Alisa Wade
 Sent: Wednesday, October 13, 2010 2:11 PM
 To: r-help@r-project.org
 Subject: [R] Matrix subscripting to wrap around from end to start of
 row
 
 Perhaps it is just that I don't even know the correct term to search
 for,
 but I can find nothing that explains how to wrap around from the end to
 a
 start of a row in a matrix.
 
 For example, you have a matrix of 2 years of data, where rows are
 years, and
 columns are months.
 month.data = matrix(c(3,4,6,8,12,90,5,14,22, 8), nrow = 2, ncol=5)
 
 I would like to take the average of months 5:1  for each year (for row
 1
 =12.5). However, I am passing the start month (5) and the end month (1)
 as
 variables.
 
 I would like to do something like
 
 year.avg = apply(month.data[, start.month:end.month], MARGIN=1, mean)
 
 But that gives me the average of months 1:5. (for row 1 =9.6)
 
 I know I could use:
 apply(month.data[, c(1,5)], 1, mean)
 but I don't know how to pass start.month, end.month into that format
 that
 because paste or sprintf forces them to strings, which are not accepted
 in a
 subscript.
 
 I have the feeling I am unaware of some obvious trick.
 Any ideas would be greatly appreciated!
 
 *
 Alisa A. Wade
 Postdoctoral Center Associate
 National Center for Ecological Analysis and Synthesis
 w...@nceas.ucsb.edu
 (406) 529-9722
 home email: alis...@gmail.com
 
   [[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] declaring GPL license

2010-10-14 Thread Dirk Eddelbuettel

On 14 October 2010 at 11:16, Marc Schwartz wrote:
| On Oct 14, 2010, at 11:13 AM, Berwin A Turlach wrote:
| 
|  G'day Marc,
|  
|  On Thu, 14 Oct 2010 10:46:39 -0500
|  Marc Schwartz marc_schwa...@me.com wrote:
|  
|  If you want (and you should), create and include a file called
|  COPYING in the 'inst' folder in the package, so that it gets copied
|  to the main package directory upon installation. [...]
|  
|  But that would be against the wishes of R core, from the Writing R
|  Extension manual:
|  
|  Whereas you should feel free to include a license file in your
|  source distribution, please do not arrange to @emph{install} yet
|  another copy of the @acronym{GNU} @file{COPYING} or
|  @file{COPYING.LIB} files but refer to the copies on
|  @url{http://www.r-project.org/Licenses/} and included in the
|  @R{} distribution (in directory @file{share/licenses}).
|  
|  :)
|  
|  Cheers,
|  
|  Berwin
| 
| 
| Yep. I stand corrected on that point. :-)

As a minor addition, keeping COPYING in the top-level (as per my earlier
email) appears to satisfy the wishes of those at the FSF (include COPYING) as
well as R Core (do not install COPYING)) -- where files in inst/ will always
get installed.   It's also simply more visible at the top-level.

Dirk

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.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] declaring GPL license

2010-10-14 Thread Stacey Wood
Thanks everyone.  Now I know that I should not include another copy of the
license, but where should I refer to the copies on
http://www.r-project.org/Licenses/? In the DESCRIPTION file?

Stacey


On Thu, Oct 14, 2010 at 12:16 PM, Marc Schwartz marc_schwa...@me.comwrote:

 On Oct 14, 2010, at 11:13 AM, Berwin A Turlach wrote:

  G'day Marc,
 
  On Thu, 14 Oct 2010 10:46:39 -0500
  Marc Schwartz marc_schwa...@me.com wrote:
 
  If you want (and you should), create and include a file called
  COPYING in the 'inst' folder in the package, so that it gets copied
  to the main package directory upon installation. [...]
 
  But that would be against the wishes of R core, from the Writing R
  Extension manual:
 
Whereas you should feel free to include a license file in your
source distribution, please do not arrange to @emph{install} yet
another copy of the @acronym{GNU} @file{COPYING} or
@file{COPYING.LIB} files but refer to the copies on
@url{http://www.r-project.org/Licenses/} and included in the
@R{} distribution (in directory @file{share/licenses}).
 
  :)
 
  Cheers,
 
Berwin


 Yep. I stand corrected on that point. :-)

 Thanks also to Prof. Ripley, who noted my error as well.

 Regards,

 Marc



[[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] Python's string translate in R?

2010-10-14 Thread jim holtman
?chartr

Is this what you are looking for?

On Thu, Oct 14, 2010 at 12:10 PM, Saptarshi Guha
saptarshi.g...@gmail.com wrote:
 Hello,

 Would one use gsub to perform pythons translate?

 in python

 table = string.maketrans(abc,xyz)
 abc.translate(table)
 xyz

 how does one do this in R?

 Thank you
 Saptarshi

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
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] Python's string translate in R?

2010-10-14 Thread Saptarshi Guha
Yes, thanks much.


On Thu, Oct 14, 2010 at 9:36 AM, jim holtman jholt...@gmail.com wrote:
 ?chartr

 Is this what you are looking for?

 On Thu, Oct 14, 2010 at 12:10 PM, Saptarshi Guha
 saptarshi.g...@gmail.com wrote:
 Hello,

 Would one use gsub to perform pythons translate?

 in python

 table = string.maketrans(abc,xyz)
 abc.translate(table)
 xyz

 how does one do this in R?

 Thank you
 Saptarshi

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




 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem that you are trying to solve?


__
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] R functions in Java

2010-10-14 Thread lord12

For example, if I have the function in R:

sum = function(a,b)
{
  sum = a+b
 return sum
 } 

In Java:

re.eval(sum(a,b)) gives me an error. 
-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-functions-in-Java-tp2995428p2995620.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] Query on save.image()

2010-10-14 Thread Megh Dal
Can anyone please tell me how can use save.image() function if it is placed 
within a function (i.e. some level up from the base level environment)? Here I 
experimented with following codes:


#rm(list=ls())
fn - function() {
x - rnorm(5)
save.image(f:/dat.RData)
  }
fn()

However I see that, the object fn() is actually stored in dat.RData file, not 
that x. I have gone through the help page and saw there is some argument 
named envir
My question is if I need to supply some value against that argument, then what 
should be the name of the required environment?

Additionally is there any option to see the hierarchy of different environments 
at my current R session?

Thanks,

__
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] Using Rscript to read from a file

2010-10-14 Thread Dirk Eddelbuettel

On 14 October 2010 at 11:21, Dirk Eddelbuettel wrote:
| On 14 October 2010 at 08:49, Saptarshi Guha wrote:
| | Hello,
| | I have this script which will be invoked as
| | 
| | Rscript a.r  a.r
| | 
| | a.r follows
| | 
| | #!/usr/bin/Rscript --vanilla
| | f=file(stdin)
| | while(TRUE){
| | y=readLines(f,n=1,warn=TRUE)
| |   if(length(y)==0) break else print(y)
| | }
| | 
| | 
| | But it only reads one line from a.r
| | How can I read line by line from standard input?
| 
| If you can substitute in r (from littler) for Rscript, then you get proper
| behaviour.  Here is an old example from littler:
| 
|$ ls -l /usr/bin | awk '!/^total/ {print $5}' | \
|r -e 'fsizes - as.integer(readLines()); print(summary(fsizes))' | \
|tail -2
| Min.  1st Qu.   Median Mean  3rd Qu. Max.
|1 172010900   10800039200 1110
|$
| 
| This uses awk to get the file size from ls, and then runs R's summary() over
| it.  For some reason, readLines() now echos back to the screen which is why I
| added the 'tail -2' at the end.

Got it. We changed something since we first created this example in 2006, and
we now need to set the -i flags.  So with that:

  $ ls -l /usr/bin | awk '!/^total/ {print $5}' | \
  r -i -e 'fsizes - as.integer(readLines()); print(summary(fsizes))'
  Min.  1st Qu.   Median Mean  3rd Qu. Max. 
 1 172010900   10800039200 1110 
  $ 

Dirk


-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.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] R on a ma c

2010-10-14 Thread Tiffany Kinder
Hello,
Is R very compatible with a Mac?  A colleague of mine indicated that
everyone he knows with a Mac has problems with R.

What can you tell me about using R with a Mac.  What do I need to download?
 I have downloaded the basic R package.

Thanks,

-- 
Tiffany Kinder
MS Student
Department of Watershed Science
Utah State University
tiffany.kin...@aggiemail.usu.edu

[[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] several car scatterplots on one graph

2010-10-14 Thread Greg Snow
The problem is that the scatterplot function is overriding the 
par(mfrow=c(2,2)) command by resetting the parameters itself (though it 
probably uses layout instead of par) to place the boxplots next to the 
scatterplot.  It was not really designed to be used the way you want.

Possible solutions:

Do it yourself, use the layout command to set up space for the scatterplots and 
boxplots, then plot them each individually using plot and boxplot commands.

Open 3 graphics devices and do a scatterplot in each one, then arrange the 
windows so you can see them all at once.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of cr...@binghamton.edu
 Sent: Wednesday, October 13, 2010 10:17 PM
 To: r-help@r-project.org
 Subject: [R] several car scatterplots on one graph
 
 R version 2.11.1 on WinXP
 
 How do I get 3 scatterplots with marginal boxplots (from the car
 package) onto a single plot?
 
 I have a data frame called bank
 
  dim(bank)
 [1] 46  5
 
 head(bank)
 
  x1x2   x3   x4 pop
 1 -0.45 -0.41 1.09 0.45   0
 2 -0.56 -0.31 1.51 0.16   0
 3  0.06  0.02 1.01 0.40   0
 4 -0.07 -0.09 1.45 0.26   0
 5 -0.10 -0.09 1.56 0.67   0
 6 -0.14 -0.07 0.71 0.28   0
 
 library(car)
 par(mfrow=c(2,2))
 
 # following lines may be wrapped badly--sorry
 
 with(bank, scatterplot(x1,x2,groups=pop, reg.line=FALSE,
 smooth=FALSE, boxplots=xy, reset.par=FALSE))
 
 with(bank, scatterplot(x1,x3,groups=pop, reg.line=FALSE,
 smooth=FALSE, boxplots=xy, reset.par=FALSE))
 
 with(bank, scatterplot(x1,x4,groups=pop, reg.line=FALSE,
 smooth=FALSE, boxplots=xy, reset.par=FALSE))
 
 I have tried various permutations of the reset.par=  option: all
 three lines FALSE, all 3 lines TRUE, the first TRUE and the others
 FALSE, vice versa, etc. And always I get just one scatterplot showing
 up on the device at a time, and occupying the whole thing.
 
 Thanks.
 
 --Chris Ryan
 SUNY Upstate Medical University
 Binghamton Clinical Campus
 
 __
 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] Poisson Regression

2010-10-14 Thread Viechtbauer Wolfgang (STAT)
I think it's useful to realize that this approach still implies that the 
\phi_{i}'s are entered as fixed effects into the model (as opposed to treating 
the \phi_{i}'s as random effects); it's just that the iterative algorithm to 
obtain the maximum likelihood estimates is faster when using 'eliminate = 
Subject' (and the output doesn't show the estimates for these nuisance 
parameters).

Since the number of parameters then rises linearly with the number of subjects, 
this may be a case where maximum likelihood theory breaks down, that is, a 
Neyman-Scott problem. See:

Neyman, J.,  Scott, E. L. (1948). Consistent estimates based on partially 
consistent observations. Econometrica, 16(1), 1-32.

Maybe somebody more familiar with this could shed some light on this.

Best,

--
Wolfgang Viechtbauer
Department of Methodology and Statistics
School for Public Health and Primary Care
Maastricht University, P.O. Box 616
6200 MD Maastricht, The Netherlands
Tel: +31 (43) 388-2277
Fax: +31 (43) 361-8388
Web: http://www.wvbauer.com


Original Message
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Michael Friendly
Sent: Thursday, October 14, 2010 14:56 To: Antonio Paredes
Cc: r-help@r-project.org
Subject: Re: [R] Poisson Regression

 On 10/13/2010 4:50 PM, Antonio Paredes wrote:
 Hello everyone,

 I wanted to ask if there is an R-package to fit the following
 Poisson regression model

 log(\lambda_{ijk}) = \phi_{i} + \alpha_{j} + \beta_{k} i=1,\cdots,N
 (subjects) j=0,1 (two levels) k=0,1 (two levels)

 treating the \phi_{i} as nuinsance parameters.

 Thank you very much

 You can use the gnm() function in the gnm package with eliminate= to
 get
 rid of parameters for each subject.
 Something like

 gnm( lambda ~ Row + Col, eliminate = Subject, family=poisson,
 data=myData)

 where Row, Col, Subject are suitable *factors*.  This is equivalent to

 gnm( lambda ~ -1 + Subject Row + Col, family=poisson)
 except that Subject parameters aren't estimated explicitly.  See
 vignette(gnmOverview)


 --
 Michael Friendly Email: friendly AT yorku DOT ca
 Professor, Psychology Dept.
 York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
 4700 Keele StreetWeb:   http://www.datavis.ca
 Toronto, ONT  M3J 1P3 CANADA

 __
 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] declaring GPL license

2010-10-14 Thread Berwin A Turlach
G'day Stacey,

On Thu, 14 Oct 2010 12:36:20 -0400
Stacey Wood sjw...@ncsu.edu wrote:

 Thanks everyone.  Now I know that I should not include another copy
 of the license, but where should I refer to the copies on
 http://www.r-project.org/Licenses/? In the DESCRIPTION file?

I used to mention that location in the License: line of the DESCRIPTION
file, after GPL (=2).  But some versions ago, that line got
standardised and now it is no longer possible to put additional text
onto that line. 

I guess you could just add a line LicenceLocation:  As far as I
understand the documentation, you are free to add additional lines
beyond those described in Writing R Extensions to the DESCRIPTION
file.  Some entries described in the manual are optional and for those
that are not some restrictions may apply that have to be followed.

Personally, I decided not to put any such reference into the
DESCRIPTION file of my packages as I guess that people who worry about
the lisence will either look into the source package (where I have a
copy) or know how to find one. :)

HTH.

Cheers,

Berwin

__
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] Query on save.image()

2010-10-14 Thread Joshua Wiley
Hi,

I do not believe you can use the save.image() function in this case.
save.image() is a wrapper for save() with defaults for the global
environment (your workspace).  Try this instead, I believe it does
what you are after:

myfun - function(x) {
y - 5 * x + x^2
save(list = ls(envir = environment(), all.names = TRUE),
 file = myfile.RData, envir = environment())
}

Notice that for both save() and ls() I used the environment() function
to grab the current environment.  This should mean that even if y
was defined globally, it would save a copy of the version inside your
function.

Hope that helps,

Josh


On Thu, Oct 14, 2010 at 9:25 AM, Megh Dal megh700...@yahoo.com wrote:
 Can anyone please tell me how can use save.image() function if it is placed 
 within a function (i.e. some level up from the base level environment)? Here 
 I experimented with following codes:


 #rm(list=ls())
 fn - function() {
    x - rnorm(5)
    save.image(f:/dat.RData)
  }
 fn()

 However I see that, the object fn() is actually stored in dat.RData file, not 
 that x. I have gone through the help page and saw there is some argument 
 named envir
 My question is if I need to supply some value against that argument, then 
 what should be the name of the required environment?

 Additionally is there any option to see the hierarchy of different 
 environments at my current R session?

 Thanks,

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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] declaring GPL license

2010-10-14 Thread Marc Schwartz
On Oct 14, 2010, at 11:36 AM, Stacey Wood wrote:

 Thanks everyone.  Now I know that I should not include another copy of the 
 license, but where should I refer to the copies on 
 http://www.r-project.org/Licenses/? In the DESCRIPTION file?
 
 Stacey


snip

Not in the DESCRIPTION file.  :-)

Given the prior comments, I did some checking on the Recommended packages 
(presuming that they can be used as correct examples) and there seems to be 
some variability present. In some cases, the COPYING file is included in the 
main source package folder, so that it is available in the distribution of the 
package source tarball, but as Dirk noted, it is not installed. 

You can then include a LICENCE file in the 'inst' directory, where that file 
has content along the lines of the following (based upon VR's MASS) for GPL2:


Copyrights
==

List any relevant copyrights here


Licence
===

This is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2. 

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

Files share/licenses/GPL-2 in the R
(source or binary) distribution is a copy of version 2 
of the 'GNU General Public License'.
These can also be viewed at http://www.r-project.org/licenses/



So in the above case, the LICENCE file will be available in both the source and 
binary/installed versions of the package, but without duplicating the content 
of the full COPYING file.

HTH,

Marc


[[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] R on a ma c

2010-10-14 Thread Ista Zahn
In my experience R runs just fine on the Mac. For basic use you don't
need to do anything special whatsoever. Just install R as you would
any other program. If you need to install packages from source you
will probably want to install Xcode. Other Mac FAQs are at
http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html

-Ista

On Thu, Oct 14, 2010 at 12:25 PM, Tiffany Kinder
tiffany.kin...@aggiemail.usu.edu wrote:
 Hello,
 Is R very compatible with a Mac?  A colleague of mine indicated that
 everyone he knows with a Mac has problems with R.

 What can you tell me about using R with a Mac.  What do I need to download?
  I have downloaded the basic R package.

 Thanks,

 --
 Tiffany Kinder
 MS Student
 Department of Watershed Science
 Utah State University
 tiffany.kin...@aggiemail.usu.edu

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




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.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] R on a ma c

2010-10-14 Thread Joshua Wiley
Dear Tiffany,

R works wonderfully with Macs (and *nix and Windows).  The main
program should be all you need, but if you have any doubts or
concerns, here is the link to download R from the website for Mac
OSes:
http://cran.r-project.org/bin/macosx/

If you are just getting started using R, it is a good idea to read
through the introduction to R manual:
http://cran.r-project.org/manuals.html

and you might also consider getting a book to help you a long the way.
 There is a large list of books related to R here:
http://www.r-project.org/doc/bib/R-books.html

I have personally found Peter Dalgaard's book a very nice book to start with:
Peter Dalgaard. Introductory Statistics with R. Springer, 2nd edition,
2008. ISBN 978-0-387-79053-4. [ bib | Discount Info | Publisher Info |
http://www.biostat.ku.dk/~pd/ISwR.html ]



Best regards and welcome to R,

Josh


On Thu, Oct 14, 2010 at 9:25 AM, Tiffany Kinder
tiffany.kin...@aggiemail.usu.edu wrote:
 Hello,
 Is R very compatible with a Mac?  A colleague of mine indicated that
 everyone he knows with a Mac has problems with R.

 What can you tell me about using R with a Mac.  What do I need to download?
  I have downloaded the basic R package.

 Thanks,

 --
 Tiffany Kinder
 MS Student
 Department of Watershed Science
 Utah State University
 tiffany.kin...@aggiemail.usu.edu

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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] R on a ma c

2010-10-14 Thread David Winsemius


On Oct 14, 2010, at 12:25 PM, Tiffany Kinder wrote:


Hello,
Is R very compatible with a Mac?



Very compatible. I have been using it as my work machine for the last  
2.75 years and several of the regular contributors to rhelp are also  
running Macs. Rock-solid. Better memory management than Windows XP or  
Vista. Simon Urbanek (and his collaborators) deserves a huge amount of  
thanks for the fine work he has done.


The R-Mac SIG is the place for mac-specific question, though:

https://stat.ethz.ch/mailman/listinfo/r-sig-mac


A colleague of mine indicated that
everyone he knows with a Mac has problems with R.


He needs more sophisticated friends :-)



What can you tell me about using R with a Mac.  What do I need to  
download?


There is a section in the installation document:

http://cran.r-project.org/doc/manuals/R-admin.html#Installing-R-under-Mac-OS-X




I have downloaded the basic R package.


That is not exactly specific enough to advise whether you got the  
correct bundle for your machine. Be sure to read the installation  
document carefully. No shortcuts.




Thanks,

--
Tiffany Kinder
MS Student
Department of Watershed Science
Utah State University


David Winsemius, MD
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.


Re: [R] Query on save.image()

2010-10-14 Thread Hadley Wickham
On Thu, Oct 14, 2010 at 11:56 AM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 Hi,

 I do not believe you can use the save.image() function in this case.
 save.image() is a wrapper for save() with defaults for the global
 environment (your workspace).  Try this instead, I believe it does
 what you are after:

 myfun - function(x) {
 y - 5 * x + x^2
 save(list = ls(envir = environment(), all.names = TRUE),
     file = myfile.RData, envir = environment())
 }

 Notice that for both save() and ls() I used the environment() function
 to grab the current environment.  This should mean that even if y
 was defined globally, it would save a copy of the version inside your
 function.

I think the defaults are actually ok in this case:

 myfun - function(x) {
+   y - 5 * x + x^2
+   save(list = ls(all.names = TRUE), file = myfile.RData)
+ }
 print(load(myfile.RData))
[1] x y

Hadley


-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

__
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] running a long R process on Linux using putty - best practice to disconnect

2010-10-14 Thread Uwe Ligges



On 14.10.2010 18:07, Martin Tomko wrote:

Dear all,
I am sure this has been solved before, googling did not help much,.
Warning, I am not great with putty/linux servers

Situation: I have been given access to an R installation on a Linux
server to do some larger number crunching that was killing my machine. I
use putty to connect, and then go R, source(myscript) and all is fine
But this will take potentially days, and I would like to disconnect

What is the best practice? Someone mentionne nohup, but this would
require starting the R script with an argument to R, I think. Is this
doable?


Right, just do

nohup R CMD BATCH myscript.R 

and make sure you save all relevant results into files within myscript.R

Uwe Ligges



Another option was using screen, btu that is not available on the server.
Any help is welcome.



Thanks
Martin

__
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] [OT] (slightly) - OpenOffice Calc and text files

2010-10-14 Thread John C Frain
-- Forwarded message --
From: John C Frain fra...@gmail.com
Date: 14 October 2010 18:20
Subject: Re: [R] [OT] (slightly) - OpenOffice Calc and text files
To: Schwab,Wilhelm K bsch...@anest.ufl.edu


Just a basic comment on Open Office Calc.  I find Open Office Calc and
excellent program for viewing and minor processing of data - much
better than Excel. In particular it is a very flexible tool for
transferring data between different packages.  However one must take a
certain amount of care in its use.

If you import a csv or text file into open office it is reformatted by
 Calc.  If you save this as csv or text or similar then the default is
to save exactly as displayed.  If I wish to retain more significant
data or dates in a particular format use the various format facilities
in Calc to ensure that what you require is displayed in Calc before
you save as csv or similar.  There is also a useful facility to edit
the output facilities before saving.  Calc or Excel or Write or Word
do add formatting that any plain text editor (Scite Notepad++ Emacs
etc.) do not.

Best Regards

John

On 13 October 2010 21:27, Schwab,Wilhelm K bsch...@anest.ufl.edu wrote:
 I know *what* happened (Calc reformatted the data in ways I did not want or 
 expect).   It is not end-of-line conventions; they reformatted the data 
 leaving the structure intact.  As to why/how, that could depend on the 
 sequence of operations, so I thought to ask here to see if you had 
 collectively either found something specific to do or to avoid.

 Gnumeric is now freshly installed and will get some testing; if I don't care 
 for it, I'll look more at emacs.  I don't ask much of a spreadsheet 
 (show/edit a grid and maybe hide/show columns for complex data sets), but it 
 would be nice if it did not reformat everything every time I open a file :(

 So far, gnumeric successfully opened a file; I will be a little less trusting 
 when it comes to saving one.  Thanks!!

 Bill




 
 From: Mike Marchywka [marchy...@hotmail.com]
 Sent: Wednesday, October 13, 2010 3:10 PM
 To: dwinsem...@comcast.net; Schwab,Wilhelm K
 Cc: r-help@r-project.org
 Subject: RE: [R] [OT] (slightly) - OpenOffice Calc and text files

 
 From: dwinsem...@comcast.net
 To: bsch...@anest.ufl.edu
 Date: Wed, 13 Oct 2010 14:52:21 -0400
 CC: r-help@r-project.org
 Subject: Re: [R] [OT] (slightly) - OpenOffice Calc and text files


 On Oct 13, 2010, at 1:13 PM, Schwab,Wilhelm K wrote:

  Hello all,
 
  I had a very strange looking problem that turned out to be due to
  unexpected (by me at least) format changes to one of my data files.
  We have a small lab study in which each run is represented by a row
  in a tab-delimited file; each row identifies a repetition of the
  experiment and associates it with some subjective measurements and
  times from our notes that get used to index another file with lots
  of automatically collected data. In short, nothing shocking.
 
  In a moment of weakness, I opened the file using (I think it's
  version 3.2) of OpenOffice Calc to edit something that I had mangled
  when I first entered it, saved it (apparently the mistake), and
  reran my analysis code. The results were goofy, and the problem was
  in my code that runs before R ever sees the data. That code was
  confused by things that I would like to ensure don't happen again,
  and I suspect that some of you might have thoughts on it.
 
  The problems specifically:
 
  (1) OO seems to be a little stingy about producing tab-delimited
  text; there is stuff online about using the csv and editing the
  filter and folks (presumably like us) saying that it deserves to be
  a separate option.

 You have been little stingy yourself about describing what you did. I
 see no specifics about the actual data used as input nor the specific
 operations. I just opened an OO.o Calc workbook and dropped a
 character vector, 1969-12-31 23:59:50 copied from help(POSIXct) into



  Have any of you found a nice (or at least predictable) way to use OO
  Calc to edit files like this?

 I didn't do anything I thought was out of the ordinary and so cannot
 reproduce your problem. (This was on a Mac, but OO.o is probably going
 to behave the same across *NIX cultures.)

 --
 David

  If it insists on thinking for me, I wish it would think in 24 hour
  time and 4 digit years :)

 Is it possible that you have not done enough thinking for _it_?

  I work on Linux, so Excel is off the table, but another spreadsheet
  or text editor would be a viable option, as would configuration
  changes to Calc.
 
  Bill

 Probably instead of guessing and seeing how various things react, you
 could go get a utility like octal dump or open in an editor that
 has a hex mode and see what happened. This could be anything- crlf convention,
 someone turned it to unicode, etc. On linux or cygwin I think you have
 od available. Then of course, if you 

Re: [R] Query on save.image()

2010-10-14 Thread Joshua Wiley
Hi,

Given what Hadley said, it looks like you don't need either one.  In
any case the logic was this:

ls() gets the NAMES of the objects
save() gets the actual data

Suppose in your workspace you define:

y - Hello, from the Global Environment

and then you used that little function I showed, that defines:

y - 5 * x + x^2

ls() will only give you the name y, you still want save() to get the
values from the right environment.

Cheers,

Josh

On Thu, Oct 14, 2010 at 10:18 AM, Megh Dal megh700...@yahoo.com wrote:
 Thanks Joshua for your reply. However I could not understand one logic. If I 
 write ls(envir = environment(), all.names = TRUE), I am actually telling R 
 to grab all objects within the current environment (in  my case, which the 
 environment within fn()). Then what is the point to put again the same 
 against envir. By putting so, what I am going to tell R?

 Thanks,

 --- On Thu, 10/14/10, Joshua Wiley jwiley.ps...@gmail.com wrote:

 From: Joshua Wiley jwiley.ps...@gmail.com
 Subject: Re: [R] Query on save.image()
 To: Megh Dal megh700...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Date: Thursday, October 14, 2010, 10:26 PM
 Hi,

 I do not believe you can use the save.image() function in
 this case.
 save.image() is a wrapper for save() with defaults for the
 global
 environment (your workspace).  Try this instead, I
 believe it does
 what you are after:

 myfun - function(x) {
 y - 5 * x + x^2
 save(list = ls(envir = environment(), all.names = TRUE),
      file = myfile.RData, envir =
 environment())
 }

 Notice that for both save() and ls() I used the
 environment() function
 to grab the current environment.  This should mean
 that even if y
 was defined globally, it would save a copy of the version
 inside your
 function.

 Hope that helps,

 Josh


 On Thu, Oct 14, 2010 at 9:25 AM, Megh Dal megh700...@yahoo.com
 wrote:
  Can anyone please tell me how can use save.image()
 function if it is placed within a function (i.e. some level
 up from the base level environment)? Here I experimented
 with following codes:
 
 
  #rm(list=ls())
  fn - function() {
     x - rnorm(5)
     save.image(f:/dat.RData)
   }
  fn()
 
  However I see that, the object fn() is actually stored
 in dat.RData file, not that x. I have gone through the
 help page and saw there is some argument named envir
  My question is if I need to supply some value against
 that argument, then what should be the name of the required
 environment?
 
  Additionally is there any option to see the hierarchy
 of different environments at my current R session?
 
  Thanks,
 
  __
  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.
 



 --
 Joshua Wiley
 Ph.D. Student, Health Psychology
 University of California, Los Angeles
 http://www.joshuawiley.com/








-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] installing grid package

2010-10-14 Thread Uwe Ligges

The message days it all: This [grid] is the name of a base package.
If you need a new version of grid: Upgrade R to R-2.12.0 which will be 
released tomorrow.


Best,
Uwe Ligges


On 14.10.2010 16:29, ogbos okike wrote:

Hi all,

I can't understand why grid package failed to installed on my machine. Can
anybody have a look and advice on where I am missing it.

  My R version is 2.9.2. After untarring:  tar xzvf grid_0.7-4.tar.gz, I
tried to configure or make but none worked, 'no such files'. I have also
tried using : sudo R CMD INSTALL /home/ogbos/Desktop/goo/grid_0.7-4.tar.gz
which also resulted in the error below.
* Installing to library '/home/ogbos/R/i486-pc-linux-gnu-library/2.8'
* Installing *source* package 'grid' ...
Error: Invalid DESCRIPTION file

Invalid package name.
This is the name of a base package.

Execution halted
ERROR: installing package DESCRIPTION failed

Thanks for any advice.
Ogbos

[[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] Query on save.image()

2010-10-14 Thread Megh Dal
Thanks Joshua for your reply. However I could not understand one logic. If I 
write ls(envir = environment(), all.names = TRUE), I am actually telling R to 
grab all objects within the current environment (in  my case, which the 
environment within fn()). Then what is the point to put again the same against 
envir. By putting so, what I am going to tell R?

Thanks,

--- On Thu, 10/14/10, Joshua Wiley jwiley.ps...@gmail.com wrote:

 From: Joshua Wiley jwiley.ps...@gmail.com
 Subject: Re: [R] Query on save.image()
 To: Megh Dal megh700...@yahoo.com
 Cc: r-h...@stat.math.ethz.ch
 Date: Thursday, October 14, 2010, 10:26 PM
 Hi,
 
 I do not believe you can use the save.image() function in
 this case.
 save.image() is a wrapper for save() with defaults for the
 global
 environment (your workspace).  Try this instead, I
 believe it does
 what you are after:
 
 myfun - function(x) {
 y - 5 * x + x^2
 save(list = ls(envir = environment(), all.names = TRUE),
      file = myfile.RData, envir =
 environment())
 }
 
 Notice that for both save() and ls() I used the
 environment() function
 to grab the current environment.  This should mean
 that even if y
 was defined globally, it would save a copy of the version
 inside your
 function.
 
 Hope that helps,
 
 Josh
 
 
 On Thu, Oct 14, 2010 at 9:25 AM, Megh Dal megh700...@yahoo.com
 wrote:
  Can anyone please tell me how can use save.image()
 function if it is placed within a function (i.e. some level
 up from the base level environment)? Here I experimented
 with following codes:
 
 
  #rm(list=ls())
  fn - function() {
     x - rnorm(5)
     save.image(f:/dat.RData)
   }
  fn()
 
  However I see that, the object fn() is actually stored
 in dat.RData file, not that x. I have gone through the
 help page and saw there is some argument named envir
  My question is if I need to supply some value against
 that argument, then what should be the name of the required
 environment?
 
  Additionally is there any option to see the hierarchy
 of different environments at my current R session?
 
  Thanks,
 
  __
  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.
 
 
 
 
 -- 
 Joshua Wiley
 Ph.D. Student, Health Psychology
 University of California, Los Angeles
 http://www.joshuawiley.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] R and Oracle

2010-10-14 Thread Siddharth Garg
Hi

Thanks for the reply. I managed to find a simpler solution using RJDBC. All
I needed to do was install RJDBC, DBI and download oracle driver for JDBC.

Regards
Siddharth

On Thu, Oct 14, 2010 at 5:32 PM, Marc Schwartz marc_schwa...@me.com wrote:

 On Oct 14, 2010, at 12:45 AM, siddharth.gar...@gmail.com wrote:

  Hi
 
  Can someone please help me with connecting to oracle via R. I have been
 trying to use ROracle but its giving me a lot of trouble because of pro*c.
 
  ThanksRegards
  Siddharth


 You have not provided sufficient information (OS, error messages, what you
 have done so far, etc.) to enable us to help you. Review the Posting Guide:

  
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html

 To start, be sure to read:

  http://cran.r-project.org/web/packages/ROracle/INSTALL

 I would also recommend searching the list archives, using one of the R
 search tools such as:

  http://www.rseek.org/

 using ROracle as a keyword.

 Depending upon your platform, you may wish to consider using the RODBC
 package instead, which I have used on Linux and OSX to connect to Oracle
 servers.

 Finally, there is the R-SIG-DB list, which is focused on R and database
 connectivity/usage. More information is here:

  https://stat.ethz.ch/mailman/listinfo/r-sig-db

 I would recommend subscribing to that list and re-posting your query there,
 with additional details, once you have reviewed the above resources.

 HTH,

 Marc Schwartz



[[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] The width argument of stem()

2010-10-14 Thread Łukasz Ręcławowicz
Or here (kill R feature):

stem(islands, width=NULL)

It may looks like a bug.

2010/10/14 Marcin Kozak nyg...@gmail.com:
 Could anyone pleaase clarify what is going on here?

-- 
Miłego dnia

__
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] RJava help

2010-10-14 Thread lord12

I need help with RJava. So I run this R code:

library(rJava) #load the rJava library
.jinit(classpath=c:/Documents and Settings/GV/workspace/Test/src,
parameters=-Xmx512m)
#the above is to load the Java virtual machine,


x = runif(1000)
y = runif(1000)
#the above are two vectors to convolve

#now you can call the Java method as
z=.jcall(Test, [D, convolve, x,y)

I get an error Error in .jcall(Test, [D, convolve, x, y) : 
  RcallMethod: cannot determine object class.

Why is this?



-- 
View this message in context: 
http://r.789695.n4.nabble.com/RJava-help-tp2995886p2995886.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] R on a ma c

2010-10-14 Thread David Cross
I have had no problems with R on my Mac ... just download, install,  
and run ... let me know if you have any problems.


Cheers

David Cross
d.cr...@tcu.edu
www.davidcross.us




On Oct 14, 2010, at 11:25 AM, Tiffany Kinder wrote:


Hello,
Is R very compatible with a Mac?  A colleague of mine indicated that
everyone he knows with a Mac has problems with R.

What can you tell me about using R with a Mac.  What do I need to  
download?

I have downloaded the basic R package.

Thanks,

--
Tiffany Kinder
MS Student
Department of Watershed Science
Utah State University
tiffany.kin...@aggiemail.usu.edu

[[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] Fw: Problem to create a matrix polynomial

2010-10-14 Thread Ron Michael
Awaiting some suggestion. Was my question not very understandable? Please let 
me know how can I offer more elaborate clarification.
Additionally, I would like to solve the determinant of p1 for the values of 
z (I am working with some multivariate time series modelling). When I use 
det() function, it am getting error that, that function is not for objects with 
class polynomial.
Any idea please?
Thanks,

--- On Wed, 13/10/10, Ron_M ron_michae...@yahoo.com wrote:

From: Ron_M ron_michae...@yahoo.com
Subject: [R] Problem to create a matrix polynomial
To: r-help@r-project.org
Date: Wednesday, 13 October, 2010, 4:31 PM


Dear all R users, I was trying to create a polymonial using the polynom() of
PolynomF package. My problem is, if I pass coefficients as simple
numerical values, it is working, but for matrix coefficient it is not. Here
is my try:

library(PolynomF)
z - polynom()

## following is working
p1 - 1- 4.5*z

## However following is not giving results as intended
p1 - diag(3)- matrix(1:9, 3,3)*z

In the 2nd example, I was expecting a matrix polynomial in z upto degree
1, which I did not get. Can anyone please correct me how to address this
problem?

Thanks,
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Problem-to-create-a-matrix-polynomial-tp2993411p2993411.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.


[R] Regression with groups and nested sub-groups

2010-10-14 Thread Robert Quinn
I have the following formula for a linear model:

z - lm(y~x + factor(a) + factor(b), data=NT2010)

where a (groups) and b (Sub-groups) are categorical variables (factors), x
is a continuous covariate, and y the response variable.  Since b is nested
within a, the formula can also be written as: 

z - lm(y~x + factor(a) + factor(a)/factor(b), data=NT2010)

and the same output is achieved when summary(z) is called.

How can I get the output to show all 3 groups that I have inputted?  There
are only group 2 and group 3 on the output, group 1 is missing.  Also there
is a subgroup (subgroup 1) of the total 9 subgroups missing.  I would like
to see the p-value of the missing group and missing sub-group even though
I'm sure they are not significantly different (0.05).  How do I change the
original formula to get all groups and sub-groups outputted?

 

 


[[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] drilling down data on charts

2010-10-14 Thread jverzani
Greg Snow Greg.Snow at imail.org writes:

 
 It is not clear what exactly you want.  Try looking at the functions
TkPredict, TkSpline, and TkApprox in the
 TeachingDemos package to see if any of those do what you want.
 
 If not, give a bit more of a description and include some sample data.
 

You could program something by using locator() perhaps although as 
Greg mentions
it isn't clear what you want.

Along those lines, in addition to the above mentioned packages, 
you might want to look at some packages that use cairoDevice 
to create interactive graphic displays. For example, you might 
find ready made features in playwith or you can use gWidgetsRGtk2 
to create something on your own.

__
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] Regression with groups and nested sub-groups

2010-10-14 Thread Joshua Wiley
Hi Robert,

In R, the default treatment contrasts for factor class variables in
regression treats the first level as the reference group when creating
the contrast matrix for the regression, so it is not really a matter
of changing the formula.

This might provide some insight:
http://www.ats.ucla.edu/stat/r/library/contrast_coding.htm

There are many ways to handle categorical data, and without knowing
exactly what you want, it is difficult to give any sound suggestions.
It really depends on your question.


Cheers,

Josh


On Thu, Oct 14, 2010 at 12:34 PM, Robert Quinn rqu...@fbr.org wrote:
 I have the following formula for a linear model:

 z - lm(y~x + factor(a) + factor(b), data=NT2010)

 where a (groups) and b (Sub-groups) are categorical variables (factors), x
 is a continuous covariate, and y the response variable.  Since b is nested
 within a, the formula can also be written as:

 z - lm(y~x + factor(a) + factor(a)/factor(b), data=NT2010)

 and the same output is achieved when summary(z) is called.

 How can I get the output to show all 3 groups that I have inputted?  There
 are only group 2 and group 3 on the output, group 1 is missing.  Also there
 is a subgroup (subgroup 1) of the total 9 subgroups missing.  I would like
 to see the p-value of the missing group and missing sub-group even though
 I'm sure they are not significantly different (0.05).  How do I change the
 original formula to get all groups and sub-groups outputted?



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


-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] Regression with groups and nested sub-groups

2010-10-14 Thread Bert Gunter
To be clear, this:

 How can I get the output to show all 3 groups that I have inputted?  There
 are only group 2 and group 3 on the output, group 1 is missing.  Also there
 is a subgroup (subgroup 1) of the total 9 subgroups missing.  I would like
 to see the p-value of the missing group and missing sub-group even though
 I'm sure they are not significantly different (0.05).

shows a fundamental lack of understanding of the basic ideas of linear
modeling (since it's basically nonsense -- an impossibility). You
would do well to contact a local statistician to help you out.

Cheers,
Bert

On Thu, Oct 14, 2010 at 12:50 PM, Joshua Wiley jwiley.ps...@gmail.com wrote:
 Hi Robert,

 In R, the default treatment contrasts for factor class variables in
 regression treats the first level as the reference group when creating
 the contrast matrix for the regression, so it is not really a matter
 of changing the formula.

 This might provide some insight:
 http://www.ats.ucla.edu/stat/r/library/contrast_coding.htm

 There are many ways to handle categorical data, and without knowing
 exactly what you want, it is difficult to give any sound suggestions.
 It really depends on your question.


 Cheers,

 Josh


 On Thu, Oct 14, 2010 at 12:34 PM, Robert Quinn rqu...@fbr.org wrote:
 I have the following formula for a linear model:

 z - lm(y~x + factor(a) + factor(b), data=NT2010)

 where a (groups) and b (Sub-groups) are categorical variables (factors), x
 is a continuous covariate, and y the response variable.  Since b is nested
 within a, the formula can also be written as:

 z - lm(y~x + factor(a) + factor(a)/factor(b), data=NT2010)

 and the same output is achieved when summary(z) is called.

 How can I get the output to show all 3 groups that I have inputted?  There
 are only group 2 and group 3 on the output, group 1 is missing.  Also there
 is a subgroup (subgroup 1) of the total 9 subgroups missing.  I would like
 to see the p-value of the missing group and missing sub-group even though
 I'm sure they are not significantly different (0.05).  How do I change the
 original formula to get all groups and sub-groups outputted?



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


 --
 Joshua Wiley
 Ph.D. Student, Health Psychology

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




-- 
Bert Gunter
Genentech Nonclinical Biostatistics
467-7374
http://devo.gene.com/groups/devo/depts/ncb/home.shtml

__
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] running a long R process on Linux using putty - best practice to disconnect

2010-10-14 Thread Martin Tomko
thank you guys, R CMD BATCH seems the way to go, and I will nudge my 
admin to install screen /byobu


Thanks heaps,
Martin

On 10/14/2010 7:21 PM, Uwe Ligges wrote:



On 14.10.2010 18:07, Martin Tomko wrote:

Dear all,
I am sure this has been solved before, googling did not help much,.
Warning, I am not great with putty/linux servers

Situation: I have been given access to an R installation on a Linux
server to do some larger number crunching that was killing my machine. I
use putty to connect, and then go R, source(myscript) and all is fine
But this will take potentially days, and I would like to disconnect

What is the best practice? Someone mentionne nohup, but this would
require starting the R script with an argument to R, I think. Is this
doable?


Right, just do

nohup R CMD BATCH myscript.R 

and make sure you save all relevant results into files within myscript.R

Uwe Ligges


Another option was using screen, btu that is not available on the 
server.

Any help is welcome.



Thanks
Martin

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





--
Martin Tomko
Postdoctoral Research Assistant

Geographic Information Systems Division
Department of Geography
University of Zurich - Irchel
Winterthurerstr. 190
CH-8057 Zurich, Switzerland

email:  martin.to...@geo.uzh.ch
site:   http://www.geo.uzh.ch/~mtomko
mob:+41-788 629 558
tel:+41-44-6355256
fax:+41-44-6356848

__
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] Looking for more in depth QDA

2010-10-14 Thread Craig Larner

Hello,

I am currently running multivariate analysis to find prediction 
equations for a specific event.  Currently, we do this by using the 
combination of LDA and SIR through the dr package.  The advantage of 
SIR is that we are giving constants for which weigh the importance of 
the factors, as well as the p-value is given in SIR.


I was looking into running QDA and was wondering if there is a command 
that will output a prediction equation and the constants for this 
equation as well as a p-value of the separation?


Thanks for anyone who can help.

Craig

__
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] R on a ma c

2010-10-14 Thread Andrew Miles
R works great on my Mac.  In fact, the user interface in some ways  
seems to be more friendly (ex. you type an open parenthesis, it  
automatically includes a close parenthesis; color coding for coding  
files, etc.)


Andrew Miles


On Oct 14, 2010, at 2:49 PM, David Cross wrote:

I have had no problems with R on my Mac ... just download, install,  
and run ... let me know if you have any problems.


Cheers

David Cross
d.cr...@tcu.edu
www.davidcross.us




On Oct 14, 2010, at 11:25 AM, Tiffany Kinder wrote:


Hello,
Is R very compatible with a Mac?  A colleague of mine indicated that
everyone he knows with a Mac has problems with R.

What can you tell me about using R with a Mac.  What do I need to  
download?

I have downloaded the basic R package.

Thanks,

--
Tiffany Kinder
MS Student
Department of Watershed Science
Utah State University
tiffany.kin...@aggiemail.usu.edu

[[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-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] 64 bit use of odbcConnectExcel

2010-10-14 Thread Jack T.

Still doesn't work, any ideas?

Error in sqlTables(channel1) : 
  first argument is not an open RODBC channel
In addition: Warning messages:
1: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified
2: In odbcDriverConnect(con, tabQuote = c([, ]), ...) :
  ODBC connection failed

My system: 

Microsoft XP Professional Version 2003 service pack2
64-bit version
-- 
View this message in context: 
http://r.789695.n4.nabble.com/64-bit-use-of-odbcConnectExcel-tp2298927p2996134.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] 2-dimensional convolution tool wanted

2010-10-14 Thread Carl Witthoft
I found the imgConvolve tool in the biOps package, but since I'm 
primarily working on OSX computers, wondered if there are any other 
2-dimensional convolution functions out there?
And, yes, I'm going to ask r-sig-mac whether biOps will compile from 
source under OSX.


I did find one convolution function somewhere, but it was limited to 
three built-in kernels, so not really helpful.


thanks
Carl

__
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] RODBC results from stored procedure

2010-10-14 Thread ang

I know this thread is from a while back, but hopefully I can still get some
help on this.

I also used RODBC to connect to a SQL Server, and my stored procedure
returns a results set (that is not stored as a temp or permanent table).

So I was wondering if there was a way to access this results set, or am I
forced to store the results into a table before I can access it?

Some options I have considered: 
a)modifying the stored procedures to insert the results into tables
b)creating temp tables (trying to stay away from this as it is not as
dynamic and would require defining of many tables if I wanted to run some ad
hoc analysis)

The reason I do not want to modify the queries/create temp or perm tables is
because the SQL end is maintained by a separate team, and I am simply using
R to connect/run analyses off the data.  I am trying to keep my side as self
contained and independent as possible.  Any suggestions/advice would be
greatly appreciated.

Thanks a lot,
Adrian
-- 
View this message in context: 
http://r.789695.n4.nabble.com/RODBC-results-from-stored-procedure-tp897462p2996173.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] Fw: Problem to create a matrix polynomial

2010-10-14 Thread Ben Bolker
Ron Michael ron_michael70 at yahoo.com writes:

 
 Awaiting some suggestion. Was my question not very understandable? 
 Please let me know how can I offer more
 elaborate clarification.
 Additionally, I would like to solve the determinant of p1
  for the values of z (I am working with some
 multivariate time series modelling). When I use det()
  function, it am getting error that, that function
 is not for objects with class polynomial.
 Any idea please?
 Thanks,

  Well, the description of the PolynomF package says
Implements univariate polynomial operations in R, so I'm
not quite sure why you'd expect it to work for matrices ...
I'm also not sure what you're trying to do: find roots
of matrix equations? Is the expm package at all helpful?
What tools do other people in your field use to solve
similar problems?  R is not in general a great tool for
symbolic manipulations, even though there are little corners
where people have implemented such capabilities.  Have
you looked at symbolic toolboxes such as Sage, Maxima, PARI
(or commercial packages) ... ?


 
 --- On Wed, 13/10/10, Ron_M ron_michael70 at yahoo.com wrote:
 
 Dear all R users, I was trying to create a polymonial using the polynom() of
 PolynomF package. My problem is, if I pass coefficients as simple
 numerical values, it is working, but for matrix coefficient it is not. Here
 is my try:
 
 library(PolynomF)
 z - polynom()
 
 ## following is working
 p1 - 1- 4.5*z
 
 ## However following is not giving results as intended
 p1 - diag(3)- matrix(1:9, 3,3)*z
 
 In the 2nd example, I was expecting a matrix polynomial in z upto degree
 1, which I did not get. Can anyone please correct me how to address this
 problem?

__
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] for loop

2010-10-14 Thread li li
Dear all,
  I have a function f(x)  which return a list as result.

$T1
[1] 0.03376190
$T2
[1] 0.04725
$T3
[1] 0.3796071
$T4
[1] 0.3713452
$T5
[1] 0.4523651
$T6
[1] 0.4575873

  I now find the result for a vector of x values at one time. I want to
store the reuslt
for each xi value in a column of a matrix

x - seq(0,1, by=0.1)
result - matrix(0, nrow=6, ncol=length(x))

for (i in 1:length(x)){result[,i] - f(x[i])}

It is not working. Can some help me.
Thank you very much!
Hannah

[[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] for loop

2010-10-14 Thread Joshua Wiley
Dear Hannah,

Well one issue is that you are trying to assign a list to a matrix
column.  This is a hazardous move, and may well be your problem.  Try:
 lapply(x, f)

that should give you some nice results, and can probably be fairly
easily converted to a matrix if you want.  It is really hard to give
you more help without having f() and without the exact details of what
went wrong or the error message (if there was one).

Best regards,

Josh



On Thu, Oct 14, 2010 at 2:53 PM, li li hannah@gmail.com wrote:
 Dear all,
  I have a function f(x)  which return a list as result.

 $T1
 [1] 0.03376190
 $T2
 [1] 0.04725
 $T3
 [1] 0.3796071
 $T4
 [1] 0.3713452
 $T5
 [1] 0.4523651
 $T6
 [1] 0.4575873

  I now find the result for a vector of x values at one time. I want to
 store the reuslt
 for each xi value in a column of a matrix

 x - seq(0,1, by=0.1)
 result - matrix(0, nrow=6, ncol=length(x))

 for (i in 1:length(x)){result[,i] - f(x[i])}

 It is not working. Can some help me.
 Thank you very much!
                        Hannah

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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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] for loop

2010-10-14 Thread Brian Diggs

On 10/14/2010 2:53 PM, li li wrote:

Dear all,
   I have a function f(x)  which return a list as result.

$T1
[1] 0.03376190
$T2
[1] 0.04725
$T3
[1] 0.3796071
$T4
[1] 0.3713452
$T5
[1] 0.4523651
$T6
[1] 0.4575873

   I now find the result for a vector of x values at one time. I want to
store the reuslt
for each xi value in a column of a matrix

x- seq(0,1, by=0.1)
result- matrix(0, nrow=6, ncol=length(x))

for (i in 1:length(x)){result[,i]- f(x[i])}

It is not working. Can some help me.
Thank you very much!
 Hannah


In order to test my solution, I needed a function that returned 
something of the structure you had.


f - function(x) {
r - as.list(rnorm(6))
names(r) - paste(T,1:6,sep=)
r
}

Using that, you can replace the for loop with:

for (i in 1:length(x)){result[,i] - unlist(f(x[i]))}

The problem is that f returns a list; you can only put a vector in part 
of a matrix.  unlist() takes care of that conversion.


--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health  Science University

__
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] for loop

2010-10-14 Thread li li
Thanks for the kind help!
   Hannah

2010/10/14 Brian Diggs dig...@ohsu.edu

  On 10/14/2010 2:53 PM, li li wrote:

 Dear all,
   I have a function f(x)  which return a list as result.

 $T1
 [1] 0.03376190
 $T2
 [1] 0.04725
 $T3
 [1] 0.3796071
 $T4
 [1] 0.3713452
 $T5
 [1] 0.4523651
 $T6
 [1] 0.4575873

   I now find the result for a vector of x values at one time. I want to
 store the reuslt
 for each xi value in a column of a matrix

 x- seq(0,1, by=0.1)
 result- matrix(0, nrow=6, ncol=length(x))

 for (i in 1:length(x)){result[,i]- f(x[i])}

 It is not working. Can some help me.
 Thank you very much!
 Hannah


 In order to test my solution, I needed a function that returned something
 of the structure you had.

 f - function(x) {
r - as.list(rnorm(6))
names(r) - paste(T,1:6,sep=)
r
 }

 Using that, you can replace the for loop with:

 for (i in 1:length(x)){result[,i] - unlist(f(x[i]))}

 The problem is that f returns a list; you can only put a vector in part of
 a matrix.  unlist() takes care of that conversion.

 --
 Brian S. Diggs, PhD
 Senior Research Associate, Department of Surgery
 Oregon Health  Science University


[[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] for loop

2010-10-14 Thread Joshua Wiley
If unlisting was the only issue, then this should also work, and will
save you the trouble of initializing a matrix, creating x, and using a
for loop.

## Brian's Function
f - function(x) {
   r - as.list(rnorm(6))
   names(r) - paste(T,1:6,sep=)
   r
}

sapply(seq(0,1, by=0.1), function(x) {unlist(f(x))})

Cheers,

Josh

On Thu, Oct 14, 2010 at 3:43 PM, li li hannah@gmail.com wrote:
 Thanks for the kind help!
               Hannah

 2010/10/14 Brian Diggs dig...@ohsu.edu

  On 10/14/2010 2:53 PM, li li wrote:

 Dear all,
   I have a function f(x)  which return a list as result.

 $T1
 [1] 0.03376190
 $T2
 [1] 0.04725
 $T3
 [1] 0.3796071
 $T4
 [1] 0.3713452
 $T5
 [1] 0.4523651
 $T6
 [1] 0.4575873

   I now find the result for a vector of x values at one time. I want to
 store the reuslt
 for each xi value in a column of a matrix

 x- seq(0,1, by=0.1)
 result- matrix(0, nrow=6, ncol=length(x))

 for (i in 1:length(x)){result[,i]- f(x[i])}

 It is not working. Can some help me.
 Thank you very much!
                         Hannah


 In order to test my solution, I needed a function that returned something
 of the structure you had.

 f - function(x) {
        r - as.list(rnorm(6))
        names(r) - paste(T,1:6,sep=)
        r
 }

 Using that, you can replace the for loop with:

 for (i in 1:length(x)){result[,i] - unlist(f(x[i]))}

 The problem is that f returns a list; you can only put a vector in part of
 a matrix.  unlist() takes care of that conversion.

 --
 Brian S. Diggs, PhD
 Senior Research Associate, Department of Surgery
 Oregon Health  Science University


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




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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 with an unbalanced split plot

2010-10-14 Thread Eugenio Larios
Hi Everyone,

I am trying to analyze a split plot experiment in the field that was
arranged like this:
I am trying to measure the fitness consequences of seed size.

Factors (X):
*Seed size*: a continuous variable, normally distributed.
*Water*: Categorical Levels- wet and dry.
*Density*: Categorical Levels- high, medium and solo
*Plot*: Counts from 1 to 20
The *response variable *(Y) was the number of seeds produced at the end of
the season.

The experiment started 15 days after plants germinated in the field.
20 plots were chosen where there was high enough density so I could
manipulate it. In an area where artificial irrigation was possible for the
wet treatment, dry treatment was natural precip.
Water was blocked so 10 plots were wet and the other 10 were dry. Randomly
assigned.
Within those 20 plots 6 focal plants were chosen and randomly assigned the
three densities. (split plot design)
I did not control for seed size since it is continuous and normally
distributed, hoping that with 120 plants total (6 in each 20 blocks) I could
get all kind of sizes for every treatment. It worked ok.

I have been trying to analyze this with lme (library NLME). I am not quiet
sure which are my random variables. models I have used are:

m-lme(log(fitness)~seedsize*density,random=~1|plot,data=dataset)
m-lme(log(fitness)~seedsize+density+water,random=~1|plot,data=dataset)

I have also tried to include plot and water as random effects:

m-lme(log(fitness)~seedsize+density+water,random=~1|plot/water,data=dataset)

I am actually not sure if I am using the right random variables here. Also
for some reason, it won't let me include seedsize*density*water triple
interaction
help!
thanks

-- 
Eugenio Larios
PhD Student
University of Arizona.
Ecology  Evolutionary Biology.
(520) 481-2263
elari...@email.arizona.edu

[[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] Replacing N.A values in a data frame

2010-10-14 Thread Gabor Grothendieck
On Thu, Oct 14, 2010 at 9:59 AM, Santosh Srinivas
santosh.srini...@gmail.com wrote:
 Wow! That’s Amazing! Many thanks!

 When I do the below ... why do the column names get thrown off? Ticker is a
 factor / character ... I tried both

 temp - head(MF_Data_Sub)
 temp
        Date Ticker   Price
 1 2008-04-01 106270 10.3287
 2 2008-04-01 106269 10.3287
 3 2008-04-01 102767 12.6832
 4 2008-04-01 102766 10.5396
 5 2008-04-01 102855  9.7833
 6 2008-04-01 102856 12.1485
 tZoo - read.zoo(temp,split=2)
 tZoo
           X102766 X102767 X102855 X102856 X106269 X106270
 2008-04-01 10.5396 12.6832  9.7833 12.1485 10.3287 10.3287

It automatically makes the names valid variable names for R as does
data.frame in R.  If you do not want that behavior add the check.names
= FALSE argument to read.zoo .

 Also, is there an easy way to do a return profile on the data below after it
 is transformed?


What is a profile on the data?   These all work: str(z); summary(z); View(z)

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.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] How to create a dissimilarity object

2010-10-14 Thread Paul Rigor (ucla)
Hi all,

I would like to use the fpc and cluster packages for clustering. However, I
would like to create a custom dissimilarity object using a library in
python.  Has anyone attempted or know of a work-around for creating a
dissimilarity object from a csv file containing pair-wise distance measures?

Thanks in advance!
Paul

[[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 to create a dissimilarity object

2010-10-14 Thread Peter Langfelder
On Thu, Oct 14, 2010 at 5:21 PM, Paul Rigor (ucla) pr...@ucla.edu wrote:
 Hi all,

 I would like to use the fpc and cluster packages for clustering. However, I
 would like to create a custom dissimilarity object using a library in
 python.  Has anyone attempted or know of a work-around for creating a
 dissimilarity object from a csv file containing pair-wise distance measures?

It is simple. Put the distance matrix into a csv file, read it in as

tab = read.csv(...)

convert to a distance as

dst = as.dist(as.matrix(tab))

then call your favorite clustering method.

Here's what as.dist does on a matrix:

mat = matrix(c(1:9), 3, 3)
mat
as.dist(mat)

HTH,

Peter

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


  1   2   >