Re: [R] Help with scatterplots in R

2010-07-30 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 29.07.2010 18:13:57:

 Hi John,
 
 yes, you are right. Here is what I have done:
 
 plot(DateJonEnd1, End1Jon,
main=Weekly Training at Endurance 1, xlim=c(13700,14750), 
xlab=Date,
ylim=c(0,350), ylab=Volume at Endurance 1, type=b, las=1)
 
 Where DateJonEnd1 is the date of weekly Training, classified as date 
and in 
 the format 2010-07-28. I have the data from 2007-05-01 to 2010-03-31.
 
 End1Jon is a numerical value, as an indicator of the volume of a 
particular 
 type of training per week. When I plot a years worth of data, R 
automatically 
 plots the months on the x-axis, however, as soon as the data spans more 
than a
 year R only gives me the years on the x-axis. However to compare the 
graphs, I
 would prefer to have the months on the x-axis, as well as the year.
 I have attached one of the graphs as an example.

Make your plot without axes by

plot(, axes=FALSE, ...)
or
plot(, xaxt=n, ...)

and than see

?axis.POSIXct   how to fine tune date axis with format option

Regards
Petr

 
 Hope this makes it a bit clearer.
 Sarah
 
 
 From: John Kane [jrkrid...@yahoo.ca]
 Sent: 28 July 2010 12:48
 To: r-help@r-project.org; Sarah Chisholm
 Subject: Re: [R] Help with scatterplots in R
 
 I think that we need an example of what you are doing before anyone can 
really
 answer that question.
 
 At the moment we don't even know how you are plotting the scatterplot.
 
 --- On Wed, 7/28/10, Sarah Chisholm sarah.chisholm...@ucl.ac.uk wrote:
 
  From: Sarah Chisholm sarah.chisholm...@ucl.ac.uk
  Subject: [R] Help with scatterplots in R
  To: r-help@r-project.org r-help@r-project.org
  Received: Wednesday, July 28, 2010, 6:57 AM
  Hi,
 
  When I plot a scatter plot, R automatically only gives the
  years on the x-axis. How can I make R also show the months
  on the x-axis?
 
  Thank you very much!
 
  [[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] R Equivalent of SAS Datastep Line-Hold (@@) Specifier?

2010-07-30 Thread Joshua Wiley
This gets you to a matrix, though it is messy and you would still have
to convert some of the columns from character to numeric, but maybe it
will give you an idea.


matrix(data = unlist(strsplit(x = readLines(textConnection(
A 1 101 M 55  5   A 1 104 F 27  0   A 1 106 M 31 35
A 1 107 F 44 21   A 1 109 M 47 15   A 1 111 F 69 70
A 1 112 F 31 10   A 1 114 F 50  0   A 1 116 M 32 20
A 1 118 F 39 25   A 1 119 F 54  0   A 1 121 M 70 38
A 1 123 F 57 55   A 1 124 M 37 18   A 1 126 F 41  0
A 1 128 F 48  8   A 1 131 F 35  0   A 1 134 F 28  0
A 1 135 M 27 40   A 1 138 F 42 12   A 2 202 M 58 68
A 2 203 M 42 22   A 2 206 M 26 30   A 2 207 F 36  0
A 2 210 F 35 25   A 2 211 M 51  0   A 2 214 M 51 60
A 2 216 F 42 15   A 2 217 F 50 50   A 2 219 F 41 35
A 2 222 F 59  0   A 2 223 F 38 10   A 2 225 F 32  0
A 2 226 F 28 16   A 2 229 M 42 48   A 2 231 F 51 45
A 2 234 F 26 90   A 2 235 M 42  0   A 3 301 M 38 28
A 3 302 M 41 20   A 3 304 M 65 75   A 3 306 F 64  0
A 3 307 F 30 30   A 3 309 F 64  5   A 3 311 M 39 80
A 3 314 F 57 85   A 3 315 M 61 12   A 3 318 F 45 95
A 3 319 F 34 26   A 3 321 M 39 10   A 3 324 M 27  0
A 3 325 F 56 35   B 1 102 M 19 68   B 1 103 F 51 10
B 1 105 M 45 20   B 1 108 F 44 65   B 1 110 M 32 25
B 1 113 M 61 75   B 1 115 M 45 83   B 1 117 F 21  0
B 1 120 F 19 55   B 1 122 F 38  0   B 1 125 M 37 72
B 1 127 F 53 40   B 1 129 M 48  0   B 1 130 F 36 80
B 1 132 M 49 20   B 1 133 F 28  0   B 1 136 F 34 45
B 1 137 F 57 95   B 1 139 F 47 40   B 1 140 M 29  0
B 2 201 F 63 10   B 2 204 M 36 49   B 2 205 M 36 16
B 2 208 F 48 12   B 2 209 F 42 40   B 2 212 F 32  0
B 2 213 M 24 88   B 2 215 M 40 59   B 2 218 M 31 24
B 2 220 F 45 72   B 2 221 F 27 55   B 2 224 M 56 70
B 2 227 F 41  0   B 2 228 F 24 65   B 2 230 M 44 30
B 2 232 M 37 32   B 2 233 F 33  0   B 3 303 M 40 26
B 3 305 M 46 15   B 3 308 M 59 82   B 3 310 F 62 38
B 3 312 M 52 40   B 3 313 F 33 40   B 3 316 M 62 87
B 3 317 M 52 60   B 3 320 F 32  2   B 3 322 F 43  0
B 3 323 F 51 35
)), [[:space:]]+)), byrow = TRUE, ncol =6)

closeAllConnections()

On Thu, Jul 29, 2010 at 3:54 PM, Paul Miller pjmiller...@yahoo.com wrote:
 Hello Everyone,

 Below is some SAS code that uses a line hold specifier to read multiple 
 observations from each of several input lines of data. There are 3 patients 
 per line in the in-stream data.

 Is there a way in R to read this kind of data? I've looked in my books and 
 online but haven't found anything

 Thanks,

 Paul


 DATA EXAMP.TRIAL;
 INPUT TRT $ CENTER PAT SEX $ AGE SCORE @@;
 DATALINES;
 A 1 101 M 55  5   A 1 104 F 27  0   A 1 106 M 31 35
 A 1 107 F 44 21   A 1 109 M 47 15   A 1 111 F 69 70
 A 1 112 F 31 10   A 1 114 F 50  0   A 1 116 M 32 20
 A 1 118 F 39 25   A 1 119 F 54  0   A 1 121 M 70 38
 A 1 123 F 57 55   A 1 124 M 37 18   A 1 126 F 41  0
 A 1 128 F 48  8   A 1 131 F 35  0   A 1 134 F 28  0
 A 1 135 M 27 40   A 1 138 F 42 12   A 2 202 M 58 68
 A 2 203 M 42 22   A 2 206 M 26 30   A 2 207 F 36  0
 A 2 210 F 35 25   A 2 211 M 51  0   A 2 214 M 51 60
 A 2 216 F 42 15   A 2 217 F 50 50   A 2 219 F 41 35
 A 2 222 F 59  0   A 2 223 F 38 10   A 2 225 F 32  0
 A 2 226 F 28 16   A 2 229 M 42 48   A 2 231 F 51 45
 A 2 234 F 26 90   A 2 235 M 42  0   A 3 301 M 38 28
 A 3 302 M 41 20   A 3 304 M 65 75   A 3 306 F 64  0
 A 3 307 F 30 30   A 3 309 F 64  5   A 3 311 M 39 80
 A 3 314 F 57 85   A 3 315 M 61 12   A 3 318 F 45 95
 A 3 319 F 34 26   A 3 321 M 39 10   A 3 324 M 27  0
 A 3 325 F 56 35   B 1 102 M 19 68   B 1 103 F 51 10
 B 1 105 M 45 20   B 1 108 F 44 65   B 1 110 M 32 25
 B 1 113 M 61 75   B 1 115 M 45 83   B 1 117 F 21  0
 B 1 120 F 19 55   B 1 122 F 38  0   B 1 125 M 37 72
 B 1 127 F 53 40   B 1 129 M 48  0   B 1 130 F 36 80
 B 1 132 M 49 20   B 1 133 F 28  0   B 1 136 F 34 45
 B 1 137 F 57 95   B 1 139 F 47 40   B 1 140 M 29  0
 B 2 201 F 63 10   B 2 204 M 36 49   B 2 205 M 36 16
 B 2 208 F 48 12   B 2 209 F 42 40   B 2 212 F 32  0
 B 2 213 M 24 88   B 2 215 M 40 59   B 2 218 M 31 24
 B 2 220 F 45 72   B 2 221 F 27 55   B 2 224 M 56 70
 B 2 227 F 41  0   B 2 228 F 24 65   B 2 230 M 44 30
 B 2 232 M 37 32   B 2 233 F 33  0   B 3 303 M 40 26
 B 3 305 M 46 15   B 3 308 M 59 82   B 3 310 F 62 38
 B 3 312 M 52 40   B 3 313 F 33 40   B 3 316 M 62 87
 B 3 317 M 52 60   B 3 320 F 32  2   B 3 322 F 43  0
 B 3 323 F 51 35
 ;


        [[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 Equivalent of SAS Datastep Line-Hold (@@) Specifier?

2010-07-30 Thread Bill.Venables
There is a much simpler way.

con - textConnection(
A 1 101 M 55  5   A 1 104 F 27  0   A 1 106 M 31 35
A 1 107 F 44 21   A 1 109 M 47 15   A 1 111 F 69 70
A 1 112 F 31 10   A 1 114 F 50  0   A 1 116 M 32 20
A 1 118 F 39 25   A 1 119 F 54  0   A 1 121 M 70 38
A 1 123 F 57 55   A 1 124 M 37 18   A 1 126 F 41  0
A 1 128 F 48  8   A 1 131 F 35  0   A 1 134 F 28  0
A 1 135 M 27 40   A 1 138 F 42 12   A 2 202 M 58 68
A 2 203 M 42 22   A 2 206 M 26 30   A 2 207 F 36  0
A 2 210 F 35 25   A 2 211 M 51  0   A 2 214 M 51 60
A 2 216 F 42 15   A 2 217 F 50 50   A 2 219 F 41 35
A 2 222 F 59  0   A 2 223 F 38 10   A 2 225 F 32  0
A 2 226 F 28 16   A 2 229 M 42 48   A 2 231 F 51 45
A 2 234 F 26 90   A 2 235 M 42  0   A 3 301 M 38 28
A 3 302 M 41 20   A 3 304 M 65 75   A 3 306 F 64  0
A 3 307 F 30 30   A 3 309 F 64  5   A 3 311 M 39 80
A 3 314 F 57 85   A 3 315 M 61 12   A 3 318 F 45 95
A 3 319 F 34 26   A 3 321 M 39 10   A 3 324 M 27  0
A 3 325 F 56 35   B 1 102 M 19 68   B 1 103 F 51 10
B 1 105 M 45 20   B 1 108 F 44 65   B 1 110 M 32 25
B 1 113 M 61 75   B 1 115 M 45 83   B 1 117 F 21  0
B 1 120 F 19 55   B 1 122 F 38  0   B 1 125 M 37 72
B 1 127 F 53 40   B 1 129 M 48  0   B 1 130 F 36 80
B 1 132 M 49 20   B 1 133 F 28  0   B 1 136 F 34 45
B 1 137 F 57 95   B 1 139 F 47 40   B 1 140 M 29  0
B 2 201 F 63 10   B 2 204 M 36 49   B 2 205 M 36 16
B 2 208 F 48 12   B 2 209 F 42 40   B 2 212 F 32  0
B 2 213 M 24 88   B 2 215 M 40 59   B 2 218 M 31 24
B 2 220 F 45 72   B 2 221 F 27 55   B 2 224 M 56 70
B 2 227 F 41  0   B 2 228 F 24 65   B 2 230 M 44 30
B 2 232 M 37 32   B 2 233 F 33  0   B 3 303 M 40 26
B 3 305 M 46 15   B 3 308 M 59 82   B 3 310 F 62 38
B 3 312 M 52 40   B 3 313 F 33 40   B 3 316 M 62 87
B 3 317 M 52 60   B 3 320 F 32  2   B 3 322 F 43  0
B 3 323 F 51 35
)
Example_Trial - data.frame(scan(con, list(Trt = , Centre = 0, 
Patient = 0, Sex = , Age = 0, Score = 0)))

## 
 head(Example_Trial)
  Trt Centre Patient Sex Age Score
1   A  1 101   M  55 5
2   A  1 104   F  27 0
3   A  1 106   M  3135
4   A  1 107   F  4421
5   A  1 109   M  4715
6   A  1 111   F  6970

Rather than use a textConnection, you would probably just use a file. 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Joshua Wiley
Sent: Friday, 30 July 2010 4:59 PM
To: Paul Miller
Cc: r-help@r-project.org
Subject: Re: [R] R Equivalent of SAS Datastep Line-Hold (@@) Specifier?

This gets you to a matrix, though it is messy and you would still have
to convert some of the columns from character to numeric, but maybe it
will give you an idea.


matrix(data = unlist(strsplit(x = readLines(textConnection(
A 1 101 M 55  5   A 1 104 F 27  0   A 1 106 M 31 35
A 1 107 F 44 21   A 1 109 M 47 15   A 1 111 F 69 70
A 1 112 F 31 10   A 1 114 F 50  0   A 1 116 M 32 20
A 1 118 F 39 25   A 1 119 F 54  0   A 1 121 M 70 38
A 1 123 F 57 55   A 1 124 M 37 18   A 1 126 F 41  0
A 1 128 F 48  8   A 1 131 F 35  0   A 1 134 F 28  0
A 1 135 M 27 40   A 1 138 F 42 12   A 2 202 M 58 68
A 2 203 M 42 22   A 2 206 M 26 30   A 2 207 F 36  0
A 2 210 F 35 25   A 2 211 M 51  0   A 2 214 M 51 60
A 2 216 F 42 15   A 2 217 F 50 50   A 2 219 F 41 35
A 2 222 F 59  0   A 2 223 F 38 10   A 2 225 F 32  0
A 2 226 F 28 16   A 2 229 M 42 48   A 2 231 F 51 45
A 2 234 F 26 90   A 2 235 M 42  0   A 3 301 M 38 28
A 3 302 M 41 20   A 3 304 M 65 75   A 3 306 F 64  0
A 3 307 F 30 30   A 3 309 F 64  5   A 3 311 M 39 80
A 3 314 F 57 85   A 3 315 M 61 12   A 3 318 F 45 95
A 3 319 F 34 26   A 3 321 M 39 10   A 3 324 M 27  0
A 3 325 F 56 35   B 1 102 M 19 68   B 1 103 F 51 10
B 1 105 M 45 20   B 1 108 F 44 65   B 1 110 M 32 25
B 1 113 M 61 75   B 1 115 M 45 83   B 1 117 F 21  0
B 1 120 F 19 55   B 1 122 F 38  0   B 1 125 M 37 72
B 1 127 F 53 40   B 1 129 M 48  0   B 1 130 F 36 80
B 1 132 M 49 20   B 1 133 F 28  0   B 1 136 F 34 45
B 1 137 F 57 95   B 1 139 F 47 40   B 1 140 M 29  0
B 2 201 F 63 10   B 2 204 M 36 49   B 2 205 M 36 16
B 2 208 F 48 12   B 2 209 F 42 40   B 2 212 F 32  0
B 2 213 M 24 88   B 2 215 M 40 59   B 2 218 M 31 24
B 2 220 F 45 72   B 2 221 F 27 55   B 2 224 M 56 70
B 2 227 F 41  0   B 2 228 F 24 65   B 2 230 M 44 30
B 2 232 M 37 32   B 2 233 F 33  0   B 3 303 M 40 26
B 3 305 M 46 15   B 3 308 M 59 82   B 3 310 F 62 38
B 3 312 M 52 40   B 3 313 F 33 40   B 3 316 M 62 87
B 3 317 M 52 60   B 3 320 F 32  2   B 3 322 F 43  0
B 3 323 F 51 35
)), [[:space:]]+)), byrow = TRUE, ncol =6)

closeAllConnections()

On Thu, Jul 29, 2010 at 3:54 PM, Paul Miller pjmiller...@yahoo.com wrote:
 Hello Everyone,

 Below is some SAS code that uses a line hold specifier to read multiple 
 observations from each of several input lines of data. There are 3 patients 
 per line in the in-stream data.

 Is there a way in R to read this kind of data? I've looked in my books and 
 online but haven't found anything

 Thanks,

 Paul


 DATA EXAMP.TRIAL;
 

Re: [R] package xpose4 in Vista - Update

2010-07-30 Thread Santosh
Thanks for your response. How do I install xpose4 package with R.2.11.1?

-Santosh

2010/7/29 Uwe Ligges lig...@statistik.tu-dortmund.de

 The binary package you downloaded is a binary for R  2.11.x. Since it is a
 package bndle, it cannot work on R-2.11.x anymore: Package bundles are no
 longer supported.

 Best,
 Uwe Ligges



 On 29.07.2010 02:11, Santosh wrote:

 Dear R experts,

 There seems to be a problem (please see the error messages below) with the
 installation of the latest version of xpose4 (version 4.2.1) with the
 latest
 R version.(2.11.1)... I didn't face such installation problems when using
 version R.2.10.1

 Would really appreciate your assistance in debugging installation of xpose
 4..2.1 with R.2.11.1

 Thanks again..
 -Santosh

 On Wed, Jul 28, 2010 at 12:46 PM, Santoshsantosh2...@gmail.com  wrote:

  Dear R experts...
 I would really appreciate your suggestions in installing a package in
 Windows Vista...

 I am unable to install a package on a windows vista based computer, in
 spite of running it as an administrator. The package xpose4.2.1 is
 available from 

 https://sourceforge.net/projects/xpose/files/Xpose4/Xpose_4.2.1/xpose4_4.2.1_win32.zip/download
 

 Following is the error message when I try to install the package from the
 Rgui command line...
 I get similar errors when I try to install the packages from Rgui
 (Packages | Install packages from local zip files) menu, but with
 default
 lib=C:/Users/santosh/Documents/R/win-library/2.11
 .___


 install.packages(C:/Users/santosh/Downloads/xpose4_4.2.1_win32.zip,repos=NULL,lib=C:/Program
 Files/R/R-2.11.1/library)
 Error in gzfile(file, r) : cannot open the connection
 In addition: Warning message:
 In gzfile(file, r) :
   cannot open compressed file 'xpose4_4.2.1_win32/DESCRIPTION', probable
 reason 'No such file or directory'
 



  However, I see file folder in which the library related folders
 are installed, and contains different xpose4 related folders..

 Thanks again,
 Santosh






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



[[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] lm.influence on glm objects

2010-07-30 Thread Xu Wang

Was this issue resolved?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/lm-influence-on-glm-objects-tp1574781p2307622.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] CBIND / MERGE two time series objects along time (overlapping indices, redundant data)

2010-07-30 Thread Bernhard Von Boyen
Hi there,

I need to merge/bind two time series objects (from RPackage: timeSeries) by 
column. The theory is laid out nicely, even for overlapping indices. 


In my example, I have overlapping indices (01.01.2001), where in one time 
series I have one data point and in the other redundant data. Default usage of 
merge and cbind would lead to the result that the one data point would be 
replicated (see example below). However, I do not like the replicating feature 
and would like to have the NA's filled instead.

Desired output, would be:
    TS.1 SS.2
2001-01-01 23.1 23.1
2001-01-01 NA  23.4

Is there a slick way to produce above result? Thank you for your answer - help 
is really appreciated.

Kind regards,

Bernhard.

---


# R Console example:
require(timeSeries)
date -timeDate(01.01.2001, format = %d.%m.%Y)
test1 - timeSeries(c(23.1), charvec = date)
test2 - timeSeries(c(23.1, 23.4), charvec = c(date, date))
colnames(test2) - SS.2 
merge(test1, test2)
GMT
   TS.1 SS.2
2001-01-01 23.1 23.1
2001-01-01 23.1 23.4
cbind(test1, test2)
Fehler in cbind(deparse.level, ...) : number of rows must match
cbind(test2, test1)
GMT
   SS.2 TS.1
2001-01-01 23.1 23.1
2001-01-01 23.4 23.1



  
[[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 get higher derivatives with deriv

2010-07-30 Thread mhofert

Okay, great. Thanks.

Cheers,

Marius
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-get-higher-derivatives-with-deriv-tp2306711p2307709.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] (no subject)

2010-07-30 Thread Natasa Tzortzaki

hello,

i am new to R and trying to calculate the beta coefficient for standard linear 
regression for a series of randomly generated numbers. I have created this 
loop, but it runs really slow, is there a way to improve it?

#number of simulations
n.k-999
#create the matrix for regression coefficients generated from #random data

beta-matrix(0,1,n.k+1)
e-matrix(0,tslength,n.k+1)


for(k in 1:n.k+1)
   {
for(i in 1:tslength)
   {
beta[1,1]-beta1
e[i,k]-c(rnorm(1,0,var.all))
beta[1,k]-summary(lm(e[1:tslength,k]~t))$coefficient[2]
   } 
   }
thanks
Anastasia Tzortzaki
  
[[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] Need a help to plot bar for time series Rain data

2010-07-30 Thread Nyanzura

Hey Guys,
I am quite new to R, am trying to plot a bar plot for my monthly rainfall
data from 1920 to 1990. For every year I have the data from January to
December. I have created this code:

data-read.table(C://R//Data//Rain.txt, header=TRUE)
data-data[,2:13]
Rdata-data[1,]
for(i in 2:79){Rdata-c(Rdata,data[i,])}
times-ts(Rdata,start=1920,frequency=12)
pdf(plot_Rain,width=20,height=5)
barplot(times)

I am getting this error:

Error in barplot.default(times) : 'height' must be a vector or a matrix

Could anyone please tell me how should I specify/write the code to plot the
bars??

Thank you in advance for your time!

Nyanzura
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-a-help-to-plot-bar-for-time-series-Rain-data-tp2307739p2307739.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] package xpose4 in Vista - Update

2010-07-30 Thread Uwe Ligges

On 30.07.2010 08:56, Santosh wrote:

Thanks for your response. How do I install xpose4 package with R.2.11.1?



Only by unbundling it manually and installing the separate packages from 
sources afterwards. I highly suggest to contact the maintainers.


Uwe



-Santosh

2010/7/29 Uwe Ligges lig...@statistik.tu-dortmund.de
mailto:lig...@statistik.tu-dortmund.de

The binary package you downloaded is a binary for R  2.11.x. Since
it is a package bndle, it cannot work on R-2.11.x anymore: Package
bundles are no longer supported.

Best,
Uwe Ligges



On 29.07.2010 02:11, Santosh wrote:

Dear R experts,

There seems to be a problem (please see the error messages
below) with the
installation of the latest version of xpose4 (version 4.2.1)
with the latest
R version.(2.11.1)... I didn't face such installation problems
when using
version R.2.10.1

Would really appreciate your assistance in debugging
installation of xpose
4..2.1 with R.2.11.1

Thanks again..
-Santosh

On Wed, Jul 28, 2010 at 12:46 PM, Santoshsantosh2...@gmail.com
mailto:santosh2...@gmail.com  wrote:

Dear R experts...
I would really appreciate your suggestions in installing a
package in
Windows Vista...

I am unable to install a package on a windows vista based
computer, in
spite of running it as an administrator. The package
xpose4.2.1 is
available from 

https://sourceforge.net/projects/xpose/files/Xpose4/Xpose_4.2.1/xpose4_4.2.1_win32.zip/download


Following is the error message when I try to install the
package from the
Rgui command line...
I get similar errors when I try to install the packages from
Rgui
(Packages | Install packages from local zip files) menu,
but with default
lib=C:/Users/santosh/Documents/R/win-library/2.11
.___



install.packages(C:/Users/santosh/Downloads/xpose4_4.2.1_win32.zip,repos=NULL,lib=C:/Program
Files/R/R-2.11.1/library)
Error in gzfile(file, r) : cannot open the connection
In addition: Warning message:
In gzfile(file, r) :
   cannot open compressed file
'xpose4_4.2.1_win32/DESCRIPTION', probable
reason 'No such file or directory'




However, I see file folder in which the library
related folders
are installed, and contains different xpose4 related folders..

Thanks again,
Santosh






[[alternative HTML version deleted]]

__
R-help@r-project.org mailto: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] reading dates in Excel into R

2010-07-30 Thread 500600

Does function ?strptime help you in any way?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/reading-dates-in-Excel-into-R-tp2306830p2307744.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] Sweave line breaks

2010-07-30 Thread soeren . vogel
Hello, when I print x in Sweave, the lines do not wrap. However, I want them to 
wrap (perhaps at a specified width). How? Thanks, *S*

keep.source=TRUE=
x - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, 
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo 
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse 
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
print(x)
@

__
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] reading dates in Excel into R

2010-07-30 Thread John C Frain
To read the data into R
1) I format my dates as -MM-DD in Excel (or OpenOffice Calc),
2) (change =na() to NA)
3) Check that required  number of significant decimal places are displayed,
4) export as csv and
5) Use readSeries() function from Rmetrics timeSeries package to read
the data into R.

For what it is worth I have found this approach flexible .

Best Regards

John

On 29 July 2010 22:18, Peter Alspach peter.alsp...@plantandfood.co.nz wrote:
 Tena koe

 What do you want to control?  You can govern the format used in R using the 
 appropriate R functions.  I doubt it would be useful to have dates read from 
 Excel depend on the format set for displaying those dates in Excel.

 HTH 
,,,

 Peter Alspach

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Hongying Li
 Sent: Friday, 30 July 2010 5:33 a.m.
 To: r-help@r-project.org
 Subject: [R] reading dates in Excel into R


 I am reading dates in Excel2007 into R.

 Here are the functions I used:

 library(RODBC)
 channel-odbcConnectExcel2007(myfile.xlsx)
 tmp-sqlFetch(channel,1,as.is=T)


 The dates in myfile.xlsx are all in this format: mm/dd/. But when I
 read it to R, some columns look like -mm-dd 00:00:00, some
 columns look like -mm-dd, and some columns are numbers. I do not
 know how I can control this.



 Any help? Thanks!



 _
 Hotmail is redefining busy with tools for the New Busy. Get more from
 your inbox.

 N:WL:en-US:WM_HMP:042010_2
       [[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.




-- 
John C Frain
Economics Department
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:fra...@tcd.ie
mailto:fra...@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] Out-of-sample predictions with boosting model

2010-07-30 Thread Benjamin Hofner

Hi Travis,

I try to give you some hints that might bring you closer to a solution.
The clue to your problem (as far as I understand it) might just be to 
appropriately use the predict function of mboost. You can specify a new 
data set (e.g. a part of your original data set not used for estimation) 
and


 predict(model, newdata = newdata)

which gives you a vector of predictions as you wanted. Thus, you could, 
for example, specify newdata such that you get your one-step ahead 
predictions.


To estimate the model only on a subset of the data you could either use

 mboost(y ~ x1 + x2 + x3, data = some_part_of_your_dataset)

or you can apply weights

 model - mboost(y ~ x1 + x2 + x3, data = data,
+ weights = c(rep(1, 100), rep(0, nrow(data) - 100)))
 predict(model) ## gives you predictions for all observations in data

Now you can extract the subset of out-of-bag predictions, i.e., 
predictions for observations with weight 0.


One further thing to mention:
You term your model blackbox, however you should note that you do NOT 
fit a blackbox model but an additive model using P-splines (which is the 
default). You can see this if you type, e.g.,


 coef(model)

and look at the names.

Another idea for your data problem might be that you fit ONE model with 
country as effect modifier specified via the by argument in all 
base-learners. A call could look like


 mboost(y ~ bbs(x1, by = country) + bbs(x2, by = country)
++ bbs(x3, by = country), data = data)


Or you could use random effects via brandom() base-learners. Oh, and 
please note that you need to tune your mstop value (e.g. via cvrisk)!


HTH
 Benjamin


Travis Berge travisrh...@gmail.com wrote:

Hi UseRs -

I am new to R, and could use some help making out-of-sample predictions
using a boosting model (the mboost command). The issue is complicated by the
fact that I have panel data (time by country), and am estimating the model
separately for each country. FYI, this is monthly data and I have 1986m1 -
2009m12 for 9 countries.

To give you a flavor of what I am doing, here is a simple example to show
how I make in-sample predictions:

# data has following columns: country year month y x1 x2 x3
dat = read.csv(data.csv)

# Create function that estimates model, produces in-sample predictions
bbox = function(df)
{
blackbox = mboost(y ~ x1 + x2 + x3)
predict(blackbox)
}

# Use lapply to estimate by country
bycountry = lapply(split(dat, dat$country), bbox)


So that in the end I have an object bycountry that contains the in-sample
predictions of the model, estimated for each country separately. What I
would like to do is take this model and estimate it for each country using
some initial data. I.e., estimate Australia with 1986m1-2003m12, make
prediction about 2004m1, roll data forward. Estimate AUS with 1986m2-2004m1,
predict 2004m2, etc for all data points. Now do the same for Canada,
Denmark, etc.

So I guess my problem is twofold. 1) How to make these out-of-sample
predictions, by country, when my data has not been declared as time-series?
(I do not think that mboost can handle time-series data...x1 x2 and x3 have
been lagged appropriately). 2) How to save the one-step ahead predictions
into a vector?

Any thoughts would be greatly appreciated. Many thanks!

-Travis

[[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] adding new devices and plots

2010-07-30 Thread Jim Lemon

On 07/30/2010 04:15 AM, Erin Hodgess wrote:

Dear R People:

I have the following function:


eplot

function (x)
{
 plot(x)
 z- locator(2)
 dev.new()
 plot(window(x, start = min(z$x), end = max(z$x)))
}




I want to generate a new plot from a subset of the original, but I
want to keep the original plot up.  When I use this, it opens a new
window, but the first device goes blank.


Hi Erin,
Maybe you want something like zoomInPlot (plotrix).

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] a Chebyshev ....really important

2010-07-30 Thread Liviu Andronic
On Thu, 29 Jul 2010 19:01:52 -0400
hussain abu-saaq hussain...@hotmail.com wrote:
 Hi. i have one question. is there any  command to use a Chebyshev  in
 R. i need them to fit the data and get a Chebyshev polynomial. thank
 you.
 
Please try
http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4q=chebyshevsa=Search+functions%2C+lists%2C+and+morecof=FORID%3A11

or 
require(sos)
findFn(chebyshev)

or similar. Please check the posting guide. Regards
Liviu

__
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] Flip axis on hist2d plot

2010-07-30 Thread Ralf B
I am plotting a heatmap using the hist2d function:

require(gplots)
x - rnorm(2000)
y - rnorm(2000)
hist2d(x, y, freq=TRUE, nbins=50, col = c(white,heat.colors(256)))

However, I would like to flip the vertical y axis so that the upper
left corner serves as the y-origin. How can I do that?

Ralf

__
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] multiple graphics windows open with sessionInfo

2010-07-30 Thread Uwe Ligges



On 29.07.2010 23:29, Erin Hodgess wrote:

Dear R People:

Hello again.  I'm trying to have 3 graphics windows visible
simultaneously.  I set up a zoo series.
Then I plot the original series.  I use the locator function to select
2 values from the original series, which generates a subset of the
original series.

Next, I plot the subset.

The last step is to produce an EWMA chart from the subset series.

Fair enough.  I've tried all sort of things, but can only have 2
graphics windows open with stuff in them.  If I go into the blank
window and maximize it, then it appears.  But other than that, it does
not.



xdate- seq(as.Date(1998-01-01),as.Date(2010-06-30),by=day)
length(xdate)

[1] 4564

xt- zoo(rnorm(4564),order=xdate)
#Here is the function itself:
eplot

function (x)
{
 require(zoo)
 require(qcc)
 windows()
 plot(x)
 z- locator(2,type=l,col=red)
 windows()
 plot(window(x, start = min(z$x), end = max(z$x)))
 windows()
 ewma(window(x, start = min(z$x), end = max(z$x)))
 dev.set(3)
  plot(window(x, start = min(z$x), end = max(z$x)))





Erin,

actually, I do not udnerstand what you want to achieve with the last two 
lines of the function.
Particularly note that dev.set(3) does only work if you have a certain 
amount of open devices once you call the function.


Best,
Uwe



}

sessionInfo()

R version 2.11.1 (2010-05-31)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] qcc_2.0.1   zoo_1.6-3   proto_0.3-8

loaded via a namespace (and not attached):
[1] dynlm_0.2-3   grid_2.11.1   lattice_0.18-8
strucchange_1.4-0 tcltk_2.11.1  tools_2.11.1  traitr_0.7





Any help would be much appreciated.

Thanks,
Erin




__
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] Need a help to plot bar for time series Rain data

2010-07-30 Thread Jim Lemon

On 07/30/2010 06:51 PM, Nyanzura wrote:


Hey Guys,
I am quite new to R, am trying to plot a bar plot for my monthly rainfall
data from 1920 to 1990. For every year I have the data from January to
December. I have created this code:

data-read.table(C://R//Data//Rain.txt, header=TRUE)
data-data[,2:13]
Rdata-data[1,]
for(i in 2:79){Rdata-c(Rdata,data[i,])}
times-ts(Rdata,start=1920,frequency=12)
pdf(plot_Rain,width=20,height=5)
barplot(times)

I am getting this error:

Error in barplot.default(times) : 'height' must be a vector or a matrix

Could anyone please tell me how should I specify/write the code to plot the
bars??


Hi Nyanzura,
I guess the first thing would be to see what:

class(times)

has to say. However, a plot with 852 bars might be a little hard to 
interpret.


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] Need a help to plot bar for time series Rain data

2010-07-30 Thread Nyanzura

Hi Jim,

Thank you very much, let me check as you suggested. But in addition what do
you think could be easy to interpret? Could you advice me please.

Nyanzura
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-a-help-to-plot-bar-for-time-series-Rain-data-tp2307739p2307858.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] 3d topographic map

2010-07-30 Thread Karl Ove Hufthammer
sh...@ucar.edu wrote:

 I would like to create a 3d topographic map using lat/lon and
 z(height).  I have been scouring the R help pages and have not located
 the package I am looking for.  Does anyone have a suggestion of package
 that will work for this?

I have some code for generating some pretty cool 3D topographic maps, 
even interactive ones. It's not very difficult to do, really, and much 
of the code is actually just for generating nice colours for the map. :-)

I thought it was quite surprising and interesting to see how shallow 
the ocean is many place, and how much the depth actually varies.

For instance, the North Sea (between the coast of Norway and the
coast of England) is only about 100 meters deep most places. But
in other places the ocean is several kilometers deep. 

Anyway, here's the code:

# First download the SRTM30_Plus data file (about 55 MiB) from
# ftp://topex.ucsd.edu/pub/srtm30_plus/srtm30/data/w020n90.Bathymetry.srtm
# See also http://topex.ucsd.edu/WWW_html/srtm30_plus.html

# Bounding box
minlat=40
maxlat=90
minlong=-20
maxlong=20

# Range of bounding box
longrange=maxlong-minlong
latrange=maxlat-minlat

# Number of columns and rows of data in the bathymetry file
ncols=60 * 2 * longrange
nrows=60 * 2 * latrange

ntot=ncols*nrows # Total number of points -- probably too many to plot ...
steps=10 # ... so we use only every 'steps' point in each direction 

ux=seq(1,ncols,by=steps) # X coordinates (longitude)
uy=seq(1,nrows,by=steps)  # Y coordinates (latitude)

dat=expand.grid(x=ux,y=uy) # Create grid
dat=transform(dat,index=(y-1)*ncols+x) # Calculate byte index in file

# Transform indices to real coordinates
dat=transform(dat, long=ggplot2::rescale(x, from=c(1,ncols),
to=c(minlong+1/60/4, maxlong-1/60/4), 
clip=FALSE),
lat=ggplot2::rescale(y, from=c(1,nrows),
to=c(maxlat-1/60/4, minlat+1/60/4), clip=FALSE))

# Name of file containing the bathymetry data
filename=w020n90.Bathymetry.srtm

# Read bathymetry data from the file
library(R.utils)
dat$z=readBinFragments(filename, what=integer, size=2, signed=TRUE,
idxs=dat$index,endian=big)

# Create matrix containing the data
dat.mat=matrix(dat$z,ncol=length(ux),byrow=TRUE)
dat.mat=t(dat.mat)[,nrow(dat.mat):1]

# Calculate topographic colours for elevation values
map.colours=function(z, water=c(-5000,0), land=c(0,1500), mountain,...)
{
z.min=min(z)
z.max=max(z)

# Divide the land gradient into two parts
land=c(land[1],mean(land),land[2]) 

# Number of unique water and land values
nw=length(unique(z[z0]))
nl=length(unique(z[z=0]))

# Create the output colour component vectors
h - s - v - rep(1, length(z))

# h-values for water
hvals=c(43/60,31/60)

# Create water colours
if(nw==1) h[z0]=hvals[2] else if(nw1)
h[z0]=approx(water,hvals,xout=z[z0],rule=2)$y

# h, s and v values for land
hvals=c(4/12,2/12,0/12)
svals=c(1,1,0)
vvals=c(.65,.9,.95)

# Create land colours
if(nl==1)
{ h[z=0] = hvals[1]; s[z=0] = svals[1]; v[z=0] = vvals[1]} else
if(nl1)
{
h[z=0]=approx(land,hvals,xout=z[z=0],rule=2)$y
s[z=0]=approx(land,svals,xout=z[z=0],rule=2)$y
v[z=0]=approx(land,vvals,xout=z[z=0],rule=2)$y
}

hsv(h,s,v)
}

# Basic contour plot -- not very pretty ...
with(dat, contour(unique(long),rev(unique(lat)),dat.mat))

# Colours make the whole thing look quite pretty ... 
ncolours=100
image(unique(dat$long),rev(unique(dat$lat)),
matrix(1:length(dat.mat),nrow=nrow(dat.mat)),
col=map.colours(dat.mat),xlab=Longitude,ylab=Latitude)

# And it looks even prettier in 3D ... 
zfacet - dat.mat[-nrow(dat.mat), -ncol(dat.mat)]
with(dat, persp(unique(long), rev(unique(lat)), dat.mat, 
expand=.2, col=map.colours(zfacet), border=NA,
shade=.3, phi=60, theta=0, axes=FALSE))

# How about an *interactive* 3D map ...
# Try holding the left mouse button and dragging
# Now try the mouse wheel (or right button and dragging)
# Finally, try clicking the middle button (or wheel) and dragging
library(rgl)
with(dat, surface3d(unique(long), rev(unique(lat)), dat.mat/1000,
col=map.colours(dat.mat)))

# Note that the elevation values are of course very much exaggerated
# In 'real life', it would look something like this (i.e., completely flat)
with(dat, surface3d(unique(long), rev(unique(lat)), dat.mat/100,
col=map.colours(dat.mat)))

-- 
Karl Ove Hufthammer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE 

[R] Programming Statistical Functions

2010-07-30 Thread hector

Hello, 
I'm new in R. I'm meteorological modeller and i will calculate some
statistics for my model results.
These statistis are the follow: 

ANB: Average Normalized Absolute BIAS
MNB: Mean Normalized BIAS
MNE: Mean Normalised Error
STDE: Standard Deviation of Error
FB: Fractional BIAS
MG: Geometric Mean BIAS
VG: Geometric Variance
SKVAR: Skill Variance
RMSE: Root Mean Square Error
NMSE: Normalized Mean Square Error
r: Correlation Coefficient
CV: Coeficient of Variation
FAC2: Fractional Predictions within a factor of two of observations
Hc: Hit Rate
IOA: Index of Agreement
Au: Unpaired Peak Concentration Accuracy
As: Spatially-paired Peak Concentration Accuracy

And their expressions are in the upload file: 
http://r.789695.n4.nabble.com/file/n2307880/Statistics.doc Statistics.doc 

I think that someone was developed this statistical functions for use in R,
but if don't exist, someone help me to programme it? Thank you!



-- 
View this message in context: 
http://r.789695.n4.nabble.com/Programming-Statistical-Functions-tp2307880p2307880.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] super class

2010-07-30 Thread Arun.stat

Is this what you wanted?

setClass(class1, representation(xc1=numeric, xc2=character))
setClass(class2, representation(cx1=character, cx2=numeric))
setClassUnion(combinedClass, c(class1,class2))
getClass(combinedClass)


-- 
View this message in context: 
http://r.789695.n4.nabble.com/super-class-tp831608p2307894.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] Programming Statistical Functions

2010-07-30 Thread stephen sefick
Maybe and r site search would help?  Try and figure out how to
calculate these yourself.  If you need help send a minimal,
reproducible example to this list, and you will probably recieve help.
 If you need a starting place for programming functions look at an
introduction to R.

#coefficient of variation
CV - function(x){mean(x)/sd(x)}

 My $0.02.

Stephen

On Fri, Jul 30, 2010 at 7:53 AM, hector hec...@ceam.es wrote:

 Hello,
 I'm new in R. I'm meteorological modeller and i will calculate some
 statistics for my model results.
 These statistis are the follow:

 ANB: Average Normalized Absolute BIAS
 MNB: Mean Normalized BIAS
 MNE: Mean Normalised Error
 STDE: Standard Deviation of Error
 FB: Fractional BIAS
 MG: Geometric Mean BIAS
 VG: Geometric Variance
 SKVAR: Skill Variance
 RMSE: Root Mean Square Error
 NMSE: Normalized Mean Square Error
 r: Correlation Coefficient
 CV: Coeficient of Variation
 FAC2: Fractional Predictions within a factor of two of observations
 Hc: Hit Rate
 IOA: Index of Agreement
 Au: Unpaired Peak Concentration Accuracy
 As: Spatially-paired Peak Concentration Accuracy

 And their expressions are in the upload file:
 http://r.789695.n4.nabble.com/file/n2307880/Statistics.doc Statistics.doc

 I think that someone was developed this statistical functions for use in R,
 but if don't exist, someone help me to programme it? Thank you!



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Programming-Statistical-Functions-tp2307880p2307880.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.




-- 
Stephen Sefick

| Auburn University                                   |
| Department of Biological Sciences           |
| 331 Funchess Hall                                  |
| Auburn, Alabama                                   |
| 36849                                                    |
|___|
| sas0...@auburn.edu                             |
| http://www.auburn.edu/~sas0025             |
|___|

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

                                -K. Mullis

__
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-07-30 Thread Dennis Murphy
Hi:

Avoiding loops in R by using vectorization is usually one of the best ways
to improve performance. Since we can't replicate your data (e.g., tslength
is not given), instead I'll generate a couple of functions to extract the
estimated beta from randomly generated data. The replicate() function comes
in handy for this type of simulation.

(1) Create a function to construct the sample and run the model:
wf - function() {
   x - sample(1:20, 10)
   y - 2 + 1.5 * x + rnorm(20)
   summary(lm(y ~ x))$coef[2]
   }
system.time(replicate(1000, wf()))
   user  system elapsed
   3.170.003.17

(2) Use a loop instead of replicate():
b - numeric(1000)
system.time(for(i in seq_along(b)) b[i] - wf())
   user  system elapsed
   3.170.003.18

(3) Use lsfit() instead (only works for simple linear regression):
wf2 - function() {
 x - sample(1:20, 10)
 y - 2 + 1.5 * x + rnorm(10)
lsfit(x, y)$coef[2]
  }
system.time(replicate(1000, wf2()))
   user  system elapsed
   0.450.000.46

Hopefully you can adapt one or more of these functions to your needs.
Dennis

On Fri, Jul 30, 2010 at 1:18 AM, Natasa Tzortzaki tz_nat...@hotmail.comwrote:


 hello,

 i am new to R and trying to calculate the beta coefficient for standard
 linear regression for a series of randomly generated numbers. I have created
 this loop, but it runs really slow, is there a way to improve it?

 #number of simulations
 n.k-999
 #create the matrix for regression coefficients generated from #random data

 beta-matrix(0,1,n.k+1)
 e-matrix(0,tslength,n.k+1)


 for(k in 1:n.k+1)
   {
for(i in 1:tslength)
   {
beta[1,1]-beta1
e[i,k]-c(rnorm(1,0,var.all))
beta[1,k]-summary(lm(e[1:tslength,k]~t))$coefficient[2]
   }
   }
 thanks
 Anastasia Tzortzaki

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


[[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] Need a help to plot bar for time series Rain data

2010-07-30 Thread Jim Lemon

On 07/30/2010 09:24 PM, Nyanzura wrote:


Hi Jim,

Thank you very much, let me check as you suggested. But in addition what do
you think could be easy to interpret? Could you advice me please.


I would probably start with:

plot(times,type=l,...)

if you can makes 'times' into a vector.

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] Sweave line breaks

2010-07-30 Thread Marc Schwartz
On Jul 30, 2010, at 4:13 AM, soeren.vo...@eawag.ch wrote:

 Hello, when I print x in Sweave, the lines do not wrap. However, I want them 
 to wrap (perhaps at a specified width). How? Thanks, *S*
 
 keep.source=TRUE=
 x - Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do 
 eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim 
 veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea 
 commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit 
 esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat 
 cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est 
 laborum.
 print(x)
 @


See ?strwrap and ?paste. Also use cat() instead of print().

The double \\ at the end of each line tells LaTeX to force a line break. 
Since R will detect the \ as an escape character, you need to double them 
when cat()ing. I also add a newline (\n) so that the output after the \\ 
goes to the next line.

 cat(paste(strwrap(x, width = 70), collapse = \n), \n)
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do\\
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim\\
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut\\
aliquip ex ea commodo consequat. Duis aute irure dolor in\\
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla\\
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in\\
culpa qui officia deserunt mollit anim id est laborum. 


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] Data Handling

2010-07-30 Thread Lily_stats

Hi,

I am trying to convert my dataset into xts. I have tried the following :

data1-read.table(data1.txt,header=F)
data2-read.table(data2.txt,header=F)

data1.xtsas.xts(data1,descr=my new xts object)

However, I get an error :

Error in as.POSIXlt.character(x, tz, ...) : 
  character string is not in a standard unambiguous format

I understand that my date and time format might not be accepted and have
tried to convert this but failed. 

Could you suggest something ?

My date is in the format : dd/mm/
My time is in the format : hh:00

Thank you in advance


-- 
View this message in context: 
http://r.789695.n4.nabble.com/Data-Handling-tp2307770p2307936.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] Ouput several lines of cat

2010-07-30 Thread Wu Gong

Hi, set sep=\n

x - c(X XXX,X XX.XX,-  ( XX.XX XXX ) )
cat(x,file=x.txt,sep=\n)

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Ouput-several-lines-of-cat-tp2307900p2307945.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 Handling

2010-07-30 Thread Gabor Grothendieck
On Fri, Jul 30, 2010 at 9:02 AM, Lily_stats sund...@gmail.com wrote:

 Hi,

 I am trying to convert my dataset into xts. I have tried the following :

 data1-read.table(data1.txt,header=F)
 data2-read.table(data2.txt,header=F)

 data1.xtsas.xts(data1,descr=my new xts object)

 However, I get an error :

 Error in as.POSIXlt.character(x, tz, ...) :
  character string is not in a standard unambiguous format

 I understand that my date and time format might not be accepted and have
 tried to convert this but failed.

 Could you suggest something ?

 My date is in the format : dd/mm/
 My time is in the format : hh:00

 Thank you in advance


 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Data-Handling-tp2307770p2307936.html
 Sent from the R help mailing list archive at Nabble.com.


Can't say too much since there is no detail in your post but you can
do something like this:

library(xts) # this also loads zoo
library(chron) # if you wish to use chron
z - read.zoo(...)
x - as.xts(z)

where you may need to use FUN= and possibly the index.column= and
other arguments to read.zoo.  See ?read.zoo and the R News 4/1 article
on dates.

__
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] simple table/matrix problem

2010-07-30 Thread Robin Hankin

Hi

Given  three vectors

 x - c(fish=3, dogs=5, bats=2)
 y - c(dogs=1, hogs=3)
 z - c(bats=3, dogs=5)

How do I create a multi-way table like the following?

 out
 x y z
bats 2 0 3
dogs 5 1 5
fish 3 0 0
hogs 0 3 0

('out' is a matrix).

See how the first line shows 'x' has 2 bats, 'y' has zero bats, and 'z' 
has 3 bats

and so on for each line.
The real application would have a matrix of size ~10 by ~1.




--
Robin K. S. Hankin
Uncertainty Analyst
University of Cambridge
19 Silver Street
Cambridge CB3 9EP
01223-764877

__
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] simple table/matrix problem

2010-07-30 Thread Henrique Dallazuanna
Try this:

Reduce(function(...)merge(..., by = 'ind', all = TRUE), lapply(list(x, y,
z), stack))

On Fri, Jul 30, 2010 at 10:39 AM, Robin Hankin rk...@cam.ac.uk wrote:

 Hi

 Given  three vectors

  x - c(fish=3, dogs=5, bats=2)
  y - c(dogs=1, hogs=3)
  z - c(bats=3, dogs=5)

 How do I create a multi-way table like the following?

  out
 x y z
 bats 2 0 3
 dogs 5 1 5
 fish 3 0 0
 hogs 0 3 0

 ('out' is a matrix).

 See how the first line shows 'x' has 2 bats, 'y' has zero bats, and 'z' has
 3 bats
 and so on for each line.
 The real application would have a matrix of size ~10 by ~1.




 --
 Robin K. S. Hankin
 Uncertainty Analyst
 University of Cambridge
 19 Silver Street
 Cambridge CB3 9EP
 01223-764877

 __
 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] how to get higher derivatives with deriv

2010-07-30 Thread peter dalgaard

On Jul 29, 2010, at 11:27 PM, Wu Gong wrote:

 
 ## specify the function string
 f.str - x^alpha
 
 ## higher derivatives 
 DD - function(f.str, x = 2, alpha=3,order = 1){
 expr.s - parse(text=f.str)
 while(order=1) {
 expr.s - D(expr.s,x)
 order - order-1}
 eval(expr.s)
 }
 
 compute
 DD(f.str,x=1,alpha=0.5,order=1)
 

Somewhat more elegant things can be done, consider for instance

 f
function (x,alpha) x^alpha
 ddf - f
 body(ddf) - D(D(body(f),x),x)
 ddf
function (x, alpha) 
x^((alpha - 1) - 1) * (alpha - 1) * alpha
 ddf(1,.5)
[1] -0.25

(wrapping this as a function which accepts an order argument is left as an 
exercise, because I'm too lazy)

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@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] bonjour

2010-07-30 Thread aline uwimana
Bonjour, je suis une étudiante en épidémiologie. j'utilise R pour mes
analyses, et un souci dans le calcul de l'AIC,BIC, et je pense calcul la
déviance puis à partir de là calculer ces informations manuellement mais
j'ai trouvé quelque chose et je ne suis pas très si c'est la déviance que
j'ai trouvé. si quelqu'un peut m'aider? je vous remercie beaucoup.

[[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 get higher derivatives with deriv

2010-07-30 Thread Ravi Varadhan
I am not as lazy as Peter (but neither am I as good as him)!  So, please
allow me to take a stab at completing his exercise:

Deriv - function(fn, order=1) {
ddf - fn
body(ddf) - D(body(f),x)
if (order  1) {
for (i in 2:order) {
body(ddf) - D(body(ddf),x)
} 
}
ddf
}

f - function (x,alpha) x^alpha

x - seq(0, 3, length=100)

plot(x, f(x, alpha=1.5), type=l, ylab=)

lines(x, Deriv(f, 1)(x, alpha=1.5), col=2)

lines(x, Deriv(f, 2)(x, alpha=1.5), col=3)


Thanks for the elegant solution, Peter.

Best,
Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of peter dalgaard
Sent: Friday, July 30, 2010 9:52 AM
To: Wu Gong
Cc: r-help@r-project.org
Subject: Re: [R] how to get higher derivatives with deriv


On Jul 29, 2010, at 11:27 PM, Wu Gong wrote:

 
 ## specify the function string
 f.str - x^alpha
 
 ## higher derivatives 
 DD - function(f.str, x = 2, alpha=3,order = 1){
 expr.s - parse(text=f.str)
 while(order=1) {
 expr.s - D(expr.s,x)
 order - order-1}
 eval(expr.s)
 }
 
 compute
 DD(f.str,x=1,alpha=0.5,order=1)
 

Somewhat more elegant things can be done, consider for instance

 f
function (x,alpha) x^alpha
 ddf - f
 body(ddf) - D(D(body(f),x),x)
 ddf
function (x, alpha) 
x^((alpha - 1) - 1) * (alpha - 1) * alpha
 ddf(1,.5)
[1] -0.25

(wrapping this as a function which accepts an order argument is left as an
exercise, because I'm too lazy)

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@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.


[R] help for creating arff file..i have the codes??

2010-07-30 Thread Mete

I need to create an arff file.i have the necesaary codes as two parts and i
need to combine them..if there is anyone who can help i'll send the
codes..thank you.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/help-for-creating-arff-file-i-have-the-codes-tp2308039p2308039.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] bonjour

2010-07-30 Thread aline uwimana
Thanx Ivan,
first of all, my english is power but i will try .
my question is about the calculation of AIC, BIC by using svyglm  in order
to choose the best model in  multiple regression.
thanx


Le 30 juillet 2010 16:17, Ivan Calandra ivan.calan...@uni-hamburg.de a
écrit :

  Salut,

 Commence par écrire en anglais. Il y a peut-être une liste spécifique en
 français, mais je ne la connais pas.
 Ensuite, lis le posting guide (lien disponible à la fin de chaque email
 posté sur la liste R).

 Si ces 2 étapes sont bien respectées, tu devrais obtenir des réponses.

 HTH, Ivan


 Le 7/30/2010 16:08, aline uwimana a écrit :

 Bonjour, je suis une étudiante en épidémiologie. j'utilise R pour mes
 analyses, et un souci dans le calcul de l'AIC,BIC, et je pense calcul la
 déviance puis à partir de là calculer ces informations manuellement mais
 j'ai trouvé quelque chose et je ne suis pas très si c'est la déviance que
 j'ai trouvé. si quelqu'un peut m'aider? je vous remercie beaucoup.

   [[alternative HTML version deleted]]



 __r-h...@r-project.org mailing 
 listhttps://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.


Re: [R] how to get higher derivatives with deriv

2010-07-30 Thread peter dalgaard

On Jul 30, 2010, at 4:28 PM, Ravi Varadhan wrote:

 I am not as lazy as Peter (but neither am I as good as him)!  So, please
 allow me to take a stab at completing his exercise:
 
 Deriv - function(fn, order=1) {
 ddf - fn
 body(ddf) - D(body(f),x)
###  Typo: body(ddf) or body(fn)

 if (order  1) {
   for (i in 2:order) {
   body(ddf) - D(body(ddf),x)
   } 
   }
 ddf
 }


Yes. 

One thing: body() and body-() are relatively expensive operations, and only 
really needed on the way in and the way out, so you might want to use a 
temporary variable.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@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] COXPH: how to get the score test and likelihood ratio test for a specific variable in a multivariate Coxph ?

2010-07-30 Thread Biau David
Hello,

I would like to get the likelihood ratio and score tests for specific variables 
in a multivariate coxph model. The default is Wald, so the tests for each 
separate variable is based on Wald's test. I have the other tests for the full 
model but I don't know how to get them for each variable.

Any idea?

 David Biau.



  
[[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] hi! l have a question please help me

2010-07-30 Thread Tal Galili
Is this a question from your homework?



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 Fri, Jul 30, 2010 at 8:14 AM, leepama butch...@hanmail.net wrote:


 1)
 dmatrix1-function(n,p,rho,sigma,k){
  muvec1=zeros(1,p)
  truep-as.matrix(c(3,1.5,0,0,2,0,0,0))
  A=eye(p)
  for(i in 1:p){
   for(j in 1:p){
A[i,j]=rho^(abs(i-j))
 X=mvrnorm(n,muvec1,A)
 y=X%*%truep+as.matrix(rnorm(n,0,sigma))
 Y=X[1:k,]
 w=y[1:k]
 Z=X[(k+1):n,]
 z=y[(k+1):n]}}
  return(list(X,Y,w,Z,z))
 }
 I made this code which performs design matrix..
 Can you help me how to make several data set??
 the code i made compute only one data set...

 2) we generate 50 data with 30 variables. The true regression
 vector is such that
 bj = 3 − 0.1j j = 1, . . . , 10,
 bj = −5 + 0.3j j = 20, . . . , 25,
 bj = 0 for the others j.
 The noise is such that sigma = 9 and the correlations are such that (j, k)
 =
 exp (−|j−k|/2  for (j, k) ∈ {11, . . . , 25}2 and the others variables 
 are
 i.i.d. N(0, 1),
 also independent from x11, . . . , x25
 how to simulate this data set

 3)we simulated 50 data sets and 40 predictors.

 β=(3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
 and σ=15. The predictors X were generated as follows:
 xi=Z1+xi
 , Z1∼N.(0,1), i=1, . . . ,5,
 xi=Z2+xi
 , Z2∼N.(0,1), i=6, . . . ,10,
 xi=Z3+xi
 , Z3∼N.(0,1), i=11, . . . ,15,
 xi∼N.(0,1), xi independent identically distributed, i=16, : : : , 40
 how to simulate this data set

 --
 View this message in context:
 http://r.789695.n4.nabble.com/hi-l-have-a-question-please-help-me-tp2307569p2307569.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.


Re: [R] Out-of-sample predictions with boosting model

2010-07-30 Thread TravisB

Thanks, Ben.

Specifying the data in this way should give me what I need - I can do this
in a loop fairly easily and wind up with what I want in the end. And I
should've been more specific, I think that mboost can handle time-series
data, it's the fact that the data is a panel bit that was giving me
issues--I'd like to think about using base learners that can handle panel
data in the future so if you have any suggestions there I'd be happy to hear
them.

Also, don't worry, the models I specify are tuned and I have thought about
what base learners are appropriate; I left it as a blackbox for the
exposition of my post. :)

Anyway, many thanks,

Travis
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Out-of-sample-predictions-with-boosting-model-tp2305458p2308082.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] logos and goodies

2010-07-30 Thread Tal Galili
Interesting topic and question.
I hope someone who knows will answer this.



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 Fri, Jul 30, 2010 at 5:06 AM, c...@witthoft.com wrote:


   I've got a couple questions related to my search (in vain) for an R
 tshirt
   or coffee mug.   The first question is simply: is there a
 higher-resolution
   R logo available than the one at r-developer.org?  (or the modified one
   provided by useR conference pages)
   Next: what are the chances of someone in the R management setting up a
   cafepress.com  R store for shirts, coffee mugs, etc?   I just sort of
   figured what with Firefox, Ubuntu, etc. selling product, R could do so as
   well.
   (I have all the gear I need to make myself a tshirt w/ the logo, but not
 as
   high quality as cafepress does)
   The  other thing I noticed is that the link to the R logos' directory,
   http://developer.r-project.org/Logo,  is blocked to the general public.
   Luckily, if you know the name of the image files is Rlogo-[1-6].png,
 you
   can  still download the images.  Any reason the /Logo directory itself
   couldn't be made read-accessible?
   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.


[[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] Next release of R planned to be 2.12.0

2010-07-30 Thread Peter Dalgaard
This mainly as a thumbs-up to sysadmins planning installation for the Fall 
semester: 

Only a small number of low-impact bugs have been found since the 2.11.1 release 
so we have decided NOT to do a 2.11.2, but head straight for 2.12.0 some time 
in October.

For the R Core Team
Peter Dalgaard

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

___
r-annou...@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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] COXPH: how to get the score test and likelihood ratio test for a specific variable in a multivariate Coxph ?

2010-07-30 Thread David Winsemius


On Jul 30, 2010, at 11:08 AM, Biau David wrote:


Hello,

I would like to get the likelihood ratio and score tests for  
specific variables
in a multivariate coxph model. The default is Wald, so the tests for  
each
separate variable is based on Wald's test. I have the other tests  
for the full

model but I don't know how to get them for each variable.

Any idea?



The first idea would be to specify which function in which package you  
are asking questions about. In the case of coxph in the survival  
package, for instance, you do get a likelihood ratio test (==  
differences in log-likelihoods) by default. A score test is, at least  
as as I understand it for individual variables, equivalent to a Wald  
test, so I don't really understand your question, since youa re  
already getting all of that in the survival package.


(You can extract a score value and loglik values from a coxph object  
by:

(with the first example in the coxph help page)

 coxph(Surv(time, status) ~ x + strata(sex), test1)$score
xoxph(Surv(time, status) ~ x + strata(sex), test1)$loglik

But anova(coxph-object) would give you these values in a neater bundle.
#Analysis of Deviance Table
# Cox model: response is Surv(time, status)
#Terms added sequentially (first to last)
#  loglik  Chisq Df Pr(|Chi|)
# NULL -3.8712
# x-3.3277 1.0871  1 0.2971

The question about getting them for each variable does not make a  
lot of sense to me, since likelihood tests are model comparisons. You  
can only make such statements about the consequences of adding or  
deleting a variable to/from an existing model.


--
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] logos and goodies

2010-07-30 Thread peter dalgaard

On Jul 30, 2010, at 4:06 AM, c...@witthoft.com wrote:

 
   I've got a couple questions related to my search (in vain) for an R tshirt
   or coffee mug.   The first question is simply: is there a higher-resolution
   R logo available than the one at r-developer.org?  (or the modified one
   provided by useR conference pages)

I think that's a setup error, it is not even accessible to the Core Team... 
(Ideally, there should be a usage policy statement in the directory, but you 
know what paves the road to Hell.) 

If you had been able to see the directory, you might have seen one attempt of a 
vector graphics version in Rlogo-1.svg. There was a thread on the issue on 
R-devel at the end of February, outlining the procedure for creating it. I am 
sure that it could be improved substantially with some additional fiddling (the 
present one was intended for highly compressed icons; it looks rather irregular 
at large magnifications).

   Next: what are the chances of someone in the R management setting up a
   cafepress.com  R store for shirts, coffee mugs, etc?   I just sort of
   figured what with Firefox, Ubuntu, etc. selling product, R could do so as
   well.
   (I have all the gear I need to make myself a tshirt w/ the logo, but not as
   high quality as cafepress does)
   The  other thing I noticed is that the link to the R logos' directory,
   http://developer.r-project.org/Logo,  is blocked to the general public.
   Luckily, if you know the name of the image files is Rlogo-[1-6].png, you
   can  still download the images.  Any reason the /Logo directory itself
   couldn't be made read-accessible?
   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.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@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] Re : COXPH: how to get the score test and likelihood ratio test for a specific variable in a multivariate Coxph ?

2010-07-30 Thread Biau David
Thx for the answer.

I am using survival.

I didn't know that the Wald and score tests were the same for individual 
variables in a coxph; I Thought the score test was the multivariate version 
of 
the Log-rank.

However, say I have only one variable in the model, I should expect the test 
for 
the full model and the one for a single variable to be the same? Then it seems 
to me that the default test is the Wald and that the Wald and the Score are 
different.

 cox_lr_age - coxph(Surv(tilr, ev_lr==1)~age, data=tam)
 summary(cox_lr_age)
Call:
coxph(formula = Surv(tilr, ev_lr == 1) ~ age, data = tam)

  n=2156 (76 observations deleted due to missingness)

coef exp(coef) se(coef) z Pr(|z|)
age 0.019504  1.019696 0.004651 4.193 2.75e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ 
’ 1 

exp(coef) exp(-coef) lower .95 upper .95
age 1.020 0.9807 1.010 1.029

Rsquare= 0.008   (max possible= 0.669 )
Likelihood ratio test= 18.4  on 1 df,   p=1.787e-05
Wald test= 17.58  on 1 df,   p=2.751e-05
Score (logrank) test = 17.86  on 1 df,   p=2.375e-05


 David Biau.





De : David Winsemius dwinsem...@comcast.net

Cc : r help list r-help@r-project.org
Envoyé le : Ven 30 juillet 2010, 17h 34min 28s
Objet : Re: [R] COXPH: how to get the score test and likelihood ratio test for 
a 
specific variable in a multivariate Coxph ?


On Jul 30, 2010, at 11:08 AM, Biau David wrote:

 Hello,
 
 I would like to get the likelihood ratio and score tests for specific 
variables
 in a multivariate coxph model. The default is Wald, so the tests for each
 separate variable is based on Wald's test. I have the other tests for the full
 model but I don't know how to get them for each variable.
 
 Any idea?
 

The first idea would be to specify which function in which package you are
asking questions about. In the case of coxph in the survival package, for 
instance, you do get a likelihood ratio test (== differences in 
log-likelihoods) 
by default. A score test is, at least as as I understand it for individual
variables, equivalent to a Wald test, so I don't really understand your 
question, since youa re already getting all of that in the survival package.

(You can extract a score value and loglik values from a coxph object by:
(with the first example in the coxph help page)

coxph(Surv(time, status) ~ x + strata(sex), test1)$score
xoxph(Surv(time, status) ~ x + strata(sex), test1)$loglik

But anova(coxph-object) would give you these values in a neater bundle.
#Analysis of Deviance Table
# Cox model: response is Surv(time, status)
#Terms added sequentially (first to last)
#  loglik  Chisq Df Pr(|Chi|)
# NULL -3.8712
# x-3.3277 1.0871  1 0.2971

The question about getting them for each variable does not make a lot of 
sense 
to me, since likelihood tests are model comparisons. You can only make such
statements about the consequences of adding or deleting a variable to/from an 
existing model.

--David Winsemius, MD
West Hartford, CT


  
[[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 get higher derivatives with deriv

2010-07-30 Thread Wu Gong

Hi Peter,

Here is my homework :)

DD - function(f,order=1){
f.str - body(f)
while(order=1) {
f.str - paste('D(',f.str,',x)',sep=)
order - order-1}
ddf - f
body(ddf) - eval(parse(text=f.str))
ddf}

f - function(x,alpha) x^alpha
DD(f)(2,3)
g - function(x,alpha) x^alpha+2*x^(alpha-1)
DD(g,2)(2,3)

It would be better to handle expressions directly, but I can only paste
strings. The reason why I didn't prefer using body() is that the derivative
only works on a mathematical function not a R function. The body(f) would
cause error when function is constructed by {}.
 

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-get-higher-derivatives-with-deriv-tp2306711p2308143.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] Need to read an Excel File

2010-07-30 Thread rajibshibly

I am trying to read an Excel file using the following:
a-read.xls(mydata.xls, sheet=1)

The file mydata.xls is stored in the working directory. However I am getting
the following error. Can anyone help.

Error in findPerl(verbose = verbose) : 
  perl executable not found. Use perl= argument to specify the correct path.
Error in file.exists(tfn) : invalid 'file' argument

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Need-to-read-an-Excel-File-tp2307915p2307915.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] Ouput several lines of cat

2010-07-30 Thread rajibshibly

Hello,
I am brand new to R. I need to know how to output the contents of cat
function into a text file. The cat is used to output several lines of string
in the following format:
X XXX
X XX.XX 
-  ( XX.XX XXX ) 

I need to get the output of all these lines into a text file.
I tried to put a file name in the cat function. However the output file only
displays single line output. 
Thanks

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Ouput-several-lines-of-cat-tp2307900p2307900.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] (no subject)

2010-07-30 Thread Daniel Nordlund
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Natasa Tzortzaki
 Sent: Friday, July 30, 2010 1:19 AM
 To: r-help@r-project.org
 Subject: [R] (no subject)
 
 
 hello,
 
 i am new to R and trying to calculate the beta coefficient for standard
 linear regression for a series of randomly generated numbers. I have
 created this loop, but it runs really slow, is there a way to improve it?
 
 #number of simulations
 n.k-999
 #create the matrix for regression coefficients generated from #random data
 
 beta-matrix(0,1,n.k+1)
 e-matrix(0,tslength,n.k+1)
 
 
 for(k in 1:n.k+1)
{
 for(i in 1:tslength)
{
 beta[1,1]-beta1
 e[i,k]-c(rnorm(1,0,var.all))
 beta[1,k]-summary(lm(e[1:tslength,k]~t))$coefficient[2]
}
}
 thanks
 Anastasia Tzortzaki
 

Anastasia,

You haven't provided a reproducible example, so I am going to guess at some of 
what you are doing.  You also have used some function names for your variable 
names which I like to avoid, so I have used 'b' as the name of the vector for 
collecting beta coefficients and 'ts' for the predictor variable.  I have set 
var.all equal to 1.

To speed up your process, you want to eliminate looping as much as possible.  
In addition, you should pre-allocate space for vectors that you are going to 
fill up in a loop.  Your e values can all be generated at once outside of your 
loop.  I also used the coef() extractor function directly on the lm() object.  
So, you could do something like the following:

# number of simulations
n.k - 999

# predictor variable
ts - 1:100

tslength - length(ts)
var.all - 1

# pre-allocate vector to collect beta coefficients
b - numeric(n.k)

# generate your e values all at once
# columns contain values for each simuation trial 
e - matrix(rnorm(n.k*tslength,0,var.all), ncol = n.k)

# run your analyses
for(k in 1:n.k) 
  {
   b[k] - coef(lm(e[,k] ~ ts))[2]
  }

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA USA

__
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] Data Handling

2010-07-30 Thread Lily_stats

Hi, 

I am very new to R so these questions may seem simple!

I have a huge 2 sets of data(matrix 5x2++) in the following formats ,
for example data.txt and data2.txt:

Date   Time X   Y
03/03/1983  20:00   0.1  990

I would like to recreate a new matrix which filters through data.txt and
data2.txt to get something as below :

Date Time   X_data1  X_data2   
Y_data1  Y_data2
31/12/2000 12:00 2.25  0
   
990

So I basically need :
1) When Date AND Time from data1.txt and data2.txt match, list the
corresponding X and Y values (X_data1,X_data2,Y_data1,Y_data2)

Thank you in advance, and I hope I have been clear enough in my message
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Data-Handling-tp2307770p2307770.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] Reading .eps file created in Illustrator

2010-07-30 Thread Patrick Schorderet

Hello,

I am trying to import an .eps file created with Adobe Illustrator and  
plot it in a Quartz window (I am using R 2.11.1 GUI 1.34 Leopard build  
32-bit (5589) on MacOSx.5.8).
I thought of using the PostScriptTrace() to convert my .eps file to  
RGML,  and then use readPicture to plot the file, but the first step  
already fails (cf below).
I also had a look at the add.image( ) example, which does work on my  
screen.
Ultimately, I would like to plot my picture and let the user click on  
different parts to run different actions.
Thanks for any help or alternative ways to do this,

Patrick


PostScriptTrace(test.eps)
/bin/sh: gs: command not found
Erreur dans PostScriptTrace(test.eps) :
   status 32512 in running command 'gs -q -dBATCH -dNOPAUSE - 
sDEVICE=pswrite -sOutputFile=/dev/null -sstdout=test.eps.xml  
capturetest.eps'
[[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] Having problem to define a subclass, please help me

2010-07-30 Thread Megh Dal
Here I am having problem to define a subclass, specially if I define that 
subclass after defining initialize() method for its superclass. Here is my code:

 setClass(a, representation=list(x=numeric, y=numeric), 
 prototype=list(x=rnorm(10), y=rnorm(10)))
[1] a
 setMethod(initialize, a, function(.Object, x, y, ...) {
+ if (length(x) != length(y)) x = y = rep(5, 4)
+ .obj...@x = x
+ .obj...@y = y
+ .Object })
[1] initialize
 setClass(b, representation=list(x1=character), contains=a)
Error in .local(.Object, ...) : element 1 is empty;
   the part of the args list of 'length' being evaluated was:
   (x)
 

Can anyone please point me where I am doing wrong?

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.


[R] finding a function or a line while debugging?

2010-07-30 Thread Raghu
guRus

Is there a way by which I can search for a particular function or a
particular line of code within the maze of all the R codes that are
interlinked? Say for instance I am running a code using quantstrat package
and on a particular line I get the error saying x is missing in is.array(x).
I want to figure out where is.array is in all the codes that my code refers
to? How do I do this? Is there like a grep or search function that can say
tell me that 'here is the function inside which is.array(X) is being called'
etc?

out-try(applyStrategy(strategy=stratSMA5D , portfolios=portfolio.st))
Error in is.array(x) : 'x' is missing

Thx
-- 
'Raghu'

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

2010-07-30 Thread raghu

Convert your datasets into xts objects and then do a cbind ordering by the
column you want. Do a ?cbind.

HTH
Raghu

On Fri, Jul 30, 2010 at 10:33 AM, Lily_stats [via R] 
ml-node+2307770-1033893256-309...@n4.nabble.comml-node%2b2307770-1033893256-309...@n4.nabble.com
 wrote:

 Hi,

 I am very new to R so these questions may seem simple!

 I have a huge 2 sets of data(matrix 5x2++) in the following formats ,
 for example data.txt and data2.txt:

 Date   Time X   Y
 03/03/1983  20:00   0.1  990

 I would like to recreate a new matrix which filters through data.txt and
 data2.txt to get something as below :

 Date Time   X_data1  X_data2
  Y_data1  Y_data2
 31/12/2000 12:00 2.25
  0990

 So I basically need :
 1) When Date AND Time from data1.txt and data2.txt match, list the
 corresponding X and Y values (X_data1,X_data2,Y_data1,Y_data2)

 Thank you in advance, and I hope I have been clear enough in my message

 --
  View message @
 http://r.789695.n4.nabble.com/Data-Handling-tp2307770p2307770.html
 To start a new topic under R help, email
 ml-node+789696-608741344-309...@n4.nabble.comml-node%2b789696-608741344-309...@n4.nabble.com
 To unsubscribe from R help, click here (link removed) .





-- 
'Raghu'

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


Re: [R] Data Handling

2010-07-30 Thread raghu

Please try:
data -  xts(data[,2:n], order.by=as.POSIXct(strptime(data[,1],
%d/%m/%Y)))

Use similar strptime for hours also.n=number of columns.

Good Luck
Raghu

On Fri, Jul 30, 2010 at 2:02 PM, Lily_stats [via R] 
ml-node+2307936-1777222343-309...@n4.nabble.comml-node%2b2307936-1777222343-309...@n4.nabble.com
 wrote:

 Hi,

 I am trying to convert my dataset into xts. I have tried the following :

 data1-read.table(data1.txt,header=F)
 data2-read.table(data2.txt,header=F)

 data1.xtsas.xts(data1,descr=my new xts object)

 However, I get an error :

 Error in as.POSIXlt.character(x, tz, ...) :
   character string is not in a standard unambiguous format

 I understand that my date and time format might not be accepted and have
 tried to convert this but failed.

 Could you suggest something ?

 My date is in the format : dd/mm/
 My time is in the format : hh:00

 Thank you in advance



 --
  View message @
 http://r.789695.n4.nabble.com/Data-Handling-tp2307770p2307936.html
 To start a new topic under R help, email
 ml-node+789696-608741344-309...@n4.nabble.comml-node%2b789696-608741344-309...@n4.nabble.com
 To unsubscribe from R help, click here (link removed) .





-- 
'Raghu'

-- 
View this message in context: 
http://r.789695.n4.nabble.com/Data-Handling-tp2307770p2307959.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] Computation of largest eigenvalue

2010-07-30 Thread Christian Weiß

 Hello,

I am looking for an R function to compute only the largest eigenvalue 
(Perron-Frobenius eigenvalue) and its corresponding eigenvector of a 
square matrix (in fact, even only of a non-negative matrix). The 
function should also be able to deal with very large but sparse matrices.


Any idea?

Best regards,

Christian Weiß


--

Dr. Christian H. Weiß

Fachbereich Mathematik
Technische Universität Darmstadt
Schlossgartenstraße 7
64289 Darmstadt
-Deutschland-

Tel.: +6151/16-3787
Email: we...@mathematik.tu-darmstadt.de
Homepage: 
http://www3.mathematik.tu-darmstadt.de/fileadmin/home/users/157/person/Person.html

--

Dein Leben wird auch dadurch nicht flach und
dumm, wenn du weißt, daß dein Kampf erfolglos
sein wird. Es ist viel flacher, wenn du für
etwas Gutes und Ideales kämpfst und nun
meinst, du müsstest es auch erreichen. Sind
denn Ideale zum Erreichen da? Leben wir denn,
um den Tod abzuschaffen? - HERMANN HESSE

__
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] creation package

2010-07-30 Thread anderson nuel
Dear r-help,

I create a package. When I installed this package (I use this command : R
CMD check namepackage),I find an error: * checking whether package
'namepackage' can be installed ... ERROR
Installation failed.

Could you help me to find solution  for this error.


Best 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] ColSideColor width in heatmap.2

2010-07-30 Thread Poetsch Anna
Dear R users,

I am trying to add a ColSideColor- bar to a heatmap created with heatmap.2.
I had to adjust the width of the heatmap, for which I used asp = 0.8.
Now the ColSideColor- Bar does not fit to the width of the heatmap anymore.
Does anyone have an idea, how I can adjust the width of the bar?

Here is a simplified example:

library(gplots)

m - matrix(1:300,30,10)
heatmap.2 ( m, asp =0.8,  dendrogram = none, key = FALSE, density.info = 
none, trace = none,
  ColSideColors = 
c(yellow,orange,red,pink,purple,blue,lightblue,lightgreen,green,black))



Thanks,
Anna


[[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 Equivalent of SAS Datastep Line-Hold (@@) Specifier?

2010-07-30 Thread Paul Miller
Hello Dr. Venables and Joshua,
 
Thank you for your replies to my post. Dr. Venables's solution is particularly 
elegant. I looked at the the help file for scan() and it seems pretty clear how 
this works. Two arguments (file= and what=) are submitted to the function. 
These are specified in order and so do not specifically need to be named. 
 
The what= argument can take the form of a list as it does here. Naming 6 
variables in the list and initializing them to either 0 or  tells R how many 
variables it's going to read, their names, and their type. So presumably when R 
encounters the first of 12 additional values in each row, it assumes that it 
should continually recycle the same six variables that were specified until it 
reaches the end of the row. And so it keeps on reading.
 
Is this correct?
 
Thanks,
 
Paul

--- On Fri, 7/30/10, bill.venab...@csiro.au bill.venab...@csiro.au wrote:


From: bill.venab...@csiro.au bill.venab...@csiro.au
Subject: RE: [R] R Equivalent of SAS Datastep Line-Hold (@@) Specifier?
To: jwiley.ps...@gmail.com, pjmiller...@yahoo.com
Cc: r-help@r-project.org
Received: Friday, July 30, 2010, 2:44 AM


There is a much simpler way.

con - textConnection(
A 1 101 M 55  5   A 1 104 F 27  0   A 1 106 M 31 35
A 1 107 F 44 21   A 1 109 M 47 15   A 1 111 F 69 70
A 1 112 F 31 10   A 1 114 F 50  0   A 1 116 M 32 20
A 1 118 F 39 25   A 1 119 F 54  0   A 1 121 M 70 38
A 1 123 F 57 55   A 1 124 M 37 18   A 1 126 F 41  0
A 1 128 F 48  8   A 1 131 F 35  0   A 1 134 F 28  0
A 1 135 M 27 40   A 1 138 F 42 12   A 2 202 M 58 68
A 2 203 M 42 22   A 2 206 M 26 30   A 2 207 F 36  0
A 2 210 F 35 25   A 2 211 M 51  0   A 2 214 M 51 60
A 2 216 F 42 15   A 2 217 F 50 50   A 2 219 F 41 35
A 2 222 F 59  0   A 2 223 F 38 10   A 2 225 F 32  0
A 2 226 F 28 16   A 2 229 M 42 48   A 2 231 F 51 45
A 2 234 F 26 90   A 2 235 M 42  0   A 3 301 M 38 28
A 3 302 M 41 20   A 3 304 M 65 75   A 3 306 F 64  0
A 3 307 F 30 30   A 3 309 F 64  5   A 3 311 M 39 80
A 3 314 F 57 85   A 3 315 M 61 12   A 3 318 F 45 95
A 3 319 F 34 26   A 3 321 M 39 10   A 3 324 M 27  0
A 3 325 F 56 35   B 1 102 M 19 68   B 1 103 F 51 10
B 1 105 M 45 20   B 1 108 F 44 65   B 1 110 M 32 25
B 1 113 M 61 75   B 1 115 M 45 83   B 1 117 F 21  0
B 1 120 F 19 55   B 1 122 F 38  0   B 1 125 M 37 72
B 1 127 F 53 40   B 1 129 M 48  0   B 1 130 F 36 80
B 1 132 M 49 20   B 1 133 F 28  0   B 1 136 F 34 45
B 1 137 F 57 95   B 1 139 F 47 40   B 1 140 M 29  0
B 2 201 F 63 10   B 2 204 M 36 49   B 2 205 M 36 16
B 2 208 F 48 12   B 2 209 F 42 40   B 2 212 F 32  0
B 2 213 M 24 88   B 2 215 M 40 59   B 2 218 M 31 24
B 2 220 F 45 72   B 2 221 F 27 55   B 2 224 M 56 70
B 2 227 F 41  0   B 2 228 F 24 65   B 2 230 M 44 30
B 2 232 M 37 32   B 2 233 F 33  0   B 3 303 M 40 26
B 3 305 M 46 15   B 3 308 M 59 82   B 3 310 F 62 38
B 3 312 M 52 40   B 3 313 F 33 40   B 3 316 M 62 87
B 3 317 M 52 60   B 3 320 F 32  2   B 3 322 F 43  0
B 3 323 F 51 35
)
Example_Trial - data.frame(scan(con, list(Trt = , Centre = 0, 
                Patient = 0, Sex = , Age = 0, Score = 0)))

## 
 head(Example_Trial)
  Trt Centre Patient Sex Age Score
1   A      1     101   M  55     5
2   A      1     104   F  27     0
3   A      1     106   M  31    35
4   A      1     107   F  44    21
5   A      1     109   M  47    15
6   A      1     111   F  69    70

Rather than use a textConnection, you would probably just use a file. 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Joshua Wiley
Sent: Friday, 30 July 2010 4:59 PM
To: Paul Miller
Cc: r-help@r-project.org
Subject: Re: [R] R Equivalent of SAS Datastep Line-Hold (@@) Specifier?

This gets you to a matrix, though it is messy and you would still have
to convert some of the columns from character to numeric, but maybe it
will give you an idea.


matrix(data = unlist(strsplit(x = readLines(textConnection(
A 1 101 M 55  5   A 1 104 F 27  0   A 1 106 M 31 35
A 1 107 F 44 21   A 1 109 M 47 15   A 1 111 F 69 70
A 1 112 F 31 10   A 1 114 F 50  0   A 1 116 M 32 20
A 1 118 F 39 25   A 1 119 F 54  0   A 1 121 M 70 38
A 1 123 F 57 55   A 1 124 M 37 18   A 1 126 F 41  0
A 1 128 F 48  8   A 1 131 F 35  0   A 1 134 F 28  0
A 1 135 M 27 40   A 1 138 F 42 12   A 2 202 M 58 68
A 2 203 M 42 22   A 2 206 M 26 30   A 2 207 F 36  0
A 2 210 F 35 25   A 2 211 M 51  0   A 2 214 M 51 60
A 2 216 F 42 15   A 2 217 F 50 50   A 2 219 F 41 35
A 2 222 F 59  0   A 2 223 F 38 10   A 2 225 F 32  0
A 2 226 F 28 16   A 2 229 M 42 48   A 2 231 F 51 45
A 2 234 F 26 90   A 2 235 M 42  0   A 3 301 M 38 28
A 3 302 M 41 20   A 3 304 M 65 75   A 3 306 F 64  0
A 3 307 F 30 30   A 3 309 F 64  5   A 3 311 M 39 80
A 3 314 F 57 85   A 3 315 M 61 12   A 3 318 F 45 95
A 3 319 F 34 26   A 3 321 M 39 10   A 3 324 M 27  0
A 3 325 F 56 35   B 1 102 M 19 68   B 1 103 F 51 10
B 1 105 M 45 20   B 1 108 F 44 65   B 1 110 M 32 25
B 1 113 M 61 75   B 1 115 M 45 83   B 1 117 F 21  0
B 1 120 F 19 55   B 1 122 F 38  0   B 1 125 M 37 72
B 

Re: [R] simple table/matrix problem

2010-07-30 Thread William Dunlap


Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com  

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Robin Hankin
 Sent: Friday, July 30, 2010 6:40 AM
 To: r-help@r-project.org
 Subject: [R] simple table/matrix problem
 
 Hi
 
 Given  three vectors
 
   x - c(fish=3, dogs=5, bats=2)
   y - c(dogs=1, hogs=3)
   z - c(bats=3, dogs=5)
 
 How do I create a multi-way table like the following?
 
   out
   x y z
 bats 2 0 3
 dogs 5 1 5
 fish 3 0 0
 hogs 0 3 0

You could try using a matrix subscript to a matrix
to insert the values, as in:

f - function (dataList) 
{
animals - sort(unique(a - unlist(lapply(dataList, names),
use.names = FALSE)))
variables - names(dataList)
retval - array(0, dim = c(length(animals), length(variables)), 
dimnames = list(animals, variables))
retval[cbind(match(a, animals), rep(seq_along(dataList), 
 vapply(dataList, length, integer(1] -
unlist(dataList, use.names = FALSE)
retval
}
 f(list(x=x,y=y,z=z))
 x y z
bats 2 0 3
dogs 5 1 5
fish 3 0 0
hogs 0 3 0

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 
 ('out' is a matrix).
 
 See how the first line shows 'x' has 2 bats, 'y' has zero 
 bats, and 'z' 
 has 3 bats
 and so on for each line.
 The real application would have a matrix of size ~10 by ~1.
 
 
 
 
 -- 
 Robin K. S. Hankin
 Uncertainty Analyst
 University of Cambridge
 19 Silver Street
 Cambridge CB3 9EP
 01223-764877
 
 __
 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] Using R for Multiple Regression

2010-07-30 Thread Ambikesh Jayal
Hi,

Subject: Using R for Multiple Regression

I am new to statistic but am interested in applying mathematical models to
solve biological problems. I have used a linear model to generate the test
data. When using this data I expect R to correctly identify the model but
that does not seem to be the case. I am certain that I am doing something
wrong but not able to figure it out.

Model:
Y = m1x1 + m2x2+ m3X3 + c

m1=5
m2=6
m3=0
c=2

Model Identified by R using lm(formula = y ~ x1 + x2 + x3)
(Intercept) 8.000e+01
x1  1.100e+01
x2 NA
x3 NA


The data I am using is as follows:

y x1 x2 x3
91 1 14 2
102 2 15 5
113 3 16 8
124 4 17 11
135 5 18 14
146 6 19 17
157 7 20 20
168 8 21 23
179 9 22 26
190 10 23 29

Kind regards

Dr. Ambikesh Jayal,
Department of Information Systems, Computing and Mathematics
Room 134 St John's Building
Brunel University
Uxbridge, Middlesex
UB8 3PH, UK
Website: http://sites.google.com/site/ambi1999/

[[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] multiple graphics windows open

2010-07-30 Thread Tal Galili
Hi Erin,

Could you please add a simple self contained code for us to try and help you
with?
(giving us code with  doesn't help)

Best,
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 Thu, Jul 29, 2010 at 10:21 PM, Erin Hodgess erinm.hodg...@gmail.comwrote:

 Dear R People:

 Now I have a function with 3 graphics windows.  I'd like for them all
 to be visible.  However, the first window goes blank.  Here is the
 basic setup.  The first plot is the entire series.  The user selects
 two points, which in turns generates a subset plot and an EWMA subset
 plot.  Finally, if things worked right, the user should be able to
 click on Tile Vertically and see all 3 windows.  Also, there should
 be a line segment on the original plot connecting the two selected
 points.

  library(zoo)
  xdate - seq(as.Date(1998-01-01),as.Date(2010-06-30),by=day)
  length(xdate)
 [1] 4564
  xt - zoo(rnorm(4564),order=xdate)
  eplot
 function (x)
 {
x11()
plot(x)
z - locator(2)
x11()
plot(window(x, start = min(z$x), end = max(z$x)))
  dev.set(dev.prev())
 segments(z$x[1],z$y[1],z$x[2],z$y[2],col=red)
dev.set(dev.next())
x11()
ewma(window(x, start = min(z$x), end = max(z$x)))
dev.set(dev.prev())
return(z)
 }
  eplot(xt)
 $x
 [1]  9400.369 11592.073

 $y
 [1] 3.641633 3.353061

 

 How do I get that original plot to appear without losing any of the
 other plots, please?

 Thanks,
 Erin

 --
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: erinm.hodg...@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.


[[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] hi! l have a question please help me

2010-07-30 Thread leepama

yes!!

I join group study that study R-programming...

so  I really tried..only to fail and made many erros..
 I really don't know
how to perform this...

-- 
View this message in context: 
http://r.789695.n4.nabble.com/hi-l-have-a-question-please-help-me-tp2307569p2308091.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] finding a function or a line while debugging?

2010-07-30 Thread Duncan Murdoch

On 30/07/2010 8:04 AM, Raghu wrote:

guRus

Is there a way by which I can search for a particular function or a
particular line of code within the maze of all the R codes that are
interlinked? Say for instance I am running a code using quantstrat package
and on a particular line I get the error saying x is missing in is.array(x).
I want to figure out where is.array is in all the codes that my code refers
to? How do I do this? Is there like a grep or search function that can say
tell me that 'here is the function inside which is.array(X) is being called'
etc?

out-try(applyStrategy(strategy=stratSMA5D , portfolios=portfolio.st))
Error in is.array(x) : 'x' is missing


?traceback

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] Need to read an Excel File

2010-07-30 Thread Gabor Grothendieck
On Fri, Jul 30, 2010 at 8:39 AM, rajibshibly rajibshi...@yahoo.com wrote:

 I am trying to read an Excel file using the following:
 a-read.xls(mydata.xls, sheet=1)

 The file mydata.xls is stored in the working directory. However I am getting
 the following error. Can anyone help.

 Error in findPerl(verbose = verbose) :
  perl executable not found. Use perl= argument to specify the correct path.
 Error in file.exists(tfn) : invalid 'file' argument


The error message seems self explanatory.  It says it could not find
perl and it is advising you to use the perl= argument of read.xls to
specify where perl is.  Alternately add perl to your path so it can
find it.

The ?read.xls help page includes examples of using the perl argument.

Please ensure you communicate which package you are using next time (I
gather from the context its gdata but it might not be obvious).

__
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] standard error for predicted mean count from ZIP

2010-07-30 Thread Brian S Cade
Does anyone have code for computing the standard error of the predicted 
mean count from a zero-inflated Poisson regression model estimated by the 
zeroinfl() function from the pscl package (and yes, we've checked with A. 
Z. already)?

Thank you

Brian

Brian S. Cade, PhD

U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bldg. C
Fort Collins, CO  80526-8818

email:  brian_c...@usgs.gov
tel:  970 226-9326
[[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] finding a function or a line while debugging?

2010-07-30 Thread Duncan Murdoch

On 30/07/2010 8:04 AM, Raghu wrote:

guRus

Is there a way by which I can search for a particular function or a
particular line of code within the maze of all the R codes that are
interlinked? Say for instance I am running a code using quantstrat package
and on a particular line I get the error saying x is missing in is.array(x).
I want to figure out where is.array is in all the codes that my code refers
to? How do I do this? Is there like a grep or search function that can say
tell me that 'here is the function inside which is.array(X) is being called'
etc?

out-try(applyStrategy(strategy=stratSMA5D , portfolios=portfolio.st))
Error in is.array(x) : 'x' is missing


?traceback

For more info, see the somewhat outdated 
http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR pages.


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] Ouput several lines of cat

2010-07-30 Thread Ted Harding
On 30-Jul-10 12:20:35, rajibshibly wrote:
 Hello,
 I am brand new to R. I need to know how to output the contents
 of cat function into a text file. The cat is used to output
 several lines of string in the following format:
 X XXX
 X XX.XX 
 -  ( XX.XX XXX ) 
 
 I need to get the output of all these lines into a text file.
 I tried to put a file name in the cat function. However the output
 file only displays single line output. 
 Thanks

cat() is somewhat special in that, by default, it does not output
a new line after each element in the list being output:

  cat(A B C,D E F,G H I)
  # A B C D E F G H I

However, you can get it to inset one by using the sep argument
(default sep =   as in the above output):

  cat(A B C,D E F,G H I,sep=\n)
  # A B C
  # D E F
  # G H I

See the description in '?cat'. The name cat, as in UNIX 'cat',
is an abbreviation for catenate, which means to string things
together in a chain. Hence the default behaviour above (but with
spaces inserted to separate the original elements). For a true
catenation, with nothing separating the chained elements, see:

  cat(A B C,D E F,G H I,sep=)
  # A B CD E FG H I

Hoping this helps.
Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 30-Jul-10   Time: 17:44:26
-- 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] problems about dynamic GMM

2010-07-30 Thread 97258031

Dear all, 

I am a new user of R, and I would like to use R to estimate dynamaic GMM of 
Arellano and Bond (1991).

The package I used is plm and its code pgmm.
However, the regression cannot run and it showed an error message:
Error in solve.default(Reduce(+, A2)) : 
  system is computationally singular: reciprocal condition number = 
2.27327e-27.

Could I please ask, how could I deal with this problems, or are there any other 
package which can help me estimate dynamic GMM?

Many thanks for help.

--
Hao-pang
 

__
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] Re : COXPH: how to get the score test and likelihood ratio test for a specific variable in a multivariate Coxph ?

2010-07-30 Thread David Winsemius


On Jul 30, 2010, at 11:53 AM, Biau David wrote:


Thx for the answer.

I am using survival.

I didn't know that the Wald and score tests were the same for  
individual variables in a coxph; I Thought the score test was the  
multivariate version of the Log-rank.


However, say I have only one variable in the model, I should expect  
the test for the full model and the one for a single variable to be  
the same?


I don't understand what you are saying. What full model?

Then it seems to me that the default test is the Wald and that the  
Wald and the Score are different.


Numerically it would appear.



 cox_lr_age - coxph(Surv(tilr, ev_lr==1)~age, data=tam)
 summary(cox_lr_age)
Call:
coxph(formula = Surv(tilr, ev_lr == 1) ~ age, data = tam)

  n=2156 (76 observations deleted due to missingness)

coef exp(coef) se(coef) z Pr(|z|)
age 0.019504  1.019696 0.004651 4.193 2.75e-05 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

exp(coef) exp(-coef) lower .95 upper .95
age 1.020 0.9807 1.010 1.029

Rsquare= 0.008   (max possible= 0.669 )
Likelihood ratio test= 18.4  on 1 df,   p=1.787e-05
Wald test= 17.58  on 1 df,   p=2.751e-05
Score (logrank) test = 17.86  on 1 df,   p=2.375e-05


You can find the methods used by executing:

#require(survival)
getAnywhere(summary.coxph)

You had not earlier indicated what functions and output you had  
questions about. The Score test to which you refer above has the  
additional parenthetical indication that it is a logrank statistic.  
Looking in Therneau and Gramsch's, Modeling Survival Data in the  
index, we find that an approximate intersection of cited pages for  
score test and log rank-test includes page 53-54 where we see the  
explanation that a) Wald test is deprecated as the least reliable and   
b) that a Wald test based on one-iteration is closely related to the  
efficient score test (but it is not clear that this is the test  
referred to in this output. Reading between the lines it appears that  
the score test above might not actually be from a Cox model but is  
rather from a log-rank procedure. I hope Therneau can clarify.


--
David.



David Biau.


De : David Winsemius dwinsem...@comcast.net
À : Biau David djmb...@yahoo.fr
Cc : r help list r-help@r-project.org
Envoyé le : Ven 30 juillet 2010, 17h 34min 28s
Objet : Re: [R] COXPH: how to get the score test and likelihood  
ratio test for a specific variable in a multivariate Coxph ?



On Jul 30, 2010, at 11:08 AM, Biau David wrote:

 Hello,

 I would like to get the likelihood ratio and score tests for  
specific variables
 in a multivariate coxph model. The default is Wald, so the tests  
for each
 separate variable is based on Wald's test. I have the other tests  
for the full

 model but I don't know how to get them for each variable.

 Any idea?


The first idea would be to specify which function in which package  
you are asking questions about. In the case of coxph in the survival  
package, for instance, you do get a likelihood ratio test (==  
differences in log-likelihoods) by default. A score test is, at  
least as as I understand it for individual variables, equivalent to  
a Wald test, so I don't really understand your question, since youa  
re already getting all of that in the survival package.


(You can extract a score value and loglik values from a coxph  
object by:

(with the first example in the coxph help page)

coxph(Surv(time, status) ~ x + strata(sex), test1)$score
xoxph(Surv(time, status) ~ x + strata(sex), test1)$loglik

But anova(coxph-object) would give you these values in a neater  
bundle.

#Analysis of Deviance Table
# Cox model: response is Surv(time, status)
#Terms added sequentially (first to last)
#  loglik  Chisq Df Pr(|Chi|)
# NULL -3.8712
# x-3.3277 1.0871  10.2971

The question about getting them for each variable does not make a  
lot of sense to me, since likelihood tests are model comparisons.  
You can only make such statements about the consequences of adding  
or deleting a variable to/from an existing model.


--David Winsemius, MD
West Hartford, CT





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] hi! l have a question please help me

2010-07-30 Thread Tal Galili
Then please read this:
http://www.r-project.org/posting-guide.html

*Basic statistics and classroom homework:* R-help is not intended for these.

If you want learning materials for R you can check out:
http://stats.stackexchange.com/questions/138/resources-for-learning-r
And:
http://www.r-statistics.com/2009/10/free-statistics-e-books-for-download/

Good luck.




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 Fri, Jul 30, 2010 at 6:19 PM, leepama butch...@hanmail.net wrote:


 yes!!

 I join group study that study R-programming...

 so  I really tried..only to fail and made many erros..
  I really don't know
 how to perform this...

 --
 View this message in context:
 http://r.789695.n4.nabble.com/hi-l-have-a-question-please-help-me-tp2307569p2308091.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.


Re: [R] newton.method

2010-07-30 Thread Prof. John C Nash

Sometimes it is easier to just write it. See below.

On 10-07-30 06:00 AM, r-help-requ...@r-project.org wrote:

Date: Thu, 29 Jul 2010 11:15:05 -0700 (PDT)
From: sammynysj...@caa.columbia.edu
To:r-help@r-project.org
Subject: Re: [R] newton.method
Message-ID:1280427305687-2306895.p...@n4.nabble.com
Content-Type: text/plain; charset=us-ascii


newton.method is in package 'animation'.

Thanks Ravi.
BBSolve/BBOptim seems to work very well although I am not familiar with the
optimization methods being used there. Is there a way to specify a tolerance
in the function to get the required precision.

I did something like this to use newton method.
require(animation)
newton.method(f, init=2, tol=10*exp(-8))
But it gives bogus results.

If someone could point me a correct working version of newton method for
finding roots and its usage, that would be helpful.

cheers,

Sam




tfn-function(x) {
 f = 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) + 2.5*exp(-1.5*x) - 100
 return(f)
}
tgr-function(x) {
 g = 0.5*2.5*exp(-0.5*(2*0.045 - x))  -1.5*2.5*exp(-1.5*x)
 return(g)
}
newt-function(start, fun, grad) {
x-start
newx-x+100 # to avoid stopping
while( 1 != 0) {
   f-fun(x)
   g-grad(x)
   newx-x-f/g
   cat(x, newx, f, g:,x,' ',newx,' ',f,' ',g,\n)
   if ((100+x) == (100+newx)) return(newx)
   tmp-readline(continue?)
   x-newx
}
}

You can try

   newt(7,tfn, tgr)

   newt(-7,tfn,tgr)

and get both roots quite quickly.

However, I'd probably used uniroot by preference as a general tool. The scripts above are 
meant for learning purposes.


Best,

John Nash

PS. I did check tgr with numDeriv -- always worth doing.

__
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] Computation of largest eigenvalue

2010-07-30 Thread Ravi Varadhan
There is the arpack() function in igraph package for computing leading
eigenvalues, but I am not sure how well it can handle very large matrices.


I have coded up an accelerated power method and have used it on dense
matrices of order 5000.  It takes around 9-10 secs for the dominant
eigenvalue and corresponding eigenvector.  

How very large is your matrix?

Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Christian Weiß
Sent: Friday, July 30, 2010 9:32 AM
To: r-help@r-project.org
Subject: [R] Computation of largest eigenvalue

  Hello,

I am looking for an R function to compute only the largest eigenvalue 
(Perron-Frobenius eigenvalue) and its corresponding eigenvector of a 
square matrix (in fact, even only of a non-negative matrix). The 
function should also be able to deal with very large but sparse matrices.

Any idea?

Best regards,

Christian Weiß


--

Dr. Christian H. Weiß

Fachbereich Mathematik
Technische Universität Darmstadt
Schlossgartenstraße 7
64289 Darmstadt
-Deutschland-

Tel.: +6151/16-3787
Email: we...@mathematik.tu-darmstadt.de
Homepage:
http://www3.mathematik.tu-darmstadt.de/fileadmin/home/users/157/person/Perso
n.html

-- 

Dein Leben wird auch dadurch nicht flach und
dumm, wenn du weißt, daß dein Kampf erfolglos
sein wird. Es ist viel flacher, wenn du für
etwas Gutes und Ideales kämpfst und nun
meinst, du müsstest es auch erreichen. Sind
denn Ideale zum Erreichen da? Leben wir denn,
um den Tod abzuschaffen? - HERMANN HESSE

__
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] Re : COXPH: how to get the score test and likelihood ratio test for a specific variable in a multivariate Coxph ?

2010-07-30 Thread Therneau, Terry M., Ph.D.
The Wald, score, and LR tests are discussed in full in my book.  They
are not the same.
The LR test is the difference between LR(beta=0) and LR(beta=final). The
score test is a Taylor series approximation to this using an expansion
around beta=0.  The Wald test is a similar Taylor series approximation,
but around beta=final.  
  If there are no tied times the score test = Log-rank test.  If there
are ties, then they are just a tiny bit different: the paper using the
log-rank has an n-1 in his variance term and the Cox model has an n.
Neither is right or wrong, just a different choice.

Terry Therneau

__
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] Formatting datetime data for gantt.chart.

2010-07-30 Thread Andrew Noyes

Overall goal:

I'd like to have a visual representation of when certain computer applications 
are running over the course of a day (data will come from a SQL query later, 
but I'm using a csv for now). My idea is to use a gantt chart, but I'm running 
into issues with the start and end time. I'm wondering if it's because I need 
to use hours instead of days as my unit of time.

Problem #1
I'm trying to use strptime to convert a datetime string (7/12/2010  5:30:05 PM) 
to POSIX so I can use it as a start/end time in a gantt chart. ( I need to 
measure hours instead of days, so as.POSIXct/lt won't work for me. I'd also 
like to retain date info so I can create weekly/monthly averages))

When tested, I get this:

 strptime(7/12/2010 5:30:05 PM, %X)
[1] NA

When I delete the date, I get:

 strptime(5:30:05 PM, %X)
[1] 2010-07-30 05:30:05

The full date string in the first example seems pretty unambiguous, so I'm not 
sure why it is not being recognized and %X should show the full datetime string 
- any suggestions?

#2
I will read the data from a csv file (and eventually, a database). A secondary 
problem I've run into is converting the entire list of times - will I need to 
create a loop to handle them all or is there a function similar to tapply() 
that I can use?

Thanks in advance for your time,

akn
  
[[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] reading dates in Excel into R

2010-07-30 Thread Hongying Li

 I just do not want the dates format change randomly (seems to me) each time I 
read it from excel2007 file into R. 
When I export the excel2007 fiel into csv file and use read.csv function then 
the dates all come out good (as mm/dd/ in csv file).
I guess I have to first import into csv file before reading into R. Just avoid 
reading from Excel2007 files directly. 
Thanks,
Hongying
 
 
 
 Date: Fri, 30 Jul 2010 10:24:50 +0100
 Subject: Re: [R] reading dates in Excel into R
 From: fra...@gmail.com
 To: peter.alsp...@plantandfood.co.nz
 CC: colorl...@hotmail.com; r-help@r-project.org
 
 To read the data into R
 1) I format my dates as -MM-DD in Excel (or OpenOffice Calc),
 2) (change =na() to NA)
 3) Check that required number of significant decimal places are displayed,
 4) export as csv and
 5) Use readSeries() function from Rmetrics timeSeries package to read
 the data into R.
 
 For what it is worth I have found this approach flexible .
 
 Best Regards
 
 John
 
 On 29 July 2010 22:18, Peter Alspach peter.alsp...@plantandfood.co.nz wrote:
  Tena koe
 
  What do you want to control?  You can govern the format used in R using the 
  appropriate R functions.  I doubt it would be useful to have dates read 
  from Excel depend on the format set for displaying those dates in Excel.
 
  HTH 
 ,,,
 
  Peter Alspach
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
  project.org] On Behalf Of Hongying Li
  Sent: Friday, 30 July 2010 5:33 a.m.
  To: r-help@r-project.org
  Subject: [R] reading dates in Excel into R
 
 
  I am reading dates in Excel2007 into R.
 
  Here are the functions I used:
 
  library(RODBC)
  channel-odbcConnectExcel2007(myfile.xlsx)
  tmp-sqlFetch(channel,1,as.is=T)
 
 
  The dates in myfile.xlsx are all in this format: mm/dd/. But when I
  read it to R, some columns look like -mm-dd 00:00:00, some
  columns look like -mm-dd, and some columns are numbers. I do not
  know how I can control this.
 
 
 
  Any help? Thanks!
 
 
 
  _
  Hotmail is redefining busy with tools for the New Busy. Get more from
  your inbox.
 
  N:WL:en-US:WM_HMP:042010_2
[[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.
 
 
 
 
 -- 
 John C Frain
 Economics Department
 Trinity College Dublin
 Dublin 2
 Ireland
 www.tcd.ie/Economics/staff/frainj/home.html
 mailto:fra...@tcd.ie
 mailto:fra...@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] R on Mac OS X 10.6 freezing up

2010-07-30 Thread Jesse Poland
 I am running R and R64 on a MacBook Pro (2.66GHz, 8GB, OS X 10.6) and 
it keeps freezing up on me (i.e. have to force quit or kill).  Same 
problem with both R and R64.  I am not doing heavy computation, mostly 
just editing some scripts in the GUI.  Also the computer is plenty fast 
with sufficient memory.  I looked around but haven't seen anything on 
this problem.


Thanks!



--
Jesse Poland
Research Geneticist
USDA-ARS
Cornell University
c: 607-339-7771

__
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-07-30 Thread Gray Calhoun
On Fri, Jul 30, 2010 at 4:59 AM, Daniel Nordlund djnordl...@verizon.net wrote:

 You haven't provided a reproducible example, so I am going to guess at some 
 of what you are doing.  You also have used some function names for your 
 variable names which I like to avoid, so I have used 'b' as the name of the 
 vector for collecting beta coefficients and 'ts' for the predictor variable.  
 I have set var.all equal to 1.


A minor point: one should probably avoid using 'ts' as a variable name
too, since it's a function in the stats package.

-- 
Gray Calhoun

Assistant Professor of Economics, Iowa State University
http://www.econ.iastate.edu/~gcalhoun/

__
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] Re : Re : COXPH: how to get the score test and likelihood ratio test for a specific variable in a multivariate Coxph ?

2010-07-30 Thread Biau David
Well thank you very much for these explanations. Unfortunately, I must admit 
the 
book I have for survival analysis seems less precise as to which test to use 
and 
why.

Still, in coxph (survival), if I have multiple variables in a model, say  X_1, 
X_2, and X_3, how do I test their respective coefficients \beta_1, \beta_2, and 
\beta_3 with the LR, score and Wald? I guess i can do it by comparing the model 
with all three variables to those without each of the variables, but is there 
not a more straightforward manner?

 David Biau.





De : Therneau, Terry M., Ph.D. thern...@mayo.edu
À : David Winsemius dwinsem...@comcast.net; Biau David djmb...@yahoo.fr
Cc : r help list r-help@r-project.org
Envoyé le : Ven 30 juillet 2010, 19h 07min 15s
Objet : RE: Re : [R] COXPH: how to get the score test and likelihood ratio test 
for a specific variable in a multivariate Coxph ?

The Wald, score, and LR tests are discussed in full in my book.  They
are not the same.
The LR test is the difference between LR(beta=0) and LR(beta=final). The
score test is a Taylor series approximation to this using an expansion
around beta=0.  The Wald test is a similar Taylor series approximation,
but around beta=final.  
  If there are no tied times the score test = Log-rank test.  If there
are ties, then they are just a tiny bit different: the paper using the
log-rank has an n-1 in his variance term and the Cox model has an n.
Neither is right or wrong, just a different choice.

Terry Therneau



  
[[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 Mac OS X 10.6 freezing up

2010-07-30 Thread Peter Dalgaard
Jesse Poland wrote:
   I am running R and R64 on a MacBook Pro (2.66GHz, 8GB, OS X 10.6) and 
 it keeps freezing up on me (i.e. have to force quit or kill).  Same 
 problem with both R and R64.  I am not doing heavy computation, mostly 
 just editing some scripts in the GUI.  Also the computer is plenty fast 
 with sufficient memory.  I looked around but haven't seen anything on 
 this problem.
 
 Thanks!


There's an R-sig-mac mailing list, which may be a better place to seek
help. If you can replicate the problem easily, I would expect that you
could help the developers considerably if you could (say) connect to the
R process and do a traceback showing where things get stuck.


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@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] Summing by index

2010-07-30 Thread steven mosher
# build a sample data frame illustrating the problem
 ids-c(rep(1234,5),rep(5436,3),rep(7864,4))
 years-c(seq(1990,1994,by=1),seq(1991,1993,by=1),seq(1990,1993,by=1))
 data-seq(14,25,by=1)
 data[6]-NA
 DF-data.frame(Id=ids,Year=years,Data=data)
 DF
 Id Year Data
1  1234 1990   14
2  1234 1991   15
3  1234 1992   16
4  1234 1993   17
5  1234 1994   18
6  5436 1991   NA
7  5436 1992   20
8  5436 1993   21
9  7864 1990   22
10 7864 1991   23
11 7864 1992   24
12 7864 1993   25

# The result wanted is a sum of DF$Data, by DF$Id. collect the sum of $Data
for each $Id
# the  result would take the form
#  Id, sum  for each Id
# Try using BY
 result-by(DF$Data,INDICES=Data$Id,FUN=sum,na.rm=T)
Error in names(IND) - deparse(substitute(INDICES))[1L] :
  'names' attribute [1] must be the same length as the vector [0]
 idx-as.list(Data$Id)


 idx2-list(1234,1234,1234,1234,1234,5436,5436,5436,7864,7864,7864,7864)
result-by(DF$Data,INDICES=idx,FUN=sum,na.rm=T)
result
[1] 215
 result-by(DF$Data,INDICES=idx2,FUN=sum,na.rm=T)
Error in tapply(1L:12L, list(1234, 1234, 1234, 1234, 1234, 5436, 5436,  :
  arguments must have same length
 idx
list()
 idx[1]
[[1]]
NULL

 idx2
[[1]]
[1] 1234

[[2]]
[1] 1234

[[3]]
[1] 1234

[[4]]
[1] 1234

[[5]]
[1] 1234

[[6]]
[1] 5436

[[7]]
[1] 5436

[[8]]
[1] 5436

[[9]]
[1] 7864

[[10]]
[1] 7864

[[11]]
[1] 7864

[[12]]
[1] 7864

 aggregate(DF$Data, by=idx2,sum,na.rm=T)
Error in aggregate.data.frame(as.data.frame(x), ...) :
  arguments must have same length



The instruction that the INDICES must have the same length is confusing me.
the number of indices will always be less than the number of rows because
the indices are repeated, we want to sum over multiple instances of the
indices
to collect the Sum by index. I'm confused.

[[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] Summing by index

2010-07-30 Thread David Winsemius


On Jul 30, 2010, at 2:41 PM, steven mosher wrote:


# build a sample data frame illustrating the problem
ids-c(rep(1234,5),rep(5436,3),rep(7864,4))
years-c(seq(1990,1994,by=1),seq(1991,1993,by=1),seq(1990,1993,by=1))
data-seq(14,25,by=1)
data[6]-NA
DF-data.frame(Id=ids,Year=years,Data=data)
DF
Id Year Data
1  1234 1990   14
2  1234 1991   15
3  1234 1992   16
4  1234 1993   17
5  1234 1994   18
6  5436 1991   NA
7  5436 1992   20
8  5436 1993   21
9  7864 1990   22
10 7864 1991   23
11 7864 1992   24
12 7864 1993   25

# The result wanted is a sum of DF$Data, by DF$Id. collect the sum  
of $Data

for each $Id
# the  result would take the form
#  Id, sum  for each Id
# Try using BY
result-by(DF$Data,INDICES=Data$Id,FUN=sum,na.rm=T)


Try instead:

result-by(DF$Data,INDICES=DF$Id,FUN=sum,na.rm=T)

--
David.

Error in names(IND) - deparse(substitute(INDICES))[1L] :
 'names' attribute [1] must be the same length as the vector [0]
idx-as.list(Data$Id)


idx2- 
list(1234,1234,1234,1234,1234,5436,5436,5436,7864,7864,7864,7864)

result-by(DF$Data,INDICES=idx,FUN=sum,na.rm=T)
result
[1] 215
result-by(DF$Data,INDICES=idx2,FUN=sum,na.rm=T)
Error in tapply(1L:12L, list(1234, 1234, 1234, 1234, 1234, 5436,  
5436,  :

 arguments must have same length

idx

list()

idx[1]

[[1]]
NULL


idx2

[[1]]
[1] 1234

[[2]]
[1] 1234

[[3]]
[1] 1234

[[4]]
[1] 1234

[[5]]
[1] 1234

[[6]]
[1] 5436

[[7]]
[1] 5436

[[8]]
[1] 5436

[[9]]
[1] 7864

[[10]]
[1] 7864

[[11]]
[1] 7864

[[12]]
[1] 7864

aggregate(DF$Data, by=idx2,sum,na.rm=T)
Error in aggregate.data.frame(as.data.frame(x), ...) :
 arguments must have same length



The instruction that the INDICES must have the same length is  
confusing me.
the number of indices will always be less than the number of rows  
because
the indices are repeated, we want to sum over multiple instances of  
the

indices
to collect the Sum by index. I'm confused.

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


Re: [R] Summing by index

2010-07-30 Thread steven mosher
ha. that was a stupid mistake. Thanks.

On Fri, Jul 30, 2010 at 11:46 AM, David Winsemius dwinsem...@comcast.netwrote:


 On Jul 30, 2010, at 2:41 PM, steven mosher wrote:

  # build a sample data frame illustrating the problem
 ids-c(rep(1234,5),rep(5436,3),rep(7864,4))
 years-c(seq(1990,1994,by=1),seq(1991,1993,by=1),seq(1990,1993,by=1))
 data-seq(14,25,by=1)
 data[6]-NA
 DF-data.frame(Id=ids,Year=years,Data=data)
 DF
Id Year Data
 1  1234 1990   14
 2  1234 1991   15
 3  1234 1992   16
 4  1234 1993   17
 5  1234 1994   18
 6  5436 1991   NA
 7  5436 1992   20
 8  5436 1993   21
 9  7864 1990   22
 10 7864 1991   23
 11 7864 1992   24
 12 7864 1993   25

 # The result wanted is a sum of DF$Data, by DF$Id. collect the sum of
 $Data
 for each $Id
 # the  result would take the form
 #  Id, sum  for each Id
 # Try using BY
 result-by(DF$Data,INDICES=Data$Id,FUN=sum,na.rm=T)


 Try instead:

 result-by(DF$Data,INDICES=DF$Id,FUN=sum,na.rm=T)

 --
 David.

 Error in names(IND) - deparse(substitute(INDICES))[1L] :
  'names' attribute [1] must be the same length as the vector [0]
 idx-as.list(Data$Id)


 idx2-list(1234,1234,1234,1234,1234,5436,5436,5436,7864,7864,7864,7864)
 result-by(DF$Data,INDICES=idx,FUN=sum,na.rm=T)
 result
 [1] 215
 result-by(DF$Data,INDICES=idx2,FUN=sum,na.rm=T)
 Error in tapply(1L:12L, list(1234, 1234, 1234, 1234, 1234, 5436, 5436,  :
  arguments must have same length

 idx

 list()

 idx[1]

 [[1]]
 NULL

  idx2

 [[1]]
 [1] 1234

 [[2]]
 [1] 1234

 [[3]]
 [1] 1234

 [[4]]
 [1] 1234

 [[5]]
 [1] 1234

 [[6]]
 [1] 5436

 [[7]]
 [1] 5436

 [[8]]
 [1] 5436

 [[9]]
 [1] 7864

 [[10]]
 [1] 7864

 [[11]]
 [1] 7864

 [[12]]
 [1] 7864

 aggregate(DF$Data, by=idx2,sum,na.rm=T)
 Error in aggregate.data.frame(as.data.frame(x), ...) :
  arguments must have same length

 

 The instruction that the INDICES must have the same length is confusing
 me.
 the number of indices will always be less than the number of rows because
 the indices are repeated, we want to sum over multiple instances of the
 indices
 to collect the Sum by index. I'm confused.

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



[[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] Layering multiple persp plots

2010-07-30 Thread Ian Bentley
Hi all,

I've got two persp plots with Identical X and Y's, and I'd like to plot them
on the same graph, so that it is obvious where one plot is above the other.
I can't find any mention of this anywhere.  Do I need to use wireframe?


Any help is appreciated.
Thanks,

-- 
Ian Bentley
M.Sc. Candidate
Queen's University
Kingston, Ontario

[[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] Summing by index

2010-07-30 Thread steven mosher
Thanks again david.

To finish out the example.
 DF
 Id Year Data
1  1234 1990   14
2  1234 1991   15
3  1234 1992   16
4  1234 1993   17
5  1234 1994   18
6  5436 1991   NA
7  5436 1992   20
8  5436 1993   21
9  7864 1990   22
10 7864 1991   23
11 7864 1992   24
12 7864 1993   25

result-by(DF$Data,INDICES=DF$Id,FUN=sum,na.rm=T)

id-as.numeric(unlist(names(result)))
 sums-unlist(result[])
 DF2-data.frame(Id=id,Sums=sums)
DF2
Id Sums
1 1234   80
2 5436   41
3 7864   94

Thanks again.

On Fri, Jul 30, 2010 at 11:46 AM, David Winsemius dwinsem...@comcast.netwrote:


 On Jul 30, 2010, at 2:41 PM, steven mosher wrote:

  # build a sample data frame illustrating the problem
 ids-c(rep(1234,5),rep(5436,3),rep(7864,4))
 years-c(seq(1990,1994,by=1),seq(1991,1993,by=1),seq(1990,1993,by=1))
 data-seq(14,25,by=1)
 data[6]-NA
 DF-data.frame(Id=ids,Year=years,Data=data)
 DF
Id Year Data
 1  1234 1990   14
 2  1234 1991   15
 3  1234 1992   16
 4  1234 1993   17
 5  1234 1994   18
 6  5436 1991   NA
 7  5436 1992   20
 8  5436 1993   21
 9  7864 1990   22
 10 7864 1991   23
 11 7864 1992   24
 12 7864 1993   25

 # The result wanted is a sum of DF$Data, by DF$Id. collect the sum of
 $Data
 for each $Id
 # the  result would take the form
 #  Id, sum  for each Id
 # Try using BY
 result-by(DF$Data,INDICES=Data$Id,FUN=sum,na.rm=T)


 Try instead:

 result-by(DF$Data,INDICES=DF$Id,FUN=sum,na.rm=T)

 --
 David.

 Error in names(IND) - deparse(substitute(INDICES))[1L] :
  'names' attribute [1] must be the same length as the vector [0]
 idx-as.list(Data$Id)


 idx2-list(1234,1234,1234,1234,1234,5436,5436,5436,7864,7864,7864,7864)
 result-by(DF$Data,INDICES=idx,FUN=sum,na.rm=T)
 result
 [1] 215
 result-by(DF$Data,INDICES=idx2,FUN=sum,na.rm=T)
 Error in tapply(1L:12L, list(1234, 1234, 1234, 1234, 1234, 5436, 5436,  :
  arguments must have same length

 idx

 list()

 idx[1]

 [[1]]
 NULL

  idx2

 [[1]]
 [1] 1234

 [[2]]
 [1] 1234

 [[3]]
 [1] 1234

 [[4]]
 [1] 1234

 [[5]]
 [1] 1234

 [[6]]
 [1] 5436

 [[7]]
 [1] 5436

 [[8]]
 [1] 5436

 [[9]]
 [1] 7864

 [[10]]
 [1] 7864

 [[11]]
 [1] 7864

 [[12]]
 [1] 7864

 aggregate(DF$Data, by=idx2,sum,na.rm=T)
 Error in aggregate.data.frame(as.data.frame(x), ...) :
  arguments must have same length

 

 The instruction that the INDICES must have the same length is confusing
 me.
 the number of indices will always be less than the number of rows because
 the indices are repeated, we want to sum over multiple instances of the
 indices
 to collect the Sum by index. I'm confused.

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



[[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] hi! l have a question please help me

2010-07-30 Thread leepama

hey!!!
this is not classroom homework!!

To do main programming,
I find some good training problems in paper...

I tried to do that...but failed

so please help me

Nobody help me...I relly don't know how to perform this...
If you solve this probelm,I will study your work to solve main problem...

so please help me
-- 
View this message in context: 
http://r.789695.n4.nabble.com/hi-l-have-a-question-please-help-me-tp2307569p2308257.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] Summing by index

2010-07-30 Thread Wu Gong

Hi,

R has a buildin function ?rowsum

rowsum(DF$Data,DF$Id,na.rm=T)

-
A R learner.
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Summing-by-index-tp2308332p2308411.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] Layering multiple persp plots

2010-07-30 Thread Duncan Murdoch

On 30/07/2010 1:22 PM, Ian Bentley wrote:

Hi all,

I've got two persp plots with Identical X and Y's, and I'd like to plot them
on the same graph, so that it is obvious where one plot is above the other.
I can't find any mention of this anywhere.  Do I need to use wireframe?
  


persp() can't do that.  persp3d() in the rgl package can.  I'm not sure 
about wireframe().  (If you use persp3d, take note of the fact that

the colours are specified slightly differently.  See ?persp3d).

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] reading dates in Excel into R

2010-07-30 Thread Gabor Grothendieck
On Fri, Jul 30, 2010 at 1:17 PM, Hongying Li colorl...@hotmail.com wrote:

  I just do not want the dates format change randomly (seems to me) each time 
 I read it from excel2007 file into R.
 When I export the excel2007 fiel into csv file and use read.csv function then 
 the dates all come out good (as mm/dd/ in csv file).
 I guess I have to first import into csv file before reading into R. Just 
 avoid reading from Excel2007 files directly.
 Thanks,
 Hongying


You could try the various alternatives in the list on this page:

   http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windowss=excel

and see if any of them work in the way you wish.

__
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] newton.method

2010-07-30 Thread sammyny

I have written versions of these in C++ but my point is to learn R and
discover all these methods in it.

thanks

On Fri, Jul 30, 2010 at 12:55 PM, Prof. John C Nash [via R] 
ml-node+2308224-1876059272-368...@n4.nabble.comml-node%2b2308224-1876059272-368...@n4.nabble.com
 wrote:

 Sometimes it is easier to just write it. See below.

 On 10-07-30 06:00 AM, [hidden 
 email]http://user/SendEmail.jtp?type=nodenode=2308224i=0wrote:

  Date: Thu, 29 Jul 2010 11:15:05 -0700 (PDT)
  From: sammyny[hidden 
  email]http://user/SendEmail.jtp?type=nodenode=2308224i=1

  To:[hidden email] http://user/SendEmail.jtp?type=nodenode=2308224i=2
  Subject: Re: [R] newton.method
  Message-ID:[hidden 
  email]http://user/SendEmail.jtp?type=nodenode=2308224i=3

  Content-Type: text/plain; charset=us-ascii
 
 
  newton.method is in package 'animation'.
 
  Thanks Ravi.
  BBSolve/BBOptim seems to work very well although I am not familiar with
 the
  optimization methods being used there. Is there a way to specify a
 tolerance
  in the function to get the required precision.
 
  I did something like this to use newton method.
  require(animation)
  newton.method(f, init=2, tol=10*exp(-8))
  But it gives bogus results.
 
  If someone could point me a correct working version of newton method for
  finding roots and its usage, that would be helpful.
 
  cheers,
 
  Sam
 


 tfn-function(x) {
   f = 2.5*exp(-0.5*(2*0.045 - x)) + 2.5*exp(-0.045) + 2.5*exp(-1.5*x) - 100

   return(f)
 }
 tgr-function(x) {
   g = 0.5*2.5*exp(-0.5*(2*0.045 - x))  -1.5*2.5*exp(-1.5*x)
   return(g)
 }
 newt-function(start, fun, grad) {
  x-start
  newx-x+100 # to avoid stopping
  while( 1 != 0) {
 f-fun(x)
 g-grad(x)
 newx-x-f/g
 cat(x, newx, f, g:,x,' ',newx,' ',f,' ',g,\n)
 if ((100+x) == (100+newx)) return(newx)
 tmp-readline(continue?)
 x-newx
  }
 }

 You can try

 newt(7,tfn, tgr)

 newt(-7,tfn,tgr)

 and get both roots quite quickly.

 However, I'd probably used uniroot by preference as a general tool. The
 scripts above are
 meant for learning purposes.

 Best,

 John Nash

 PS. I did check tgr with numDeriv -- always worth doing.

 __
 [hidden email] http://user/SendEmail.jtp?type=nodenode=2308224i=4mailing 
 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.


 --
  View message @
 http://r.789695.n4.nabble.com/newton-method-tp2306111p2308224.html
 To unsubscribe from newton.method, click here (link removed) .




-- 
View this message in context: 
http://r.789695.n4.nabble.com/newton-method-tp2306111p2308277.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] Using data frame col names and variables

2010-07-30 Thread Cadmium 2
Hi to you all!

I'm new to R and to this mailing list, so do please excuse me if my question
sounds stupid.

Currently I'm working with a data frame called results.

In each column of results I have a set of results for different
experiments  (all results are numerical) realized in different dates, so
that each row corresponds to a day.

To make it clear when displaying the results, I gave names to the columns
with the names of the experiments realized. I also gave names to the rows
based on the day the experiments where realized.

My problem now is that I'm trying to separate this experiments based on a
criteria that is not important for the moment. What I want to be able to do
is, given an experiment name, obtain the time series of the results of that
experiment.

I know I can do this by typing

results$nameoftheexperiment

But what if I have a variable name which contains the experiment's name?

Doing the following

results$name

doesn't work, as expected, since there is no column with name name.

Any help would be appreciated.

Thank you very much!

[[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] Fw: Having problem to define a subclass, please help me

2010-07-30 Thread Megh Dal
Dear all, apart from my previous question, I would also like to ask one more 
question here, which is as follows:

#let me 1st define a class and a subclass
setClass(a, representation=list(x=numeric, y=numeric), 
prototype=list(x=rep(1,3),y=rep(2,3)))
setClass(b, representation=list(x1=character, y1=character), 
prototype=list(x1=rep(A,3),y1=rep(B,3)), contains=a)

#Now I define the method for initialize() for class a
setMethod(initialize, a, function(.Object, x, y, ...) {
  if (length(x) != length(y)) x=y=rep(10,4)
  .obj...@x = x
  .obj...@y = y
  .Object })
new(a, x=rnorm(4), y=rnorm(4))
new(a, x=rnorm(4), y=rnorm(3))

#Next I define method for initialize() for subclass b

setMethod(initialize, b, function(.Object, x1, y1, ...) {
  if (length(x1) == length(y1)) x1=y1=rep(bbb,4)
  .obj...@x1 = x1
  .obj...@y1 = y1
  .Object })

 new(b, x1=letters[1:3], x2=letters[2:4], x=rnorm(4), y=rnorm(3))
An object of class b
Slot x1:
[1] bbb bbb bbb bbb

Slot y1:
[1] bbb bbb bbb bbb

Slot x:
[1] 1 1 1

Slot y:
[1] 2 2 2

 new(b, x1=letters[1:3], x2=letters[2:4], x=rnorm(4), y=rnorm(4))
Error in checkSlotAssignment(object, name, value) :
  assignment of an object of class numeric is not valid for slot y1 in an 
object of class b; is(value, character) is not TRUE

Here my questions are:
1. Why I am getting the prototype object in next to previous example for slots 
x  y?
2. Why just previous example generates some error?
3. The method initialize() function for a subclass requires explicit 
description of all slots of it's superclass? If yes why? In my understanding, 
all defined law for super-class should be inherited by it's sub-class, 
therefore no need to define again.

I would be really grateful if someone clarify those.

Thanks


--- On Fri, 7/30/10, Megh Dal megh700...@yahoo.com wrote:

 From: Megh Dal megh700...@yahoo.com
 Subject: Having problem to define a subclass, please help me
 To: r-h...@stat.math.ethz.ch
 Date: Friday, July 30, 2010, 4:46 PM
 Here I am having problem to define a
 subclass, specially if I define that subclass after defining
 initialize() method for its superclass. Here is my code:
 
  setClass(a, representation=list(x=numeric,
 y=numeric), prototype=list(x=rnorm(10), y=rnorm(10)))
 [1] a
  setMethod(initialize, a, function(.Object, x, y,
 ...) {
 +               
              
    if (length(x) != length(y)) x = y = rep(5,
 4)
 +               
              
    .obj...@x = x
 +               
              
    .obj...@y = y
 +               
              
    .Object })
 [1] initialize
  setClass(b, representation=list(x1=character),
 contains=a)
 Error in .local(.Object, ...) : element 1 is empty;
    the part of the args list of 'length'
 being evaluated was:
    (x)
  
 
 Can anyone please point me where I am doing wrong?
 
 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.


[R] Problem with par and bubble plot

2010-07-30 Thread Filoche

Hi all.

I have been trying to plot 9 bubble plots on each page of a PDF file. For
this, I'm using : 

par(mfcol = c(3,3), mar = c(3,3,3,3), oma = c(0,0,0,0));

However, when plotting the bubble plot (gstats package), it plots the graph
on a full page. I tried to plot something else with plot(x,y) and it works
as intended. So I'm guessing the problem comes from the bubble plot itself.

Anyone suggestion?

Best regards,
Phil
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Problem-with-par-and-bubble-plot-tp2308452p2308452.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] Using data frame col names and variables

2010-07-30 Thread David Winsemius


On Jul 30, 2010, at 2:12 PM, Cadmium 2 wrote:


Hi to you all!

I'm new to R and to this mailing list, so do please excuse me if my  
question

sounds stupid.

Currently I'm working with a data frame called results.

In each column of results I have a set of results for different
experiments  (all results are numerical) realized in different  
dates, so

that each row corresponds to a day.

To make it clear when displaying the results, I gave names to the  
columns
with the names of the experiments realized. I also gave names to the  
rows

based on the day the experiments where realized.

My problem now is that I'm trying to separate this experiments based  
on a
criteria that is not important for the moment. What I want to be  
able to do
is, given an experiment name, obtain the time series of the results  
of that

experiment.

I know I can do this by typing

results$nameoftheexperiment

But what if I have a variable name which contains the experiment's  
name?


Doing the following

results$name

doesn't work, as expected, since there is no column with name name.


Try:

results[ , name]

And read the the help page for ?Extract. The $ formalism does not  
evaluate its argument whereas the [ function does.


--
David.




Any help would be appreciated.

Thank you very much!

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


Re: [R] svydesign syntax

2010-07-30 Thread Thomas Lumley

On Thu, 22 Jul 2010, R user wrote:


This message is for those familiar with the survey package. I need to fit a
weighted Cox model to accommodate the sampling weights as I have a
case-control study with controls sampled at random from a database in a
ratio 2:1 to cases (whom were all sampled). I want to make sure I am using
the right svydesign syntax to specify this sampling design. Can anyone
please check if the statement below is appropriate for my design?

#group represents the case (total of 132) vs control (253 out of the total
of 853 controls) groups; prob is 1 for cases and 253/853 for controls and
ssize=132 for cases and 853 otherwise;

dstr=svydesign(id=~1, strata=~group, prob=~prob, fpc=~ssize, data=noNA)



This is technically correct but probably not for what you want.  You probably 
want

dstr=svydesign(id=~1, strata=~group, prob=~prob,  data=noNA)
or
dstr = twophase(id=list(~1,~1), strata=list(NULL, ~group), data=noNA)

Your svydesign() call treats the database as the full population.  This could 
be correct, but usually people want estimates for the 'superpopulation' from 
which the population was sampled.  The first option above is very slightly 
conservative, the second describes the two phases of sampling that give first 
the whole database and then your subsample.

   -thomas

Thomas Lumley
Professor of Biostatistics
University of Washington, Seattle

__
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] reading dates in Excel into R

2010-07-30 Thread Dimitri Liakhovitski
I've wasted a lot of time trying to read in dates from Excel. Even
importing .csv files has not guarantees and often produces garbage
instead of dates.
What I found works best is saving the Excel data base as a
tab-delimited file .txt (after having formatted the dates in the
format you need, e.g., mm/dd/). And then you can read it
(including dates) into R no problems.
Dimitri


On Fri, Jul 30, 2010 at 1:31 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 On Fri, Jul 30, 2010 at 1:17 PM, Hongying Li colorl...@hotmail.com wrote:

  I just do not want the dates format change randomly (seems to me) each time 
 I read it from excel2007 file into R.
 When I export the excel2007 fiel into csv file and use read.csv function 
 then the dates all come out good (as mm/dd/ in csv file).
 I guess I have to first import into csv file before reading into R. Just 
 avoid reading from Excel2007 files directly.
 Thanks,
 Hongying


 You could try the various alternatives in the list on this page:

   http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windowss=excel

 and see if any of them work in the way you wish.

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




-- 
Dimitri Liakhovitski
Ninah Consulting
www.ninah.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] reading dates in Excel into R

2010-07-30 Thread Gray Calhoun
Hi Hongying,
  There is a manual on the R website about data import and export that
explains different options.
--Gray

On 7/30/10, Hongying Li colorl...@hotmail.com wrote:

  I just do not want the dates format change randomly (seems to me) each time
 I read it from excel2007 file into R.
 When I export the excel2007 fiel into csv file and use read.csv function
 then the dates all come out good (as mm/dd/ in csv file).
 I guess I have to first import into csv file before reading into R. Just
 avoid reading from Excel2007 files directly.
 Thanks,
 Hongying



 Date: Fri, 30 Jul 2010 10:24:50 +0100
 Subject: Re: [R] reading dates in Excel into R
 From: fra...@gmail.com
 To: peter.alsp...@plantandfood.co.nz
 CC: colorl...@hotmail.com; r-help@r-project.org

 To read the data into R
 1) I format my dates as -MM-DD in Excel (or OpenOffice Calc),
 2) (change =na() to NA)
 3) Check that required number of significant decimal places are displayed,
 4) export as csv and
 5) Use readSeries() function from Rmetrics timeSeries package to read
 the data into R.

 For what it is worth I have found this approach flexible .

 Best Regards

 John

 On 29 July 2010 22:18, Peter Alspach peter.alsp...@plantandfood.co.nz
 wrote:
  Tena koe
 
  What do you want to control?  You can govern the format used in R using
  the appropriate R functions.  I doubt it would be useful to have dates
  read from Excel depend on the format set for displaying those dates in
  Excel.
 
  HTH 
 ,,,

  Peter Alspach
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
  project.org] On Behalf Of Hongying Li
  Sent: Friday, 30 July 2010 5:33 a.m.
  To: r-help@r-project.org
  Subject: [R] reading dates in Excel into R
 
 
  I am reading dates in Excel2007 into R.
 
  Here are the functions I used:
 
  library(RODBC)
  channel-odbcConnectExcel2007(myfile.xlsx)
  tmp-sqlFetch(channel,1,as.is=T)
 
 
  The dates in myfile.xlsx are all in this format: mm/dd/. But when I
  read it to R, some columns look like -mm-dd 00:00:00, some
  columns look like -mm-dd, and some columns are numbers. I do not
  know how I can control this.
 
 
 
  Any help? Thanks!
 
 
 
  _
  Hotmail is redefining busy with tools for the New Busy. Get more from
  your inbox.
 
  N:WL:en-US:WM_HMP:042010_2
[[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.
 



 --
 John C Frain
 Economics Department
 Trinity College Dublin
 Dublin 2
 Ireland
 www.tcd.ie/Economics/staff/frainj/home.html
 mailto:fra...@tcd.ie
 mailto:fra...@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.



-- 
Gray Calhoun

Assistant Professor of Economics, Iowa State University
http://www.econ.iastate.edu/~gcalhoun/

__
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: Re: R statical-script for analysis (India)

2010-07-30 Thread Nilesh Vaghela


Nilesh M. Vaghela
Research Scholar
c/o Prof. N. V. Sastry,
Department of Chemistry,
Sardar Patel University
Vallabhvidyanagar-388 120
Gujarat, India

--- On Thu, 29/7/10, Kurt Hornik kurt.hor...@wu.ac.at wrote:


From: Kurt Hornik kurt.hor...@wu.ac.at
Subject: Re: R statical-script for analysis (India)
To: Nilesh Vaghela nilesh_sp...@yahoo.in
Cc: c...@r-project.org
Date: Thursday, 29 July, 2010, 8:17 AM


 Nilesh Vaghela writes:

 Dear Sir,

  I am doing research work on solution behavior of the ionic liquids by
surface tension and conductivity measurements. We get some references
 (see attachment) in which the data analysis of the were done by R
 statical programme. We want to do same. But we do not know how to
 write script for analysis of the data.Basically it is Philips equation for cmc 
determination.
 Please explain me and be needful in my research work.  Kind 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] conditonal if

2010-07-30 Thread putri wikie
Hi,

I have problem with my R program. Actually, it just a simple program, but I do 
not know the error is. Here is part of my program:


if (tau2ca==0) {MVvc - 0.01} else {MVvc - tau2ca}
ri_vc - si2/MVvc
vi_vc - ri_vc + 1
Y_bar_vc - sum(y/vi_vc)/sum((1/vi_vc))
tau2MVvc - sum((1/vi_vc)*(y - Y_bar_vc)^2)/(k-1)


But then, there is an error displayed in workspace

Error in if (tau2ca == 0) { : missing value where TRUE/FALSE needed

I do not know why there is an error like that. I think I type the program 
correctly. Also, I just want to make sure whether my program below is right or 
not.

for (l in 1:k)
{if (a[l]==0 | b[l]==0 | c[l]==0 | d[l]==0) 
{ a[l] - a[l]+0.5
 b[l] - b[l]+0.5
 c[1] - c[1]+0.5
 d[1] - d[1]+0.5
}
}

Looking forward to hearing from you.


Many thanks,
-pwikie-



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


  1   2   >