Re: [R] Data import export zipped files from URLs

2010-01-23 Thread Velappan Periasamy
 cannot open: HTTP status was '404 Not Found' while running the
following commands

f - tempfile()
download.file(http://nseindia.com/content/equities/scripvol/datafiles/01-01-2010-TO-23-01-2010RCOMXN.csv;,
f)
myData - read.csv(f)


On 1/19/10, Henrique Dallazuanna www...@gmail.com wrote:
 Try this:

 f - tempfile()
 download.file(http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip;,
 f)
 myData - read.csv(unzip(f))

 On Tue, Jan 19, 2010 at 2:56 PM, Velappan Periasamy veepsi...@gmail.com
 wrote:
 How to unzip this file?.

 mydata -
 unzip(http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip;)
 Warning message:
 In
 unzip(http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip;)
 :
  error 1 in extracting from zip file


 __
 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


__
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] Quartiles and Inter-Quartile Range

2010-01-23 Thread Girish A.R.

Interestingly, Hmisc::describe() and summary() seem to be using one Type, and
stats::fivenum() seems to be using another Type.

 fivenum(cbiomass)
[1]  910.0 1039.0 1088.5 1156.5 1415.0
 summary(cbiomass)
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
91010481088110411391415 
 describe(cbiomass)$counts
   n  missing   unique Mean  .05  .10  .25  .50 
.75 
12  0 12   1104  920.5  938.3 1047.5 1088.5
1138.8 
 .90  .95 
1248.7 1327.0 

cheers,
-Girish
-- 
View this message in context: 
http://n4.nabble.com/Quartiles-and-Inter-Quartile-Range-tp1145817p1248728.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] Optimizing C code

2010-01-23 Thread Christophe Genolini

Duncan Murdoch a écrit :

On 22/01/2010 12:52 PM, Christophe Genolini wrote:

Thanks both of you.


  Inf - Inf
 [1] NaN
So isn't the line 9 useless ? If either x[i] or y[i] are NA, then dev 
will be NA and !ISNAN(dev) will detect it...

Sothe loop cool be

8.for(i = 0 ; i  taille ; i++) {
10.dev = (x[i] - y[i]);
11.if(!ISNAN(dev)) {
12.  dist += dev * dev;
13.  count++;
15.  }
16. }

No ?
  


That would presumably give the same answer, but there are lots of 
reasons it might not be useless:


- the author might find it clearer, or easier to generalize to integer 
data (where your version wouldn't work).

- it might be faster, because it can abort sooner.
- it might be essentially equivalent in all important respects.

Duncan Murdoch


That's 3 good reasons to keep the other code. Thanks.

Christophe
 Duncan Murdoch
 Christophe


 #define both_FINITE(a,b) (R_FINITE(a)  R_FINITE(b))
 #define both_non_NA(a,b) (!ISNAN(a)  !ISNAN(b))

 1. static double R_euclidean2(double *x, double *y, int taille)
 2. {
 3.double dev, dist;
 4.int count, i;
 5.
 6.count= 0;
 7.dist = 0;
 8.for(i = 0 ; i  taille ; i++) {
 9.if(both_non_NA(x[i], y[i])) {
 10.dev = (x[i] - y[i]);
 11.if(!ISNAN(dev)) {
 12.dist += dev * dev;
 13.count++;
 14.}
 15.}
 16.}
 17.if(count == 0)return NA_REAL;
 18.if(count != taille) dist /= ((double)count/taille);
 19.return sqrt(dist);
 20.}

 __
 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] Quartiles and Inter-Quartile Range

2010-01-23 Thread David Freedman

and SAS give one a choice of 5 option, and i'm fairly sure that it used 
a different default than does R (although one of the 5 corresponds to 
the sas default)

see pctldef on
http://www.technion.ac.il/docs/sas/proc/z0146803.htm

my simple brain thinks of thinks of the problem as 'how does one 
calculate the median of 4 values?'

david freedman

Girish A.R. [via R] wrote:
 Interestingly, Hmisc::describe() and summary() seem to be using one 
 Type, and stats::fivenum() seems to be using another Type.

  fivenum(cbiomass)
 [1]  910.0 1039.0 1088.5 1156.5 1415.0
  summary(cbiomass)
Min. 1st Qu.  MedianMean 3rd Qu.Max.
 91010481088110411391415
  describe(cbiomass)$counts
n  missing   unique Mean  .05  .10  .25 
  .50  .75
 12  0 12   1104  920.5  938.3 1047.5 
 1088.5 1138.8
  .90  .95
 1248.7 1327.0

 cheers,
 -Girish

 View message @ 
 http://n4.nabble.com/Quartiles-and-Inter-Quartile-Range-tp1145817p1248728.html
  

 To unsubscribe from Re: Quartiles and Inter-Quartile Range, click here 
  (link removed) =. 



-- 
View this message in context: 
http://n4.nabble.com/Quartiles-and-Inter-Quartile-Range-tp1145817p1264043.html
Sent from the R help mailing list archive at Nabble.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] R and Limesurvey

2010-01-23 Thread Fabrice DELENTE
Hello.

I used Limesurvey to get answers to a survey. Now I need to process the data
collected.

I exported the R syntax file describing the survey structure, the file is a 

http://fdelente.free.fr/Surveydata_syntax.R

It contains lines like

attributes(data)$variable.labels[which(names(data)==V5)]=Quel âge avez-vous 
?

that are the clear text of my question.

I'd like to be able to reference these values to display them.

I tried print(attributes(data)$variable.labels[V5] but it gives NA whereas
I'd like to get Quel âge avez-vous ?.

How does this work?

Thanks for any hint!

-- 
Fabrice DELENTE

__
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] rda.cv cross validation

2010-01-23 Thread Alexandre Serra Barreto

   Dear RÂ listmates,
   I am doing a cross validation with rda.cv to set alpha and delta parameters
   in a training set counting on 614 instances. The result of the process in R
   is:
   rda.cv(fit = z, x = Tt, y = TtL, nfold = 10)
   $nonzero
   Â Â Â Â Â  delta
   alpha  0 0.333 0.667 1 1.333 1.667 2 2.333 2.667 3
   Â   0Â Â Â Â Â 9Â Â Â Â   9Â Â Â Â   9  8Â Â Â Â  8Â Â Â Â  8 8Â Â Â Â
   7Â Â Â Â  6 4
   Â  0.11 9Â Â Â Â  9Â Â Â Â  8 8Â Â Â Â  6Â Â Â Â  3 1Â Â Â Â  1Â Â Â Â  1 0
   Â  0.22 9Â Â Â Â  8Â Â Â Â  7 6Â Â Â Â  2Â Â Â Â  1 1Â Â Â Â  0Â Â Â Â  0 0
   Â  0.33 9Â Â Â Â  8Â Â Â Â  6 2Â Â Â Â  1Â Â Â Â  1 0Â Â Â Â  0Â Â Â Â  0 0
   Â  0.44 9Â Â Â Â  8Â Â Â Â  4 2Â Â Â Â  1Â Â Â Â  0 0Â Â Â Â  0Â Â Â Â  0 0
   Â  0.55 9Â Â Â Â  6Â Â Â Â  2 1Â Â Â Â  0Â Â Â Â  0 0Â Â Â Â  0Â Â Â Â  0 0
   Â  0.66 9Â Â Â Â  6Â Â Â Â  2 1Â Â Â Â  0Â Â Â Â  0 0Â Â Â Â  0Â Â Â Â  0 0
   Â  0.77 9Â Â Â Â  6Â Â Â Â  2 1Â Â Â Â  0Â Â Â Â  0 0Â Â Â Â  0Â Â Â Â  0 0
   Â  0.88 9Â Â Â Â  5Â Â Â Â  2 0Â Â Â Â  0Â Â Â Â  0 0Â Â Â Â  0Â Â Â Â  0 0
   Â  0.99 9Â Â Â Â  4Â Â Â Â  1 0Â Â Â Â  0Â Â Â Â  0 0Â Â Â Â  0Â Â Â Â  0 0

   $cv.err
   Â Â Â Â Â  delta
   alpha   0 0.333 0.667   1 1.333 1.667   2 2.333 2.667   3
   Â  0Â Â Â Â Â  22Â Â Â  23Â Â Â  23Â  25Â Â Â  25Â Â Â  25Â  23Â Â Â Â
   25Â Â Â Â  26Â  34
   Â  0.11 24Â Â Â  24Â Â Â  25Â  28Â Â Â  31Â Â Â Â  54Â  64Â Â Â Â  72Â Â Â
   160 214
   Â  0.22 24Â Â Â  25Â Â Â  29Â  39Â Â Â  58Â Â Â Â  72 144Â Â Â  214Â Â  214
   214
   Â  0.33 24Â Â Â  27Â Â Â  36Â  56Â Â Â  72Â Â Â  160 214Â Â Â 214Â Â  214
   214
   Â  0.44 25Â Â Â  30Â Â Â  53Â  64Â Â  126Â Â Â  214 214Â Â  214Â Â  214 214
   Â  0.55 25Â Â Â  32Â Â Â  53Â  73Â Â  214Â Â Â  214 214Â Â  214Â Â  214 214
   Â  0.66 25Â Â Â  35Â Â Â  57 127Â Â  214Â Â  214 214Â Â  214Â Â  214 214
   Â  0.77 25Â Â Â  37Â Â Â  64 201Â Â  214Â Â  214 214Â Â  214Â Â  214 214
   Â  0.88 25Â Â Â  42Â Â Â  76 214Â Â  214Â Â  214 214Â Â  214Â Â  214 214
   Â  0.99 25Â Â Â  49Â Â Â  85 214Â Â  214Â Â  214 214Â Â  214Â Â  214 214
   My doubt is: What do these numbers in the second table really represent? I
   am considerind that they are the averaged number of missclassifications for
   each set. Am I right?
   Thanks,
   Alexandre.
__
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] rda.cv cross validation

2010-01-23 Thread Alexandre Serra Barreto

   Dear RÂ listmates,
   I am doing a cross validation with rda.cv to set alpha and delta parameters
   in a training set counting on 614 instances. The result of the process in R
   is:
   Â Â Â Â Â  delta
   alpha  0 0.333 0.667 1 1.333 1.667 2 2.333 2.667 3
   Â  0Â Â Â  9Â Â Â Â  9Â Â Â Â  9 8Â Â Â Â  8Â Â Â Â  8 8Â Â Â Â  7Â Â Â Â  6
   4
   Â  0.11 9Â Â Â Â  9Â Â Â Â  8 8Â Â Â Â  6Â Â Â Â  3 1Â Â Â Â  1Â Â Â Â  1 0
   Â  0.22 9Â Â Â Â  8Â Â Â Â  7 6Â Â Â Â  2Â Â Â Â  1 1Â Â Â Â  0Â Â Â Â  0 0
   Â  0.33 9Â Â Â Â  8Â Â Â Â  6 2Â Â Â Â  1Â Â Â Â  1 0Â Â Â Â  0Â Â Â Â  0 0
   Â  0.44 9Â Â Â Â  8Â Â Â Â  4 2Â Â Â Â  1Â Â Â Â  0 0Â Â Â Â  0Â Â Â Â  0 0
   Â  0.55 9Â Â Â Â  6Â Â Â Â  2 1Â Â Â Â  0Â Â Â Â  0 0Â Â Â Â  0Â Â Â Â  0 0
   Â  0.66 9Â Â Â Â  6Â Â Â Â  2 1Â Â Â Â  0Â Â Â Â  0 0Â Â Â Â  0Â Â Â Â  0 0
   Â  0.77 9Â Â Â Â  6Â Â Â Â  2 1Â Â Â Â  0Â Â Â Â  0 0Â Â Â Â  0Â Â Â Â  0 0
   Â  0.88 9Â Â Â Â  5Â Â Â Â  2 0Â Â Â Â  0Â Â Â Â  0 0Â Â Â Â   0Â Â Â Â  0 0
   Â  0.99 9Â Â Â Â  4Â Â Â Â  1 0Â Â Â Â  0Â Â Â Â  0 0Â Â Â Â  0Â Â Â Â  0 0

   $cv.err
   Â Â Â Â Â  delta
   alpha   0 0.333 0.667   1 1.333 1.667   2 2.333 2.667   3
   Â  0Â Â Â  22Â Â Â  23Â Â Â  23Â  25Â Â Â  25Â Â Â  25Â  23Â Â Â  25Â Â Â
   26Â  34
   Â  0.11 24Â Â Â  24Â Â Â  25Â  28Â Â Â  31Â Â Â  54Â  64Â Â Â  72Â Â  160
   214
   Â  0.22 24Â Â Â  25Â Â Â  29Â  39Â Â Â  58Â Â Â  72 144Â Â  214Â Â  214 214
   Â  0.33 24Â Â Â  27Â Â Â  36Â  56Â Â Â  72Â Â  160 214Â Â  214Â Â  214 214
   Â  0.44 25Â Â Â  30Â Â Â  53Â  64Â Â  126Â Â  214 214Â Â  214Â Â  214 214
   Â  0.55 25Â Â Â  32Â Â Â  53Â  73Â Â  214Â Â  214 214Â Â  214Â Â  214 214
   Â  0.66 25Â Â Â  35Â Â Â  57 127Â Â  214Â Â  214 214Â Â  214Â Â  214 214
   Â  0.77 25Â Â Â  37Â Â Â  64 201Â Â  214Â Â  214 214Â Â  214Â Â  214 214
   Â  0.88 25Â Â Â  42Â Â Â  76 214Â Â  214Â Â  214 214Â Â  214Â Â  214 214
   Â  0.99 25Â Â Â  49Â Â Â  85 214Â Â  214Â Â  214 214Â Â  214Â Â  214 214

   My doubt is: What do these numbers in the second table really represent? I
   am considerind that they are the averaged number of missclassifications for
   each set. Am I right?
   Thanks,
   Alexandre.
__
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 import export zipped files from URLs

2010-01-23 Thread Velappan Periasamy
The same link works and dowloads data while copying and pasteing  the
link in firebox address box.
the file is there and the server is active.

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

2010-01-23 Thread Peter Dalgaard

Fabrice DELENTE wrote:

Hello.

I used Limesurvey to get answers to a survey. Now I need to process the data
collected.

I exported the R syntax file describing the survey structure, the file is a 


http://fdelente.free.fr/Surveydata_syntax.R

It contains lines like

attributes(data)$variable.labels[which(names(data)==V5)]=Quel âge avez-vous 
?

that are the clear text of my question.

I'd like to be able to reference these values to display them.

I tried print(attributes(data)$variable.labels[V5] but it gives NA whereas
I'd like to get Quel âge avez-vous ?.

How does this work?


Hmm, does it help if you first  set

names(attributes(data)$variable.labels) - names(data)

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] ltext, small lattice question

2010-01-23 Thread Troels Ring
Dear friends - I have a dataset of 40 patients in two groups observed on 
three occasions. I only want to plot a line
for each patient in the two groups. I use the ltext  function to put the 
patient  number but fail to make lattice understand the numbers as 
unique since apparently it starts all over with 1:20 for each panel 
instead of respecting my desires to have 1:20 and then 21:40.

I'm on windows vista, R2.9.2
Best wishes
Troels

score -  runif(120,0,100)
pt - gl(40,3,120)
times - rep(c(0,3,6),40)
trt - gl(2,60,120)
ach - data.frame(score=score,pt=pt,times=times,trt=trt)
library(lattice)
myPanel - function(x,y,...){
panel.xyplot(x,y,...)
ltext(x-.1,y+1,paste(pt),cex=0.5) }

xyplot(score~times|trt,groups=pt,type=c(p,l),ach,
panel=myPanel)

--
Troels Ring
Department of nephrology
Aalborg Hospital
Mølleparkvej 
phone: +4599326629


Heliosvej 12
9210 Aalborg SØ
98140582
30480176

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

2010-01-23 Thread Fabrice DELENTE
 Hmm, does it help if you first  set
 
 names(attributes(data)$variable.labels) - names(data)

Yes, it does, many thanks!

I'll take some time later to work out what all these commands mean :^)

-- 
Fabrice DELENTE

__
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 import export zipped files from URLs

2010-01-23 Thread Henrique Dallazuanna
Your url is wrong. is missing .zip in the end.

See the code again.

On Sat, Jan 23, 2010 at 6:37 AM, Velappan Periasamy veepsi...@gmail.com wrote:
  cannot open: HTTP status was '404 Not Found' while running the
 following commands

 f - tempfile()
 download.file(http://nseindia.com/content/equities/scripvol/datafiles/01-01-2010-TO-23-01-2010RCOMXN.csv;,
 f)
 myData - read.csv(f)


 On 1/19/10, Henrique Dallazuanna www...@gmail.com wrote:
 Try this:

 f - tempfile()
 download.file(http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip;,
 f)
 myData - read.csv(unzip(f))

 On Tue, Jan 19, 2010 at 2:56 PM, Velappan Periasamy veepsi...@gmail.com
 wrote:
 How to unzip this file?.

 mydata -
 unzip(http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip;)
 Warning message:
 In
 unzip(http://nseindia.com/content/historical/EQUITIES/2010/JAN/cm15JAN2010bhav.csv.zip;)
 :
  error 1 in extracting from zip file


 __
 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





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

__
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] sorted reshaping?

2010-01-23 Thread ivo welch
thank you, dennis.  your example was much better than my own, too.

for everyone else's benefit who will be searching for the answers for
this problem on r-help, let me extend this a little.   the problem
arises primarily in data sets that are sparse.  in my case, the first
(ordered) firm does not have data in the first (ordered) year.

 firm - c(0,rep(1:10, each = 5))
 year - c(2004,rep(2002:2006, 10))
 resp - c(1.0,rnorm(50))
 dat.long - data.frame(firm = firm, year = year, resp = resp)
 dat.wide - reshape(dat.long, direction = 'wide', idvar = 'firm', timevar= 
 'year')
 head(dat.wide)

yields

   firm resp.2004 resp.2002 resp.2003 resp.2005 resp.2006
1 01.NANANANA
2 1   -0.4483   -0.76231.06250.4654  -0.36041
7 2   -0.1373   -0.86480.72720.1637  -0.09235
1231.08350.45440.1577   -1.6991  -1.04559
1741.13902.1633   -1.22980.9460  -0.28682
225   -0.89061.0084   -0.1948   -0.6801  -0.47192


in contrast, the library(reshape) function did yield the desired order:

 library(reshape)
Loading required package: plyr
 dat.cast - cast(dat.long, firm ~ year)
Using resp as value column.  Use the value argument to cast to
override this choice
 head(dat.cast)
  firm2002200320042005 2006
10  NA  NA  1.  NA   NA
21 -0.7623  1.0625 -0.4483  0.4654 -0.36041
32 -0.8648  0.7272 -0.1373  0.1637 -0.09235
43  0.4544  0.1577  1.0835 -1.6991 -1.04559
54  2.1633 -1.2298  1.1390  0.9460 -0.28682
65  1.0084 -0.1948 -0.8906 -0.6801 -0.47192


I think this example would make a nice addition to ?reshape.  for
see also, I would add library(reshape).  finally, it would be nice
if an email would be on each R help (in R documentation) to make
suggestions for improvements.

regards,

/iaw

Ivo Welch (ivo.we...@brown.edu, ivo.we...@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] sorted reshaping?

2010-01-23 Thread Gabor Grothendieck
This also works (giving a matrix so use as.data.frame if you want it
as a data frame):

 tapply(dat.long[,3], dat.long[1:2], c)
year
firm20022003   2004   20052006
  0   NA  NA  1.000 NA  NA
  1   0.86456075 -1.06794272  1.1850129 -0.1385206 -0.41101249
  2   0.04505626  0.24331227 -0.7902969  0.6833840  0.17823240
  3  -2.07018155  0.32203467 -1.0867019  1.1990902 -0.86256005
  4  -1.04872782 -0.90006314  1.0398810 -0.3545491 -0.93241925
  5  -1.55728162  0.98297102  1.0280005  1.6397312  0.79278075
  6   0.21446824  0.10913775  1.1284486 -0.4148321  0.95917517
  7  -1.97895845 -0.05366712  0.9740745  0.8070221  1.33701029
  8  -1.94635463 -1.03172741  1.5351331 -2.0643955  0.63561387
  9  -0.08866245  0.42450753 -0.8108118  0.5155799 -1.54716628
  10  0.11008895  0.18344337  0.3891310  0.9016668  0.04618046


On Sat, Jan 23, 2010 at 8:25 AM, ivo welch ivo...@gmail.com wrote:
 thank you, dennis.  your example was much better than my own, too.

 for everyone else's benefit who will be searching for the answers for
 this problem on r-help, let me extend this a little.   the problem
 arises primarily in data sets that are sparse.  in my case, the first
 (ordered) firm does not have data in the first (ordered) year.

 firm - c(0,rep(1:10, each = 5))
 year - c(2004,rep(2002:2006, 10))
 resp - c(1.0,rnorm(50))
 dat.long - data.frame(firm = firm, year = year, resp = resp)
 dat.wide - reshape(dat.long, direction = 'wide', idvar = 'firm', timevar= 
 'year')
 head(dat.wide)

 yields

   firm resp.2004 resp.2002 resp.2003 resp.2005 resp.2006
 1     0    1.        NA        NA        NA        NA
 2     1   -0.4483   -0.7623    1.0625    0.4654  -0.36041
 7     2   -0.1373   -0.8648    0.7272    0.1637  -0.09235
 12    3    1.0835    0.4544    0.1577   -1.6991  -1.04559
 17    4    1.1390    2.1633   -1.2298    0.9460  -0.28682
 22    5   -0.8906    1.0084   -0.1948   -0.6801  -0.47192


 in contrast, the library(reshape) function did yield the desired order:

 library(reshape)
 Loading required package: plyr
 dat.cast - cast(dat.long, firm ~ year)
 Using resp as value column.  Use the value argument to cast to
 override this choice
 head(dat.cast)
  firm    2002    2003    2004    2005     2006
 1    0      NA      NA  1.      NA       NA
 2    1 -0.7623  1.0625 -0.4483  0.4654 -0.36041
 3    2 -0.8648  0.7272 -0.1373  0.1637 -0.09235
 4    3  0.4544  0.1577  1.0835 -1.6991 -1.04559
 5    4  2.1633 -1.2298  1.1390  0.9460 -0.28682
 6    5  1.0084 -0.1948 -0.8906 -0.6801 -0.47192


 I think this example would make a nice addition to ?reshape.  for
 see also, I would add library(reshape).  finally, it would be nice
 if an email would be on each R help (in R documentation) to make
 suggestions for improvements.

 regards,

 /iaw
 
 Ivo Welch (ivo.we...@brown.edu, ivo.we...@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-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] MAC R crashes

2010-01-23 Thread David Winsemius
The typical reason for a crash on startup is a corrupted (or version  
mismatched) .RData file.


http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#R_002eapp-GUI-crashes-on-startup_0021

--
David.


On Jan 22, 2010, at 6:32 PM, Peter Rossi wrote:


Dear R-Help Group:

R will not start on my imac running 10.6.2.  I installed both  
R2.10.1 and
2.10.0 from pkg. It crashed on both. I tried both the R and R64 apps  
and

both versions 2.10.1 and 2.10.0.  I googled and found nothing on this.

Below is part of report:

Process: R [767]
Path:/Applications/R64.app/Contents/MacOS/R
Identifier:  org.R-project.R
Version: R 2.10.0 GUI 1.30 Leopard build 64-bit (5511)
Code Type:   X86-64 (Native)
Parent Process:  launchd [182]

Date/Time:   2010-01-22 15:22:28.306 -0800
OS Version:  Mac OS X 10.6.2 (10C2234)
Report Version:  6

Interval Since Last Report:  868605 sec
Crashes Since Last Report:   12
Per-App Crashes Since Last Report:   1
Anonymous UUID:   
2711C8BB-9B34-4F6D-98AF-8753700C7B8F


Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x, 0x
Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Application Specific Information:
abort() called
*** Terminating app due to uncaught exception  
'NSInvalidArgumentException',
reason: '-[NSApplication _setup:]: unrecognized selector sent to  
instance

0x1006088b0'


If I delete my Rprofile, R will sometimes run but hangs and goes
non-responsive when I type only one letter of a command.

cat .Rprofile
# Example of .Rprofile
.First - function() {
   library(bayesm)
 library(tcltk)
   cat( tcltk,bayesm loaded \n\n)
   }
  source(my_R_functions.R)
 cat( custom functions loaded \n)
.Last - function()  cat(\n   Goodbye!\n\n)


I have fully updated by mac os.

Any help would be most appreciated.

Peter Rossi

__
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
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] simulation of binary data

2010-01-23 Thread Juliet Hannah
Check out the help page of the lrm function in the rms library. To
show how lrm is used,
the examples simulate data for logistic regression. This may give you
some ideas.

On Wed, Jan 20, 2010 at 10:41 AM, omar kairan omarkaira...@gmail.com wrote:
 Hi,

 could someone help me with dilemma on the simulation of logistic
 regressiondata with multicollinearity effect and high leverage point..

 Thank you

        [[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] Rotating the axis labels in the basic graphic device ?

2010-01-23 Thread Uwe Ligges



On 22.01.2010 21:26, Tal Galili wrote:

Hello dear R help group,


I learned recently that one can change the rotation of labels in the axis,
when using a lattice plot, for example:

library(lattice)
barchart(yield ~ variety , data = barley,
  groups = year,
  ylab = Barley Yield (bushels/acre),
  scales = list(rot = 45))

My question is: Is there an application of rot in something like barplot ?
The only solution I know of is using las = X (X is 1,2, or 3)
Is there another solution/hack for this ?


No, by design there is just the las way ...

Uwe Ligges




Thanks!

Tal







Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com/ (English)
--

[[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] Rotating the axis labels in the basic graphic device ?

2010-01-23 Thread Tal Galili
Uwe and Marc,
You two just made me smile in more then one way - thank you :)

Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com/ (English)
--




On Sat, Jan 23, 2010 at 6:07 PM, Marc Schwartz marc_schwa...@me.com wrote:


 On Jan 23, 2010, at 9:59 AM, Uwe Ligges wrote:

 
 
  On 23.01.2010 16:56, Marc Schwartz wrote:
  On Jan 23, 2010, at 9:51 AM, Uwe Ligges wrote:
 
 
 
  On 22.01.2010 21:26, Tal Galili wrote:
  Hello dear R help group,
 
 
  I learned recently that one can change the rotation of labels in the
 axis,
  when using a lattice plot, for example:
 
  library(lattice)
  barchart(yield ~ variety , data = barley,
   groups = year,
   ylab = Barley Yield (bushels/acre),
   scales = list(rot = 45))
 
  My question is: Is there an application of rot in something like
 barplot ?
  The only solution I know of is using las = X (X is 1,2, or 3)
  Is there another solution/hack for this ?
 
  No, by design there is just the las way ...
 
  Uwe Ligges
 
 
  Actually, there is a method and it is in the R FAQs:
 
 
 http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f
 
 
  Yes you are right, Marc, thank you!
  I would not call this as by design and it sometimes need quite a lot
 fiddling if font sizes change.
 
  Best,
  Uwe


 Quite right Uwe, it is not by design, but is consistent with:

  library(fortunes)
  fortune(yoda)

 ;-)

 As you note, it took some understanding and tweaking of base graphics
 parameters and such to get that method to work.

 Cheers,

 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.


[R] matrix to a C function

2010-01-23 Thread Christophe Genolini

Hi the list,
Is there a way to give a matrix to a C function, and then to use it as a 
matrix ?

I write a function to print a matrix, but I use it as a vector :

1. void printMatrix(double *mTraj,int *nbCol, int *nbLigne){
2. int i=0,j=0;
3. for(i=0 ;  i  *nbLigne ; i++){
4. for(j=0 ; j  *nbCol ; j++){
5. Rprintf( %f,mTraj[i * *nbCol + j]);
6. }
7. Rprintf(\n);
8.}
9. }

I would like to use it as a matrix (line 5 changes) :

1. void printMatrix(double *mTraj,int *nbCol, int *nbLigne){
2. int i=0,j=0;
3. for(i=0 ;  i  *nbLigne ; i++){
4. for(j=0 ; j  *nbCol ; j++){
5. Rprintf( %f,mTraj[i,j]);
6. }
7. Rprintf(\n);
8.}
9. }

It does not work, but is there an solution close to this ?

Thanks.
Christophe

__
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] Rotating the axis labels in the basic graphic device ?

2010-01-23 Thread Marc Schwartz
On Jan 23, 2010, at 10:25 AM, Tal Galili wrote:

 Marc,
 Following the R FAQ you linked to, I wonder how to ALWAYS have the text and 
 the plot region fit.
 I know that if the text is too long, one can use the par(mar = c(big.number, 
 4, 4 ,4)) and get the text to fit.
 The question is:
 Is there a way to make the plot know what big.number should be so the 
 text wouldn't go beyond plot regions ?
 
 (I suspect my question might get lost inside this topic, if so - I'll repeat 
 it with a different header)
 
 Thanks again,
 Tal
 

snip


Tal,

I suspect that you would to create an algorithm using functions such as 
strwidth() and strheight() to get the plot metrics for the sizes of the 
character labels to have a sense of how much room would be required given other 
parameters.

I am guessing that if you were to look at the appropriate source code in the 
lattice package, something along these lines is implemented there, since 
lattice supports rotated labels 'out of the box' and would logically have to 
consider these plotting characteristics at some level.

Otherwise, it is a manual tweaking process.

HTH,

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] About LU decomposition in R

2010-01-23 Thread Walmes Zeviani

Read the Matrix package documentation

require(Matrix)
help(lu, html=TRUE)

Walmes.

-
..oooO
..
..()... 0ooo...  Walmes Zeviani
...\..(.(.)... Master in Statistics and Agricultural
Experimentation
\_). )../   walmeszevi...@hotmail.com, Lavras - MG, Brasil

(_/
-- 
View this message in context: 
http://n4.nabble.com/About-LU-decomposition-in-R-tp1229137p1288264.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] Error: could not find function

2010-01-23 Thread Remus Suciu
Hi.
I'm trying to create an Agresti-Coull confidence interval without using the
binom package.
Despite many trials, I keep getting the same problem- see below.
 y=334
 n=1160
 alpha=.05
 b=(y+.5*qnorm(1-alpha/2)**2)/(n+qnorm(1-alpha/2)**2)
 b
[1] 0.288631
 ac=b+qnorm(1-alpha/2)*sqrt(b(1-b)/(n+qnorm(1-alpha/2)**2))
Error: could not find function b

What am I missing? What am I doing wrong?

Thank you,
Remus

[[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] Rotating the axis labels in the basic graphic device ?

2010-01-23 Thread Uwe Ligges



On 23.01.2010 17:42, Marc Schwartz wrote:

On Jan 23, 2010, at 10:25 AM, Tal Galili wrote:


Marc,
Following the R FAQ you linked to, I wonder how to ALWAYS have the text and the 
plot region fit.
I know that if the text is too long, one can use the par(mar = c(big.number, 4, 
4 ,4)) and get the text to fit.
The question is:
Is there a way to make the plot know what big.number should be so the text 
wouldn't go beyond plot regions ?

(I suspect my question might get lost inside this topic, if so - I'll repeat it 
with a different header)

Thanks again,
Tal



snip


Tal,

I suspect that you would to create an algorithm using functions such as 
strwidth() and strheight() to get the plot metrics for the sizes of the 
character labels to have a sense of how much room would be required given other 
parameters.

I am guessing that if you were to look at the appropriate source code in the 
lattice package, something along these lines is implemented there, since 
lattice supports rotated labels 'out of the box' and would logically have to 
consider these plotting characteristics at some level.


Well, lattice relies on grid and grid can place arbitrary viewports with 
arbitrary rotations everywhere by design.




Otherwise, it is a manual tweaking process.


Indeed, that's the thing I meant with not by design.  ;-)

Best wishes,
Uwe





HTH,

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] Rotating the axis labels in the basic graphic device ?

2010-01-23 Thread Tal Galili
Marc,
Following the R FAQ you linked to, I wonder how to ALWAYS have the text and
the plot region fit.
I know that if the text is too long, one can use the par(mar = c(big.number,
4, 4 ,4)) and get the text to fit.
The question is:
Is there a way to make the plot know what big.number should be so the
text wouldn't go beyond plot regions ?

(I suspect my question might get lost inside this topic, if so - I'll repeat
it with a different header)

Thanks again,
Tal





Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com/ (English)
--




On Sat, Jan 23, 2010 at 5:56 PM, Marc Schwartz marc_schwa...@me.com wrote:

 On Jan 23, 2010, at 9:51 AM, Uwe Ligges wrote:

 
 
  On 22.01.2010 21:26, Tal Galili wrote:
  Hello dear R help group,
 
 
  I learned recently that one can change the rotation of labels in the
 axis,
  when using a lattice plot, for example:
 
  library(lattice)
  barchart(yield ~ variety , data = barley,
   groups = year,
   ylab = Barley Yield (bushels/acre),
   scales = list(rot = 45))
 
  My question is: Is there an application of rot in something like
 barplot ?
  The only solution I know of is using las = X (X is 1,2, or 3)
  Is there another solution/hack for this ?
 
  No, by design there is just the las way ...
 
  Uwe Ligges


 Actually, there is a method and it is in the R FAQs:


 http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f

 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] Rotating the axis labels in the basic graphic device ?

2010-01-23 Thread Marc Schwartz
On Jan 23, 2010, at 9:51 AM, Uwe Ligges wrote:

 
 
 On 22.01.2010 21:26, Tal Galili wrote:
 Hello dear R help group,
 
 
 I learned recently that one can change the rotation of labels in the axis,
 when using a lattice plot, for example:
 
 library(lattice)
 barchart(yield ~ variety , data = barley,
  groups = year,
  ylab = Barley Yield (bushels/acre),
  scales = list(rot = 45))
 
 My question is: Is there an application of rot in something like barplot ?
 The only solution I know of is using las = X (X is 1,2, or 3)
 Is there another solution/hack for this ?
 
 No, by design there is just the las way ...
 
 Uwe Ligges


Actually, there is a method and it is in the R FAQs:

  
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f

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] Rotating the axis labels in the basic graphic device ?

2010-01-23 Thread Uwe Ligges



On 23.01.2010 16:56, Marc Schwartz wrote:

On Jan 23, 2010, at 9:51 AM, Uwe Ligges wrote:




On 22.01.2010 21:26, Tal Galili wrote:

Hello dear R help group,


I learned recently that one can change the rotation of labels in the axis,
when using a lattice plot, for example:

library(lattice)
barchart(yield ~ variety , data = barley,
  groups = year,
  ylab = Barley Yield (bushels/acre),
  scales = list(rot = 45))

My question is: Is there an application of rot in something like barplot ?
The only solution I know of is using las = X (X is 1,2, or 3)
Is there another solution/hack for this ?


No, by design there is just the las way ...

Uwe Ligges



Actually, there is a method and it is in the R FAQs:

   
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f



Yes you are right, Marc, thank you!
I would not call this as by design and it sometimes need quite a lot 
fiddling if font sizes change.


Best,
Uwe



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] Help on tcl/tk package installation

2010-01-23 Thread Uwe Ligges



On 23.01.2010 01:35, 李道丰 wrote:

Hi,

how to compile with tcl/tk support ? command line options?
thank you:)


There is a manual called R Installation and Administration you are 
obviously not aware of (probably because you never read the posting 
guide of the mailing list). That manual contains a section (cuurently 
Appendix A.2.1) Tcl/Tk ...


Best wishes,
Uwe Ligges






2010/1/22 Uwe Liggeslig...@statistik.tu-dortmund.de


You need to reinstall R and compile with tcl/tk support (best is to use
R-2.10.1 nowadays since yours is already outdated).

Best,
Uwe Ligges




On 22.01.2010 08:13, 李道丰 wrote:


Hi, Dear all,

i encounted a problem with tcl/tk installation
actually i want to install q-value package
i use the R CMD INSTALL command:
[r...@bioinfo ~]# R CMD INSTALL qvalue_1.20.0.tar.gz
* Installing to library �usr/local/lib64/R/library�
* Installing *source* package ‘qvalue�...

** R
** data
** inst
** preparing package for lazy loading
Error in firstlib(which.lib.loc, package) :
   Tcl/Tk support is not available on this system
Error : package 'tcltk' could not be loaded
ERROR: lazy loading failed for package ‘qvalue�
* Removing �usr/local/lib64/R/library/qvalue�

i do some search work with google, suggest i need to install tcl and tk at
system level
i download the source tcl and tk from sourceforge and installed them:
[r...@bioinfo ~]# tclsh
% info patchlevel
8.4.13
%
i uninstall R package with make uninstall and make distclean,then
reinstall
R
but the problem stills occurs
i am using Redhat enterprise linux 5 x64 version
packages metioned above are listed follow:
R-2.9.2.tar.gz
tcl8.5.8-src.tar.gz
tk8.5.8-src.tar.gz
qvalue_1.20.0.tar.gz

any commments would be very appeciated:)
thank you in advance:)





__
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.htmlhttp://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] Error: could not find function

2010-01-23 Thread Uwe Ligges



On 23.01.2010 17:50, Remus Suciu wrote:

Hi.
I'm trying to create an Agresti-Coull confidence interval without using the
binom package.
Despite many trials, I keep getting the same problem- see below.

y=334
n=1160
alpha=.05
b=(y+.5*qnorm(1-alpha/2)**2)/(n+qnorm(1-alpha/2)**2)
b

[1] 0.288631

ac=b+qnorm(1-alpha/2)*sqrt(b(1-b)/(n+qnorm(1-alpha/2)**2))

Error: could not find function b

What am I missing?


The * between b and (1-b), I guess.

Uwe Ligges


What am I doing wrong?

Thank you,
Remus

[[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] Rotating the axis labels in the basic graphic device ?

2010-01-23 Thread Marc Schwartz

On Jan 23, 2010, at 9:59 AM, Uwe Ligges wrote:

 
 
 On 23.01.2010 16:56, Marc Schwartz wrote:
 On Jan 23, 2010, at 9:51 AM, Uwe Ligges wrote:
 
 
 
 On 22.01.2010 21:26, Tal Galili wrote:
 Hello dear R help group,
 
 
 I learned recently that one can change the rotation of labels in the axis,
 when using a lattice plot, for example:
 
 library(lattice)
 barchart(yield ~ variety , data = barley,
  groups = year,
  ylab = Barley Yield (bushels/acre),
  scales = list(rot = 45))
 
 My question is: Is there an application of rot in something like barplot 
 ?
 The only solution I know of is using las = X (X is 1,2, or 3)
 Is there another solution/hack for this ?
 
 No, by design there is just the las way ...
 
 Uwe Ligges
 
 
 Actually, there is a method and it is in the R FAQs:
 
   
 http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f
 
 
 Yes you are right, Marc, thank you!
 I would not call this as by design and it sometimes need quite a lot 
 fiddling if font sizes change.
 
 Best,
 Uwe


Quite right Uwe, it is not by design, but is consistent with:

  library(fortunes)
  fortune(yoda)

;-)

As you note, it took some understanding and tweaking of base graphics 
parameters and such to get that method to work.

Cheers,

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] lm on group

2010-01-23 Thread Adaikalavan Ramasamy
You can guess by looking at class(g). It is a factor. It is NOT 
regressing on the mean of g (i.e. 2.5 and 7.5) and you could have 
changed g from (0,5] and (5,10] to A and B with the same results.


Read some books or help(lm) to get an idea of what the outputs mean.

Regards, Adai



newbieR wrote:

Hi all,

  I have a quick question about lm on group, say I have:


x - 1:10
y - x*3
buckets - seq(0, 10, by=5)
g - cut(x, buckets)
summary(lm(y ~ g - 1))

  Coefficients:
  Estimate Std. Error t value Pr(|t|)
g(0,5]   9.000  2.121   4.243  0.00283 ** 
g(5,10]   24.000  2.121  11.314 3.35e-06 ***


 What is it doing exactly? I guess the estimate is the mean of the y's
in each group. 


 How about other stats.. what do they exactly mean when we do lm on
groups? 



Thanks a lot!


__
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] fatal error unable to restore saved data in .rdata

2010-01-23 Thread Badaoui, Saad
Dear R help team,

I am trying to open R to continue my analysis but it doesn't want to open and I 
get this message fatal error unable to restore saved data in .rdata. I don't 
know what went wrong ( iam using Windows). Could you please help me on this? 
Thanks a lot

Best Regards


Saad

[[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] Failure to produce italics in jpeg

2010-01-23 Thread Dennis Fisher

Colleagues,

Using R 2.10.1 in OS X (Snow Leopard), I created JPEG documents that  
were intended to include italicized text.  In the JPEG versions, the  
italics appear in bold-face.  The identical code (except for the call  
to the device) yields italics in PDF.  A minimal example is:


PDF version:

pdf(plot.pdf)
plot(1,1)
mtext(bquote(italic(P)  .(0.005)))
dev.off()


JPEG version:

jpeg(file=plot.jpeg, pointsize=12, bg=white, res=150, quality=100)
plot(1,1)
mtext(bquote(italic(P)  .(0.005)))
dev.off()


I can't find any info in the help pages for either jpeg or bquote that  
explain this.


Any ideas?

Dennis

Dennis Fisher MD
P  (The P Less Than Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.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] fatal error unable to restore saved data in .rdata

2010-01-23 Thread Duncan Murdoch

On 23/01/2010 10:56 AM, Badaoui, Saad wrote:

Dear R help team,

I am trying to open R to continue my analysis but it doesn't want to open and I get this 
message fatal error unable to restore saved data in .rdata. I don't know what 
went wrong ( iam using Windows). Could you please help me on this? Thanks a lot


Rename the .rdata file to something else, and R won't try to open it. 
It looks as though somehow it has been corrupted.


If it was the only place you stored your intermediate results, you're 
going to have to start over.  But next time, don't do that.


Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] first and second derivative calculation

2010-01-23 Thread Adaikalavan Ramasamy

How about?

 eval( D( expression( t^3-6*t^2+5*t+30 ), t ) )



David Winsemius wrote:

On Jan 22, 2010, at 6:49 PM, Marlin Keith Cox wrote:


I can plot this just fine:
t-seq(0,4, by=.1)
y- t^3-6*t^2+5*t+30
plot(t,y ,xlab=t-values, ylab=f(t), type=l)
This is the first derivative, how I I make a similar plot?
t-seq(0,4, by=.1)
y- t^3-6*t^2+5*t+30
y1-D(expression(t^3-6*t^2+5*t+30), 't')


There might be some sort of deparse() operation that one could do on  
y1, but what follows sidesteps that level of programming.



y1fn - function(t) {3 * t^2 - 6 * (2 * t) + 5}
par(new=TRUE)
plot(t, y1fn(t), ylab=, xlab=, axes=FALSE)
  axis(side=4, at=seq(-7,5,by=1) )


--

David.


Thanks ahead of time.

kc


On Fri, Jan 22, 2010 at 12:41 PM, Doran, Harold hdo...@air.org  
wrote:



D(expression(t^3-6*t^2+5*t + 30), 't')

3 * t^2 - 6 * (2 * t) + 5


D(D(expression(t^3-6*t^2+5*t + 30), 't'), 't')

3 * (2 * t) - 6 * 2

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org 
]

On Behalf Of Marlin Keith Cox
Sent: Friday, January 22, 2010 4:37 PM
To: r-help@r-project.org
Subject: [R] first and second derivative calculation

I would like to calculate a first and second derivative and am having
problems finding a simple solution.  My syntax may be off as I am  
not a

mathematician, so pardon ahead of time.
data:
t-seq(0,4, by=.1)
The function is:
H(t) = t^3-6*t^2+5*t + 30

from here I plot the curve:
plot(x,y ,xlab=x-values, ylab=f(x), type=l)
But would like to similarly plot the curve for both the first and  
second

derivatives.
I can calculate the derivatives by hand but would like to get R to  
do this

for me.
by hand:
H'(t) = 3*t^2 - 12*t + 5
H''(t) = 6*t-12
Keith

--
M. Keith Cox, Ph.D.
Alaska NOAA Fisheries, National Marine Fisheries Service
Auke Bay Laboratories
17109 Pt. Lena Loop Rd.
Juneau, AK 99801
keith@noaa.gov
marlink...@gmail.com
U.S. (907) 789-6603

  [[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.htmlhttp://www.r-project.org/posting-guide.html 
and provide commented, minimal, self-contained, reproducible code.





--
M. Keith Cox, Ph.D.
Alaska NOAA Fisheries, National Marine Fisheries Service
Auke Bay Laboratories
17109 Pt. Lena Loop Rd.
Juneau, AK 99801
keith@noaa.gov
marlink...@gmail.com
U.S. (907) 789-6603

[[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
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-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] fatal error unable to restore saved data in .rdata

2010-01-23 Thread Patrick Burns

And once you've renamed the file and started R,
it might be worth a try to see if you can 'attach'
the file.

On 23/01/2010 17:22, Duncan Murdoch wrote:

On 23/01/2010 10:56 AM, Badaoui, Saad wrote:

Dear R help team,

I am trying to open R to continue my analysis but it doesn't want to
open and I get this message fatal error unable to restore saved data
in .rdata. I don't know what went wrong ( iam using Windows). Could
you please help me on this? Thanks a lot


Rename the .rdata file to something else, and R won't try to open it. It
looks as though somehow it has been corrupted.

If it was the only place you stored your intermediate results, you're
going to have to start over. But next time, don't do that.

Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
Patrick Burns
pbu...@pburns.seanet.com
http://www.burns-stat.com
(home of 'The R Inferno' and 'A Guide for the Unwilling S User')

__
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 to a C function

2010-01-23 Thread Romain Francois

Christophe,

That's another question for the R-devel mailing list.

A few things however.

Short answer : no it is not possible. I don't think x[i,j] is even 
syntactically valid in C or C++.


I'd suggest you to give a go at the .Call interface that lets you 
manipulate R objects directly. So in your example with the .Call 
interface you'd only have to pass one argument and figure out the matrix 
dimensions internally with the C api of R. Something like this perhaps:


SEXP pr( SEXP x ){
/* extract the dim attribute */
SEXP dim = getAttrib( x, R_DimSymbol ) ;
int nrow = INTEGER(dim)[0];
int ncol = INTEGER(dim)[1];

/* extracting the pointer just once */
double * p = REAL(x) ;

int i,j;
for( i=0; inrow; i++){
for( j=0; jncol; j++){
Rprintf(  %f , p[i+nrow*j] ) ;
}
Rprintf( \\n ) ;
};
return R_NilValue ; /* NULL */
}


You can use the regular print function (called PrintValue internally), 
which will nicely take care of aligning the columns properly, etc ...


SEXP pr( SEXP x ){
PrintValue( x ) ;
return( R_NilValue ) ;
}

Finally, you can use C++ through the Rcpp package and write something 
like this :


SEXP pr( SEXP x){
RcppMatrixViewdouble m(x) ;
int i,j;
int nrow = m.rows() ;
int ncol = m.cols() ;
for( i=0; inrow; i++){
for( j=0; jncol; j++){
Rprintf(  %f, m(i,j) ) ;
}
Rprintf( \\n ) ;
}
return R_NilValue ;
}

The indexing here is done with the round brackets here because it is 
just not valid to have more than one parameters passed to operator[] in 
C or C++.


Romain

On 01/23/2010 05:04 PM, Christophe Genolini wrote:


Hi the list,
Is there a way to give a matrix to a C function, and then to use it as a
matrix ?
I write a function to print a matrix, but I use it as a vector :

1. void printMatrix(double *mTraj,int *nbCol, int *nbLigne){
2. int i=0,j=0;
3. for(i=0 ; i  *nbLigne ; i++){
4. for(j=0 ; j  *nbCol ; j++){
5. Rprintf( %f,mTraj[i * *nbCol + j]);
6. }
7. Rprintf(\n);
8. }
9. }

I would like to use it as a matrix (line 5 changes) :

1. void printMatrix(double *mTraj,int *nbCol, int *nbLigne){
2. int i=0,j=0;
3. for(i=0 ; i  *nbLigne ; i++){
4. for(j=0 ; j  *nbCol ; j++){
5. Rprintf( %f,mTraj[i,j]);
6. }
7. Rprintf(\n);
8. }
9. }

It does not work, but is there an solution close to this ?

Thanks.
Christophe



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/KfKn : Rcpp 0.7.2
|- http://tr.im/JOlc : External pointers with Rcpp
`- http://tr.im/JFqa : R Journal, Volume 1/2, December 2009

__
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] ff package: ff objects don't reload completely on NFS drives from a different machine

2010-01-23 Thread Hao Cen
Hi ff users and Jens,

I am using the ff package and it has been working great. Recently I
noticed an unexpected behavior in the ff package --  when I save an ff
matrix on one machine to an NFS drive and load it on another machine from
the save NFS drive,  I got quote a lot of zeros in the matrix. The
following code reproduces the error

mat = matrix(1:25, 5)
matFF = ff(mat, dim=dim(mat),  dimnames = dimnames(mat),
dimorder = c(2,1),
filename=  ~/m.ff, overwrite=TRUE)
save(matFF, file = ~/mat.ff.rda)
load(file = ~/mat.ff.rda)
open(matFF)
matFF

If I execute all the six lines at one machine. Everything works fine.
However, when I only execute the last three line at another machine, I got

 matFF
ff (open) integer length=25 (25) dim=c(5,5) dimorder=c(2,1)
 [,1] [,2] [,3] [,4] [,5]
[1,]00000
[2,]00000
[3,]00000
[4,]00000
[5,]00000

If the matrix is larger, say mat = matrix(1:2, 5), I would get the
following -- dozens of zeros at the end.
 ff (open) integer length=2 (2) dim=c(5,4000) dimorder=c(2,1)
  [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]   [,3993] [,3994]
[,3995] [,3996] [,3997] [,3998] [,3999] [,4000]
[1,] 1 6111621263136 :   19961   19966  
19971   19976   19981   19986   19991   19996
[2,] 2 7121722273237 :   19962   19967  
19972   19977   19982   19987   19992   19997
[3,] 3 8131823283338 :   19963   19968  
19973   19978   19983   19988   19993   19998
[4,] 4 9141924293439 :   19964   19969  
19974   19979   19984   19989   19994   1
[5,] 510152025303540 :   0   0
  0   0   0   0   0   0

I tried set caching =  mmeachflush in the ff function but it doesn't
help.  My computing enrionment is linux 64 bit, R 2.10, ff 2.1.

If you know what causes the issue or how to solve it, please let me know.
I highly appreciate.

Jeff

__
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 apply a function on each column of a matrix

2010-01-23 Thread anna

Hello everyone, I get for each date a measure for n elements in the form of a
matrix. I am converting it to a ts object using ts(). I want to apply a
function on each column. I started using the apply function ( set to 2) but
what it returns is a matrix with the same columns representing the function
applied on the last column of the initial matrix. I have been trying to use
the sapply function or an apply in an apply but didn't get it to work the
way I wanted. Have anyone any idea about it?

-- 
View this message in context: 
http://n4.nabble.com/How-to-apply-a-function-on-each-column-of-a-matrix-tp1288436p1288436.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] How to implement a select distinct x, count(distinct y) ... group by x for a data frame

2010-01-23 Thread Dimitri Shvorob

... Being an R newbie, I can only think of extracting distinct x values with
unique, looping over them, extracting matching rows from the original data
frame, applying table, and recording the size of table's output alongside
the x value being checked. Is there a more elegant way? 

Thank you.
-- 
View this message in context: 
http://n4.nabble.com/How-to-implement-a-select-distinct-x-count-distinct-y-group-by-x-for-a-data-frame-tp1288418p1288418.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] lattice ltext

2010-01-23 Thread Troels Ring

Dear friends - please give me a hand.
I have a dataset of 40 patients in two groups observed on three 
occasions. I only want to plot a line
for each patient in the two groups. I use the ltext  function to put the 
patient  number but fail to make lattice understand the numbers as 
unique since apparently it starts all over with 1:20 for each panel 
instead of respecting my desires to have 1:20 and then 21:40.

I'm on windows vista, R2.9.2
Best wishes
Troels

score -  runif(120,0,100)
pt - gl(40,3,120)
times - rep(c(0,3,6),40)
trt - gl(2,60,120)
ach - data.frame(score=score,pt=pt,times=times,trt=trt)

myPanel - function(x,y,...){
panel.xyplot(x,y,...)
ltext(x-.1,y+1,paste(pt),cex=0.5) }

xyplot(score~times|trt,groups=pt,type=c(p,l),ach,
panel=myPanel)

--
Troels Ring
Department of nephrology
Aalborg Hospital
Mølleparkvej 
phone: +4599326629


Heliosvej 12
9210 Aalborg SØ
98140582
30480176

__
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 apply a function on each column of a matrix

2010-01-23 Thread anna

Here is the last code that I wrote but it would give me the same problem:
I have the matrix mat with n columns mat.1, mat.2 ...mat.n

#To be able to use lapply I convert it to a data.frame: 
mat - data.frame(mat)

lapply(mat, function, argument of function)

It works but I still get for all elements the function applied for the last
element. The elements of my results are all the same I don't understand I
did exactly as shown on this website: 
http://www.ats.ucla.edu/stat/r/library/advanced_function_r.htm#lapply
-- 
View this message in context: 
http://n4.nabble.com/How-to-apply-a-function-on-each-column-of-a-matrix-tp1288436p1288471.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] Rotating the axis labels in the basic graphic device ?

2010-01-23 Thread Jim Lemon

On 01/24/2010 03:25 AM, Tal Galili wrote:

Marc,
Following the R FAQ you linked to, I wonder how to ALWAYS have the text and
the plot region fit.
I know that if the text is too long, one can use the par(mar = c(big.number,
4, 4 ,4)) and get the text to fit.
The question is:
Is there a way to make the plot know what big.number should be so the
text wouldn't go beyond plot regions ?



Hi Tal,
I've been working on this, as it often appears on the help list. The 
function getMarginWidth in the plotrix package tries to solve the common 
problem of fitting text or legends in the margins of the plot. I would 
like to improve this function and perhaps extend it so that the user can 
specify an area in which something must fit and get the appropriate 
par argument to use. All suggestions are welcome.


Jim

__
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 implement a select distinct x, count(distinct y) ... group by x for a data frame

2010-01-23 Thread jim holtman
Yes.

?sqldf
?split
?lapply

But unless you provide commented, minimal, self-contained,
reproducible code, it is hard to say how to proceed to a solution.

On Sat, Jan 23, 2010 at 5:46 PM, Dimitri Shvorob
dimitri.shvo...@gmail.com wrote:

 ... Being an R newbie, I can only think of extracting distinct x values with
 unique, looping over them, extracting matching rows from the original data
 frame, applying table, and recording the size of table's output alongside
 the x value being checked. Is there a more elegant way?

 Thank you.
 --
 View this message in context: 
 http://n4.nabble.com/How-to-implement-a-select-distinct-x-count-distinct-y-group-by-x-for-a-data-frame-tp1288418p1288418.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.




-- 
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] How to apply a function on each column of a matrix

2010-01-23 Thread Jim Lemon

On 01/24/2010 11:11 AM, anna wrote:


Here is the last code that I wrote but it would give me the same problem:
I have the matrix mat with n columns mat.1, mat.2 ...mat.n

#To be able to use lapply I convert it to a data.frame:
mat- data.frame(mat)

lapply(mat, function, argument of function)

It works but I still get for all elements the function applied for the last
element. The elements of my results are all the same I don't understand I
did exactly as shown on this website:
http://www.ats.ucla.edu/stat/r/library/advanced_function_r.htm#lapply

Hi anna,
If you could post your matrix mat (or something else that produces the 
problem you describe if mat is private or too big) and the commands 
you used, someone will probably figure out what is going wrong.


Jim

__
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] ff package: ff objects don't reload completely on NFS drives from a different machine

2010-01-23 Thread Henrik Bengtsson
Hi,

this could be due to how NFS works.  Note that there can be up to a 30
second delay before other hosts on the same file system see the
updates that was flushed by one machine.  You basically cannot treat
files on an shared NFS file system as if you are working on a single
machine.  You have to add some higher protection if your data sources
should be shared ...and that is not an easy problem if you want it to
be bullet proof.  You need to use a semaphore/mutex or other ways to
communicate when files are updated/flushed/read etc.  I'm still
looking for a such a mechanism done over a file system that is bullet
proof (without having to relying on a central server).

My $.02

/Henrik

On Sat, Jan 23, 2010 at 12:02 PM, Hao Cen h...@andrew.cmu.edu wrote:
 Hi ff users and Jens,

 I am using the ff package and it has been working great. Recently I
 noticed an unexpected behavior in the ff package --  when I save an ff
 matrix on one machine to an NFS drive and load it on another machine from
 the save NFS drive,  I got quote a lot of zeros in the matrix. The
 following code reproduces the error

 mat = matrix(1:25, 5)
 matFF = ff(mat, dim=dim(mat),  dimnames = dimnames(mat),
                dimorder = c(2,1),
                filename=  ~/m.ff, overwrite=TRUE)
 save(matFF, file = ~/mat.ff.rda)
 load(file = ~/mat.ff.rda)
 open(matFF)
 matFF

 If I execute all the six lines at one machine. Everything works fine.
 However, when I only execute the last three line at another machine, I got

 matFF
 ff (open) integer length=25 (25) dim=c(5,5) dimorder=c(2,1)
     [,1] [,2] [,3] [,4] [,5]
 [1,]    0    0    0    0    0
 [2,]    0    0    0    0    0
 [3,]    0    0    0    0    0
 [4,]    0    0    0    0    0
 [5,]    0    0    0    0    0

 If the matrix is larger, say mat = matrix(1:2, 5), I would get the
 following -- dozens of zeros at the end.
  ff (open) integer length=2 (2) dim=c(5,4000) dimorder=c(2,1)
      [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]   [,3993] [,3994]
 [,3995] [,3996] [,3997] [,3998] [,3999] [,4000]
 [1,]     1     6    11    16    21    26    31    36 :   19961   19966
 19971   19976   19981   19986   19991   19996
 [2,]     2     7    12    17    22    27    32    37 :   19962   19967
 19972   19977   19982   19987   19992   19997
 [3,]     3     8    13    18    23    28    33    38 :   19963   19968
 19973   19978   19983   19988   19993   19998
 [4,]     4     9    14    19    24    29    34    39 :   19964   19969
 19974   19979   19984   19989   19994   1
 [5,]     5    10    15    20    25    30    35    40 :       0       0
  0       0       0       0       0       0

 I tried set caching =  mmeachflush in the ff function but it doesn't
 help.  My computing enrionment is linux 64 bit, R 2.10, ff 2.1.

 If you know what causes the issue or how to solve it, please let me know.
 I highly appreciate.

 Jeff

 __
 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] How to implement a select distinct x, count(distinct y) ... group by x for a data frame

2010-01-23 Thread Gabor Grothendieck
Regarding your subject, the sqldf package on CRAN allows you to apply
SQL statements directly to R data frames.  http://sqldf.googlecode.com

On Sat, Jan 23, 2010 at 5:46 PM, Dimitri Shvorob
dimitri.shvo...@gmail.com wrote:

 ... Being an R newbie, I can only think of extracting distinct x values with
 unique, looping over them, extracting matching rows from the original data
 frame, applying table, and recording the size of table's output alongside
 the x value being checked. Is there a more elegant way?

 Thank you.
 --
 View this message in context: 
 http://n4.nabble.com/How-to-implement-a-select-distinct-x-count-distinct-y-group-by-x-for-a-data-frame-tp1288418p1288418.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Data import export zipped files from URLs

2010-01-23 Thread Velappan Periasamy
http://nseindia.com/content/equities/scripvol/datafiles/01-01-2010-TO-23-01-2010RCOMXN.csv


the  url is correct. it is not zipped file.
copy the url in the browser window you will get the
this ..


Symbol,Series,Date, Prev Close,Open Price,High Price,Low Price,Last
Price,Close Price,Average Price,Total Traded Quantity,Turnover in
Lacs,
RCOM,EQ,04-Jan-2010,172.35,173,175.8,172.55,175.25,175.2,174.17,2418999,4213.1160435,
RCOM,EQ,05-Jan-2010,175.2,176,182,175.8,181.45,181.35,178.64,6033757,10778.7459905,
RCOM,EQ,06-Jan-2010,181.35,182.5,184.4,180.8,181.5,181.8,182.76,4680776,8554.525768,
RCOM,EQ,07-Jan-2010,181.8,183.7,185.3,182.5,183.8,183.9,184.05,4255338,7831.773937,
RCOM,EQ,08-Jan-2010,183.9,184.5,185.15,180.2,181.1,180.85,182.14,3775898,6877.5970215,
RCOM,EQ,11-Jan-2010,180.85,184,184,180.2,181.85,182.1,182.04,3601269,6555.8894695,
RCOM,EQ,12-Jan-2010,182.1,182.1,182.85,175.05,175.3,175.45,179.06,4834928,8657.6031315,
RCOM,EQ,13-Jan-2010,175.45,174,176.6,173.05,175.7,175.55,175.01,3276310,5733.8242525,
RCOM,EQ,14-Jan-2010,175.55,177.2,184.2,175.65,182.85,183,180.8,7227593,13067.2365775,
RCOM,EQ,15-Jan-2010,183,183,193.4,183,191.3,191.6,191.03,15459863,29533.7056915,
RCOM,EQ,18-Jan-2010,191.6,189.9,193.8,188.35,190.05,190.45,191.27,4710277,9009.3851875,
RCOM,EQ,19-Jan-2010,190.45,190,192.9,185.2,186.5,186.35,188.67,4458474,8411.945425,
RCOM,EQ,20-Jan-2010,186.35,187,190.6,185.3,186.6,186.9,188.05,3581194,6734.2921825,
RCOM,EQ,21-Jan-2010,186.9,186.85,189.75,184.15,185.3,185.15,186.85,3673061,6863.2499155,
RCOM,EQ,22-Jan-2010,185.15,183.7,184.7,176.45,181.6,181.55,181.5,4194634,7613.198626,

__
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 apply a function on each column of a matrix

2010-01-23 Thread Ted Harding
 On 24-Jan-10 00:27:37, Jim Lemon wrote:
 On 01/24/2010 11:11 AM, anna wrote:

 Here is the last code that I wrote but it would give me the
 same problem:
 I have the matrix mat with n columns mat.1, mat.2 ...mat.n

 #To be able to use lapply I convert it to a data.frame:
 mat- data.frame(mat)

 lapply(mat, function, argument of function)

 It works but I still get for all elements the function applied
 for the last element. The elements of my results are all the
 same I don't understand I did exactly as shown on this website:
 http://www.ats.ucla.edu/stat/r/library/advanced_function_r.htm#lapply
 
 Hi anna,
 If you could post your matrix mat (or something else that
 produces the problem you describe if mat is private or too big)
 and the commands you used, someone will probably figure out what
 is going wrong.
 
 Jim

I agree with Jim's comments. It may help to formulate your reply
to considet the following simple case of applying a function on
each column of a matrix:

  X2 - function(x){ x^2 }
  M - matrix(c(1,2,3,4,5,6,7,8,9),nrow=3)
  M
  #  [,1] [,2] [,3]
  # [1,]147
  # [2,]258
  # [3,]369

  X2 - function(x){ x^2 }
  apply(M,2,X2)
  #  [,1] [,2] [,3]
  # [1,]1   16   49
  # [2,]4   25   64
  # [3,]9   36   81

  SX2 - function(x){ sum(x^2) }
  apply(M,2,SX2)
  # [1]  14  77 194

Not ythe use of apply(), not lapply(); also that the result is
not a matrix (with 1 row) but a vector (dimensionless):

  dim(apply(M,2,SX2))
  # NULL

If you want the result to be a 1-row vector, then you need to
force this explicitly:

  N - apply(M,2,SX2)
  # dim(N)-c(1,3)

  N
  #  [,1] [,2] [,3]
  # [1,]   14   77  194

or (in this case) more simply:

  rbind(NULL,apply(M,2,SX2))
  #  [,1] [,2] [,3]
  # [1,]   14   77  194

If that approach does not work with your matrix and your function,
then there must be something special about one or the other!
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 24-Jan-10   Time: 00:49:12
-- 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] End of File for binary files

2010-01-23 Thread rn00b

Hello,

I'm new to R and I'm writing a function to read binary tables (the binary
version of read.table essentially). I'm having trouble figuring out how to
determine when I reach end-of-file. Can anybody please help?

thanks!
-- 
View this message in context: 
http://n4.nabble.com/End-of-File-for-binary-files-tp1288509p1288509.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] End of File for binary files

2010-01-23 Thread jim holtman
If you are reading a 'binary' file, then the end of file is when you
read the last byte; the system will tell you.  Exactly what are you
trying do to?  When you do a read, you typically request the number of
bytes to read and then the system returns the number of bytes read.
But since you did not give an indication of what/how you are trying to
do this, it is hard to make an exact suggestion.  Did you have some
experience that you think you did not get an end of file indication?
More information is required.

On Sat, Jan 23, 2010 at 9:40 PM, rn00b forzat...@gmail.com wrote:

 Hello,

 I'm new to R and I'm writing a function to read binary tables (the binary
 version of read.table essentially). I'm having trouble figuring out how to
 determine when I reach end-of-file. Can anybody please help?

 thanks!
 --
 View this message in context: 
 http://n4.nabble.com/End-of-File-for-binary-files-tp1288509p1288509.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.




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


[R] header files for R packages

2010-01-23 Thread David Lubbers
I have 6 or 7 nice constants (for example 1852 meters per nautical mile)
I would like to have available to 4 or 5 functions in an R package.   In
C this would just be a header .h file and I would just include  I am
stuck trying to figure out how to create something like a C header file
for an R package.  Any ideas?

__
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] End of File for binary files

2010-01-23 Thread rn00b

I am using readBin to continuously read characters from the binary file. I'm
trying to figure out how many characters are in the file. What I would like
to do is something like
(while! EOF)
{
charRead -.Internal(readBin(con,character,1L,NA,TRUE,swap))
i++
}

I'm not clear on how to determine the EOF condition in this case. 
-- 
View this message in context: 
http://n4.nabble.com/End-of-File-for-binary-files-tp1288509p1288525.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] End of File for binary files

2010-01-23 Thread jim holtman
Are you really trying to read in binary?  You are asking for
characters which would be a null terminated string.  If you are trying
to read in binary zeroes, this will not work.  What you need to do is
to use 'raw'.  Actually you should create a R script to test out the
various conditions you want.  If you use 'raw', this will read in the
actual bytes in the file.  You can check to see if the length of the
vector is what you requested.  If it is not, then you have reached an
end of file.  It is easy enough to try out the various options to see
what happens.  So if you are trying to read binary, then use 'raw'.
If you are reading null terminated strings, then 'character' will
work.  If your file consists of binary integers, then use 'integer'
and make sure you know if the 'endian' of the data.  There are lots of
other cases/conditions depending on what you are trying to do.

On Sat, Jan 23, 2010 at 10:40 PM, rn00b forzat...@gmail.com wrote:

 I am using readBin to continuously read characters from the binary file. I'm
 trying to figure out how many characters are in the file. What I would like
 to do is something like
 (while! EOF)
 {
 charRead -.Internal(readBin(con,character,1L,NA,TRUE,swap))
 i++
 }

 I'm not clear on how to determine the EOF condition in this case.
 --
 View this message in context: 
 http://n4.nabble.com/End-of-File-for-binary-files-tp1288509p1288525.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.




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


[R] Feature selection

2010-01-23 Thread Amy Hessen

 
 
Hi,
 
Could you please tell me whether there are feature selection algorithms in R or 
not such as genetic algorithms? If so, could you please tell me in which 
package?
 
Cheers,
Amy   
_
View photos of singles in your area! Browse profiles for FREE

[[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] tree()...binary reponse giving only one split

2010-01-23 Thread Seth

Hi,
I'm new to CART.  I have a data set with a binary reponse (0/1) and several
predictors.  I chose 2 continuous predictors to start and used the following
code.

testdata.ltr-tree(nondev85dev06~dist_rampm_wa + dis_prim_wa,testdata)

The two predictors should be quite explanatory based upon previous work. 
After running this code, I am getting only one split using the first
predictor listed.  I've tried this with other sets of 2 and 3 predictors and
it is always the same case, only one is used for a single split.  I thought
perhaps it was the binary nature of my data set.  So, I constructed another
where the response was 0,1, or 2.  I got the same result.  I've also tried
the same experiment with predictors that are binary and got the same
results.  I've searched the help but can't find any answers. Thanks. Seth
-- 
View this message in context: 
http://n4.nabble.com/tree-binary-reponse-giving-only-one-split-tp1288546p1288546.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.