[R] FW: Questions related to R- Credit Risk

2009-12-28 Thread Lisete Fernandes de Noronha (DGR)
I am a new user of R software, and at the moment I am interested in applying 
"R" to calculate Credit Risk measures.

I have already been in contact with Andreas Wittmann (responsible for 
CreditMetrics package). Nevertheless, there are some doubts that I have which 
Andreas could not help me. 

Is it possible to get the answers for my questions?

1. Which package calculates lgd?

 2. Besides CreditMetrics package, which packages are related with 
 Credit Risk in order to calculate credit risk measures, as:

 -  Loss Distribution;
 -  VAR;
 -  Unexpected Losses:
 -  Risk Contribution


Thank you
Best regards,
Lisete Noronha


-Original Message-
From: Andreas Wittmann [mailto:andreas_wittm...@gmx.de] 
Sent: sexta-feira, 25 de Dezembro de 2009 8:24
To: Lisete Fernandes de Noronha (DGR)
Subject: Re: Questions related to R- Credit Risk

Hi Lisete,

sorry, but spontaneously i have no answers for your questions. please 
search the following mailing lists and if your questions cannot be 
answered, ask the questions there again.

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

best regards and merry christmans

Andreas




Lisete Fernandes de Noronha (DGR) wrote:
>
> Thanks for your help.
>
> Sorry, but I have more questions for you.
>
> 1. Can you tell me which package calculates lgd?
>
> 2. Besides CreditMetrics package, which packages are related with 
> Credit Risk in order to calculate credit risk measures, as:
>
> -  Loss Distribution;

> -  VAR;

> -  Unexpected Losses:

> -  Risk Contribution
>
> Best Regards,
>
> Lisete
>
>  
>
>  
>
> 
>
> *From:* Andreas Wittmann [mailto:andreas_wittm...@gmx.de]
> *Sent:* segunda-feira, 21 de Dezembro de 2009 18:00
> *To:* Lisete Fernandes de Noronha (DGR)
> *Subject:* Re: Questions related to R- Credit Risk
>
>  
>
> Dear Lisete,
>
> thank you for using the CreditMetrics package.
>
>1. the pd is the probability of default, as you can see in the
>   migration matrix this is the last column without the last row.
>2. the lgd is not calculated in this package, it is only an input
>   parameter and actually it is only possibly to use the same lgd
>   for each rating.
>
>
> hope this helps.
>
> best regards
>
> Andreas
>
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] To export results

2009-12-28 Thread sathiya_mtm

Hi

I am new to this software, Please tell me how to save the result to a word
or text format from R console.

For example, if I run a regression, and I want to save the result in the
word what should I do for that. Please do reply for my query.

Thanks
Arun Sathiya.
-- 
View this message in context: 
http://n4.nabble.com/To-export-results-tp989600p989600.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] [R-pkgs] micEcon split into miscTools, micEconAids, and micEcon

2009-12-28 Thread Arne Henningsen
The "micEcon" package has been split into three packages: miscTools,
micEconAids, and micEcon.

a) miscTools (version 0.6-0) includes miscellaneous small tools and
utilities that are not related to (micro)economics, e.g. colMedians(),
rowMedians(), insertCol(), insertRow(), vecli(), symMatrix(),
triang(), semidefiniteness(), compPlot(), and rSquared(). The
miscTools package should depend on (almost) no other packages so that
it can be used in other packages without increasing the total
(recursive!) dependencies of these packages too much.

b) micEconAids (version 0.6-0) includes all functions and methods for
demand analysis with the Almost Ideal Demand System (AIDS) of Deaton
and Muellbauer (1980). Since these functions and methods comprised a
large and rather specific "group" within the "old" micEcon package, it
makes sense (IMHO) to separate them into a separate package.

c) micEcon (version 0.6-0) includes the remaining parts of the "old"
micEcon package, e.g. for economic analysis with Cobb-Douglas
functions, translog functions, quadratic functions, CES (constant
elasticity of substitution) functions, SNQ (symmetric normalized
quadratic = generalized McFadden) profit functions, or linearly
homogeneous non-parametric functions.

I have uploaded all three packages to CRAN. They should be available
for download on CRAN and its mirrors (at latest) in a few days.

Feedback is highly welcome!

/Arne

-- 
Arne Henningsen
http://www.arne-henningsen.name

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Inverse matrix

2009-12-28 Thread FMH
Dear All,

Let A is a matrix which is:
A <- matrix(c(1,2,3,4),nrow=2) 

How could we find the inverse of A? I try to use ginv(A), but it didn't worked.

Thanks

Fir

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Inverse matrix

2009-12-28 Thread Henrique Dallazuanna
Try:

solve(a)

On Mon, Dec 28, 2009 at 8:53 AM, FMH  wrote:
> Dear All,
>
> Let A is a matrix which is:
> A <- matrix(c(1,2,3,4),nrow=2)
>
> How could we find the inverse of A? I try to use ginv(A), but it didn't 
> worked.
>
> Thanks
>
> Fir
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


[R] WHO Anthro growth curve macros and R

2009-12-28 Thread Gustaf Rydevik
Hi all,

I've got a project where I have to calculate weight-for-age Z-scores,
preferably using the WHO standards.

WHO have been very nice to publish macros for doing this in both
STATA,SPSS, SAS and Splus formats
(see http://www.who.int/childgrowth/software/en/), but for some reason
have chosen not to use the free R alternative to Splus.

In the Splus zipfile there are nine datafiles with a "sdd" file
ending, presumably data dumps from Splus 7.x. I've tried using
restore.data from the foreign package, but that does not work
(probably because the data is saved in the newer format).

I'm considering trying to read in spss files and massaging them to fit
to the format that the splus macro is expecting, but I'd prefer to be
able to use the Splus files directly.

Has anyone on the list tried using the WHO anthro macros with R, and
can tell me how they did it?
Alternatively, could some, very kind, person try and open the Splus
files, and save them in a R-readable format?
I would be extremely grateful for any help on this.

Best regards,

Gustaf Rydevik


-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] anova

2009-12-28 Thread Iasonas Lamprianou
Dear friends, 

I have run an ANOVA using a linear variable as dependent and a nominal variable 
with five groups as independent (factor). The F test is statistically 
significant F(4, 431)=2.54, p=0.036.However, the multiple comparisons have 
shown no difference between any two groups (no matter whether I used sheffe, 
tukeys, lsd etc). What is the interpretation?

Thanks
Jason




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


[R] Matrix to list object

2009-12-28 Thread Ron_M

let consider following matrix :

mat <- matrix(rnorm(45), 15)

Now I want  to convert it to a list object "mat_list", which will have 15
elements and each element will again be a matrix with 3 rows and 3 columns.

How can I do that?

Thanks,
-- 
View this message in context: 
http://n4.nabble.com/Matrix-to-list-object-tp989738p989738.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] To export results

2009-12-28 Thread Muhammad Rahiz

> write.table(x2, "filename.txt", col.name=FALSE, row.name=FALSE)

# where x2 = variable you want to save


Muhammad Rahiz  |  Doctoral Student in Regional Climate Modeling

Climate Research Laboratory, School of Geography & the Environment  
Oxford University Centre for the Environment
South Parks Road, Oxford, OX1 3QY, United Kingdom 
Tel: +44 (0)1865-285194	 Mobile: +44 (0)7854-625974

Email: muhammad.ra...@ouce.ox.ac.uk






sathiya_mtm wrote:

Hi

I am new to this software, Please tell me how to save the result to a word
or text format from R console.

For example, if I run a regression, and I want to save the result in the
word what should I do for that. Please do reply for my query.

Thanks
Arun Sathiya.



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


Re: [R] Matrix to list object

2009-12-28 Thread Henrique Dallazuanna
Try this:

mat_list <- lapply(split(mat, seq(nrow(mat))), matrix, ncol = 3)

On Mon, Dec 28, 2009 at 9:20 AM, Ron_M  wrote:
>
> let consider following matrix :
>
> mat <- matrix(rnorm(45), 15)
>
> Now I want  to convert it to a list object "mat_list", which will have 15
> elements and each element will again be a matrix with 3 rows and 3 columns.
>
> How can I do that?
>
> Thanks,
> --
> View this message in context: 
> http://n4.nabble.com/Matrix-to-list-object-tp989738p989738.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.
>



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

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


[R] auto regression

2009-12-28 Thread Gavriel & Esti Zoladz
I need to check if there is an auto regression in the data that I have. I
did find 'R functions for regression analysis', but I can't find the 'right'
one for me in there.

What would be the correct command to use in this case?

Thanks,
EZ

[[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] graph shading is overlaying axes

2009-12-28 Thread Dean1

How can I resolve this problem?...

As a general example,
plot (1:4)
polygon(c(0,0,5,5),c(0,5,5,0), border="lavenderblush1", col =
"lavenderblush1")
###see how this overlays the axes lines

#I have tried...
for (k in 1:4)  axis(k, lwd.ticks=0, label=F)
#...but this misses the corners


Any suggestions?
-- 
View this message in context: 
http://n4.nabble.com/graph-shading-is-overlaying-axes-tp989750p989750.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] Help with Moving Average in R

2009-12-28 Thread Saji Ren

thanks, man. And what a stupid mistake!!!

Plus, do you know any package in R that perform good rolling estimation?
-- 
View this message in context: 
http://n4.nabble.com/Help-with-Moving-Average-in-R-tp989627p989764.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] graph shading is overlaying axes

2009-12-28 Thread jim holtman
Try this:

plot (1:4)
polygon(c(0,0,5,5),c(0,5,5,0), border="lavenderblush1", col =
"lavenderblush1")
###see how this overlays the axes lines
box()



On Mon, Dec 28, 2009 at 6:38 AM, Dean1  wrote:

>
> How can I resolve this problem?...
>
> As a general example,
> plot (1:4)
> polygon(c(0,0,5,5),c(0,5,5,0), border="lavenderblush1", col =
> "lavenderblush1")
> ###see how this overlays the axes lines
>
> #I have tried...
> for (k in 1:4)  axis(k, lwd.ticks=0, label=F)
> #...but this misses the corners
>
>
> Any suggestions?
> --
> View this message in context:
> http://n4.nabble.com/graph-shading-is-overlaying-axes-tp989750p989750.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

[[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 and Finance - EAD, LGD, PD

2009-12-28 Thread Ricardo Gonçalves Silva
Thanks Liu,

You are right, my concerning is Basel II, and I was wondering to find a R 
package for this.
But I also can't find any package. 
By the way, since I'm in banking industry, I need to use the portfolio approach.
Any other hints still welcome.

Rick


From: Wensui Liu 
Sent: Sunday, December 27, 2009 11:13 PM
To: Cedrick W. Johnson 
Cc: Ricardo Gonçalves Silva ; R-Help 
Subject: Re: [R] R and Finance - EAD, LGD, PD


i think rick's questions are more related to basel II instead of R and don't 
think there is such a R package. 
per my limited knowledge, there are many ways to calculate PD, EAD, and LGD, 
either on portfolio level or on account level. So it really depends on how you 
are going to estimate them. On the side of consumer credit risk, it makes more 
sense to estimate 3 models on the account level, which should be under the 
umbrella of GLM. While PD / LGD are well studied, EAD is not. There are 
multiple ways to estimate EAD, such as LEQ/CCF/EADF, depending on the 
characteristic of accounts.


2009/12/27 Cedrick W. Johnson 

  Howdy-

  You may want to check out the R-sig-finance list and search through the 
postings here:
  http://n4.nabble.com/Rmetrics-f925806.html

  There's quite a few packages in the CRAN taskviews as well:

  http://cran.r-project.org/web/views/Finance.html

  -cj 



  Ricardo Gonçalves Silva wrote:

Hi,

I'm currently beginning to use R for financial analysis (mainly Basel II 
benchmarks) and I would like to know if any R-User can give me some initial 
directions on packages and tutorials which I can use to calculate capital 
requirements, default probabilities, and related stuff.

Thanks in advance,

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




-- 
==
WenSui Liu
Blog   : statcompute.spaces.live.com
Tough Times Never Last. But Tough People Do.  - Robert Schuller
==







Nenhum vírus encontrado nessa mensagem recebida.
Verificado por AVG - www.avgbrasil.com.br 
Versão: 9.0.722 / Banco de dados de vírus: 270.14.121/2589 - Data de 
Lançamento: 12/27/09 07:18:00

[[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] Modified R Code

2009-12-28 Thread jim holtman
For your problem A, why do you want to create so many variables?  Leave the
data in the 'newrate' list and reference the information from there.  It
will be much easier.  Think about the data structures that you want to work
with, especially if you have a variable number of objects/files that you are
going to be processing.  It is not entirely clear what you are trying to do,
but from the basic structure it does appear that with the right data
structure you can do what you want without having to 'replicate' a lot of
code.  For example, if you can easily reference the items in 'newrate' as
the following:

newrate[[1]]$min1
newrate[[2]]$max3# and so on

This can be done in a loop and it appears that most of Problem B can be
handled by common code.  You probably need to read a little more about
'lists' because they are your friend in these kind of situations.

On Sun, Dec 27, 2009 at 10:55 PM, Maithili Shiva
wrote:

>
> Dear R helpers,
>
> I have following input files. (Actually they are more than 10 rates but
> here i am considering only 2 rates to write my problem)
>
> rate1.csv
> min1max1min2  max2  min3   max3
> 1.051.30   1.30  1.65 1.65
> 1.99
>
> rate2.csv
> min1max1min2  max2  min3   max3
> 2.052.30   2.30  2.65 2.65
> 2.99
>
>
> The simple R code I had used to read these files was as given below -
>
> # OLD CODE
>
> rates1 = read.csv('rate1.csv)
> rates2 = read.csv('rate2.csv')
>
> rate1_min1  = rates1$min1
> rate1_max1 = rates1$max1
> rate1_min2  = rates1$min2
> rate1_max2 = rates1$max2
> rate1_min3  = rates1$min3
> rate1_max3 = rates1$max3
>
> rate2_min1  = rates2$min1
> rate2_max1 = rates2$max1
> rate2_min2  = rates2$min2
> rate2_max2 = rates2$max2
> rate2_min3  = rates2$min3
> rate2_max3 = rates2$max3
>
>
> Since I am not aware how many rates I will be dealing with (it can be 2, 4,
> or 10), hence I can't hardcode my input like I had defined above.
>
> So with the guidance of R - help, I had rerwitten the input code as given
> below.
>
> # NEW CODE
>
> n = 2  # It gives me no of rates
>
> X = paste('rate', 1:n, '.csv', sep = ' ' )
>
> # the output is "rate1.csv"  " rate2.csv"
>
> newrate = lapply(X, read.csv)
>
> # the output is as given below
>
> newrate
>
> [ [1] ]
> min1 max1min2  max2 min3   max3
> 1   1.051.30  1.301.65   1.651.99
>
> [ [2] ]
> min1 max1min2  max2 min3   max3
> 1   2.052.30  2.302.65   2.652.99
>
> ## _
>
> ## PROBLEM
>
> # PROBLEM - A
>
> If I apply the command (As given in OLD CODE above)
>
> rate1_min1  = rates1$min1
> # The output which I get is
> min1
> 1  1.05
>
> On similar lines I define
>
> rate1_min1 = newrate[[1]] [1]
> # The output which I get is
> min1
> 1  1.05
>
> rate1_max1 = newrate[[1]] [2]
>
> will give me output
>
> max1
> 1  1.30
>
> and so on.
>
> So I will have to define it 12 times to assign the respective min and max
> values.
>
> My problem is instead of hard coding like I have done in OLD CODE, I need
> to assign these respective input values using a loop or some other way (as
> it becomes cumbersome if no of rates exceed say 10 and also since I am not
> aware how many rate files i will be dealing with) so that in the end I
> should be able to assign (say) the values like
>
> rate1_min1  = 1.05
> rate1_max1 = 1.30
> rate1_min2  = 1.30
> rate1_max2 = 1.65
> rate1_min3  = 1.65
> rate1_max3 = 1.99
>
> rate2_min1  = 2.05
> rate2_max1 = 2.30
> rate2_min2  = 2.30
> rate2_max2 = 2.65
> rate2_min3  = 2.65
> rate2_max3 = 2.99
>
> If there are say 10 rates, then this will continue till
>
> rate10_min1 =  ..
> rate10_max1 = ..
> .
> so on.
>
> ## 
>
> # PROBLEM - B
>
> # Suppose Rij = ith Rate and jth range. (There are 3 ranges i.e. j= 3).
>
> data_label = expand.grid(c("R11", "R12", "R13"), c("R21", "R23", "R23"))
>
> # gives the output like
>
>   data_label
>  Var1Var2
> 1R11 R21
> 2R12 R21
> 3R13 R21
> 4R11 R22
> 5R12 R22
> 6R13 R22
> 7R11 R23
> 8R12 R23
> 9R13 R23
>
>
> If instead of two rates, suppose there are three rates, I will have to
> modify my code as
>
> data_label = expand.grid(c("R11", "R12", "R13"), c("R21", "R23", "R23"),
> c("R31", "R32", "R33"))
>
> If I define say
>
> n = no_of_rates  # I will be taking this figure from some otehr csv file.
>
> My PROBLEM = B is how do I write the above code pertaining to data_label in
> terms of 'n'.
>
> ## ___
>
> I understand I am giving the impression as I need some kind

Re: [R] Modified R Code

2009-12-28 Thread Maithili Shiva
Dear Sir,

Thanks a lot for your guidance. Definitely I will go through lists. The no of 
variables for any given rate say rate1 are three different ranges.

e.g. rate1 has three ranges

Range1  = (1.05 - 1.30) Range2  = (1.30 - 1.65)  Range3 = (1.65 - 
1.99)

Likewise rate2 has three ranges

Range1 =  (2.05 - 2.30)    Range3 = (2.30 - 2.65)        Range3 = (2.65 - 
2.99)

etc.    

(Sir, in the end I need to generate some no of random numbers from varios 
combinations of these two rates. Effectively there are 3^2 = 9 range 
combinations and I have already done it.)


Sir individually I was able to read newrate[[1]]$min1 etc. but my problem is 
construction of loop. I am not able to construct a loop though I tried varios 
options. But I get something like no of items mismatch something. 
(Unfortunately R is not installed on this machine as it doesn't belong to me so 
i can't give exact error message)


Sir, I need to write the loop for following (Loop is required as I don't know 
how many rates I will be dealiong with as an input.)

rate1_min1  = rates1$min1
rate1_max1 = rates1$max1
rate1_min2  = rates1$min2
rate1_max2 = rates1$max2
rate1_min3  = rates1$min3
rate1_max3 = rates1$max3
 

rate2_min1  = rates2$min1
rate2_max1 = rates2$max1
rate2_min2  = rates2$min2
rate2_max2 = rates2$max2
rate2_min3  = rates2$min3
rate2_max3 = rates2$max3

Sir, please advise.

Regards

Maithili





--- On Mon, 28/12/09, jim holtman  wrote:

From: jim holtman 
Subject: Re: [R] Modified R Code
To: "Maithili Shiva" 
Cc: r-help@r-project.org
Date: Monday, 28 December, 2009, 1:11 PM

For your problem A, why do you want to create so many variables?  Leave the 
data in the 'newrate' list and reference the information from there.  It will 
be much easier.  Think about the data structures that you want to work with, 
especially if you have a variable number of objects/files that you are going to 
be processing.  It is not entirely clear what you are trying to do, but from 
the basic structure it does appear that with the right data structure you can 
do what you want without having to 'replicate' a lot of code.  For example, if 
you can easily reference the items in 'newrate' as the following:

 
newrate[[1]]$min1
newrate[[2]]$max3    # and so on
 
This can be done in a loop and it appears that most of Problem B can be handled 
by common code.  You probably need to read a little more about 'lists' because 
they are your friend in these kind of situations.



On Sun, Dec 27, 2009 at 10:55 PM, Maithili Shiva  
wrote:


Dear R helpers,
 
I have following input files. (Actually they are more than 10 rates but here i 
am considering only 2 rates to write my problem)

 
rate1.csv
min1    max1    min2  max2  min3   max3
1.051.30   1.30  1.65 1.65  1.99
 
rate2.csv
min1    max1    min2  max2  min3   max3

2.052.30   2.30  2.65 2.65  2.99
  
 
The simple R code I had used to read these files was as given below -
 
# OLD CODE
 
rates1 = read.csv('rate1.csv)

rates2 = read.csv('rate2.csv')
 
rate1_min1  = rates1$min1
rate1_max1 = rates1$max1
rate1_min2  = rates1$min2
rate1_max2 = rates1$max2
rate1_min3  = rates1$min3
rate1_max3 = rates1$max3
 

rate2_min1  = rates2$min1
rate2_max1 = rates2$max1
rate2_min2  = rates2$min2
rate2_max2 = rates2$max2
rate2_min3  = rates2$min3
rate2_max3 = rates2$max3
 
 
Since I am not aware how many rates I will be dealing with (it can be 2, 4, or 
10), hence I can't hardcode my input like I had defined above.

 
So with the guidance of R - help, I had rerwitten the input code as given below.
 
# NEW CODE
 
n = 2  # It gives me no of rates
 
X = paste('rate', 1:n, '.csv', sep = ' ' )

 
# the output is "rate1.csv"  " rate2.csv"
 
newrate = lapply(X, read.csv)
 
# the output is as given below
 
newrate
 
[ [1] ]
    min1 max1    min2  max2 min3   max3

1   1.05    1.30  1.301.65   1.65    1.99
 
[ [2] ]  
    min1 max1    min2  max2 min3   max3
1   2.05    2.30  2.302.65   2.65    2.99

 
## _
 
## PROBLEM
 
# PROBLEM - A
 
If I apply the command (As given in OLD CODE above)
 
rate1_min1  = rates1$min1
# The output which I get is 

    min1
1  1.05
 
On similar lines I define
 
rate1_min1 = newrate[[1]] [1]
# The output which I get is 
    min1
1  1.05
 
rate1_max1 = newrate[[1]] [2]
 
will give me output
 

    max1
1  1.30
 
and so on.
 
So I will have to define it 12 times to assign the respective min and max 
values. 
 
My problem is instead of hard coding like I have done in OLD CODE, I need to 
assign these respective input values using a loop or some other way (as it 
becomes cumbersome if no of rates exceed say 10 and also since I am not aware 
how many rate files

Re: [R] Modified R Code

2009-12-28 Thread jim holtman
I would still think you should look at lists.  For example, your ranges
could be specified with:

> ranges <- list(list(c(1.05, 1.3), c(1.3,.65), c(1.65, 1.99)),
+list(c(2.05, 2.3), c(2.3, 2.65), c(2.65, 2.99)))
>
> ranges
[[1]]
[[1]][[1]]
[1] 1.05 1.30
[[1]][[2]]
[1] 1.30 0.65
[[1]][[3]]
[1] 1.65 1.99

[[2]]
[[2]][[1]]
[1] 2.05 2.30
[[2]][[2]]
[1] 2.30 2.65
[[2]][[3]]
[1] 2.65 2.99


And you can reference each on with indices from a loop.

If you are really set on creating a lot of objects, then the following loop
might do it for you:

for (i in 1:length(newrate)){
for (j in names(newrate[[i]])){
assign(paste('rate', i, '_', j, sep=''), newrate[[i]][j])
}
}



On Mon, Dec 28, 2009 at 8:31 AM, Maithili Shiva wrote:

>   Dear Sir,
>
> Thanks a lot for your guidance. Definitely I will go through lists. The no
> of variables for any given rate say rate1 are three different ranges.
>
> e.g. rate1 has three ranges
>
> Range1  = (1.05 - 1.30) Range2  = (1.30 - 1.65)  Range3 = (1.65
> - 1.99)
>
> Likewise rate2 has three ranges
>
> Range1 =  (2.05 - 2.30)Range3 = (2.30 - 2.65)Range3 = (2.65
> - 2.99)
>
> etc.
>
> (Sir, in the end I need to generate some no of random numbers from varios
> combinations of these two rates. Effectively there are 3^2 = 9 range
> combinations and I have already done it.)
>
>
> Sir individually I was able to read newrate[[1]]$min1 etc. but my problem
> is construction of loop. I am not able to construct a loop though I tried
> varios options. But I get something like no of items mismatch something.
> (Unfortunately R is not installed on this machine as it doesn't belong to me
> so i can't give exact error message)
>
>
> Sir, I need to write the loop for following (Loop is required as I don't
> know how many rates I will be dealiong with as an input.)
>
>
> rate1_min1  = rates1$min1
> rate1_max1 = rates1$max1
> rate1_min2  = rates1$min2
> rate1_max2 = rates1$max2
> rate1_min3  = rates1$min3
> rate1_max3 = rates1$max3
>
> rate2_min1  = rates2$min1
> rate2_max1 = rates2$max1
> rate2_min2  = rates2$min2
> rate2_max2 = rates2$max2
> rate2_min3  = rates2$min3
> rate2_max3 = rates2$max3
>
> Sir, please advise.
>
> Regards
>
> Maithili
>
>
>
>
>
> --- On *Mon, 28/12/09, jim holtman * wrote:
>
>
> From: jim holtman 
> Subject: Re: [R] Modified R Code
> To: "Maithili Shiva" 
> Cc: r-help@r-project.org
> Date: Monday, 28 December, 2009, 1:11 PM
>
>
>  For your problem A, why do you want to create so many variables?  Leave
> the data in the 'newrate' list and reference the information from there.  It
> will be much easier.  Think about the data structures that you want to work
> with, especially if you have a variable number of objects/files that you are
> going to be processing.  It is not entirely clear what you are trying to do,
> but from the basic structure it does appear that with the right data
> structure you can do what you want without having to 'replicate' a lot of
> code.  For example, if you can easily reference the items in 'newrate' as
> the following:
>
> newrate[[1]]$min1
> newrate[[2]]$max3# and so on
>
> This can be done in a loop and it appears that most of Problem B can be
> handled by common code.  You probably need to read a little more about
> 'lists' because they are your friend in these kind of situations.
>
> On Sun, Dec 27, 2009 at 10:55 PM, Maithili Shiva 
> http://mc/compose?to=maithili_sh...@yahoo.com>
> > wrote:
>
>>
>> Dear R helpers,
>>
>> I have following input files. (Actually they are more than 10 rates but
>> here i am considering only 2 rates to write my problem)
>>
>> rate1.csv
>> min1max1min2  max2  min3
>> max3
>> 1.051.30   1.30
>> 1.65 1.65  1.99
>>
>> rate2.csv
>> min1max1min2  max2  min3
>> max3
>> 2.052.30   2.30
>> 2.65 2.65  2.99
>>
>>
>> The simple R code I had used to read these files was as given below -
>>
>> # OLD CODE
>>
>> rates1 = read.csv('rate1.csv)
>> rates2 = read.csv('rate2.csv')
>>
>> rate1_min1  = rates1$min1
>> rate1_max1 = rates1$max1
>> rate1_min2  = rates1$min2
>> rate1_max2 = rates1$max2
>> rate1_min3  = rates1$min3
>> rate1_max3 = rates1$max3
>>
>> rate2_min1  = rates2$min1
>> rate2_max1 = rates2$max1
>> rate2_min2  = rates2$min2
>> rate2_max2 = rates2$max2
>> rate2_min3  = rates2$min3
>> rate2_max3 = rates2$max3
>>
>>
>> Since I am not aware how many rates I will be dealing with (it can be 2,
>> 4, or 10), hence I can't hardcode my input like I had defined above.
>>
>> So with the guidance of R - help, I had rerwitten the input code as given
>> below.
>>
>> # NEW CODE
>>
>> n = 2  # It gives me no of rates
>>
>> X = paste('rate', 1:n, '.csv', sep = ' ' )
>>
>> # the output is "rate1.csv"  " rate2.csv"
>>
>> newrate = lapply(X, read.csv)
>>
>> # the output is as given below
>>
>> newrate
>>
>> [ [1] ]
>> m

Re: [R] To export results

2009-12-28 Thread David Winsemius


On Dec 28, 2009, at 12:19 AM, sathiya_mtm wrote:



Hi

I am new to this software, Please tell me how to save the result to  
a word

or text format from R console.

For example, if I run a regression, and I want to save the result in  
the

word what should I do for that. Please do reply for my query.


?capture.output
?sink

perhaps:
capture.output(fit<- lm(y~z), file="lmout.txt")

or even:
fit<- lm(y~z)
capture.output( summary(fit), file="lmout.txt")



Thanks
Arun Sathiya.
--
View this message in context: 
http://n4.nabble.com/To-export-results-tp989600p989600.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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

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


[R] Ops method does not dispatch on either of two classes

2009-12-28 Thread Jens Oehlschlägel
I have defined boolean methods for bit and bitwhich objects, for example
|.bit <- function(e1,e2)
and
|.bitwhich <- function(e1,e2)

Both methods coerce their arguments to the respective class, however if I do 
something like 

bit_obj | bitwhich_obj

then I get a warning 

Warning message:
Incompatible methods ("|.bit", "|.bitwhich") for "|" 

and none of the two methods is called. Instead the (internal) method for 
logicals seems to be called - not even coercing its arguments to logical. Same 
problem with Ops.bit and Ops.bitwhich .

What is the recommended way to get my methods reliably dispatched? 

Jens Oehlschlägel

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


[R] Help With Custom QQ Plot

2009-12-28 Thread Adam Carr
Good Morning:

I have attached a text file with one hundred thirty six observations. I would 
like to create a qq plot with the following features:

1. Observed values on the y-axis.
2. Normal approximation line on the plot.
3. X-axis with vertical reference lines at the following percentiles of the 
data: 1, 10, 20, 50, 80, 90 and 99.
4. Data appearing on the plot as distinct points.

I assume that qqmath (lattice) is the best approach to this although I have not 
been able to sort out the proper syntax to yield the plot I'm after. I 
understand how to determine the quantiles of the data, and I can use qqmath() 
to generate a plot which has the observed values on the y-axis, and the plot is 
based on a normal distribution, but beyond this I'm struggling.

I do not have the R Graphics text by  or Visualizing Data by Bill Cleveland but 
I have several other R books (Crawley, Ugarte et al, Braun/Murdoch, Rizzo, etc) 
but coverage of the lattice package seems light.

I very much appreciate any help that could be offered.

Thank you.

Adam


  113
116
120
120
124
114
118
117
118
119
116
113
118
112
129
117
118
112
114
125
125
116
123
121
113
118
121
127
125
127
125
125
115
115
114
118
128
121
118
115
114
117
120
112
131
131
127
115
112
116
116
111
115
120
113
117
124
119
112
114
116
115
126
124
121
112
121
116
117
115
115
112
116
115
118
119
118
114
115
112
115.5
110
120
119
111
121
118
118
119
117
113
115
117
110
113
113
113
119
116
115
116
TUS
114
120
118
117
116
124
113
117
114
115
116
114
124
118
115
112
115
115
115
117
117
130
116
113
116
114
117
114
117
119
113
113
114
112
119
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] anova

2009-12-28 Thread Ista Zahn
This email list is about R, not introductory statistics. But the
answer to your question is: reject the 4 df hypothesis that the
population means of the 5 groups are all equal. Retain each single df
hypothesis about pairwise population mean differences.

-Ista

On Mon, Dec 28, 2009 at 6:02 AM, Iasonas Lamprianou
 wrote:
> Dear friends,
>
> I have run an ANOVA using a linear variable as dependent and a nominal 
> variable with five groups as independent (factor). The F test is 
> statistically significant F(4, 431)=2.54, p=0.036.However, the multiple 
> comparisons have shown no difference between any two groups (no matter 
> whether I used sheffe, tukeys, lsd etc). What is the interpretation?
>
> Thanks
> Jason
>
>
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

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


Re: [R] [BioC] make.cdf.package: Error: cannot allocate vector of size 1 Kb

2009-12-28 Thread Peng Yu
My machine has 8GB memory. I had quit all other programs that might
take a lot of memory when I try the script (before I post the first
message in this thread). The cdf file is of only 741 MB. It is strange
to me to see the error.

On Mon, Dec 28, 2009 at 2:38 AM, Wolfgang Huber  wrote:
> Dear Peng Yu
>
> how big is the RAM of your computer? You could try with closing all other
> applications before running this script. You could try on a server with more
> RAM.
>
> I tried downloading the file whose URL who give below, but gave up after
> some failed rounds with the extraordinarily annoying and intrusive
> registration procedure that Affymetrix has set up for this. Let us know how
> it goes with the suggestions above, if they don't help, I'd try again with
> that.
>
>        Best wishes
>        Wolfgang
>
>
>> I run the following example. The cdf file is downloaded from the
>> following link. I'm wondering what the problem is with
>> make.cdf.package.
>>
>>
>> http://www.affymetrix.com/Auth/support/downloads/library_files/MoEx-1_0-st-v1.text.cdf.zip
>>
>> $ Rscript MoEx-1_0-st-v1.cdf.R
>>>
>>> library(makecdfenv)
>>
>> Loading required package: Biobase
>>
>> Welcome to Bioconductor
>>
>>  Vignettes contain introductory material. To view, type
>>  'openVignette()'. To cite Bioconductor, see
>>  'citation("Biobase")' and for packages 'citation(pkgname)'.
>>
>> Loading required package: affy
>> Loading required package: affyio
>>>
>>> sessionInfo()
>>
>> R version 2.10.0 (2009-10-26)
>> x86_64-unknown-linux-gnu
>>
>> locale:
>>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>>  [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> other attached packages:
>> [1] makecdfenv_1.24.0 affyio_1.14.0     affy_1.24.2       Biobase_2.6.1
>>
>> loaded via a namespace (and not attached):
>> [1] preprocessCore_1.8.0
>>>
>>> make.cdf.package('MoEx-1_0-st-v1.text.cdf', species='Mus_musculus')
>>
>> Reading CDF file.
>> Error: cannot allocate vector of size 1 Kb
>> Execution halted
>>
>> ___
>> Bioconductor mailing list
>> bioconduc...@stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>> Search the archives:
>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>
>
>
> --
> Wolfgang Huber
> EMBL
> http://www.embl.de/research/units/genome_biology/huber/contact
>
>
>

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


[R] How to change the default Date format for write.csv function?

2009-12-28 Thread George . Zou
Hi,

I have a data.frame containing a Date column.  When using write.csv() 
function to generate a CSV file, I always get the Date column formatted as 
"-MM-DD".   I would like to have it formatted as "MM/DD/", but 
could not find an  easy way to do it.Here is the test code:

d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03", 
"2009-12-04")), price=c(120.00, 123.00))
write.csv(d, file="C:/temp/test.csv", row.names=FALSE)

The test.csv generated looks like this:

"ticker","date","price"
"IBM",2009-12-03,120
"IBM",2009-12-04,123

I would like to have the date fields in the CSV formatted as "MM/DD/". 
 Is there any easy way to do this?

Thanks in advance.

George Zou

The information contained in this e-mail, and any attachment, is confidential 
and is intended solely for the use of the intended recipient. Access, copying 
or re-use of the e-mail or any attachment, or any information contained 
therein, by any other person is not authorized. If you are not the intended 
recipient please return the e-mail to the sender and delete it from your 
computer. Although we attempt to sweep e-mail and attachments for viruses, we 
do not guarantee that either are virus-free and accept no liability for any 
damage sustained as a result of viruses. 

Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures 
relating to European legal entities.
[[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] Help with Moving Average in R

2009-12-28 Thread Berend Hasselman


On 28-12-2009, at 13:53, Saji Ren [via R] wrote:

> thanks, man. And what a stupid mistake!!! 
> 

My pleasure.
> Plus, do you know any package in R that perform good rolling estimation? 
> 

No.
But I did a search on "rolling estimation" in the R-help mailing list on Nabble 
and found this

http://n4.nabble.com/How-to-compute-Rolling-analysis-of-Standard-Deviation-using-ZOO-package-td862392.html#a862392

I then had a look at the help in the zoo package  for rollapply.
>From the examples I see that rollapply can be used for a rolling regression.
Good luck.

Berend


-- 
View this message in context: 
http://n4.nabble.com/Help-with-Moving-Average-in-R-tp989627p989828.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] How to change the default Date format for write.csv function?

2009-12-28 Thread jim holtman
try this:

d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03",
"2009-12-04")), price=c(120.00, 123.00))
# convert to your desired format
d$mydate <- format(d$date, "%m/%d/%Y")
write.csv(subset(d, select=-date), file="C:/temp/test.csv", row.names=FALSE)


On Mon, Dec 28, 2009 at 10:19 AM,  wrote:

> Hi,
>
> I have a data.frame containing a Date column.  When using write.csv()
> function to generate a CSV file, I always get the Date column formatted as
> "-MM-DD".   I would like to have it formatted as "MM/DD/", but
> could not find an  easy way to do it.Here is the test code:
>
> d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03",
> "2009-12-04")), price=c(120.00, 123.00))
> write.csv(d, file="C:/temp/test.csv", row.names=FALSE)
>
> The test.csv generated looks like this:
>
> "ticker","date","price"
> "IBM",2009-12-03,120
> "IBM",2009-12-04,123
>
> I would like to have the date fields in the CSV formatted as "MM/DD/".
>  Is there any easy way to do this?
>
> Thanks in advance.
>
> George Zou
>
> The information contained in this e-mail, and any attachment, is
> confidential and is intended solely for the use of the intended recipient.
> Access, copying or re-use of the e-mail or any attachment, or any
> information contained therein, by any other person is not authorized. If you
> are not the intended recipient please return the e-mail to the sender and
> delete it from your computer. Although we attempt to sweep e-mail and
> attachments for viruses, we do not guarantee that either are virus-free and
> accept no liability for any damage sustained as a result of viruses.
>
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain
> disclosures relating to European legal entities.
>[[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.
>



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

What is the problem that you are trying to solve?

[[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 change the default Date format for write.csv function?

2009-12-28 Thread Henrique Dallazuanna
Try this:

newD <- replace(d, sapply(d, function(x)inherits(x, "Date")),
format(d[sapply(d, function(x)inherits(x, "Date"))], "%m/%d/%Y"))
write.csv(newD, file="C:/temp/test.csv", row.names=FALSE)

On Mon, Dec 28, 2009 at 1:19 PM,   wrote:
> Hi,
>
> I have a data.frame containing a Date column.  When using write.csv()
> function to generate a CSV file, I always get the Date column formatted as
> "-MM-DD".   I would like to have it formatted as "MM/DD/", but
> could not find an  easy way to do it.    Here is the test code:
>
> d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03",
> "2009-12-04")), price=c(120.00, 123.00))
> write.csv(d, file="C:/temp/test.csv", row.names=FALSE)
>
> The test.csv generated looks like this:
>
> "ticker","date","price"
> "IBM",2009-12-03,120
> "IBM",2009-12-04,123
>
> I would like to have the date fields in the CSV formatted as "MM/DD/".
>  Is there any easy way to do this?
>
> Thanks in advance.
>
> George Zou
>
> The information contained in this e-mail, and any attachment, is confidential 
> and is intended solely for the use of the intended recipient. Access, copying 
> or re-use of the e-mail or any attachment, or any information contained 
> therein, by any other person is not authorized. If you are not the intended 
> recipient please return the e-mail to the sender and delete it from your 
> computer. Although we attempt to sweep e-mail and attachments for viruses, we 
> do not guarantee that either are virus-free and accept no liability for any 
> damage sustained as a result of viruses.
>
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain 
> disclosures relating to European legal entities.
>        [[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.
>



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

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


Re: [R] How to change the default Date format for write.csv function?

2009-12-28 Thread Gabor Grothendieck
Try this:

> write.csv(transform(d, date = format(date, "%m/%d/%Y")))
"","ticker","date","price"
"1","IBM","12/03/2009",120
"2","IBM","12/04/2009",123


On Mon, Dec 28, 2009 at 10:19 AM,   wrote:
> Hi,
>
> I have a data.frame containing a Date column.  When using write.csv()
> function to generate a CSV file, I always get the Date column formatted as
> "-MM-DD".   I would like to have it formatted as "MM/DD/", but
> could not find an  easy way to do it.    Here is the test code:
>
> d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03",
> "2009-12-04")), price=c(120.00, 123.00))
> write.csv(d, file="C:/temp/test.csv", row.names=FALSE)
>
> The test.csv generated looks like this:
>
> "ticker","date","price"
> "IBM",2009-12-03,120
> "IBM",2009-12-04,123
>
> I would like to have the date fields in the CSV formatted as "MM/DD/".
>  Is there any easy way to do this?
>
> Thanks in advance.
>
> George Zou
>
> The information contained in this e-mail, and any attachment, is confidential 
> and is intended solely for the use of the intended recipient. Access, copying 
> or re-use of the e-mail or any attachment, or any information contained 
> therein, by any other person is not authorized. If you are not the intended 
> recipient please return the e-mail to the sender and delete it from your 
> computer. Although we attempt to sweep e-mail and attachments for viruses, we 
> do not guarantee that either are virus-free and accept no liability for any 
> damage sustained as a result of viruses.
>
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain 
> disclosures relating to European legal entities.
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] WHO Anthro growth curve macros and R

2009-12-28 Thread Frank E Harrell Jr

Gustaf,

I would be advisable to first check that such z scores are valid 
statistically (I have my doubts).  They make a number of assumptions, 
chief among them being that un-normalized weight is not a proper 
physiologic summary.  It is almost always the case that joint modeling 
of age and weight (e.g., ANCOVA) works better.


Frank

Gustaf Rydevik wrote:

Hi all,

I've got a project where I have to calculate weight-for-age Z-scores,
preferably using the WHO standards.

WHO have been very nice to publish macros for doing this in both
STATA,SPSS, SAS and Splus formats
(see http://www.who.int/childgrowth/software/en/), but for some reason
have chosen not to use the free R alternative to Splus.

In the Splus zipfile there are nine datafiles with a "sdd" file
ending, presumably data dumps from Splus 7.x. I've tried using
restore.data from the foreign package, but that does not work
(probably because the data is saved in the newer format).

I'm considering trying to read in spss files and massaging them to fit
to the format that the splus macro is expecting, but I'd prefer to be
able to use the Splus files directly.

Has anyone on the list tried using the WHO anthro macros with R, and
can tell me how they did it?
Alternatively, could some, very kind, person try and open the Splus
files, and save them in a R-readable format?
I would be extremely grateful for any help on this.

Best regards,

Gustaf Rydevik





--
Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
 Department of Biostatistics   Vanderbilt University

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


Re: [R] graph shading is overlaying axes

2009-12-28 Thread Dean1

Thanks, this solves the problem
-- 
View this message in context: 
http://n4.nabble.com/graph-shading-is-overlaying-axes-tp989750p989787.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] apply loop - using/providing a data frame to loop over

2009-12-28 Thread Daniel Malter
Hi,

I want to extract individual names from a single string that contains all
names. My problem is not the extraction itself, but the looping over the
extraction start and end points, which I try to realize with apply.

#Say, I have a string with names.
authors=c("Schleyer T, Spallek H, Butler BS, Subramanian S, Weiss D,
Poythress ML, Rattanathikun P, Mueller G")

#Since I only want the surname and the initial of the first name, I create
respective indices
starts=c(1, 13, 24, 35, 50, 59, 73, 90)
ends=c(10, 21, 31, 47, 56, 69, 87, 98)

#Now I can extract the names, e.g. the third one, with
substr(authors,start=starts[3],stop=ends[3])

#So far so good, but I want to loop over all indices using apply
#For that I wrote a function g, that takes "a" as the author string, and
"data" as the start and end points for extraction
g=function(a,data){substr(a,data[,1],data[,2])}

#If provided with a specific row of the data frame, g works
g(authors,data.frame(starts,ends)[3,])

#If I try to loop g through the rows of the starts/ends data frame, it does
not work.
apply(data.frame(starts,ends),1,g,a=authors)

#Interestingly, if the data frame to loop over is just a vector, it works
also (e.g. for extracting just the first initial)
g=function(e,a){substr(a,e,e)}
apply(data.frame(ends),1,g,a=authors)

So the problem probably lies in correctly supplying "apply" with the data
frame. I would greatly appreciate your help.

Daniel

---
"Who has visions should see a doctor," 
Helmut Schmidt, German Chancellor (1974-1982).

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] refering to the 'boundaries' of a graph

2009-12-28 Thread Dean1

Please see this code for a demonstration of my problem...

xlim <- c(-1,5)
plot(1:4, xlim=xlim)
abline(v=xlim[1])
abline(v=xlim[2])

When I refer to xlim, it is not referring to the boundaries of the graphical
region, it refers to the maximum and minimum xticks.  My question is how can
I refer to the x axis boundaries (and similarly y axis) of the graph?
-- 
View this message in context: 
http://n4.nabble.com/refering-to-the-boundaries-of-a-graph-tp989790p989790.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] WHO Anthro growth curve macros and R

2009-12-28 Thread Thomas Lumley

On Mon, 28 Dec 2009, Gustaf Rydevik wrote:


Hi all,

I've got a project where I have to calculate weight-for-age Z-scores,
preferably using the WHO standards.

WHO have been very nice to publish macros for doing this in both
STATA,SPSS, SAS and Splus formats
(see http://www.who.int/childgrowth/software/en/), but for some reason
have chosen not to use the free R alternative to Splus.




I'm considering trying to read in spss files and massaging them to fit
to the format that the splus macro is expecting, but I'd prefer to be
able to use the Splus files directly.

Has anyone on the list tried using the WHO anthro macros with R, and
can tell me how they did it?
Alternatively, could some, very kind, person try and open the Splus
files, and save them in a R-readable format?


It looks as though only very minimal editing of the S-PLUS code would be needed 
to make it work in R, and read.spss or read.dta would be able to read in the 
SPSS or Stata versions of the reference data. Making an R package would be 
pretty straightforward. However,  the license says

"The User is not permitted to modify, adapt, translate, reverse engineer, decompile, disassemble, 
or otherwise attempt to discover the source code of the software, without prior permission from 
WHO.  "


I'm assuming that simply echoing the .ssc file to the screen doesn't violate 
this, but anything that would make the functions usable probably would.

 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity 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] How to change the default Date format for write.csv function?

2009-12-28 Thread George . Zou
Hi,

This problem might be a little harder than it appears. 

I receive a few emails all suggesting that convert the Date field to 
character by calling format(date, "%m/%d/%Y") in one way or another. Well, 
this is not the solution I'm looking for and it doesn't work for me.   All 
the date fields are generated with quotes around them, which will be 
treated by other software as string instead of date.   Please note, the 
write.csv() function doesn't put quotes around date.   All I need is to 
change the format behavior of Date without adding any quotes.  So the 
output of CSV I'm looking for should be:

"ticker","date","price"
"IBM",12/03/2009,120
"IBM",12/04/2009,123

Not this:

"ticker","date","price"
"IBM","12/03/2009",120
"IBM","12/04/2009",123

Thanks for trying though.

George



From:
george@bnymellon.com
To:
r-help@r-project.org
Date:
12/28/2009 10:20 AM
Subject:
[R] How to change the default Date format for write.csv function?
Sent by:
r-help-boun...@r-project.org



Hi,

I have a data.frame containing a Date column.  When using write.csv() 
function to generate a CSV file, I always get the Date column formatted as 

"-MM-DD".   I would like to have it formatted as "MM/DD/", but 
could not find an  easy way to do it.Here is the test code:

d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03", 
"2009-12-04")), price=c(120.00, 123.00))
write.csv(d, file="C:/temp/test.csv", row.names=FALSE)

The test.csv generated looks like this:

"ticker","date","price"
"IBM",2009-12-03,120
"IBM",2009-12-04,123

I would like to have the date fields in the CSV formatted as "MM/DD/". 

 Is there any easy way to do this?

Thanks in advance.

George Zou

The information contained in this e-mail, and any attachment, is 
confidential and is intended solely for the use of the intended recipient. 
Access, copying or re-use of the e-mail or any attachment, or any 
information contained therein, by any other person is not authorized. If 
you are not the intended recipient please return the e-mail to the sender 
and delete it from your computer. Although we attempt to sweep e-mail and 
attachments for viruses, we do not guarantee that either are virus-free 
and accept no liability for any damage sustained as a result of viruses. 

Please refer to http://disclaimer.bnymellon.com/eu.htm for certain 
disclosures relating to European legal entities.
 [[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.




The information contained in this e-mail, and any attachment, is confidential 
and is intended solely for the use of the intended recipient. Access, copying 
or re-use of the e-mail or any attachment, or any information contained 
therein, by any other person is not authorized. If you are not the intended 
recipient please return the e-mail to the sender and delete it from your 
computer. Although we attempt to sweep e-mail and attachments for viruses, we 
do not guarantee that either are virus-free and accept no liability for any 
damage sustained as a result of viruses. 

Please refer to http://disclaimer.bnymellon.com/eu.htm for certain disclosures 
relating to European legal entities.
[[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] refering to the 'boundaries' of a graph

2009-12-28 Thread Henrique Dallazuanna
Try this:

par("usr") give the boundaries.

abline(v = par("usr")[1], col = "red", lwd = 2)
abline(v = par("usr")[2], col = "red", lwd = 2)

On Mon, Dec 28, 2009 at 11:55 AM, Dean1  wrote:
>
> Please see this code for a demonstration of my problem...
>
> xlim <- c(-1,5)
> plot(1:4, xlim=xlim)
> abline(v=xlim[1])
> abline(v=xlim[2])
>
> When I refer to xlim, it is not referring to the boundaries of the graphical
> region, it refers to the maximum and minimum xticks.  My question is how can
> I refer to the x axis boundaries (and similarly y axis) of the graph?
> --
> View this message in context: 
> http://n4.nabble.com/refering-to-the-boundaries-of-a-graph-tp989790p989790.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.
>



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

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


Re: [R] apply loop - using/providing a data frame to loop over

2009-12-28 Thread Gabor Grothendieck
Try this. It picks out each string of word characters (\w+) followed
by a space followed by a word character:

> library(gsubfn)
> strapply(authors, "\\w+ \\w", c)[[1]]
[1] "Schleyer T"  "Spallek H"   "Butler B""Subramanian S"
[5] "Weiss D" "Poythress M" "Rattanathikun P" "Mueller G"

You might need to adjust the regular expression slightly depending on
what the general case is.  See http://gsubfn.googlecode.com for more.

On Mon, Dec 28, 2009 at 7:46 AM, Daniel Malter  wrote:
> Hi,
>
> I want to extract individual names from a single string that contains all
> names. My problem is not the extraction itself, but the looping over the
> extraction start and end points, which I try to realize with apply.
>
> #Say, I have a string with names.
> authors=c("Schleyer T, Spallek H, Butler BS, Subramanian S, Weiss D,
> Poythress ML, Rattanathikun P, Mueller G")
>
> #Since I only want the surname and the initial of the first name, I create
> respective indices
> starts=c(1, 13, 24, 35, 50, 59, 73, 90)
> ends=c(10, 21, 31, 47, 56, 69, 87, 98)
>
> #Now I can extract the names, e.g. the third one, with
> substr(authors,start=starts[3],stop=ends[3])
>
> #So far so good, but I want to loop over all indices using apply
> #For that I wrote a function g, that takes "a" as the author string, and
> "data" as the start and end points for extraction
> g=function(a,data){substr(a,data[,1],data[,2])}
>
> #If provided with a specific row of the data frame, g works
> g(authors,data.frame(starts,ends)[3,])
>
> #If I try to loop g through the rows of the starts/ends data frame, it does
> not work.
> apply(data.frame(starts,ends),1,g,a=authors)
>
> #Interestingly, if the data frame to loop over is just a vector, it works
> also (e.g. for extracting just the first initial)
> g=function(e,a){substr(a,e,e)}
> apply(data.frame(ends),1,g,a=authors)
>
> So the problem probably lies in correctly supplying "apply" with the data
> frame. I would greatly appreciate your help.
>
> Daniel
>
> ---
> "Who has visions should see a doctor,"
> Helmut Schmidt, German Chancellor (1974-1982).
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] How to change the default Date format for write.csv function?

2009-12-28 Thread Henrique Dallazuanna
Use the quote argument:

write.csv(d, file="C:/temp/test.csv", row.names=FALSE, quote = FALSE)

On Mon, Dec 28, 2009 at 2:17 PM,   wrote:
> Hi,
>
> This problem might be a little harder than it appears.
>
> I receive a few emails all suggesting that convert the Date field to
> character by calling format(date, "%m/%d/%Y") in one way or another. Well,
> this is not the solution I'm looking for and it doesn't work for me.   All
> the date fields are generated with quotes around them, which will be
> treated by other software as string instead of date.   Please note, the
> write.csv() function doesn't put quotes around date.   All I need is to
> change the format behavior of Date without adding any quotes.  So the
> output of CSV I'm looking for should be:
>
> "ticker","date","price"
> "IBM",12/03/2009,120
> "IBM",12/04/2009,123
>
> Not this:
>
> "ticker","date","price"
> "IBM","12/03/2009",120
> "IBM","12/04/2009",123
>
> Thanks for trying though.
>
> George
>
>
>
> From:
> george@bnymellon.com
> To:
> r-help@r-project.org
> Date:
> 12/28/2009 10:20 AM
> Subject:
> [R] How to change the default Date format for write.csv function?
> Sent by:
> r-help-boun...@r-project.org
>
>
>
> Hi,
>
> I have a data.frame containing a Date column.  When using write.csv()
> function to generate a CSV file, I always get the Date column formatted as
>
> "-MM-DD".   I would like to have it formatted as "MM/DD/", but
> could not find an  easy way to do it.    Here is the test code:
>
> d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03",
> "2009-12-04")), price=c(120.00, 123.00))
> write.csv(d, file="C:/temp/test.csv", row.names=FALSE)
>
> The test.csv generated looks like this:
>
> "ticker","date","price"
> "IBM",2009-12-03,120
> "IBM",2009-12-04,123
>
> I would like to have the date fields in the CSV formatted as "MM/DD/".
>
>  Is there any easy way to do this?
>
> Thanks in advance.
>
> George Zou
>
> The information contained in this e-mail, and any attachment, is
> confidential and is intended solely for the use of the intended recipient.
> Access, copying or re-use of the e-mail or any attachment, or any
> information contained therein, by any other person is not authorized. If
> you are not the intended recipient please return the e-mail to the sender
> and delete it from your computer. Although we attempt to sweep e-mail and
> attachments for viruses, we do not guarantee that either are virus-free
> and accept no liability for any damage sustained as a result of viruses.
>
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain
> disclosures relating to European legal entities.
>                 [[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.
>
>
>
>
> The information contained in this e-mail, and any attachment, is confidential 
> and is intended solely for the use of the intended recipient. Access, copying 
> or re-use of the e-mail or any attachment, or any information contained 
> therein, by any other person is not authorized. If you are not the intended 
> recipient please return the e-mail to the sender and delete it from your 
> computer. Although we attempt to sweep e-mail and attachments for viruses, we 
> do not guarantee that either are virus-free and accept no liability for any 
> damage sustained as a result of viruses.
>
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain 
> disclosures relating to European legal entities.
>        [[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.
>



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

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


Re: [R] How to change the default Date format for write.csv function?

2009-12-28 Thread George . Zou
Nice try, but that will turn off quote for all fields.  I want quotes for 
text fields, and no quotes for date and numeric fields.   Please see the 
desired CSV output in my previous email. 

George



From:
Henrique Dallazuanna 
To:
george@bnymellon.com
Cc:
r-help@r-project.org
Date:
12/28/2009 12:44 PM
Subject:
Re: [R] How to change the default Date format for write.csv function?
Sent by:
r-help-boun...@r-project.org



Use the quote argument:

write.csv(d, file="C:/temp/test.csv", row.names=FALSE, quote = FALSE)

On Mon, Dec 28, 2009 at 2:17 PM,   wrote:
> Hi,
>
> This problem might be a little harder than it appears.
>
> I receive a few emails all suggesting that convert the Date field to
> character by calling format(date, "%m/%d/%Y") in one way or another. 
Well,
> this is not the solution I'm looking for and it doesn't work for me.   
All
> the date fields are generated with quotes around them, which will be
> treated by other software as string instead of date.   Please note, the
> write.csv() function doesn't put quotes around date.   All I need is to
> change the format behavior of Date without adding any quotes.  So the
> output of CSV I'm looking for should be:
>
> "ticker","date","price"
> "IBM",12/03/2009,120
> "IBM",12/04/2009,123
>
> Not this:
>
> "ticker","date","price"
> "IBM","12/03/2009",120
> "IBM","12/04/2009",123
>
> Thanks for trying though.
>
> George
>
>
>
> From:
> george@bnymellon.com
> To:
> r-help@r-project.org
> Date:
> 12/28/2009 10:20 AM
> Subject:
> [R] How to change the default Date format for write.csv function?
> Sent by:
> r-help-boun...@r-project.org
>
>
>
> Hi,
>
> I have a data.frame containing a Date column.  When using write.csv()
> function to generate a CSV file, I always get the Date column formatted 
as
>
> "-MM-DD".   I would like to have it formatted as "MM/DD/", but
> could not find an  easy way to do it.Here is the test code:
>
> d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03",
> "2009-12-04")), price=c(120.00, 123.00))
> write.csv(d, file="C:/temp/test.csv", row.names=FALSE)
>
> The test.csv generated looks like this:
>
> "ticker","date","price"
> "IBM",2009-12-03,120
> "IBM",2009-12-04,123
>
> I would like to have the date fields in the CSV formatted as 
"MM/DD/".
>
>  Is there any easy way to do this?
>
> Thanks in advance.
>
> George Zou
>
> The information contained in this e-mail, and any attachment, is
> confidential and is intended solely for the use of the intended 
recipient.
> Access, copying or re-use of the e-mail or any attachment, or any
> information contained therein, by any other person is not authorized. If
> you are not the intended recipient please return the e-mail to the 
sender
> and delete it from your computer. Although we attempt to sweep e-mail 
and
> attachments for viruses, we do not guarantee that either are virus-free
> and accept no liability for any damage sustained as a result of viruses.
>
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain
> disclosures relating to European legal entities.
> [[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.
>
>
>
>
> The information contained in this e-mail, and any attachment, is 
confidential and is intended solely for the use of the intended recipient. 
Access, copying or re-use of the e-mail or any attachment, or any 
information contained therein, by any other person is not authorized. If 
you are not the intended recipient please return the e-mail to the sender 
and delete it from your computer. Although we attempt to sweep e-mail and 
attachments for viruses, we do not guarantee that either are virus-free 
and accept no liability for any damage sustained as a result of viruses.
>
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain 
disclosures relating to European legal entities.
>[[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.
>



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

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



The information contained in this e-mail, and any attachment, is confidential 
and is intended solely for the use of the intended recipient. Access, copying 
or re-use

Re: [R] How to change the default Date format for write.csv function?

2009-12-28 Thread Henrique Dallazuanna
Try this:

cat('"', paste(names(newD), collapse = '","'), '"\n', sep = '', file =
'temp.txt', append = TRUE)
cat(paste(apply(newD, 1,
function(l)paste('"', l[1], '",', l[2], ',', l[3], sep = "")),
  collapse = "\n"), file = 'temp.txt', append = TRUE)


Using newD object from my previous email

On Mon, Dec 28, 2009 at 3:52 PM,  wrote:

>
> Nice try, but that will turn off quote for all fields.  I want quotes for
> text fields, and no quotes for date and numeric fields.   Please see the
> desired CSV output in my previous email.
>
> George
>
>
>  From: Henrique Dallazuanna  To:
> george@bnymellon.com Cc:
> r-help@r-project.org
> Date: 12/28/2009 12:44 PM Subject: Re: [R] How to change the default Date
> format for write.csvfunction?
>  Sent by: r-help-boun...@r-project.org
> --
>
>
>
> Use the quote argument:
>
> write.csv(d, file="C:/temp/test.csv", row.names=FALSE, quote = FALSE)
>
> On Mon, Dec 28, 2009 at 2:17 PM,   wrote:
> > Hi,
> >
> > This problem might be a little harder than it appears.
> >
> > I receive a few emails all suggesting that convert the Date field to
> > character by calling format(date, "%m/%d/%Y") in one way or another.
> Well,
> > this is not the solution I'm looking for and it doesn't work for me.
> All
> > the date fields are generated with quotes around them, which will be
> > treated by other software as string instead of date.   Please note, the
> > write.csv() function doesn't put quotes around date.   All I need is to
> > change the format behavior of Date without adding any quotes.  So the
> > output of CSV I'm looking for should be:
> >
> > "ticker","date","price"
> > "IBM",12/03/2009,120
> > "IBM",12/04/2009,123
> >
> > Not this:
> >
> > "ticker","date","price"
> > "IBM","12/03/2009",120
> > "IBM","12/04/2009",123
> >
> > Thanks for trying though.
> >
> > George
> >
> >
> >
> > From:
> > george@bnymellon.com
> > To:
> > r-help@r-project.org
> > Date:
> > 12/28/2009 10:20 AM
> > Subject:
> > [R] How to change the default Date format for write.csv function?
> > Sent by:
> > r-help-boun...@r-project.org
> >
> >
> >
> > Hi,
> >
> > I have a data.frame containing a Date column.  When using write.csv()
> > function to generate a CSV file, I always get the Date column formatted
> as
> >
> > "-MM-DD".   I would like to have it formatted as "MM/DD/", but
> > could not find an  easy way to do it.Here is the test code:
> >
> > d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03",
> > "2009-12-04")), price=c(120.00, 123.00))
> > write.csv(d, file="C:/temp/test.csv", row.names=FALSE)
> >
> > The test.csv generated looks like this:
> >
> > "ticker","date","price"
> > "IBM",2009-12-03,120
> > "IBM",2009-12-04,123
> >
> > I would like to have the date fields in the CSV formatted as
> "MM/DD/".
> >
> >  Is there any easy way to do this?
> >
> > Thanks in advance.
> >
> > George Zou
> >
> > The information contained in this e-mail, and any attachment, is
> > confidential and is intended solely for the use of the intended
> recipient.
> > Access, copying or re-use of the e-mail or any attachment, or any
> > information contained therein, by any other person is not authorized. If
> > you are not the intended recipient please return the e-mail to the sender
> > and delete it from your computer. Although we attempt to sweep e-mail and
> > attachments for viruses, we do not guarantee that either are virus-free
> > and accept no liability for any damage sustained as a result of viruses.
> >
> > Please refer to http://disclaimer.bnymellon.com/eu.htm for certain
> > disclosures relating to European legal entities.
> > [[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.
> >
> >
> >
> >
> > The information contained in this e-mail, and any attachment, is
> confidential and is intended solely for the use of the intended recipient.
> Access, copying or re-use of the e-mail or any attachment, or any
> information contained therein, by any other person is not authorized. If you
> are not the intended recipient please return the e-mail to the sender and
> delete it from your computer. Although we attempt to sweep e-mail and
> attachments for viruses, we do not guarantee that either are virus-free and
> accept no liability for any damage sustained as a result of viruses.
> >
> > Please refer to http://disclaimer.bnymellon.com/eu.htm for certain
> disclosures relating to European legal entities.
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-he

Re: [R] [BioC] make.cdf.package: Error: cannot allocate vector of size 1 Kb

2009-12-28 Thread Martin Morgan
Peng Yu wrote:
> My machine has 8GB memory. I had quit all other programs that might
> take a lot of memory when I try the script (before I post the first
> message in this thread). The cdf file is of only 741 MB. It is strange
> to me to see the error.

For me this tops out at about 13 gigs.

The reason is I think in the C-level implementation details. R_alloc is
called repeatedly during file parsing, where likely the author intends
to Calloc / Free.

Martin

> 
> On Mon, Dec 28, 2009 at 2:38 AM, Wolfgang Huber  wrote:
>> Dear Peng Yu
>>
>> how big is the RAM of your computer? You could try with closing all other
>> applications before running this script. You could try on a server with more
>> RAM.
>>
>> I tried downloading the file whose URL who give below, but gave up after
>> some failed rounds with the extraordinarily annoying and intrusive
>> registration procedure that Affymetrix has set up for this. Let us know how
>> it goes with the suggestions above, if they don't help, I'd try again with
>> that.
>>
>>Best wishes
>>Wolfgang
>>
>>
>>> I run the following example. The cdf file is downloaded from the
>>> following link. I'm wondering what the problem is with
>>> make.cdf.package.
>>>
>>>
>>> http://www.affymetrix.com/Auth/support/downloads/library_files/MoEx-1_0-st-v1.text.cdf.zip
>>>
>>> $ Rscript MoEx-1_0-st-v1.cdf.R
 library(makecdfenv)
>>> Loading required package: Biobase
>>>
>>> Welcome to Bioconductor
>>>
>>>  Vignettes contain introductory material. To view, type
>>>  'openVignette()'. To cite Bioconductor, see
>>>  'citation("Biobase")' and for packages 'citation(pkgname)'.
>>>
>>> Loading required package: affy
>>> Loading required package: affyio
 sessionInfo()
>>> R version 2.10.0 (2009-10-26)
>>> x86_64-unknown-linux-gnu
>>>
>>> locale:
>>>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>>>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>>>  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
>>>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>>>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
>>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>>
>>> attached base packages:
>>> [1] stats graphics  grDevices utils datasets  methods   base
>>>
>>> other attached packages:
>>> [1] makecdfenv_1.24.0 affyio_1.14.0 affy_1.24.2   Biobase_2.6.1
>>>
>>> loaded via a namespace (and not attached):
>>> [1] preprocessCore_1.8.0
 make.cdf.package('MoEx-1_0-st-v1.text.cdf', species='Mus_musculus')
>>> Reading CDF file.
>>> Error: cannot allocate vector of size 1 Kb
>>> Execution halted
>>>
>>> ___
>>> Bioconductor mailing list
>>> bioconduc...@stat.math.ethz.ch
>>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>>> Search the archives:
>>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>>
>>
>> --
>> Wolfgang Huber
>> EMBL
>> http://www.embl.de/research/units/genome_biology/huber/contact
>>
>>
>>
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] apply loop - using/providing a data frame to loop over

2009-12-28 Thread Henrique Dallazuanna
Try this:

mapply(substr, x = authors, start = starts, stop = ends)

On Mon, Dec 28, 2009 at 10:46 AM, Daniel Malter  wrote:
> Hi,
>
> I want to extract individual names from a single string that contains all
> names. My problem is not the extraction itself, but the looping over the
> extraction start and end points, which I try to realize with apply.
>
> #Say, I have a string with names.
> authors=c("Schleyer T, Spallek H, Butler BS, Subramanian S, Weiss D,
> Poythress ML, Rattanathikun P, Mueller G")
>
> #Since I only want the surname and the initial of the first name, I create
> respective indices
> starts=c(1, 13, 24, 35, 50, 59, 73, 90)
> ends=c(10, 21, 31, 47, 56, 69, 87, 98)
>
> #Now I can extract the names, e.g. the third one, with
> substr(authors,start=starts[3],stop=ends[3])
>
> #So far so good, but I want to loop over all indices using apply
> #For that I wrote a function g, that takes "a" as the author string, and
> "data" as the start and end points for extraction
> g=function(a,data){substr(a,data[,1],data[,2])}
>
> #If provided with a specific row of the data frame, g works
> g(authors,data.frame(starts,ends)[3,])
>
> #If I try to loop g through the rows of the starts/ends data frame, it does
> not work.
> apply(data.frame(starts,ends),1,g,a=authors)
>
> #Interestingly, if the data frame to loop over is just a vector, it works
> also (e.g. for extracting just the first initial)
> g=function(e,a){substr(a,e,e)}
> apply(data.frame(ends),1,g,a=authors)
>
> So the problem probably lies in correctly supplying "apply" with the data
> frame. I would greatly appreciate your help.
>
> Daniel
>
> ---
> "Who has visions should see a doctor,"
> Helmut Schmidt, German Chancellor (1974-1982).
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

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


Re: [R] apply loop - using/providing a data frame to loop over

2009-12-28 Thread Daniel Malter
Works a charme, thanks.

Daniel

-
cuncta stricte discussurus
-
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Gabor Grothendieck
Sent: Monday, December 28, 2009 12:34 PM
To: Daniel Malter
Cc: r-h...@stat.math.ethz.ch
Subject: Re: [R] apply loop - using/providing a data frame to loop over

Try this. It picks out each string of word characters (\w+) followed
by a space followed by a word character:

> library(gsubfn)
> strapply(authors, "\\w+ \\w", c)[[1]]
[1] "Schleyer T"  "Spallek H"   "Butler B""Subramanian S"
[5] "Weiss D" "Poythress M" "Rattanathikun P" "Mueller G"

You might need to adjust the regular expression slightly depending on
what the general case is.  See http://gsubfn.googlecode.com for more.

On Mon, Dec 28, 2009 at 7:46 AM, Daniel Malter  wrote:
> Hi,
>
> I want to extract individual names from a single string that contains all
> names. My problem is not the extraction itself, but the looping over the
> extraction start and end points, which I try to realize with apply.
>
> #Say, I have a string with names.
> authors=c("Schleyer T, Spallek H, Butler BS, Subramanian S, Weiss D,
> Poythress ML, Rattanathikun P, Mueller G")
>
> #Since I only want the surname and the initial of the first name, I create
> respective indices
> starts=c(1, 13, 24, 35, 50, 59, 73, 90)
> ends=c(10, 21, 31, 47, 56, 69, 87, 98)
>
> #Now I can extract the names, e.g. the third one, with
> substr(authors,start=starts[3],stop=ends[3])
>
> #So far so good, but I want to loop over all indices using apply
> #For that I wrote a function g, that takes "a" as the author string, and
> "data" as the start and end points for extraction
> g=function(a,data){substr(a,data[,1],data[,2])}
>
> #If provided with a specific row of the data frame, g works
> g(authors,data.frame(starts,ends)[3,])
>
> #If I try to loop g through the rows of the starts/ends data frame, it
does
> not work.
> apply(data.frame(starts,ends),1,g,a=authors)
>
> #Interestingly, if the data frame to loop over is just a vector, it works
> also (e.g. for extracting just the first initial)
> g=function(e,a){substr(a,e,e)}
> apply(data.frame(ends),1,g,a=authors)
>
> So the problem probably lies in correctly supplying "apply" with the data
> frame. I would greatly appreciate your help.
>
> Daniel
>
> ---
> "Who has visions should see a doctor,"
> Helmut Schmidt, German Chancellor (1974-1982).
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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.


[R] What might be the security issues from installing R?

2009-12-28 Thread Peterson, Eric B.
I work in a US government office, where regular computer users are not allowed 
Admin access to their computers, and all software must go through an extensive 
evaluation to be approved for installation and use.  Several of us in my office 
would greatly benefit from R, so I'd like to request that it go through the 
approval process.  Does anyone out there have any experience or advice to share?

My guess is that we may run into problems due to R being open-source, leading 
to a potential perception that the code might be poorly controlled. This could 
be further complicated by the need for downloading additional open-source 
packages.  At present, I am not aware of any open source software that has 
passed through the approval process, though I am also not aware of any policy 
against open-source.

Thanks!
---
Eric Peterson, Ph.D.
Data Steward
Trinity River Restoration Program
(contracted through SAIC)
530-623-1810
http://www.trrp.net
http://www.saic.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] 2D array of strings

2009-12-28 Thread Francesco Napolitano
Sorry for the dumb question, but I couldn't figure this out myself.

Consider the following:

> str <- c("abc","def")
> array(str, c(2,1))
 [,1]
[1,] "abc"
[2,] "def"

How can i obtain the outcome of the second instruction without
specifying the number of rows?

Thank you in advance,
Francesco.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] What might be the security issues from installing R?

2009-12-28 Thread Marc Schwartz

On Dec 28, 2009, at 12:23 PM, Peterson, Eric B. wrote:

I work in a US government office, where regular computer users are  
not allowed Admin access to their computers, and all software must  
go through an extensive evaluation to be approved for installation  
and use.  Several of us in my office would greatly benefit from R,  
so I'd like to request that it go through the approval process.   
Does anyone out there have any experience or advice to share?


My guess is that we may run into problems due to R being open- 
source, leading to a potential perception that the code might be  
poorly controlled. This could be further complicated by the need for  
downloading additional open-source packages.  At present, I am not  
aware of any open source software that has passed through the  
approval process, though I am also not aware of any policy against  
open-source.


Thanks!



Eric,

You might want to review the following document, which discusses R's  
SDLC, albeit in the context of FDA regulated clinical trials:


  http://www.r-project.org/doc/R-FDA.pdf

Note that the above document covers R as distributed by The R  
Foundation, so does not cover user contributed packages available via  
CRAN or other means.


If you were to search the R list archives, you will see that there are  
other U.S. ".gov" e-mail address from various organizations that use  
R, including NOAA, NPS, NIH, EPA, DOC and FRB. There are also many  
governmental bodies outside the U.S. that use R.


Another issue to be aware of is that since version 2.10.0, R uses  
dynamically built HTML pages for help. This requires the use of an R  
installed local web server, which might conflict with local policies.  
More information is available in the FAQs:


  http://cran.r-project.org/doc/manuals/R-admin.html#Help-options

If you are running Windows, you might be interested in the following:

  
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#Does-R-run-under-Windows-Vista_003f

and perhaps:

  
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#The-Internet-download-functions-fail_002e

From a more generic perspective, if your institution is using Linux,  
Apache, OpenOffice, Firefox or Thunderbird among others, they are  
already using open source software.


The barrier to using open source gets lower all the time.

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] 2D array of strings

2009-12-28 Thread Tony Plate

matrix(str, ncol=1)

Francesco Napolitano wrote:

Sorry for the dumb question, but I couldn't figure this out myself.

Consider the following:


str <- c("abc","def")
array(str, c(2,1))

 [,1]
[1,] "abc"
[2,] "def"

How can i obtain the outcome of the second instruction without
specifying the number of rows?

Thank you in advance,
Francesco.

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



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


Re: [R] How to change the default Date format for write.csvfunction?

2009-12-28 Thread William Dunlap

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of 
> george@bnymellon.com
> Sent: Monday, December 28, 2009 8:18 AM
> To: r-help@r-project.org
> Subject: Re: [R] How to change the default Date format for 
> write.csvfunction?
> 
> Hi,
> 
> This problem might be a little harder than it appears. 
> 
> I receive a few emails all suggesting that convert the Date field to 
> character by calling format(date, "%m/%d/%Y") in one way or 
> another. Well, 
> this is not the solution I'm looking for and it doesn't work 
> for me.   All 
> the date fields are generated with quotes around them, which will be 
> treated by other software as string instead of date.   Please 
> note, the 
> write.csv() function doesn't put quotes around date.   All I 
> need is to 
> change the format behavior of Date without adding any quotes.  So the 
> output of CSV I'm looking for should be:
> 
> "ticker","date","price"
> "IBM",12/03/2009,120
> "IBM",12/04/2009,123
> 
> Not this:
> 
> "ticker","date","price"
> "IBM","12/03/2009",120
> "IBM","12/04/2009",123

Write a function that adds double quotes
for the columns with classes that you want
quoted and call write.csv with quote=FALSE.
E.g., the following function f puts double
quotes around character and factor columns:

   f <- function (dataframe) 
   {
   doubleQuoteNoFancy <- function(x) paste("\"", x, "\"", sep = "")
   for (i in seq_along(dataframe)) {
   if (is(dataframe[[i]], "character")) 
   dataframe[[i]] <- doubleQuoteNoFancy(dataframe[[i]])
   else if (is(dataframe[[i]], "factor")) 
   levels(dataframe[[i]]) <-
doubleQuoteNoFancy(levels(dataframe[[i]]))
   else if (is(dataframe[[i]], "Date"))
   dataframe[[i]] <- format(dataframe[[i]], "%m/%d/%Y")
   }
   colnames(dataframe) <- doubleQuoteNoFancy(colnames(dataframe))
   dataframe
   }

Use it as:
   > write.csv(f(d), file=stdout(), quote=FALSE, row.names=FALSE)
   "ticker","date","price"
   "IBM",12/03/2009,120
   "IBM",12/04/2009,123

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> 
> Thanks for trying though.
> 
> George
> 
> 
> 
> From:
> george@bnymellon.com
> To:
> r-help@r-project.org
> Date:
> 12/28/2009 10:20 AM
> Subject:
> [R] How to change the default Date format for write.csv function?
> Sent by:
> r-help-boun...@r-project.org
> 
> 
> 
> Hi,
> 
> I have a data.frame containing a Date column.  When using write.csv() 
> function to generate a CSV file, I always get the Date column 
> formatted as 
> 
> "-MM-DD".   I would like to have it formatted as 
> "MM/DD/", but 
> could not find an  easy way to do it.Here is the test code:
> 
> d <- data.frame(ticker=c("IBM", "IBM"), date = 
> as.Date(c("2009-12-03", 
> "2009-12-04")), price=c(120.00, 123.00))
> write.csv(d, file="C:/temp/test.csv", row.names=FALSE)
> 
> The test.csv generated looks like this:
> 
> "ticker","date","price"
> "IBM",2009-12-03,120
> "IBM",2009-12-04,123
> 
> I would like to have the date fields in the CSV formatted as 
> "MM/DD/". 
> 
>  Is there any easy way to do this?
> 
> Thanks in advance.
> 
> George Zou
> 
> The information contained in this e-mail, and any attachment, is 
> confidential and is intended solely for the use of the 
> intended recipient. 
> Access, copying or re-use of the e-mail or any attachment, or any 
> information contained therein, by any other person is not 
> authorized. If 
> you are not the intended recipient please return the e-mail 
> to the sender 
> and delete it from your computer. Although we attempt to 
> sweep e-mail and 
> attachments for viruses, we do not guarantee that either are 
> virus-free 
> and accept no liability for any damage sustained as a result 
> of viruses. 
> 
> Please refer to http://disclaimer.bnymellon.com/eu.htm for certain 
> disclosures relating to European legal entities.
>  [[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.
> 
> 
> 
> 
> The information contained in this e-mail, and any attachment, 
> is confidential and is intended solely for the use of the 
> intended recipient. Access, copying or re-use of the e-mail 
> or any attachment, or any information contained therein, by 
> any other person is not authorized. If you are not the 
> intended recipient please return the e-mail to the sender and 
> delete it from your computer. Although we attempt to sweep 
> e-mail and attachments for viruses, we do not guarantee that 
> either are virus-free and accept no liability for any damage 
> sustained as a result of viruses. 
> 
> Please refer to http://disclaimer.bnymellon.com/eu.htm for 
> certain disclosures 

Re: [R] 2D array of strings

2009-12-28 Thread milton ruser
Hi Francesco,

Be carefull with create a object named str, because you crash str()
function. I don't know if it have implications on any package or functions.

bests

milton

On Mon, Dec 28, 2009 at 4:32 PM, Francesco Napolitano
wrote:

> Sorry for the dumb question, but I couldn't figure this out myself.
>
> Consider the following:
>
> > str <- c("abc","def")
> > array(str, c(2,1))
> [,1]
> [1,] "abc"
> [2,] "def"
>
> How can i obtain the outcome of the second instruction without
> specifying the number of rows?
>
> Thank you in advance,
> Francesco.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] refering to the 'boundaries' of a graph

2009-12-28 Thread John Kane

I think what you are encountering is a standard R default.  R, by default, adds 
4% to the axes. I suspect that this is to avoid graphing points right on the  x 
or x axis and thus obscuring them.

 Have a look at ?par xaxs for more information and how to change the default.


 
--- On Mon, 12/28/09, Dean1  wrote:

> From: Dean1 
> Subject: [R]  refering to the 'boundaries' of a graph
> To: r-help@r-project.org
> Received: Monday, December 28, 2009, 8:55 AM
> 
> Please see this code for a demonstration of my problem...
> 
> xlim <- c(-1,5)
> plot(1:4, xlim=xlim)
> abline(v=xlim[1])
> abline(v=xlim[2])
> 
> When I refer to xlim, it is not referring to the boundaries
> of the graphical
> region, it refers to the maximum and minimum xticks. 
> My question is how can
> I refer to the x axis boundaries (and similarly y axis) of
> the graph?
> -- 
> View this message in context: 
> http://n4.nabble.com/refering-to-the-boundaries-of-a-graph-tp989790p989790.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.
> 


  __
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] nls error message

2009-12-28 Thread Jim Bouldin

When I try to run the following non-linear regression with  variables
index1 and prl3:

> beta = 4
> nls(index1~beta*(1/prl3),start = list(beta = 4))

I get this error message:

Error in nls(index1 ~ beta * (1/prl3), start = list(beta = 4)) : 
  REAL() can only be applied to a 'numeric', not a 'logical'

I've got no clue as to the REAL() to which this is referring.  Any help
appreciated. Thanks in advance.


Jim Bouldin
Research Ecologist
Department of Plant Sciences, UC Davis
Davis CA, 95616
530-554-1740

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] accessing members of a data.frame

2009-12-28 Thread Nick Torenvliet
I have the following code

fileList <-list.files(path = ".", pattern = "[^a-z].txt$", all.files =
FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE)
for (x in 1:length(fileList)){
fileLines <- data.frame(read.table(fileList[x]))
print(string)
}

the lines of the file all have the following format...
AB,20091224,156,156,154,154,55,1198

Can I access the comma separated values directly via indexes on fileLines?
e.g. I want to be able to do something like this...

>date <- fileLines[1][2]
>print(date)
"20091224"

I've been trying for a while and I haven't been able to hit the separate
elements.

Nick

[[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 change the default Date format for write.csvfunction?

2009-12-28 Thread Tony Plate

You can use a numeric value for the quote= argument to write.table to specify 
which columns should have quotes.


d <- data.frame(ticker=c("IBM", "IBM"), date = as.Date(c("2009-12-03", 
"2009-12-04")), price=c(120.00, 123.00))
d1 <- as.data.frame(lapply(d, function(x) if (is(x, "Date")) format(x, 
"%m/%d/%Y") else x))
write.table(d1, quote=which(sapply(d, function(x) !is.numeric(x) & !is(x, 
"Date"

"ticker" "date" "price"
"1" "IBM" 12/03/2009 120
"2" "IBM" 12/04/2009 123




-- Tony Plate


William Dunlap wrote:

-Original Message-
From: r-help-boun...@r-project.org 
[mailto:r-help-boun...@r-project.org] On Behalf Of 
george@bnymellon.com

Sent: Monday, December 28, 2009 8:18 AM
To: r-help@r-project.org
Subject: Re: [R] How to change the default Date format for 
write.csvfunction?


Hi,

This problem might be a little harder than it appears. 

I receive a few emails all suggesting that convert the Date field to 
character by calling format(date, "%m/%d/%Y") in one way or 
another. Well, 
this is not the solution I'm looking for and it doesn't work 
for me.   All 
the date fields are generated with quotes around them, which will be 
treated by other software as string instead of date.   Please 
note, the 
write.csv() function doesn't put quotes around date.   All I 
need is to 
change the format behavior of Date without adding any quotes.  So the 
output of CSV I'm looking for should be:


"ticker","date","price"
"IBM",12/03/2009,120
"IBM",12/04/2009,123

Not this:

"ticker","date","price"
"IBM","12/03/2009",120
"IBM","12/04/2009",123


Write a function that adds double quotes
for the columns with classes that you want
quoted and call write.csv with quote=FALSE.
E.g., the following function f puts double
quotes around character and factor columns:

   f <- function (dataframe) 
   {

   doubleQuoteNoFancy <- function(x) paste("\"", x, "\"", sep = "")
   for (i in seq_along(dataframe)) {
   if (is(dataframe[[i]], "character")) 
   dataframe[[i]] <- doubleQuoteNoFancy(dataframe[[i]])
   else if (is(dataframe[[i]], "factor")) 
   levels(dataframe[[i]]) <-

doubleQuoteNoFancy(levels(dataframe[[i]]))
   else if (is(dataframe[[i]], "Date"))
   dataframe[[i]] <- format(dataframe[[i]], "%m/%d/%Y")
   }
   colnames(dataframe) <- doubleQuoteNoFancy(colnames(dataframe))
   dataframe
   }

Use it as:
   > write.csv(f(d), file=stdout(), quote=FALSE, row.names=FALSE)
   "ticker","date","price"
   "IBM",12/03/2009,120
   "IBM",12/04/2009,123

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 


Thanks for trying though.

George



From:
george@bnymellon.com
To:
r-help@r-project.org
Date:
12/28/2009 10:20 AM
Subject:
[R] How to change the default Date format for write.csv function?
Sent by:
r-help-boun...@r-project.org



Hi,

I have a data.frame containing a Date column.  When using write.csv() 
function to generate a CSV file, I always get the Date column 
formatted as 

"-MM-DD".   I would like to have it formatted as 
"MM/DD/", but 
could not find an  easy way to do it.Here is the test code:


d <- data.frame(ticker=c("IBM", "IBM"), date = 
as.Date(c("2009-12-03", 
"2009-12-04")), price=c(120.00, 123.00))

write.csv(d, file="C:/temp/test.csv", row.names=FALSE)

The test.csv generated looks like this:

"ticker","date","price"
"IBM",2009-12-03,120
"IBM",2009-12-04,123

I would like to have the date fields in the CSV formatted as 
"MM/DD/". 


 Is there any easy way to do this?

Thanks in advance.

George Zou

The information contained in this e-mail, and any attachment, is 
confidential and is intended solely for the use of the 
intended recipient. 
Access, copying or re-use of the e-mail or any attachment, or any 
information contained therein, by any other person is not 
authorized. If 
you are not the intended recipient please return the e-mail 
to the sender 
and delete it from your computer. Although we attempt to 
sweep e-mail and 
attachments for viruses, we do not guarantee that either are 
virus-free 
and accept no liability for any damage sustained as a result 
of viruses. 

Please refer to http://disclaimer.bnymellon.com/eu.htm for certain 
disclosures relating to European legal entities.

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




The information contained in this e-mail, and any attachment, 
is confidential and is intended solely for the use of the 
intended recipient. Access, copying or re-use of the e-mail 
or any attachment, or any information contained therein, by 
any other person is not authorized. If you are not the 
intended recipient please return the e-mail to the sender and 
delete it from you

[R] Accessing members

2009-12-28 Thread Nick Torenvliet
Consider the following

> fileLines
  V1   V2V3V4 V5 V6V7 V8
1 AB 20091224 156.0 156.0 154.00 154.0055   1198
2   AB.C 20091224 156.0 156.0 156.00 156.00 0  0
3  ABF10 20091224 156.0 156.0 156.00 156.0055444
4  ABH10 20091224 156.0 156.0 156.00 156.00 0749
5  ABH11 20091224 157.2 157.2 157.20 157.20 0  0
6  ABH12 20091224 157.2 157.2 157.20 157.20 0  0
7  ABK10 20091224 157.2 157.2 157.20 157.20 0  5
8  ABK11 20091224 157.2 157.2 157.20 157.20 0  0
9  ABN10 20091224 157.2 157.2 157.20 157.20 0  0
10 ABN11 20091224 157.2 157.2 157.20 157.20 0  0
11 ABV10 20091224 157.2 157.2 157.20 157.20 0  0
12 ABV11 20091224 157.2 157.2 157.20 157.20 0  0
13 ABZ10 20091224 157.2 157.2 157.20 157.20 0  0
14 ABZ11 20091224 157.2 157.2 157.20 157.20 0  0
15RS 20091224 395.0 395.0 381.42 381.42 12918 100618
16  RS.C 20091224 395.0 399.1 395.00 398.70  1680  0
17 RSF10 20091224 395.0 399.1 395.00 398.70  2277   3081
18 RSF11 20091224 420.3 420.3 420.30 420.3050203
19 RSF12 20091224 415.5 415.5 415.50 415.50 0  0
20 RSH10 20091224 401.1 403.9 399.50 403.60  9925  79548
21 RSH11 20091224 419.2 419.2 419.20 419.20 0193
22 RSK10 20091224 406.9 409.9 406.40 409.90   264   5769
23 RSK11 20091224 415.5 415.5 415.50 415.50 0  0
24 RSN10 20091224 414.7 415.2 410.00 415.20   189   6391
25 RSN11 20091224 415.5 415.5 415.50 415.50 0  2
26 RSX10 20091224 414.9 417.9 413.00 417.30   213   5431
27 RSX11 20091224 415.5 415.5 415.50 415.50 0  0
28WF 20091224 363.0 363.0 363.00 363.00 0  0
29WW 20091224 152.0 152.0 152.00 152.00 0  0

> attributes (fileLines)
$names
[1] "V1" "V2" "V3" "V4" "V5" "V6" "V7" "V8"

$class
[1] "data.frame"

$row.names
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
25
[26] 26 27 28 29

> fileLines[1,2]
[1] 20091224
As expected!

> fileLines[1,3]
[1] 156
As expected!

> fileLines[1,1]
[1] AB
29 Levels: AB AB.C ABF10 ABH10 ABH11 ABH12 ABK10 ABK11 ABN10 ABN11 ... WW
Doh!

How do I access the "AB" element directly?

Nick

[[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] What might be the security issues from installing R?

2009-12-28 Thread Barry Rowlingson
On Mon, Dec 28, 2009 at 6:23 PM, Peterson, Eric B.  wrote:

> My guess is that we may run into problems due to R being open-source, leading 
> to a potential perception that the code might be poorly controlled. This 
> could be further complicated by the need for downloading additional 
> open-source packages.  At present, I am not aware of any open source software 
> that has passed through the approval process, though I am also not aware of 
> any policy against open-source.

 The 'Core' of R is code committed (and therefore 'controlled') by a
smallish group of  people:

http://www.r-project.org/contributors.html

 The real problem would come when you start adding additional packages
from CRAN or R-forge or some other source. These are written by
hundreds or possibly thousands of people.

 I've not heard of any malicious code ever being found in an R
package, but maybe one day I'll sneak a back-door server into one of
mine and see how long before it gets spotted. I don't think any formal
review of CRAN package code is ever done (someone may prove me wrong
here, but there's zillions of lines of code in CRAN now).

Barry

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Accessing members

2009-12-28 Thread Thomas S. Dye

Hi Nick,

Your first column is being stored as a factor.  You can either take  
care when creating the matrix to keep the values in this column as  
characters, or you might want to convert the result using  
as.character().


HTH,
Tom

On Dec 28, 2009, at 1:14 PM, Nick Torenvliet wrote:


Consider the following


fileLines

 V1   V2V3V4 V5 V6V7 V8
1 AB 20091224 156.0 156.0 154.00 154.0055   1198
2   AB.C 20091224 156.0 156.0 156.00 156.00 0  0
3  ABF10 20091224 156.0 156.0 156.00 156.0055444
4  ABH10 20091224 156.0 156.0 156.00 156.00 0749
5  ABH11 20091224 157.2 157.2 157.20 157.20 0  0
6  ABH12 20091224 157.2 157.2 157.20 157.20 0  0
7  ABK10 20091224 157.2 157.2 157.20 157.20 0  5
8  ABK11 20091224 157.2 157.2 157.20 157.20 0  0
9  ABN10 20091224 157.2 157.2 157.20 157.20 0  0
10 ABN11 20091224 157.2 157.2 157.20 157.20 0  0
11 ABV10 20091224 157.2 157.2 157.20 157.20 0  0
12 ABV11 20091224 157.2 157.2 157.20 157.20 0  0
13 ABZ10 20091224 157.2 157.2 157.20 157.20 0  0
14 ABZ11 20091224 157.2 157.2 157.20 157.20 0  0
15RS 20091224 395.0 395.0 381.42 381.42 12918 100618
16  RS.C 20091224 395.0 399.1 395.00 398.70  1680  0
17 RSF10 20091224 395.0 399.1 395.00 398.70  2277   3081
18 RSF11 20091224 420.3 420.3 420.30 420.3050203
19 RSF12 20091224 415.5 415.5 415.50 415.50 0  0
20 RSH10 20091224 401.1 403.9 399.50 403.60  9925  79548
21 RSH11 20091224 419.2 419.2 419.20 419.20 0193
22 RSK10 20091224 406.9 409.9 406.40 409.90   264   5769
23 RSK11 20091224 415.5 415.5 415.50 415.50 0  0
24 RSN10 20091224 414.7 415.2 410.00 415.20   189   6391
25 RSN11 20091224 415.5 415.5 415.50 415.50 0  2
26 RSX10 20091224 414.9 417.9 413.00 417.30   213   5431
27 RSX11 20091224 415.5 415.5 415.50 415.50 0  0
28WF 20091224 363.0 363.0 363.00 363.00 0  0
29WW 20091224 152.0 152.0 152.00 152.00 0  0


attributes (fileLines)

$names
[1] "V1" "V2" "V3" "V4" "V5" "V6" "V7" "V8"

$class
[1] "data.frame"

$row.names
[1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21  
22 23 24

25
[26] 26 27 28 29


fileLines[1,2]

[1] 20091224
As expected!


fileLines[1,3]

[1] 156
As expected!


fileLines[1,1]

[1] AB
29 Levels: AB AB.C ABF10 ABH10 ABH11 ABH12 ABK10 ABK11 ABN10  
ABN11 ... WW

Doh!

How do I access the "AB" element directly?

Nick

[[alternative HTML version deleted]]

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


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


Re: [R] Accessing member

2009-12-28 Thread John Kane

Assuming the data set is called xx

   subset (xx, xx$V1=="AB") 

or 
   xx[1,]

if you now AB is the first row of the data.
--- On Mon, 12/28/09, Nick Torenvliet  wrote:

> From: Nick Torenvliet 
> Subject: [R] Accessing members
> To: r-help@r-project.org
> Received: Monday, December 28, 2009, 6:14 PM
> Consider the following
> 
> > fileLines
>       V1   
>    V2    V3    V4 
>    V5     V6   
> V7     V8
> 1     AB 20091224 156.0 156.0 154.00
> 154.00    55   1198
> 2   AB.C 20091224 156.0 156.0 156.00
> 156.00     0      0
> 3  ABF10 20091224 156.0 156.0 156.00 156.00 
>   55    444
> 4  ABH10 20091224 156.0 156.0 156.00 156.00 
>    0    749
> 5  ABH11 20091224 157.2 157.2 157.20 157.20 
>    0      0
> 6  ABH12 20091224 157.2 157.2 157.20 157.20 
>    0      0
> 7  ABK10 20091224 157.2 157.2 157.20 157.20 
>    0      5
> 8  ABK11 20091224 157.2 157.2 157.20 157.20 
>    0      0
> 9  ABN10 20091224 157.2 157.2 157.20 157.20 
>    0      0
> 10 ABN11 20091224 157.2 157.2 157.20 157.20 
>    0      0
> 11 ABV10 20091224 157.2 157.2 157.20 157.20 
>    0      0
> 12 ABV11 20091224 157.2 157.2 157.20 157.20 
>    0      0
> 13 ABZ10 20091224 157.2 157.2 157.20 157.20 
>    0      0
> 14 ABZ11 20091224 157.2 157.2 157.20 157.20 
>    0      0
> 15    RS 20091224 395.0 395.0 381.42 381.42 12918
> 100618
> 16  RS.C 20091224 395.0 399.1 395.00 398.70 
> 1680      0
> 17 RSF10 20091224 395.0 399.1 395.00 398.70 
> 2277   3081
> 18 RSF11 20091224 420.3 420.3 420.30 420.30   
> 50    203
> 19 RSF12 20091224 415.5 415.5 415.50 415.50 
>    0      0
> 20 RSH10 20091224 401.1 403.9 399.50 403.60 
> 9925  79548
> 21 RSH11 20091224 419.2 419.2 419.20 419.20 
>    0    193
> 22 RSK10 20091224 406.9 409.9 406.40
> 409.90   264   5769
> 23 RSK11 20091224 415.5 415.5 415.50 415.50 
>    0      0
> 24 RSN10 20091224 414.7 415.2 410.00
> 415.20   189   6391
> 25 RSN11 20091224 415.5 415.5 415.50 415.50 
>    0      2
> 26 RSX10 20091224 414.9 417.9 413.00
> 417.30   213   5431
> 27 RSX11 20091224 415.5 415.5 415.50 415.50 
>    0      0
> 28    WF 20091224 363.0 363.0 363.00 363.00 
>    0      0
> 29    WW 20091224 152.0 152.0 152.00 152.00 
>    0      0
> 
> > attributes (fileLines)
> $names
> [1] "V1" "V2" "V3" "V4" "V5" "V6" "V7" "V8"
> 
> $class
> [1] "data.frame"
> 
> $row.names
>  [1]  1  2  3  4  5  6 
> 7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
> 24
> 25
> [26] 26 27 28 29
> 
> > fileLines[1,2]
> [1] 20091224
> As expected!
> 
> > fileLines[1,3]
> [1] 156
> As expected!
> 
> > fileLines[1,1]
> [1] AB
> 29 Levels: AB AB.C ABF10 ABH10 ABH11 ABH12 ABK10 ABK11
> ABN10 ABN11 ... WW
> Doh!
> 
> How do I access the "AB" element directly?
> 
> Nick
> 
>     [[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.
> 


  __
Looking for the perfect gift? Give the gift of Flickr! 

http://www.flickr.com/gift/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Have you used RGoogleDocs and RGoogleData?

2009-12-28 Thread Farrel Buchinsky
Dear Adrian

Are you able to help me with problems that I am having with RGoogleData? I
would greatly appreciate it if you could give me some general trouble
shooting ideas or better yet if you could fix the problem.

I believe that I updated to the latest version of RGoogleData as evidenced
by
>  packageDescription("RGoogleData")
Package: RGoogleData
Type: Package
Title: An R interface to Google Data (Docs, Calendar, Contacts, Finance,
etc.)
Version: 0.2.0
Date: 2009-12-11
Depends: rJava
Author: Adrian A. Dragulescu
Maintainer: Adrian A. Dragulescu 
Description: Provide R access to Google Data API.
License: GPL-3
Repository: R-Forge
Repository/R-Forge/Project: rgoogledata
Repository/R-Forge/Revision: 6
Date/Publication: 2009-12-13 21:43:52
Packaged: 2009-12-14 21:05:13 UTC; rforge
Built: R 2.10.1; ; 2009-12-14 23:02:39 UTC; windows

-- File: C:/PROGRA~2/R/R-210~1.1/library/RGoogleData/Meta/package.rds

But Alas

My previous script has stopped working.

library(RGoogleData)
ps <-readline(prompt="get the password in ")
con <-googleConnect("fjb...@gmail.com",ps)
allXls <- getSpreadsheets(con)
xls <- allXls[[which(sapply(allXls, slot, "title") == "OnCall")]]
allWks <- getWorksheets(xls)# get the worksheets
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
  java.lang.ClassCastException: com.google.gdata.data.TextContent cannot be
cast to com.google.gdata.data.OutOfLineContent


I also tried:

target <-downloadDocument(doc="OnCall",
filepath="C:/Users/fbuchinsky/Documents/My Dropbox/OnCalltrial.csv",
fileformat="csv", sheetIndex=1)
Error in regexpr("%3A", d...@key) :
  trying to get slot "key" from an object of a basic class ("character")
with no slots

Farrel Buchinsky


Sent from Pittsburgh, Pennsylvania, United States

On Thu, Dec 10, 2009 at 10:38, Adrian Dragulescu wrote:

>
> I will try to have something in place by Monday to allow you to download a
> specific sheet not default to the first.  I will let you know.
>
> Adrian
>
>
> On Thu, 10 Dec 2009, Farrel Buchinsky wrote:
>
>  Thank you Adrian. Your response was very informative.
>>
>> ?downloadDocument filled me with excitement untill I read, "If you try to
>> download a spreadsheet with multiple worksheets into a 'csv' or 'tsv'
>> format, only the first worksheet will be downloaded."
>>
>> So now there is a convenient fast way to read data under two circumstances
>>
>>  1. if the spreadsheet has been
>> published<
>> http://blog.revolution-computing.com/2009/09/how-to-use-a-google-spreadsheet-as-data-in-r.html
>> >
>>  2. if one only wants the first sheet (RGoogleData's downloadDocument()).
>>
>>
>>
>> Farrel Buchinsky
>> Google Voice Tel: (412) 567-7870
>>
>> Sent from Pittsburgh, Pennsylvania, United States
>>
>> On Thu, Dec 10, 2009 at 09:32, Adrian Dragulescu > >wrote:
>>
>>
>>> Farrel,
>>>
>>> Please read the manuals.  On the RGoogleData package page you can read:
>>> "The package provides R access to Google services through the Google
>>> supported Java API.
>>>
>>> [...]
>>>
>>> A package with very similar functionality is maintained by Duncan Temple
>>> Lang at \url{http://www.omegahat.org/RGoogleDocs/}.  The approach taken
>>> there is to use \code{RCurl} and \code{XML} to interact with the lower
>>> level Google HTML protocol.  You should check it out too."
>>>
>>> Regarding the questions you have about speed.  Google spreadsheets is
>>> labeled Labs, mabye there are performance issues on Google side.  The
>>> approach for both RGoogleDocs and RGoogleData is to make requests to the
>>> Google servers and parse the XML results.  RGoogleDocs parses using a C
>>> library, RGoogleData uses a Java library.  Going through the Java
>>> interface
>>> is an extra step, so that might explain the speed difference.
>>>
>>> Check ?downloadDocument if you want to download the entire document.  It
>>> should be fast.  You can load it into R after that.
>>>
>>> Best,
>>> Adrian
>>>
>>>
>>>
>>> On Wed, 9 Dec 2009, Farrel Buchinsky wrote:
>>>
>>>  Both of these applications fulfill a great need of mine: to read data
>>>
 directly from google spreadsheets that are private to myself and one or
 two
 collaborators. Thanks to the authors. I had been using RGoogleDocs for
 the
 about 6 months (maybe more) but have had to stop using it in the past
 month
 since for some reason that I do not understand it no longer reads google
 spreadsheets. I loved it. Its loss depresses me. I started using
 RGoogleData
 which works.

 I have noticed that both packages read data slowly. RGoogleData is much
 slower than RGoogleDocs used to be. Both seem a lot slower than if one
 manually downloaded a google spreadsheet as a csv and then used read.csv
 function - but then I would not be able to use scripts and execute
 without
 finding and futzing.

 Can anyone explain in English why these packages read slower than a csv
 download?
 Can anyone explain what the core differenc

Re: [R] Help With Custom QQ Plot

2009-12-28 Thread Adam Carr
Hello Dennis:

Thanks for the reply and for your help. I apologize for the errant TUS in the 
data. Your statement about the quantiles of the data belonging to the vertical 
axis is correct of course and it helped me realize an error of mine: the 
quantiles plotted as vertical reference lines are from a fitted distribution 
based on the data. I have included an example of the plot in the attachment.

I ran the code you sent and it is a very good start. I simply need to 
understand how to include the fitted normal data as the x-axis or as a set of 
vertical reference points.

About the distinct data points: you are correct about this as well. I realize 
that there are ties in the data. This is pretty typical for these kinds of 
material property measurements. I meant, but did not state clearly, that I 
wanted to plot the data as points and not as a line.

Thanks again for your help.

Adam 




From: Dennis Murphy 
To: Adam Carr 
Sent: Mon, December 28, 2009 4:12:54 PM
Subject: Re: [R] Help With Custom QQ Plot

Hi: 

This isn't precisely what you want, but it's a start. Both base graphics and 
lattice plot the normal
quantiles on the horizontal axis and the observed values on the vertical axis, 
so it's the transpose
of what you want.

After reading in your data (I had to get rid of the stray TUS two-thirds of the 
way down the file)
into an object I called qqdata, I did the following:

qqq <- quantile(qqdata, c(.01, .1, .2, .5, .8, .9, .99))
qqnorm(qqdata)
qqline(qqdata)
abline(h = qqq, lty = 'dotted')

This is all using base graphics. Use xlab, ylab and main in the qqnorm() call 
to adjust the labels.

The author of lattice, Deepayan Sarkar, has published a book called Lattice, 
available from 
Springer. If you were to use it, the appropriate function would be qqmath, 
whose default
theoretical distribution is the normal.

 If you insist on having the theoretical quantiles on the
vertical axis, then in R you would likely have to use ggplot2, but you would 
have to build up
the plot from its elements.


On Mon, Dec 28, 2009 at 6:49 AM, Adam Carr  wrote:

Good Morning:
>
>I have attached a text file with one hundred thirty six observations. I would 
>like to create a qq plot with the following features:
>
>1. Observed values on the y-axis.
>
Check. 

2. Normal approximation line on the plot.
>
Check. 

3. X-axis with vertical reference lines at the following percentiles of the 
data: 1, 10, 20, 50, 80, 90 and 99.
>
If your data are on the Y-axis, the percentiles of the *data* would also have 
to be on the y-axis.
This is shown on the plot. Check. 

4. Data appearing on the plot as distinct points.
>
qqnorm does what it can, but you have numerous tied values in your data. How do 
you expect them to
be plotted as distinct points? You can jitter them, but that will have some 
impact on the corresponding
quantiles and the position of the fitted 'normal approximation line' .


>I assume that qqmath (lattice) is the best approach to this although I have 
>not been able to sort out the proper syntax to yield the plot I'm after. I 
>understand how to determine the quantiles of the data, and I can use qqmath() 
>to generate a plot which has the observed values on the y-axis, and the plot 
>is based on a normal distribution, but beyond this I'm struggling.
>
>I do not have the R Graphics text by  or Visualizing Data by Bill Cleveland 
>but I have several other R books (Crawley, Ugarte et al, Braun/Murdoch, Rizzo, 
>etc) but coverage of the lattice package seems light.
>
>I very much appreciate any help that could be offered.
>
>Thank you.
>
>Adam
>
>
>     
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
>
>



  

Example Plot for Recreation in R.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] accessing members of a data.frame

2009-12-28 Thread jim holtman
?read.csv

On Mon, Dec 28, 2009 at 5:31 PM, Nick Torenvliet
wrote:

> I have the following code
>
> fileList <-list.files(path = ".", pattern = "[^a-z].txt$", all.files =
> FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE)
> for (x in 1:length(fileList)){
>fileLines <- data.frame(read.table(fileList[x]))
>print(string)
> }
>
> the lines of the file all have the following format...
> AB,20091224,156,156,154,154,55,1198
>
> Can I access the comma separated values directly via indexes on fileLines?
> e.g. I want to be able to do something like this...
>
> >date <- fileLines[1][2]
> >print(date)
> "20091224"
>
> I've been trying for a while and I haven't been able to hit the separate
> elements.
>
> Nick
>
>[[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.
>



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

What is the problem that you are trying to solve?

[[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] subsetting by groups, with conditions

2009-12-28 Thread Seth W Bigelow
I have a data set similar to this:

P1idVeg1Veg2AreaPoly2   P2ID
1   p   p   1   1
1   p   p   1.5 2
2   p   p   2   3
2   p   h   3.5 4

For each group of "Poly1id" records, I wish to output (subset) the record 
which has largest "AreaPoly2" value, but only if Veg1=Veg2. For this 
example, the desired dataset would be

P1idVeg1Veg2AreaPoly2   P2ID
1   p   p   1.5 2
2   p   p   2   3
 
Can anyone point me in the right direction on this?

Dr. Seth  W. Bigelow
Biologist, USDA-FS Pacific Southwest Research Station
1731 Research Park Drive, Davis California
[[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] 2D array of strings

2009-12-28 Thread David Winsemius


On Dec 28, 2009, at 4:24 PM, milton ruser wrote:


Hi Francesco,

Be carefull with create a object named str, because you crash str()
function. I don't know if it have implications on any package or  
functions.


Agree that is not a good idea, but don't agree with why. The action of  
creating an object with the same name will not generally "crash the  
function" but will often crash the wetware.


--
David.



bests

milton

On Mon, Dec 28, 2009 at 4:32 PM, Francesco Napolitano
wrote:


Sorry for the dumb question, but I couldn't figure this out myself.

Consider the following:


str <- c("abc","def")
array(str, c(2,1))

   [,1]
[1,] "abc"
[2,] "def"

How can i obtain the outcome of the second instruction without
specifying the number of rows?

Thank you in advance,
Francesco.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] subsetting by groups, with conditions

2009-12-28 Thread jim holtman
try this:

> x <- read.table(textConnection("P1idVeg1Veg2AreaPoly2
P2ID
+ 1   p   p   1   1
+ 1   p   p   1.5 2
+ 2   p   p   2   3
+ 2   p   h   3.5 4"), header=TRUE, as.is=TRUE)
> # split the dataframe by P1id
> x.s <- split(x, x$P1id)
> # now go through the sets to see which is the largest
> result <- lapply(x.s, function(.sub){
+ .match <- subset(.sub, Veg1 == Veg2)
+ if (length(.match) > 0){
+ return(.match[which.max(.match$AreaPoly2),])
+ }
+ else {
+ return(NULL)
+ }
+ })
> do.call(rbind, result)
  P1id Veg1 Veg2 AreaPoly2 P2ID
11pp   1.52
22pp   2.03
>


On Mon, Dec 28, 2009 at 8:03 PM, Seth W Bigelow  wrote:

> I have a data set similar to this:
>
> P1idVeg1Veg2AreaPoly2   P2ID
> 1   p   p   1   1
> 1   p   p   1.5 2
> 2   p   p   2   3
> 2   p   h   3.5 4
>
> For each group of "Poly1id" records, I wish to output (subset) the record
> which has largest "AreaPoly2" value, but only if Veg1=Veg2. For this
> example, the desired dataset would be
>
> P1idVeg1Veg2AreaPoly2   P2ID
> 1   p   p   1.5 2
> 2   p   p   2   3
>
> Can anyone point me in the right direction on this?
>
> Dr. Seth  W. Bigelow
> Biologist, USDA-FS Pacific Southwest Research Station
> 1731 Research Park Drive, Davis California
>[[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.
>



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

What is the problem that you are trying to solve?

[[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] subsetting by groups, with conditions

2009-12-28 Thread Gabor Grothendieck
Assuming your data frame is called DF we can use sqldf like this.  The
inner select calculates the maximum AreaPoly2 for each group such that
Veg1 = Veg2 and the outer select returns the corresponding row.


library(sqldf)
sqldf("select * from DF a where AreaPoly2 =
  (select max(AreaPoly2) from DF where Veg1 = Veg2 and P1id = a.P1id)")

Running it looks like this:

> library(sqldf)
> sqldf("select * from DF a where AreaPoly2 =
+   (select max(AreaPoly2) from DF where Veg1 = Veg2 and P1id = a.P1id)")
  P1id Veg1 Veg2 AreaPoly2 P2ID
11pp   1.52
22pp   2.03


On Mon, Dec 28, 2009 at 8:03 PM, Seth W Bigelow  wrote:
> I have a data set similar to this:
>
> P1id    Veg1    Veg2    AreaPoly2       P2ID
> 1       p       p       1               1
> 1       p       p       1.5             2
> 2       p       p       2               3
> 2       p       h       3.5             4
>
> For each group of "Poly1id" records, I wish to output (subset) the record
> which has largest "AreaPoly2" value, but only if Veg1=Veg2. For this
> example, the desired dataset would be
>
> P1id    Veg1    Veg2    AreaPoly2       P2ID
> 1       p       p       1.5             2
> 2       p       p       2               3
>
> Can anyone point me in the right direction on this?
>
> Dr. Seth  W. Bigelow
> Biologist, USDA-FS Pacific Southwest Research Station
> 1731 Research Park Drive, Davis California
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] subsetting by groups, with conditions

2009-12-28 Thread David Winsemius


On Dec 28, 2009, at 7:03 PM, Seth W Bigelow wrote:


I have a data set similar to this:

P1idVeg1Veg2AreaPoly2   P2ID
1   p   p   1   1
1   p   p   1.5 2
2   p   p   2   3
2   p   h   3.5 4

For each group of "Poly1id" records, I wish to output (subset) the  
record

which has largest "AreaPoly2" value, but only if Veg1=Veg2. For this
example, the desired dataset would be

P1idVeg1Veg2AreaPoly2   P2ID
1   p   p   1.5 2
2   p   p   2   3


Can you be more expansive (or perhaps more accurate?) about the  
conditions you want satisfied? Looking at the that dataset, I only see  
one row that has the largest value for AreaPoly2 within the three  
records where Veg1==Veg2.


Otherwise I would think the answer might be along these lines:
> dft <- read.table(textConnection("P1idVeg1Veg2 
AreaPoly2   P2ID

+ 1   p   p   1   1
+ 1   p   p   1.5 2
+ 2   p   p   2   3
+ 2   p   h   3.5 4"), header=T)
> dft$Veg1 <- factor(dft$Veg1, levels=levels(dft$Veg2))

> s.dft <- subset(dft, Veg1==Veg2)

> s.dft[which.max(s.dft$AreaPoly2),]
  P1id Veg1 Veg2 AreaPoly2 P2ID
32pp 23

--
David



Can anyone point me in the right direction on this?

Dr. Seth  W. Bigelow
Biologist, USDA-FS Pacific Southwest Research Station
1731 Research Park Drive, Davis California
[[alternative HTML version deleted]]

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


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


Re: [R] Accessing members

2009-12-28 Thread GlenB


This is a result of how R treats factors.

There's more than one way to do what I think you're asking for.

I've constructed a smaller version of your data frame to illustrate one
quick way if that's all you need:

> smdat<-
> data.frame(V1=c("AB","AB.C","ABF10"),V2=rep("20091224",3),V3=rep(156.0,3))
> smdat
 V1   V2  V3
1AB 20091224 156
2  AB.C 20091224 156
3 ABF10 20091224 156
> smdat[1,][1]
  V1
1 AB

-- 
View this message in context: 
http://n4.nabble.com/Accessing-members-tp990043p990097.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] Accessing members

2009-12-28 Thread David Winsemius


On Dec 28, 2009, at 5:14 PM, Nick Torenvliet wrote:


Consider the following


fileLines

 V1   V2V3V4 V5 V6V7 V8
1 AB 20091224 156.0 156.0 154.00 154.0055   1198
2   AB.C 20091224 156.0 156.0 156.00 156.00 0  0
3  ABF10 20091224 156.0 156.0 156.00 156.0055444

.
.



attributes (fileLines)

$names
[1] "V1" "V2" "V3" "V4" "V5" "V6" "V7" "V8"

$class
[1] "data.frame"

$row.names
[1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21  
22 23 24

25
[26] 26 27 28 29


fileLines[1,2]

[1] 20091224
As expected!


fileLines[1,3]

[1] 156
As expected!


fileLines[1,1]

[1] AB
29 Levels: AB AB.C ABF10 ABH10 ABH11 ABH12 ABK10 ABK11 ABN10  
ABN11 ... WW

Doh!

How do I access the "AB" element directly?


You already did access that element directly. You were given a bit  
more information than you expected but the value of fileLines[1,1] is  
"AB" and you were also advised that such value was one of 29 possible  
values for the particular factor set of which it is a member.



--
David



Nick

[[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] ggplot2, building a simple formula interface

2009-12-28 Thread Bryan Hanson
I¹m trying to build a simple formula interface to work with a function using
ggplot2. The following scheme ³works² up until the plot(p) request, at which
point there are complaints about xlim¹s and a blank graphics window.
Looking at str(p) I do see the limits are NULL, plus layer 1 claims to have
an empty data frame (but df is reproduced correctly).  I'm sure I'm missing
something really obvious; alas my ggplot2 book is at work and it's cold
outside!


simple <- function(formula, data, ...){
mf <- model.frame(formula = formula, data = data)}

res <- rnorm(100)
f1 <- rep(c("C", "D", "D", "C"), 25)
f2 <- rep(c("A", "B"), 50)
mydata <- data.frame(res, f1, f2)

df <- simple(~ res + f1, mydata)
p <- ggplot(df, aes(f1, res)) + geom_boxplot()
plot(p)

Thanks, Bryan
*
Bryan Hanson
Acting Chair
Professor of Chemistry & Biochemistry
DePauw University, Greencastle IN USA

> sessionInfo()
R version 2.10.1 (2009-12-14)
x86_64-apple-darwin9.8.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] ggplot2_0.8.5  digest_0.4.2   reshape_0.8.3  proto_0.3-8
mvbutils_2.5.0 ChemoSpec_1.43
 [7] R.utils_1.2.4  R.oo_1.6.5 R.methodsS3_1.0.3  rgl_0.87
lattice_0.17-26mvoutlier_1.4
[13] plyr_0.1.9 RColorBrewer_1.0-2 chemometrics_0.5   som_0.3-4
robustbase_0.5-0-1 rpart_3.1-45
[19] pls_2.1-0  pcaPP_1.7  mvtnorm_0.9-8  nnet_7.3-1
mclust_3.4 MASS_7.3-4
[25] lars_0.9-7 e1071_1.5-22   class_7.3-1

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] anova

2009-12-28 Thread Richard M. Heiberger

You may need to look at some other contrasts than the pairwise.
For example,
3(x.bar_A + x.bar_B)  -  2(x.bar_C + x.bar_D + x.bar_E)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Accessing members

2009-12-28 Thread Nick Torenvliet
Thanks everyone... the as.character(fileLines[1][1]) solution worked well...


Factors??? the treatment is so far away from what I know.

Cool though...


On Mon, Dec 28, 2009 at 8:55 PM, David Winsemius wrote:

>
> On Dec 28, 2009, at 5:14 PM, Nick Torenvliet wrote:
>
>  Consider the following
>>
>>  fileLines
>>>
>> V1   V2V3V4 V5 V6V7 V8
>> 1 AB 20091224 156.0 156.0 154.00 154.0055   1198
>> 2   AB.C 20091224 156.0 156.0 156.00 156.00 0  0
>> 3  ABF10 20091224 156.0 156.0 156.00 156.0055444
>>
> .
>
> .
>
>>
>>  attributes (fileLines)
>>>
>> $names
>> [1] "V1" "V2" "V3" "V4" "V5" "V6" "V7" "V8"
>>
>> $class
>> [1] "data.frame"
>>
>> $row.names
>> [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
>> 24
>> 25
>> [26] 26 27 28 29
>>
>>  fileLines[1,2]
>>>
>> [1] 20091224
>> As expected!
>>
>>  fileLines[1,3]
>>>
>> [1] 156
>> As expected!
>>
>>  fileLines[1,1]
>>>
>> [1] AB
>> 29 Levels: AB AB.C ABF10 ABH10 ABH11 ABH12 ABK10 ABK11 ABN10 ABN11 ... WW
>> Doh!
>>
>> How do I access the "AB" element directly?
>>
>
> You already did access that element directly. You were given a bit more
> information than you expected but the value of fileLines[1,1] is "AB" and
> you were also advised that such value was one of 29 possible values for the
> particular factor set of which it is a member.
>
>
> --
> David
>
>
>> Nick
>>
>>[[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.


[R] error logging

2009-12-28 Thread Nick Torenvliet
Yet another question...

I'm wondering if there is a built in facility to log errors.   I've got this
statement that gives me verbose DBI errors as they come up (to standard
output), but I'd like to trap and log them to a file as I running about
300 sql statements through this particular piece of code and I'd like to
keep the loop going and deal with all the errors once the bulk of it has
been processed.

atmpt <- try(dbGetQuery(con,sql))
options(show.error.messages = TRUE)
if(inherits(atmpt, "try-error")){

}

The R docs aren't structured in the way I'm used to(I will get the hang of
it)... so I'm more than willing to ?theDesiredCommand at the R - prompt...
if you'd lead me in the right direction.

Thanks again!

Nick

[[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] error logging

2009-12-28 Thread Gabor Grothendieck
Try this:

logfile <- file("logfile")
open(logfile, "w")
sink(logfile, type = "message")
1/"a"  # generate an error


On Mon, Dec 28, 2009 at 11:11 PM, Nick Torenvliet
 wrote:
> Yet another question...
>
> I'm wondering if there is a built in facility to log errors.   I've got this
> statement that gives me verbose DBI errors as they come up (to standard
> output), but I'd like to trap and log them to a file as I running about
> 300 sql statements through this particular piece of code and I'd like to
> keep the loop going and deal with all the errors once the bulk of it has
> been processed.
>
>        atmpt <- try(dbGetQuery(con,sql))
>        options(show.error.messages = TRUE)
>        if(inherits(atmpt, "try-error")){
>
>        }
>
> The R docs aren't structured in the way I'm used to(I will get the hang of
> it)... so I'm more than willing to ?theDesiredCommand at the R - prompt...
> if you'd lead me in the right direction.
>
> Thanks again!
>
> Nick
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] error logging

2009-12-28 Thread Nick Torenvliet
Beauty thank-you... I'm crashing but I'll check that out in a couple when I
get back.  Must go snowboarding tomorrow!

On Mon, Dec 28, 2009 at 11:20 PM, Gabor Grothendieck <
ggrothendi...@gmail.com> wrote:

> Try this:
>
> logfile <- file("logfile")
> open(logfile, "w")
> sink(logfile, type = "message")
> 1/"a"  # generate an error
>
>
> On Mon, Dec 28, 2009 at 11:11 PM, Nick Torenvliet
>  wrote:
> > Yet another question...
> >
> > I'm wondering if there is a built in facility to log errors.   I've got
> this
> > statement that gives me verbose DBI errors as they come up (to standard
> > output), but I'd like to trap and log them to a file as I running about
> > 300 sql statements through this particular piece of code and I'd like
> to
> > keep the loop going and deal with all the errors once the bulk of it has
> > been processed.
> >
> >atmpt <- try(dbGetQuery(con,sql))
> >options(show.error.messages = TRUE)
> >if(inherits(atmpt, "try-error")){
> >
> >}
> >
> > The R docs aren't structured in the way I'm used to(I will get the hang
> of
> > it)... so I'm more than willing to ?theDesiredCommand at the R -
> prompt...
> > if you'd lead me in the right direction.
> >
> > Thanks again!
> >
> > Nick
> >
> >[[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.


[R] R2

2009-12-28 Thread Nancy Adam

Hi everyone,
I tried to write the code of computing R2 for a regression system but I failed.
This is the code I use for computing RMSE:
 
my_svm_model <- function(myformula, mydata, mytestdata) 
  {
  mymodel <- svm(myformula, data=mydata)   
  mytest <- predict(mymodel, mytestdata)
  error <- mytest - mytestdata[,1]
  -sqrt(mean(error**2))
 
  }
can anyone please tell me what I have to change to compute R2 instead of RMSE?
 
Many thanks,
Nancy 
_


[[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] how can I use R functions in Fortran 90

2009-12-28 Thread Anny Huang
Hi all,

Is there a way that I can import R functions into Fortran? Especially, I
want to generate random numbers from some not-so-common distributions (e.g.
inverted chi square) but did not find any routines written in Fortran that
deal with distributions other than uniform and normal.

Thanks.
Anny

[[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 can I use R functions in Fortran 90

2009-12-28 Thread Guo-Hao Huang


You can read the manual below.
good luck!

http://www.biometrics.mtu.edu/CRAN/doc/manuals/R-exts.html#The-R-API
For example, suppose we want to call R's normal random numbers from FORTRAN. 
We need a C wrapper along the lines of



#include 

void F77_SUB(rndstart)(void) { GetRNGstate(); }
void F77_SUB(rndend)(void) { PutRNGstate(); }
double F77_SUB(normrnd)(void) { return norm_rand(); }
to be called from FORTRAN as in

  subroutine testit()
  double precision normrnd, x
  call rndstart()
  x = normrnd()
  call dblepr("X was", 5, x, 1)
  call rndend()
  end
Note that this is not guaranteed to be portable, for the return conventions 
might not be compatible between the C and FORTRAN compilers used. (Passing 
values via arguments is safer.)





with regards,



   Guo-Hao Huang

--
From: "Anny Huang" 
Sent: Tuesday, December 29, 2009 1:45 PM
To: 
Subject: [R] how can I use R functions in Fortran 90


Hi all,

Is there a way that I can import R functions into Fortran? Especially, I
want to generate random numbers from some not-so-common distributions 
(e.g.

inverted chi square) but did not find any routines written in Fortran that
deal with distributions other than uniform and normal.

Thanks.
Anny

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