Re: [R] What is the HEX code for "transparent" color?

2024-06-07 Thread Roland Rau via R-help

On 6/6/24 18:41, Duncan Murdoch wrote:

On 2024-06-06 4:37 a.m., Yosu Yurramendi wrote:

What is the HEX code for "transparent" color?
I've tried "" "FF00" "", but they don't work.


If the other answers don't solve your problem, you should give us some 
context.  Not all graphics functions in R can handle transparency, so 
please show us some reproducible code for what you are trying.


Duncan Murdoch



I usually use the alpha argument of the rgb() function for transparency.
Does this code snippet help to give you an idea how it works.

plot(1, 1, type="n", xlim=c(0,10), ylim=c(0,10))
rect(xleft=0, xright=7.5, ybottom=0, ytop=7.5,
 col=rgb(0, 0, 1, alpha=0.5))
rect(xleft=2.5, xright=10, ybottom=2.5, ytop=10,
 col=rgb(1, 0, 0, alpha=0.5))

Please check
?rgb
Especially the "Details" section should be helpful where you will find a 
list of devices which are supported or not supported.


I hope this helps a bit.

All the best,
Roland


--
This mail has been sent through the MPI for Demographic ...{{dropped:2}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Is there a canonical way to pronounce CRAN?

2022-05-04 Thread Roland Rau via R-help

Dear all,

I talked with colleagues this morning and we realized that some people 
(=me) pronounce CRAN like the German word "Kran" (probably pronounced 
like "cruhn" in English -- if it was a word).
My colleague pronounced it as "Sea-Ran" or "Sea-Run". The colleague was 
a student and has worked at the same institution as an R Core Developer 
and heard it from him personally.


So now I am puzzled. Have I been wrong about 43% of my life? ;-)

Honestly: Is there a unique way how the core developers prounounce CRAN?

Not an urgent question at all but maybe interesting to many of us.

Thanks,
Roland

--
This mail has been sent through the MPI for Demographic ...{{dropped:2}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Change position in package rgl

2014-04-13 Thread Roland Rau
On 04/12/2014 07:03 PM, Duncan Murdoch wrote:
 I think you could hack something like that (see the description in
 ?par3d of how rendering is accomplished), but there's currently no
 support for it, and it wouldn't be easy, as currently P and M in that
 description are read-only quantities computed indirectly.  So you'd have
 to essentially trick rgl into producing the P matrix corresponding to
 the viewing position you want.
 
 I am currently working on some changes that might make this easier, but
 they likely aren't going to be released for several months.
 
 Duncan Murdoch
Dear Duncan,

thank you very much. I was thinking I might have missed something obvious.

Thanks,
Roland

--
This mail has been sent through the MPI for Demographic ...{{dropped:2}}

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

2014-04-12 Thread Roland Rau
Dear all,

I am using package rgl and I want to change the position where I stand.
Maybe a small example might clarify what I am looking for:


# Begininng of explanatory example
library(rgl)
data(volcano)

# the example ?rgl.surface
y - 2 * volcano
x - 10 * (1:nrow(y))
z - 10 * (1:ncol(y))
ylim - range(y)
ylen - ylim[2] - ylim[1] + 1
colorlut - terrain.colors(ylen)
col - colorlut[ y-ylim[1]+1 ]

rgl.open()
rgl.surface(x, z, y, color=col, back=lines)
## now I have the nice volcano surface
## with rgl.viewpoint I can change the elevation
## and the angle from where I look at the rgl.surface
# example of ?rgl.viewpoint
start - proc.time()[3]
while ((i - 36*(proc.time()[3]-start))  360) {
  rgl.viewpoint(i,i/4);
}
# End of explanatory example

What I am looking for (in this example) would be a way for me to stand
on the crater of the volcano, looking in a specific direction. Is there
something like a function where I can specify my coordinates (x,y,z) and
angle and a zoom factor?

Thank you,
Roland

--
This mail has been sent through the MPI for Demographic ...{{dropped:2}}

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


Re: [R] reading files from two folders

2012-03-28 Thread Roland Rau
Hi,

On 03/28/2012 08:48 AM, uday wrote:
 I would like to read data from two different folder and then combine this
 together 
 the code which I have tried are as follows 
 setwd(/Groups/data_first/)
 file_was - list.files(path = ., pattern = v2.0.2.was, all.files =
 FALSE, full.names = FALSE, recursive = FALSE, ignore.case = FALSE)
 path-c(/Groups/data_second/)
 file_wasaux2 -list.files(path,pattern=v2.0.2.wasaux2)
 files- 1
  for ( i in files){
  data1  - read.table(file_was[i],header=TRUE)
  data2  - read.table(paste(path1t, file_wasaux2[i],header=TRUE))
  data   - cbind (data1,data2)
 } 
 but I get error 
 (Error in read.table(SCI_WFMD_L2_w6002_200301_v2.0.2.wasaux2, header = TRUE)
 :
   object 'SCI_WFMD_L2_w6002_200301_v2.0.2.wasaux2' not found)
 
 could somebody please tell me how to solve this problem?
 

I assume that the problem is the following line:
  data2  - read.table(paste(path1t, file_wasaux2[i],header=TRUE))
The default separator of paste is  , see:
?paste
that probably means that the file you want to read has a different name
than what you actually provide as the file name.

Just a guess, though

Please let me add that it is probably not a good idea to call your data
data. First, it is not very descriptive, meaning: you may have problems
in the future to understand your own code. Second, a function of the
same name exists already.

Hope this helps,
Roland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 call R-squared values from lm's?

2010-12-02 Thread Roland Rau

On 12/02/2010 03:15 PM, Wegan, Michael (DNRE) wrote:

I would like to call both p-values and R-squared values from lm's in a 
function.  I can get the p-values from coef(summary(name.lm))[r,c], however, I 
cannot figure out how to call the R-squared values without manually calling the 
summary and inserting them in the script - which negates the value of 
automating the process through a function.

Thanks,
Mike


I hope this does the trick:

set.seed(1234)
x - 1:10
y - (4 + 3*x)+rnorm(10)

my.lm - lm(y~x)
summary(my.lm)$r.squared
summary(my.lm)$adj.r.squared

Enjoy,
Roland

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

2010-12-01 Thread Roland Rau

On 12/01/2010 02:43 PM, alcesgabbo wrote:


I plot the first column with the following function:
plot(m[,1],type=o, xaxt=n,ylim=c(min(m[,1:length(colnames(m))])-1,
max(m[,1:length(colnames(m))])+1))

for the other columns I use there functions:

lines(m[,2],type=\o\)

lines(m[,3],type=\o\)

ok, it works.

But is there a way to do this prodcedures recursively??

for example:

for each columns {
  lines(m[,column],type=\o\)
}

I try with :

lines(m[,2:length(colnames(m))],type=\o\)


Is there a special need to do it recursively?

Would the following not do the trick, too?

m - matrix(c(1,6,3,2,5,4,3,6,3,4,5,4), byrow=TRUE, ncol=3)
matplot(m, type=o, xaxt=n,ylim=c(min(m[,1:length(colnames(m))])-1,
max(m[,1:length(colnames(m))])+1),
lty=1, col=black)

Or simply:
matplot(m, type=o, xaxt=n, lty=1, col=black)

Hope this helps,
Roland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] a bit off topic: data for dragsters?

2008-11-17 Thread Roland Rau
Dear all,

does anyone of you know where to get some simple data from dragster racing
(the race where you go for 1/4 mile straight)?
Best would be some data where you have two columns with Col 1 Time since
start of race in miliseconds and Col 2 Distance traveled.

Thank you very much,
Roland

[[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] Fw: How to learn R language?

2008-08-27 Thread Roland Rau

Ajay ohri wrote:

   - go with Bob and Peter's book. Too many sources can be confusing.
   - Join the list, create filters for keywords of your specialty (like from
   R -Help ) contains regression.
   - Try use it for a live project .


I think this is really very good advice:
- 2 books (I would recommend Peter Dalgaard's and Modern Applied 
Statistics by Venables/Ripley)

- the R-help list is very, very valuable
- most importantly: use it for some real project

Please let me add two more things:
- the road is long. Even after years using it exclusively as your 
statistical language/package of choice, there are still surprises around 
the corner (at least it happens to me, just discovered '.bquote' a few 
weeks ago)
- have an open mind. For example, if you have a background in SPSS, 
Excel, ... but not in general purpose programming languages, you might 
be surprised that your data don't have to be in rectangular shape. In my 
experience this is one of the first obstacles for students with a social 
science background.
- You get often world-class help and advice *for free* on the r-help 
list. So please read the posting guide before posting questions to the 
r-help list. This will save you some answer which might appear to be 
rude (but usually answer your question anyway).


I hope this helps you further,
Roland

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

2008-08-25 Thread Roland Rau

Hi,

Jason Thibodeau wrote:

I am attempting to perform some simple data manipulation on a large data
set. I have a snippet of the whole data set, and my small snippet is 2GB in
CSV.

Is there a way I can read my csv, select a few columns, and write it to an
output file in real time? This is what I do right now to a small test file:

data - read.csv('data.csv', header = FALSE)

data_filter - data[c(1,3,4)]

write.table(data_filter, file = filter_data.csv, sep = ,, row.names =
FALSE, col.names = FALSE)


in this case, I think R is not the best tool for the job. I would rather 
suggest to use an implementation of the awk language (e.g. gawk).
I just tried the following on WinXP (zipped file (87MB zipped, 1.2GB 
unzipped), piped into gawk)

unzip -p myzipfile.zip | gawk '{print $1, $3, $4}'  myfiltereddata.txt
and it took about 90 seconds.

Please note that you might need to specify your delimiter (field 
separator (FS) and output field separator (OFS)) =

gawk '{FS=,; OFS=,} {print $1, $3, $4}' data.csv  filter_data.scv

I hope this helps (despite not encouraging the usage of R),
Roland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Large data sets with R (binding to hadoop available?)

2008-08-21 Thread Roland Rau

Hi

Avram Aelony wrote:


Dear R community,

I find R fantastic and use R whenever I can for my data analytic needs.  
Certain data sets, however, are so large that other tools seem to be 
needed to pre-process data such that it can be brought into R for 
further analysis.


Questions I have for the many expert contributors on this list are:

1. How do others handle situations of large data sets (gigabytes, 
terabytes) for analysis in R ?


I usually try to store the data in an SQLite database and interface via 
functions from the packages RSQLite (and DBI).


No idea about Question No. 2, though.

Hope this helps,
Roland


P.S. When I am sure that I only need a certain subset of large data 
sets, I still prefer to do some pre-processing in awk (gawk).
2.P.S. The size of my data sets are in the gigabyte range (not terabyte 
range). This might be important if your data sets are *really large* and 
you want to use sqlite: http://www.sqlite.org/whentouse.html


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

2008-08-21 Thread Roland Rau

Hi,

[EMAIL PROTECTED] wrote:

I have tried

mean(Incubation)

and

mean(as.numeric(Incubation))


what about
mean(Incubation, na.rm=TRUE)
?

I get the following result:
 mean(Incubation, na.rm=TRUE)
Time difference of 4.295455 hours



but I think that, since there are so many NA values in Incubation, R 
gives a mean value of NA.


R returns (correctly) NA for such operations when NAs occur in the 
dataset. Sorry, but I don't know where to find it at the moment but 
there is standard for this.
It has nothing to do with the proportion of NAs in the dataset 
(...since there are so many NA values...)



Is there any way of either extracting all
numeric values (i.e. all non-NA values) from the Incubation vector, 


Incubation[is.numeric(Incubation)]

but this is probably not what you want, since the NAs are also 
considered numeric:


 is.numeric(Incubation)
[1] TRUE

or

finding the mean value of only the numeric values in the Incubation vector?


see above:
NAs are also numeric in this case
mean(Incubation[is.numeric(Incubation)])
 mean(Incubation[is.numeric(Incubation)])
Time difference of NA hours



Hope this helps,
Roland

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

2008-08-19 Thread Roland Rau

Hi,

Kanak Choudhury wrote:

Hi,
i have made a code for optimizing a function using constrOptim. i need
hessain matrix of the parameters. how could i get hessain matrix when i will
use constrOptim? May i get get any help from anyone?



the function fdHess from package 'nlme' can help you?

library(nlme)
?fdHess

I hope this helps,
Roland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] changing plot font for Times new roman

2008-08-18 Thread Roland Rau

Hi,

milton ruser wrote:

we choose an family of fonts. I tryed par(family=times)
without success.



what about this:
pdf(plot1Times.pdf, family=Times)
plot(1,1)
dev.off()
pdf(plot1NotTimes.pdf)
plot(1,1)
dev.off()


Maybe you check also the help for
?postscriptFonts

I hope this helps you a bit further.

Best,
Roland







Surfing on R archieve I got an suggestion of
use par(font.lab=6), but when I go to the
par(font.lab) help the highest value there is 5.
How can I have sure that font.lab=6 is the Times
New Roman?

Thanks in advance,

miltinho astronauta
brazil
---

op-par()

x11(800,500)
par(mfrow=c(1,2))

x-plot(runif(100),rnorm(100) , main=standard font)

par(font.lab=6)
par(font.axis=6)

x-plot(runif(100),rnorm(100) , main=font=6)
par-op

[[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] readable dendrograms with many units

2008-08-18 Thread Roland Rau

Hi,

since you are new to R, you might not be aware of some nice feature at 
the homepage of R: the task view

http://cran.r-project.org/web/views/
For various topics, somebody kindly provided an overview of packages and 
functions for the specific topic.

Also for cluster analysis:
http://cran.r-project.org/web/views/Cluster.html

Welcome to R, I hope this gets you started,
Roland





Paul Slater wrote:

Using Mathematica, I've performed a hierarchical clustering
of 3,107 U. S. counties based on 1995-2000 intercounty
migration, using an algorithm of my own devising
(see http://arxiv.org/abs/0807.1550). I can also generate
the associated 3,107 x 3,107 matrix of ultrametric distances.

Unfortunately, as far as I have been able to
determine, the Mathematica hierarchical clustering
package only produces readable dendrograms with twenty-or-so
or fewer units.

So, I'm wondering whether I can be more successful in looking at
my clustering results overall with R (which
I have not previously used). Please note that I'd rather not have to
produce a hierarchical clustering from scratch using one of the more
standard methodologies (single, complete linkage,...). So, I might
have to use the (non-sparse) 3,107 x 3,107 matrix of ultrametric
distances as an input distance matrix.

Thanks for any suggestions/information...,


Paul B. Slater

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ignoring zeros or converting to NA

2008-08-13 Thread Roland Rau

Hi,

since many suggestions are following the form of
x[x==0] (or similar)
I would like to ask if this is really recommended?
What I have learned (the hard way) is that one should not test for 
equality of floating point numbers (which is the default for R's numeric 
values, right?) since the binary representation of these (decimal) 
floating point numbers is not necessarily exact (with the classic 
example of decimal 0.1).
Is it okay in this case for the value zero where all binary elements are 
zero? Or does R somehow recognize that it is an integer?


Just some questions out of curiosity.

Thank you,
Roland


rcoder wrote:

Hi everyone,

I have a matrix that has a combination of zeros and NAs. When I perform
certain calculations on the matrix, the zeros generate Inf values. Is
there a way to either convert the zeros in the matrix to NAs, or only
perform the calculations if not zero (i.e. like using something similar to
an !all(is.na() construct)?

Thanks,

rcoder


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


Re: [R] Memory allocation problem

2008-08-12 Thread Roland Rau

Jamie Ledingham wrote:

becomes too much to handle by the time the loop reaches 170.  Has anyone
had any experience of this problem before?  Is it possible to 'wipe' R's
memory at the end of each loop - all results are plotted and saved or
written to text file at the end of each loop so this may be the ideal
solution.


Besides using gc() (- email by John Kerpel), you might also consider to 
remove all objects:

rm(list=ls())

I hope this helps,
Roland

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

2008-08-11 Thread Roland Rau

Charles C. Berry wrote:


Should someone start a pool on when SAS will offer 'R language support' ??


At least Biostatistics Denmark developed something in this direction.
Too bad that Rolf Poalis made only this announcement:
http://tolstoy.newcastle.edu.au/R/help/04/04/0009.html
in the beginning of April 2004...

SCNR,
Roland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Differential Equations there use in R (population modeling)

2008-08-11 Thread Roland Rau

Hi,

stephen sefick wrote:

e1 - function(x,b,t){
d-(x)*(b^t)
plot(d)
}

e1(2, 2,seq(from=0, to=6, by=1))

Is there a way to do this with a change in time.  I would like to use
differential equations.  I am trying to model
a population with an initial value, fecundity per time step, and a
death rate.  


just a small recommendation: do you know Hal Caswell's Book Matrix 
Population Models?

This is the homepage of the book http://www.sinauer.com/detail.php?id=0965
He explains in detail how to construct and analyze population models 
with an initial value and (time varying) fertility and mortality. The 
matrix models in his book allow also to relax your (implicit) assumption 
of having no age structure in your population.


I hope this helps you further.

Best,
Roland

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

2008-08-11 Thread Roland Rau

Hi Kevin,

check
?dump

set.seed(1234)
list1 - list(a1=rnorm(100), a2=rnorm(10))
list2 - list(a1=rnorm(50), a2=rnorm(25))

mylist - list(top1=list1, top2=list2)
dump(list=mylist, file=mydumpedlist.r)
rm(mylist)

# please note that you have to quote the name
# of the object(s) you want to dump!

source(mydumpedlist.r)
ls()

I hope this helps,
Roland



[EMAIL PROTECTED] wrote:

I have a list

List(Sku= , Shape=1, Scale=3, DayOfYear=daylist)
Note: picture daylist as c(2,3,4,3) it is a list with variable length.

Then I have a list of lists

al - c(al, List(List(Sku= , Shape=1, Scale=3, DayOfYear=daylist))
Note: same comment on daylist as above.

So far this creates a list of lists just how I want it. If I do al[1] I get 
each member and the variable length list 'daylist'.

Now I want to export this list of lists:

write.table(mlist, SkuInfo.dat, row.names = FALSE,  sep=,)

But I get an error that the list lengths are not equal. The only member of this 
list that has a variable length would be DayOfYear

How can I output this list of lists when each element list contains a variable 
length list?

Thank you.

Kevin

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

2008-08-11 Thread Roland Rau

Hi,

Brandon Invergo wrote:

You can use the length() and which() functions for that:

  length(which(m == 2))

Or even shorter since TRUE Values have a value of 1

mymatrix - matrix(sample(x=1:10, size=1000, replace=TRUE), ncol=5)
sum(mymatrix==2)
length(which(mymatrix==2)) #should give the same result

Best,
Roland

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

2008-08-11 Thread Roland Rau

dott wrote:

Hi,

Suppose I have a vector in real number
(x1, x2, x3, x4, x5, x6)

My question is how I can get  
x5*x3*x1 + x6*x4*x2 ?


Thanks a lot.
Dot.


hard to say what you mean?
Maybe summing up all elements in odd positions and the ones in even 
positions?


myvector - 1:6

1*3*5 + 2*4*6
sum(prod(myvector[((1:length(myvector))%%2)==1]),prod(myvector[((1:length(myvector))%%2)==0])) 




Best,
Roland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] long run time for loop operation matrix fill

2008-08-08 Thread Roland Rau

Hi,

Bert Gunter wrote:

speedup over explicit loops. As you said, their greatest advantage is
elegance and code readability (as functional programming, rather than
procedural programming, constructs).

As you also said, vectorizing calculations is a central theme in R that
takes some getting used to. I know of no general prescriptions for how to do
it; I, too, am still learning.



I think it takes time and experience.

To get you started, the following items might be helpful:
If I recall correctly, John Chambers dedicated some part of his book 
Programming with Data on the whole object view. (Again, if I 
remember and interpret it correctly) he means that one should not think 
element-by-element wise but thinking about the whole object you want 
to manipulate.
Please note that he authored another book, published within the last few 
weeks called Software for Data Analysis: Programming with R. Maybe 
there is also something on the subject.


S Programming by William Venables  Brian D. Ripley also provides very 
helpful information on the topic.


Please search also on the web for S Poetry by Patrick Burns. It is 
available for free and very informative.


Best,
Roland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Tcl\tk not supported on this system

2008-08-08 Thread Roland Rau

Hi,

have a look here:
http://tolstoy.newcastle.edu.au/R/e4/help/08/07/17379.html

Hope this helps,
Roland


Michael Gormley wrote:

trying to install the pbatR package, I was greeted with the error

Error: package 'tcltk' does not have a name space
Execution halted

Directly installing the package tcltk2 returned the following error:

Loading required package: tcltk
Error in firstlib(which.lib.loc, package) :
Tcl/Tk support is not available on this system

I have seen from previous posts that tcl/tk must be present when R is
installed.
I tried reinstalling R from source using

./configure
make

and although the installation went fine I received the same errors.

Typing rpm -qa|grep tcl returns:
tclx-8.3.5-4
tcl-8.4.7-2
tcl-8.4.7-2

Typing rpm -qa|grep tk returns:
gtkspell-2.0.7-2
atk-1.8.0-2
gtk+-1.2.10-33
gtk2-2.4.13-22
authconfig-gtk-4.6.10-rhel4.3
gtkhtml2-2.6.2-1
gtk-engines-0.12-6.el4
tk-8.4.7-2
gtksourceview-1.1.0-4
gtk-engines-0.12-6.el4
tk-8.4.7-2
gnome-python2-gtkhtml2-2.6.0-3
gtkglarea-1.2.2-16
gtk2-engines-2.2.0-7.el4
gtkhtml3-3.3.2-6.EL
usermode-gtk-1.74-1
atk-1.8.0-2
gtk2-2.4.13-22
pygtk2-libglade-2.4.0-1
gtk+-1.2.10-33
gtkhtml2-2.6.2-1
pygtk2-2.4.0-1

So it seems that tcl and tk are present on the system.  I saw a post
suggesting that I may need some development packages?  What is a good place
to find these packages?

I am running R version 2.5.1 on a Linux machine running Redhat Enterprise 3.


Let me know if you need any more info on the operating system and if there
are any ideas on how to resolve these issues.

Thanks,
Michael Gormley

[[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] Programming Contest

2008-08-05 Thread Roland Rau

Dear all,

for those of you who have too much time (nobody) and those who enjoy 
participating in programming contests (maybe some of you), I found an 
interesting site linked from reddit's programming section: 
http://www.reddit.com/r/programming/

The actual contest is at the site: http://selfexplanatorycode.blogspot.com/
You need to find all two word anagrams from the string documenting 
given a list of words.
The key is to write it without any comments and the code should be 
rather self-explanatory even for an outsider who does not 'speak' your 
programming language of choice.


Isn't R a prime candidate to do such a thing?

Maybe some of you submit some solutions to this website (and maybe also 
here). I created something within 5 minutes (but it is terribly 
inefficient).


Best,
Roland

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

2008-08-01 Thread Roland Rau

Hi Rostam,

did you check
?rgb
already?

Hope this helps,
Roland


rostam shahname wrote:

Hi R users,
I would like to create an image using three matrices which contain the
values of Red, Green, and Blue of each pixel, i.e. one matrix which has
values of red, one which has values of green, and one which has values of
blue.
The values are between 0 and 1 instead of 0-255.
I have obtained the matrices using the getChannels of pixmap library.
I wonder if anyone knows how to create the image using RGB matrices.
Thanks for your help.

Thanks,
Rostam

[[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] how to replace NA values in a list

2008-08-01 Thread Roland Rau

Hi,

to be honest, I never created a matrix of lists before, but hopefully 
this code will help you?


set.seed(12345)
my.pool - c(NA, 0:10)
n - 25

alist - list(sample(x=my.pool, size=n, replace=TRUE))
alist

mymatrix - matrix(rep(alist, 6*3), nrow=6)
mymatrix2 - lapply(X=mymatrix, FUN=function(x) ifelse(is.na(x),0,x))
mymatrix2


Best,
Roland

Shang Liu wrote:
I have a matrix named spec (see below), it is a 6x3 matrix, and each element of spec is a list. For example, spec[1,wavenumber] is a list, and it contains 1876 numeric numbers and NAs. I want to replace the NAs to zero, but don't know how to change it, the difficulty may be all the elements are of the class list, so it is hard to change. 

Thank you for your help! 


matrix spec:

 wavenumber   prescan  postscan
H001 Numeric,1876 Numeric,1876 Numeric,1876

H002 Numeric,1876 Numeric,1876 Numeric,1876
H003 Numeric,1876 Numeric,1876 Numeric,1876
H004 Numeric,1876 Numeric,1876 Numeric,1876
H005 Numeric,1876 Numeric,1876 Numeric,1876
H006 Numeric,1876 Numeric,1876 Numeric,1876
[[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] R -Legality Question about R's Open Source GNU GPL License

2008-07-30 Thread Roland Rau

Hi,

Stevens, Martin Henry H. Dr. wrote:

The limit of use is that you cannot profit from it. It is Open Source.


I am not sure what you mean exactly. If you mean that you can not earn 
any money selling free software (in terms of the GPL2, which is R's 
licence), this seems to be not the case:

http://www.fsf.org/licensing/essays/selling.html

Best,
Roland

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

2008-07-30 Thread Roland Rau

Hi,

check
?sample

n - 200
mydata.set - rnorm(10)
my.random.subset - sample(x=mydata.set, size=n, replace=TRUE)

my.random.subset


I hope this helps,
Roland



Alessandro wrote:

Hi all,

 


I wish to do a random subset (i.e. 200 or 300 points) from a dataset, but I
don't find the right code in R.

 


Thanks for help

 


alessandro


[[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] Random subset

2008-07-30 Thread Roland Rau
But probably you will need to set replace=FALSE if you want to sample 
from your original data set without replacement.


Sorry for the possible confusion,
Roland


Roland Rau wrote:

Hi,

check
?sample

n - 200
mydata.set - rnorm(10)
my.random.subset - sample(x=mydata.set, size=n, replace=TRUE)

my.random.subset


I hope this helps,
Roland



Alessandro wrote:

Hi all,

 

I wish to do a random subset (i.e. 200 or 300 points) from a dataset, 
but I

don't find the right code in R.

 


Thanks for help

 


alessandro


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.



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


Re: [R] Case statements in R

2008-07-29 Thread Roland Rau

Dear all,

may I suggest to include this quotation of Patrick Burns in the fortunes 
package? :-)


Best,
Roland


Patrick Burns wrote:

A good reason to use '' rather than '' is if evaluating
whatever is on the right will create an error if what is on
the left is FALSE.  '' and '||' stop if they already know
the answer from seeing the left side.  So they are likely faster
by a few nanoseconds, but it's the ability to stop before you
go off a cliff that is probably the key feature.



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

2008-07-28 Thread Roland Rau

Hi,

maybe the following code helps to achieve what you want?
It seems to me it is basically a 'recode' question.

set.seed(1234) # not neccessary but this ensures we have the same
#results
random.values - runif(n=30, min=0, max=100)
newgrouping - cut(x=random.values, breaks=c(0,0.1, 1, 2, 5, 10, 25, 
50, 	75, 95, 100), labels=1:10)

cbind(random.values,newgrouping)

## should result in:
  random.values newgrouping
 [1,]11.3703411   6
 [2,]62.2299405   8
 [3,]60.9274733   8
 [4,]62.3379442   8
 [5,]86.0915384   9
 [6,]64.0310605   8
 [7,] 0.9495756   2
 [8,]23.2550506   6
 [9,]66.6083758   8
[10,]51.4251141   8
[11,]69.3591292   8
[12,]54.4974836   8
[13,]28.2733584   7
[14,]92.3433484   9
etc.


I hope this helps,
Roland



Wade Wall wrote:

Hi all,

I am trying to convert geometric means in a matrix to cover classes.  My
values are as such:

perc-c(0,0.025136418, 0.316227766, 1.414213562,3.16227766, 7.071067812,
  15.8113883, 35.35533906, 61.23724357, 84.40971508, 97.46794345)
cover-c(0,1,2,3,4,5,6,7,8,9,10)

This is what I am trying to accomplish

veg_mean[veg_mean0  veg_mean  .1] - 1
veg_mean[veg_mean= .1  veg_mean  1.0] - 2
veg_mean[veg_mean=1.0   veg_mean  2.0] - 3
veg_mean[veg_mean=2.0   veg_mean  5.0] - 4
veg_mean[veg_mean= 5.0   veg_mean  10.0] - 5
veg_mean[veg_mean= 10.0   veg_mean  25] - 6
veg_mean[veg_mean= 25.0  veg_mean  50.0] - 7
veg_mean[veg_mean=50.0  veg_mean  75.0] - 8
veg_mean[veg_mean= 75.0  veg_mean  95.0 ] - 9
veg_mean[veg_mean= 95.0  veg_mean = 100] - 10
veg_mean[veg_mean 100] - NA

where values are assigned based on the geometric means.  However, I think
that my syntax for the  operator is wrong and I can't find a reference to
proper syntax.  I basically want to bin the geometric means.

Any help would be greatly appreciated.

Thanks,

Wade

[[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] Legality Question about R's Open Source GNU GPL License

2008-07-28 Thread Roland Rau

Jim Porzak wrote:

All this is included in the distribution in doc folder:

1. see FAQ: 2.11 Can I use R for commercial purposes?
2. Specific GNU License is in file COPYING


Furthermore,

the start-up message of R can (hopefully) help you in your case.
It mentions to type in
license()
or
licence()
to read more about the license.

In addition, maybe you can refer your legal department to the site:
http://www.r-project.org/foundation/memberlist.html
Of course, it is no proof of anything (and I have to mention that I did 
not study law myself), but it might give your legal department some 
impression that many companies are using the software. Check the list of 
Benefactors, Supporters and Donors: maybe there is a competitor of your 
company? Maybe they could gain some advantage by using R? ;-)


Best,
Roland










HTH,
Jim Porzak
Responsys, Inc.
San Francisco, CA
http://www.linkedin.com/in/jimporzak



On Mon, Jul 28, 2008 at 11:32 AM, zerfetzen [EMAIL PROTECTED] wrote:

Hi,
I use R at home, and am interested in using it at my work company (which is
in the Fortune 100).  I began the request, and our legal team has given some
gruff about the open source license.  Not boring you with the details here,
but I used some info on gnu.org as a rebuttal, and someone at the company
replied that the generalities of GNU GPL may differ from R's specific GNU
GPL license, and that I should refer specifically to it, and it should be on
the CRAN website.

I may be blind, but haven't seen such a document.  Does one exist, and how
may I obtain it?  I believe they are wrong.  Our legal team is notorious for
being overly conservative, and I'm personally betting they think I won't
look into it, and then they won't have to deal with it.  But I will, and I
want to use R.  Thanks.

PS
Sorry if the document was posted and obvious, and I simply couldn't find it.
Thanks.
--
View this message in context: 
http://www.nabble.com/Legality-Question-about-R%27s-Open-Source-GNU-GPL-License-tp18696623p18696623.html
Sent from the R help mailing list archive at Nabble.com.

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



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



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Minor Bug in Documentation of merge()

2008-07-25 Thread Roland Rau

Dear all,

I would like to point to a minor bug in the documentation of merge().

The documentation (?merge) says
all logical; all = L is shorthand for all.x = L and all.y = L.

I think the correct description should be
all logical; all = T is shorthand for all.x = T and all.y = T.

The source file which needs to be fixed is
src/library/base/man/merge.Rd

To be sure that it hasn't been fixed in the meantime, I checked the 
merge.Rd in R-patched_2008-07-24.tar.gz and R-devel_2008-07-24.tar.gz.


Thanks,
Roland

Little code example:

 set.seed(12345)
 df.A - data.frame(Year=2000:2004, myvar.A=rnorm(5))
 df.B - data.frame(Year=1998:2002, myvar.B=rnorm(5))
 merge(df.A, df.B, all=L)
Error in merge.data.frame(df.A, df.B, all = L) : object L not found
 merge(df.A, df.B, all=T)
  Yearmyvar.Amyvar.B
1 1998 NA -1.8179560
2 1999 NA  0.6300986
3 2000  0.5855288 -0.2761841
4 2001  0.7094660 -0.2841597
5 2002 -0.1093033 -0.9193220
6 2003 -0.4534972 NA
7 2004  0.6058875 NA


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

2008-07-25 Thread Roland Rau

Hi,

what about:

mydata - c(1,2,3,NA, Inf, -Inf, NaN, 5, 6, 7)
mydata2 - ifelse(is.na(mydata) | is.infinite(mydata),
   0, mydata)

mydata
mydata2

nmarti wrote:

I know I can use x - na.omit(x), and other forms of this, to get rid of
some of these errors.  


I know what you mean, I think, but I would not call it errors. Rather, 
it is following a standard specification.

Check
?is.finite

for further information (and the links therein).

Hope this helps,
Roland

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

2008-07-22 Thread Roland Rau

Hi,

rlearner309 wrote:

I have a question about how to filter the data frame:
Suppose my data frame has variables like gender, age,... How to get a subset
of the data frame, with only female (or male) and/or age  50...?  What is
the typical syntax?  I tried several condition expressions, but none of them
worked...

Thanks a lot!


I guess the other people answered the question already.
But may I ask if your background is in SPSS?
I just had this impression talking about 'filter' and the unique way of 
using 'syntax'.


Best,
Roland

P.S. The first statistical software I used was SPSS and I would have 
asked in exactly the same way when I started using R. :-)


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Problem with TLC/TK on Ubuntu

2008-07-18 Thread Roland Rau

Hi Davide,

did you check the R Installation and Administration Manual?
In Section A.2.1 you will find some more information.

Make sure that you have the 'dev' packages installed of tcl8.x and tk8.x.

If you don't know where 'tclConfig.sh' and 'tkConfig.sh' are located, 
just find them:

locate tclConfig.sh
locate tkConfig.sh

now you will know the path to those two files.
All you need to do now is (in the correct directory of course):
./configure --with-tcl-config=/my/path/to/tclConfig.sh
--with-tk-config=/my/path/to/tkConfig.sh
make
etc.

I hope this helps,
Roland







Davide Massidda wrote:

Dear all,
I have installed R on Linux/Ubuntu 8.04. When I try to load the tcltk
package, I get the response:


library(tcltk)

Error in firstlib(which.lib.loc, package) :
  Tcl/Tk support is not available on this system
Error in library(tcltk) : . First.lib failed for 'tcltk'

In order to solve this problem, I try to:
1. To download the tcl and the tk packages (version: 8.5) from
http://www.tcl.tk and to install them (the -dev packages also), but the
error hold over.
2. To install the previous releases (version: 8.4) for these packages. The
error hold over.
3. To set the environment variables 'TCL_LIBRARY' and 'TK_LIBRARY', in this
mode:
TCL_LIBRARY=/usr/local/lib/tcl8.5 *  (or 8.4)*
TK_LIBRARY=/usr/lib/tk8.5   *(or 8.4)*
but the error hold over.
4.Therefore, after this modifications, i uninstalled R and I installed again
it. I try to do this both without setting environment variables and setting
it. The error hold over.
I look for a solution.

Thank you

Davide Massidda
*--
QPLab - Quantitative Psychology laboratory
Department of General Psychology
Via Venezia 8 -35131 Padova, Italia*

[[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] smooth.spline

2008-07-18 Thread Roland Rau

Spencer Graves wrote:
I found the first chapter of Paul Dierckx (1993) Curve and Surface 
Fitting with Splines (Oxford U. Pr.).  Beyond that, I've learned a lot 
from the 'fda' package and the two companion volumes by Ramsay and 
Silverman (2006) Functional Data Analysis, 2nd ed. and (2002) Applied 
Functional Data Analysis (both Springer).

If I may add my 2 cents:
Section 2 (B-Splines in a Nutshell) in the article listed below, is in 
my opinion, a good and compact outline of B-Splines.


* Flexible Smoothing with $B$-splines and Penalties
* Paul H. C. Eilers, Brian D. Marx
* Statistical Science, Vol. 11, No. 2 (May, 1996), pp. 89-102

I hope this helps,
Roland

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


Re: [R] First attempt to use R

2008-07-03 Thread Roland Rau

Hi Ted,

hopefully the following information gets you started:

Ted wrote:
What I want to do is extract time series data from a database(say, PostgreSQL 
or MySQL - I routinely use both), analyse it, and put a selection of the 
statistical results into specific tables.


Check the following document: 
http://cran.r-project.org/doc/manuals/R-data.html

The R Data Import/Export Manual. There is a section on Relational Databases.
Please check also the available packages here:
http://cran.wustl.edu/web/packages/index.html (or from any other CRAN 
mirror).
There is, for example, a package called RMySQL which will probably help 
you (but there are also others RODBC, DBI, RSQLite, DBI, ...)

There is even a special interest group for databases (R-SIG-DB).




For example, suppose I have daily values for several variates.  One thing I 
might try is to fit a cubic spline to the data, 
Please check also the listing of available packages (URL given above). 
There seem to be quite a few spline-related packages. Please note that 
there is a function

smooth.spline
included in the packages 'stats' (part of the standard installation of R)


I hope this helps,
Roland

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

2008-06-18 Thread Roland Rau

Hi,

diver495 wrote:

Using Visual Basic I can complete the same script (simple loop of 500
itterations) in 0.1 sec.
Is it realy R not suitable for huge computing.


If you are happy with Visual Basic, then there is no need for you to use R.
In case your message was not a flamebait, it is well known that loops 
like these are often bottlenecks for R.


There are many resources how to easily avoid them. See, for example, S 
Programming by Venables and Ripley or John Chambers' book: Programming 
with data.
Even searching the mail archive for subject like avoid loops might be 
helpful.

You might also consider checking functions like apply, tapply, ...

Best,
Roland

P.S.
It seems there is also a good book available for scientific computing 
with Visual Basic:

http://www.ibiblio.org/Dave/Dr-Fun/df22/df2210.jpg

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

2008-06-16 Thread Roland Rau

Hi,

did you have a look at the manual An Introduction to R? 
(http://cran.r-project.org/doc/manuals/R-intro.html).
Chapter Statistical Models in R should answer (most of) your questions 
concerning linear regression.


kayj wrote:


Also each x is a categorical variable with 4 categories so I have to
introduce  three variables for each x 



If I understood correctly what you mean (- coding of dummy variables), 
this is not necessary in R. If you variable is a factor, R does it for 
you automatically. If you are unhappy with the choice of reference 
category,  please check:

?relevel

I hope this helps,
Roland

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

2008-06-06 Thread Roland Rau

Dear all,

a related follow up -- with the hope for some feedback from the specialists.
Is the following general advice justified:
=
If one has not more than 4GB RAM and one wants to run primarily R on 
one's Linux machine, it is a good idea to install the 32bit version of 
the operating system.

The reasons are:
The machine has 4GB RAM which implies that the 32bit version can 
(theoretically) use the whole available memory address space. The 
advantage of addressing more memory using 64bit is in this instance of a 
4GB computer lost. Furthermore, 64bit often runs slower than 32bit (see 
Section 8 of R Admin Manual) due to the larger pointer size.

=

Thanks,
Roland


steven wilson wrote:

Dear all;

I'm planning to install Linux on my computer to run R (I'm bored of
W..XP). However, I haven't used Linux before and I would appreciate,
if possible, suggestions/comments about what could be the best option
install, say Fedora, Ubuntu or OpenSuse which to my impression are the
most popular ones (at least on the R-help lists). The computer is a PC
desktop with 4GB RAM and  Intel Quad-Core Xeon processor and will be
used only to run R.

Thanks
Steven



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

2008-05-30 Thread Roland Rau

Hi Carlos,

Carlos López wrote:
I´m trying to find datasets that will give me residuals, after applying 
the lm function, with no normality, non linearity, and heteroscedacity 
so I can try to exemplify
those cases in the linear regression model. Can you give any advice on 
what datasets would be appropiate? I can´t use the ones in the alr3 
package because those have

already been seen in class.

Thank you very much :-)
natorro



if you don't want to simulate your own data, you might have a look at 
the NIST Reference Datasets

http://www.itl.nist.gov/div898/strd/

I hope this help?
Roland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 do you exit a function in R?

2008-05-29 Thread Roland Rau

Hi

Bill Cunliffe wrote:

For example, based on a certain condition, I may want to exit my code early:

 


# Are there the same number of assets in prices and
positions?

if (nAssetPositions != nAssetPrices) {

cat(Different number of assets! \n\n)

exit function

}

I think the easiest thing to use is the 'stopifnot()' function.
afunction - function(myinput) {
stopifnot(is.numeric(myinput))
return(myinput * 2)
}

Alternatively, you can also do:

afunction2 - function(myinput) {
if (!is.numeric(myinput)) stop(Input not numeric)
return(myinput * 2)
}

 afunction(roland)
Error: is.numeric(myinput) is not TRUE
 afunction2(roland)
Error in afunction2(roland) : Input not numeric
 afunction2(123)
[1] 246
 afunction(123)
[1] 246



I hope this helps,
Roland

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

2008-05-29 Thread Roland Rau

Carlos López wrote:
I´m trying to find datasets that will give me residuals, after applying 
the lm function, with no normality, non linearity, and heteroscedacity 
so I can try to exemplify
those cases in the linear regression model. Can you give any advice on 
what datasets would be appropiate? I can´t use the ones in the alr3 
package because those have

already been seen in class.

Thank you very much :-)
natorro

if you know what you are looking for (or not looking for), wouldn't it 
be the easiest and fastest thing to do to simulate such a dataset yourself?


Best,
Roland

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


Re: [R] lm() function

2008-05-29 Thread Roland Rau

Hi,

Cleber Nogueira Borges wrote:

hanen wrote:

hi,
my linear model is y=c+a*x1+b*x2 i tried to found a, c, b by the use of:
mymodel-lm(y~1+x1+x2) where y, x1, x2 are 3 vectors with the same length
the result is a=NA.so i want to know where is the problem.
  


It's the sum of x1 and x2 equal to one?
run the command:  round( sum(  c(x1,x2) ),12)==1


may I ask how this may solve the problem?
You concatenate the two vectors x1, x2; calculate the sum of it; round 
it to 12 digits; and then check whether it is equal to 1.


Roland

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

2008-05-25 Thread Roland Rau

Hi Wade,

Wade Wall wrote:

Hi all,

I don't know if this is the proper place to ask this, but I am trying to
configure emacs/ess on Ubuntu 8.04 to run the way described for ESS and


I think the easiest way to install emacs/ess on Ubuntu 8.04 is via the 
repositories.
Simply use your favorite package manager (I use synaptic) and choose the 
ess package. If Emacs hasn't been installed yet, it will do so 
automatically.


I hope this helps,
Roland

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

2008-05-25 Thread Roland Rau

Hi Wade,

Wade Wall wrote:
I first installed through the package manager, but was unable to start R 
without opening a script file.  So I installed from the tarball, but am 
still unable to open R using any commands;  ESS loads into a buffer; but 
I can't use M-x-R to open R.   the only way I can open R is to open a 


are you sure R is installed?


script file first.  Maybe my question is, how do I create a new script 
file, type some commands, open R, and run script from the file?


this is a simple session which should work to create a new script file, 
typing some commands, opening R and run the whole content from the 
buffer in R. Please note that there might be a message like Cannot read 
history file /your/file/path

C refers to the CTRL key and M to the Meta key (- ALT)

C-x C-f myscript.r
rnorm(100)
C-x 2
C-x o
M-x R
C-x o
C-c M-b



I hope this helps you further,
Roland

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

2008-05-24 Thread Roland Rau

Hi,

Antony Unwin wrote:
R has spread far and wide with great success.  It is not only used  
extensively in universities, but also apparently in governmental  
organisations and in industry.  As the recent discussion of R's Pros  
and Cons shows, there are many reasons for this.  It would be  
interesting to know just how widely R is used, where it is used most  
(and where least or not at all).  Does anyone have a good overview?


I don't really have a good overview, but the following page might give 
some indication where people are using R:

http://www.r-project.org/foundation/memberlist.html


Hope this helps a bit,
Roland

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

2008-05-23 Thread Roland Rau

Monica Pisica wrote:

- You can save scripts, but not *.exe.


If you want to contrast R with statistical packages like SPSS or Stata 
(and if your audience has rather a background in those than in general 
purpose languages), I think this is not really a problem unless I missed 
something recently about the capabilities of SPSS or Stata.


Best,
Roland

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

2008-05-14 Thread Roland Rau

Dear all,

I have several datasets and I want to generate pdf plots from them.
I also want to generate automatically the names of the files. They are 
country-specific and the element mycurrentdata[1,1] contains this 
information.


So what I do is something like this:
pdf(file=paste(mycurrentdata[1,1], .pdf, sep=), width=...etc)

The only problem I have is that some of the country names contain white 
space (e.g., United Kingdom). This is no problem for generating the 
pdf plots but it may become problematic during further processing (e.g. 
incl. the plots in LaTeX documents).


Is there an easy function to strip white space out of character strings 
(similar to the strip.white=TRUE option in read.table/scan)?


I'd appreciate any kind of help and I hope I did not miss anything 
completely obvious.


Thanks,
Roland

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

2008-05-14 Thread Roland Rau

Dear all,

I would like to say thanks for the help of Mark Leeds (off-list), 
Jeremiah Rounds (off-list), and Jim Holtman.


I will use the solution Mark and Jim provided using the gsub function.
A bit embarrassing for me that I did not remember the function since I 
used it myself awhile ago.


I am still impressed with the R community: three good answers in less 
than one hour.
What is the average time for support staff of proprietary (statistical) 
software providers to respond to user questions (and how much does it cost)?


Thanks again,
Roland


jim holtman wrote:
It depends on what you mean by striping the white space.  Here is an 
example of how it might be done:
 
  x - c(United Kingdom, Europe, United States, a   
longer string)

  gsub( +, _, x)
[1] United_Kingdom  Europe  United_States   a_longer_string
 


On Wed, May 14, 2008 at 12:06 PM, Roland Rau [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Dear all,

I have several datasets and I want to generate pdf plots from them.
I also want to generate automatically the names of the files. They
are country-specific and the element mycurrentdata[1,1] contains
this information.

So what I do is something like this:
pdf(file=paste(mycurrentdata[1,1], .pdf, sep=), width=...etc)

The only problem I have is that some of the country names contain
white space (e.g., United Kingdom). This is no problem for
generating the pdf plots but it may become problematic during
further processing (e.g. incl. the plots in LaTeX documents).

Is there an easy function to strip white space out of character
strings (similar to the strip.white=TRUE option in read.table/scan)?

I'd appreciate any kind of help and I hope I did not miss anything
completely obvious.

Thanks,
Roland

__
R-help@r-project.org mailto:R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
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 you are trying to solve?


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


Re: [R] what kind of residuals are the ones calculated in coxph?

2008-05-13 Thread Roland Rau

Hi Karen,

those are martingale residuals.

You don't have to be a Guru to find it out.
Did you check
?coxph
Under values it tells you
an object of class coxph. See coxph.object for details.
So you can ask for help for coxph.object
?coxph.object

and then you will see among the components:
residuals
the martingale residuals.

I hope this helps,
Roland




Chang Liu wrote:

Hi Gurus:
 
In the coxph() objects in Survival package, there is an attribute called residuals. Usually, there are several kinds for censored survival data. I can't seem to find in the documentation as to which one this is calculating. Anyone knows?
 
Karen

_


[[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] basehaz and newdata

2008-04-07 Thread Roland Rau
Hi,

just looked at it briefly and I don't know if it is the real cause for 
your problems. But 'data' as well as 'newdata' require a data.frame and 
not a list as input.

Does this help?

Best,
Roland


mah wrote:
 I am unable to get the basehaz function to apply a proportional
 hazards model to a new data frame.  I replicated my specific situation
 with the example for coxph in the help, where I changed the x value of
 the first record from 0 to 1.  Is there something incorrect in the
 syntax that I am using?  Thanks in advance!
 
 test1 - list(time=  c(4, 3,1,1,2,2,3),
   status=c(1,NA,1,0,1,1,0),
   x= c(0, 2,1,1,1,0,0),
   sex=   c(0, 0,0,0,1,1,1))
 test2 - list(time=  c(4, 3,1,1,2,2,3),
   status=c(1,NA,1,0,1,1,0),
   x= c(1, 2,1,1,1,0,0),
   sex=   c(0, 0,0,0,1,1,1))
 f1 - coxph( Surv(time, status) ~ x + strata(sex), data=test1)
 #stratified model
 f2 - coxph( Surv(time, status) ~ x + strata(sex), data=test2)
 #stratified model
  f1
 Call:
 coxph(formula = Surv(time, status) ~ x + strata(sex), data = test1)
 
 
   coef exp(coef) se(coef) zp
 x 1.17  3.22 1.29 0.907 0.36
 
 Likelihood ratio test=0.87  on 1 df, p=0.351  n=6 (1 observation
 deleted due to missingness)
 f2
 Call:
 coxph(formula = Surv(time, status) ~ x + strata(sex), data = test2)
 
 
coef exp(coef) se(coef)zp
 x 0.896  2.45 1.42 0.63 0.53
 
 Likelihood ratio test=0.38  on 1 df, p=0.535  n=6 (1 observation
 deleted due to missingness)
 basehaz(f1, newdata=test2)
 Error in basehaz(f1, newdata = test2) :
   unused argument(s) (newdata = list(time = c(4, 3, 1, 1, 2, 2, 3),
 status = c(1, NA, 1, 0, 1, 1, 0), x = c(1, 2, 1, 1, 1, 0, 0), sex =
 c(0, 0, 0, 0, 1, 1, 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.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Beginner help with retrieving frequency and transforming a matrix

2008-03-28 Thread Roland Rau
Hi Sean,

is this roughly what you are looking for (please note that in the 
example data you provided there is only one level of ID given, no S-4, 
...) ?

  DF
 ID  Cl Co  BrdInd A AB AB.1 frq
1  S-3 IND  A BR_F BR_F01 1  00 1.0
2  S-3 IND  A BR_F BR_F01 1  00 1.0
3  S-3 IND  A BR_F BR_F01 1  00 1.0
4  S-3 IND  A BR_F BR_F01 1  00 1.0
5  S-3 IND  A BR_F BR_F01 1  00 1.0
6  S-3 IND  A BR_F BR_F01 0  10 0.5
7  S-3 IND  A BR_F BR_F02 0  01 0.0
8  S-3 IND  A BR_F BR_F02 0  10 0.5
9  S-3 IND  A BR_F BR_F02 1  00 1.0
10 S-3 IND  A BR_F BR_F02 1  00 1.0
11 S-3 IND  A BR_F BR_F02 0  10 0.5
12 S-3 IND  A BR_F BR_F02 1  00 1.0
  DF2 - aggregate(x=DF$frq, by=list(ID=DF$ID, Ind=DF$Ind), FUN=mean)
  DF2
IDInd x
1 S-3 BR_F01 0.917
2 S-3 BR_F02 0.667
  FinalDF - tapply(X=DF$frq, INDEX=list(Ind=DF$Ind, ID=DF$ID), FUN=mean)
  FinalDF
 ID
IndS-3
   BR_F01 0.917
   BR_F02 0.667
 

Best,
Roland


Sean MacEachern wrote:
 Hi All,
 
 Just hoping some one can give me a hand with a problem...
 
 I have a dataframe (DF) with about 5 million entries that looks something
 like the following:
 
 DF
 ID  Cl Co  BrdInd A AB  AB
 1  S-3 IND  A BR_F BR_F01 1  0   0
 2  S-3 IND  A BR_F BR_F01 1  0   0
 3  S-3 IND  A BR_F BR_F01 1  0   0
 4  S-3 IND  A BR_F BR_F01 1  0   0
 5  S-3 IND  A BR_F BR_F01 1  0   0
 6  S-3 IND  A BR_F BR_F01 0  1   0
 7  S-3 IND  A BR_F BR_F02 0  0   1
 8  S-3 IND  A BR_F BR_F02 0  1   0
 9  S-3 IND  A BR_F BR_F02 1  0   0
 10 S-3 IND  A BR_F BR_F02 1  0   0
 11 S-3 IND  A BR_F BR_F02 1  0   0
 12 S-3 IND  A BR_F BR_F02 1  0   0
 
 I am interested in retrieving the frequency of A for everything with the
 same Ind code.
 
 I have initially created a column called 'frq' that calculates the
 individual A frequency
 
 
 DF$frq=apply(DF,1,function(x) if(x[6]==1)1 else if (x[7]==1)0.5 else 0)
 
 DF
 
 ID  Cl Co  BrdInd A AB  AB  frq
 1  S-3 IND  A BR_F BR_F01 1  0   0   1
 2  S-3 IND  A BR_F BR_F01 1  0   0   1
 3  S-3 IND  A BR_F BR_F01 1  0   0   1
 4  S-3 IND  A BR_F BR_F01 1  0   0   1
 5  S-3 IND  A BR_F BR_F01 1  0   0   1
 6  S-3 IND  A BR_F BR_F01 0  1   0  0.5
 7  S-3 IND  A BR_F BR_F02 0  0   1   0
 8  S-3 IND  A BR_F BR_F02 0  1   0  0.5
 9  S-3 IND  A BR_F BR_F02 1  0   0   1
 10 S-3 IND  A BR_F BR_F02 1  0   0   1
 11 S-3 IND  A BR_F BR_F02 0  1   0  0.5
 12 S-3 IND  A BR_F BR_F02 1  0   0   1
 
 I've created a new DF that contains the info I'm interested in:
 
 DF2 = cbind(DF[1],DF[5],DF[9])
 
 DF2
 
 IDInd frq
 1  S-3 BR_F01 1 
 2  S-3 BR_F01 1 
 ...
 ...
 ...
 11 S-3 BR_F02 0.5
 12 S-3 BR_F02 1 
 
 
 I am wondering is there a method that I can call to calculate the frequency
 of A or frq for all individuals with the same Ind code so the DF (matrix)
 looks something like the following? (I've saw something in a tut based on
 t-tests that I thought would work, but no joy...)
 
 
 NewDF
 
 IDInd frq
 1  S-3 BR_F01 0.9167
 2  S-3 BR_F02 0.6667
  
 
 Further, is there to then transform the matrix to look something like the
 following?
 
 
 FinalDF
 
 Ind   S-3  S-4  S-5 S-100
 BR_F01 0.9167  0.5   1 0.6667
 BR_F02 0.6667  0.2   1 0.5
 ...
 ...
 ...
 BR_Z98   0.51   0.3 1
 BR_Z9910.6   1 0.5
 
 
 
 Thanks in advance for any help you can offer, and please let me know if
 there is any further information I can provide.
 
 Sean
 
 
 sessionInfo()
 R version 2.6.0 (2007-10-03)
 i386-apple-darwin8.10.1
 
 locale:
 en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
 
 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Dimensions of a List

2008-03-25 Thread Roland Rau
Hi,

Shubha Vishwanath Karanth wrote:
 l=list(list(c(1,2),c(4,5),c(6,7)),list(c(11,22,33),c(44,55,66)))
 
 How do I know the dimensions of this list?... In other words, how many
 sub-lists, sub-sub-lists etc...are there in l? How do I know this?
 
  

  l=list(list(c(1,2),c(4,5),c(6,7)),list(c(11,22,33),c(44,55,66)))
  str(l)
List of 2
  $ :List of 3
   ..$ : num [1:2] 1 2
   ..$ : num [1:2] 4 5
   ..$ : num [1:2] 6 7
  $ :List of 2
   ..$ : num [1:3] 11 22 33
   ..$ : num [1:3] 44 55 66


I hope this is what you were looking for?

Best,
Roland

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

2008-03-04 Thread Roland Rau
Hi,

Erika Frigo wrote:
 Good evening to everybody,
 I have  problems to import in R a really big dataset (more than 100 
 values). Which is the best package to install?
 Is there someone who works with this kind of dataset and can help me, please?
 
Maybe the package SQLiteDF could be useful for you. 
http://cran.r-project.org/web/packages/SQLiteDF/index.html

But since you mention that the data has 1 mio values, I think it should 
be no problem to read the data set conventionally.
  (object.size(rnorm(1e06)))/(1024^2)
[1] 7.629417

Assuming that all data are numeric, the data-set should consume less 
than 8MB.

I hope this helps,
Roland

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

2008-03-04 Thread Roland Rau
Hi Maura,

Maura E Monville wrote:
 I tried to install ade4TKGUI but it failed maybe because I did not
 install Tcl/Tk on my Linux/SuSE ???
 
 * Installing *source* package 'ade4TkGUI' ...
 ** R
 ** inst
 ** preparing package for lazy loading
 Loading required package: ade4
 
 Attaching package: 'ade4'
 
 
 The following object(s) are masked from package:base :
 
  within
 
 Loading required package: tcltk
 Error in firstlib(which.lib.loc, package) :
   Tcl/Tk support is not available on this system
 Error: package 'tcltk' could not be loaded


I recently had a similar problem on my computer. I don't know whether 
you installed R from source code yourself or used some pre-compiled 
package for SuSE. One potential reason for your error might be that 
tcltk has not been installed.
Please check Section A.2.1 of the R Installation and Administration 
Manual. It helped me in this case (add configuration options, e.g. 
--with-tcltk).

I hope this helps,
Roland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 read HUGE data sets?

2008-02-28 Thread Roland Rau
Hi,

Jorge Iván Vélez wrote:
 Dear R-list,
 
 Does somebody know how can I read a HUGE data set using R? It is a hapmap
 data set (txt format) which is around 4GB. After read it, I need to delete
 some specific rows and columns. I'm running R 2.6.2 patched over XP SP2

in such a case, I would recommend not to use R in the beginning. Try to 
use awk[1] to cut out the correct rows and columns. If the resulting 
data are still very large, I would suggest to read it into a Database 
System. My experience is limited in that respect: I only used SQLite. 
But in conjunction with the RSQLite package, I was managed all my big 
data problems.

Check http://www.ibm.com/developerworks/library/l-awk1.html to get you 
smoothly started with awk.

I hope this helps,
Roland

[1] I think the gawk implementation offers most options (e.g. for 
timing) but I recently used mawk on Windows XP and it was way faster (or 
was it nawk?). If you don't have experience in some language such as 
perl, I'd say it is much easier to learn awk than perl.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Drawing several pictures on a plot

2008-02-22 Thread Roland Rau
Hi Marcin,

in addition to Greg Snow's answer, you may also check the Introduction 
to R Manual, especially Section 12.5. In subsection 12.5.3 (in the PDF 
version), there is also a graphical example of the margins.
http://cran.r-project.org/doc/manuals/R-intro.pdf

Mam nadzieje, ze to pomoze.

Do widzenia,
Roland


Marcin Kozak wrote:
 Hi,
 
 I want to draw several pictures on one plot and do as follows:
 
 xy-matrix(rnorm(100,100,10),50)
 op - par(mfrow = c(2, 2), pty = s)
 plot(xy,ann=F);plot(xy,ann=F);plot(xy,ann=F);plot(xy,ann=F)
 par(op)
 
 What I need now is to set the size of the pictures within this plot
 since there is too much free space among the pictures, making the plot
 look not that pretty. How can I do that?

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

2008-02-21 Thread Roland Rau
Hi,

the package 'survival' provides the possibility to estimate Cox PH 
models with a frailty term.
library(survival)
?frailty

If this is not what you are looking for, there is also a package called 
'frailtypack'. But I have no experience with that.

I hope this helps.

Best,
Roland

P.S. Bocconi and survival analysis? Sounds like you work together with 
(or take a course from) Francesco Billari. If this is the case, please 
say hello to him from me.

[EMAIL PROTECTED] wrote:
 Dear R-help,
 I am trying to estimate a Cox model with nested effects, or better
 
 h(t,v,w)=v*w*h0(t)*exp(B'x)
 
 where h(t,v,w) is the individual hazard function
w and v are both frailty terms (gamma or normal distributed)
 I have 12 clusters and for each one of them I would like to associate a 
 realization of v, while w is a random effect for the whole population. 
 At the population level I should integrate out both the frailty 
 distributions.
 This type of model is usually called nested frailty model.
 I would like to know if there is a package which could allow me to 
 estimate it.
 
 Thank you very much indeed
 Silvia
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] coloring a graph left or right of an abline

2008-02-21 Thread Roland Rau
Hi Georg,

Georg Ehret wrote:
 Dear R community,
I would wish to color the background of my histogram differently to the
 left and right of an abline... Can you please help?

maybe not very elegant or beautiful, but I hope it will get you started:

### Start of Code Example
n - 1000
myxlims - c(-3,3)
myylims - c(0,0.6)
mydata - rnorm(n)
marker - 1
hist(mydata, breaks=50, xlim=myxlims, ylim=myylims, freq=FALSE)
rect(xleft=myxlims[1], xright=marker, ybottom=0, ytop=max(myylims),
  col=red, border=FALSE)
rect(xleft=marker, xright=myxlims[2], ybottom=0, ytop=max(myylims),
  col=blue, border=FALSE)
hist(mydata, breaks=50, xlim=myxlims, ylim=myylims, col=green,
  freq=FALSE, add=TRUE)
abline(v=marker, col=black, lwd=3, lty=1)
### End of Code Example

Best,
Roland


 
 Thankin you,
 Georg.
 
 
 Georg Ehret
 JHU
 Baltimore - USA
 
   [[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] Compare mean survival time

2008-02-19 Thread Roland Rau
Hi,

Xing Yuan wrote:
 Dear List,
 
 Does anybody no how to compare mean survival times for two (more) groups in
 R? What test statistics should I use?


my answer is less of an R answer than a literature answer:
John P. Klein and Melvin L. Moeschberger devote section 4.5 in their 
book Survival Analysis (Springer, starting on page 117 in the 2nd 
edition) to the topic: Point and Interval Estimates of the Mean and 
Median Survival Time.

I hope this helps,
Roland

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

2008-02-19 Thread Roland Rau
Hi,

Marc Bernard wrote:
 Dear all,

   I am looking for a good reference on Survival analysis. I am looking for 
 a booking containing both applications and Maths. Explaining different 
 methods in survival analysis 

since I just answered in another thread with a book recommendation on 
survival analysis, the only book I ever bought myself on survival 
analysis is:
Klein/Moeschberger: Survival Analysis (Springer)
It has lots of applications and maths as you are mentioning that this 
is what you are looking for.
Two classic books which are often cited:
a) Cox/Oates: Analysis of Survival Data
b) Kalbfleisch/Prentice: The Statistical Analysis of Failure Time Data

In the other thread, Ben Bolker suggested the book by Therneau and 
Grambsch. Unfortunately, I have no experience with that one. Please note 
that Terry Therneau wrote the original version of the survival package in S.

I also borrowed the book Survival Analysis Using S. Analysis of 
Time-to-Event Data. This is a book which focuses on how to implement 
various methods from survival analysis in S. This is certainly useful 
but I checked usually the theory in Klein/Moeschberger. The 
implementation of standard methods was easily found in the documentation 
of the survival package (big thanks to Terry Therneau and Thomas Lumley!)

I hope this helps,
Roland

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

2008-02-19 Thread Roland Rau
Hi Kathy,

maybe this article could be also of use for you?
Ihaka, R., and Gentleman, R. (1996), R: A Language for Data Analysis 
and Graphics, The Journal of Computational and Graphical Statistics, 5, 
299-314

Best,
Roland


Kathy Gerber wrote:
 Earlier today I sent a question to Frank Harrell as an R developer with 
 whom I am most familiar.  He suggested also that I put my questions to 
 the list for additional responses.  Next month I'll be giving a talk on 
 R as an example of high quality open source software.  I think there is 
 much to learn from R as a high quality extensible product that (at least 
 as far as I can tell) has never been spun or hyped like so many open 
 source fads.
 
 The question that intrigues me the most is why is R as an open source 
 project is so incredibly successful and other projects, say for example, 
 Octave don't enjoy that level of success?
 
 I have some ideas of course, but I would really like to know your 
 thoughts when you look at R from such a vantage point.
 
 Thanks.
 Kathy Gerber
 University of Virginia
 ITC - Research Computing Support
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] writing a simple function

2008-02-13 Thread Roland Rau
Hi,
mohamed nur anisah wrote:
 Dear lists,

   any suggestion on how to write a function to return a TRUE if interval 
 [a,b] overlaps the interval [c,d]. I've tried it but an error occur saying 
 that 'could not find function v ; in addition warning message occur'. Below 
 is my codes.Please help me sort this problem as i'm in process of learning of 
 writing a function. Many thanks


does this do what you want?

overlap - function(a,b,c,d) {
all(c:d %in% a:b)
}
overlap(1,5,3,4)
overlap(1,2,3,4)


Best,
Roland



   overlap-function(m,n){
 t=length(m)
 v=length(n)
 tt=logical(t)
 tv=logical(v)
  for(i in 1:m){
   for(i in 1:n){
   if(v(i,j)=t(i,j)){
  tt=T
  tv=T
}
   }
  }
 k=c(tt,tv)
 return(k)
 }

   Regards,
   Anisah
 

 -
 
   [[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] writing a simple function

2008-02-13 Thread Roland Rau
Hi,

Ben Bolker wrote:
 Roland Rau roland.rproject at gmail.com writes:
 
 does this do what you want?

 overlap - function(a,b,c,d) {
  all(c:d %in% a:b)
 }
 overlap(1,5,3,4)
 overlap(1,2,3,4)
 
   Do you really want this to be discrete?  How about
 
 overlap - function(a,b,c,d) {
ac  bd
 }
you are absolutely right.[1]
I assume with discrete you mean integers?
I think the bigger problem with my function is that it makes way too 
many comparisons than are actually necessary (memory and time problems).

What about the following function:
overlap - function(intval1, intval2) {
   (min(intval1)  min(intval2))  (max(intval1)  max(intval2))
}

Best,
Roland

[1] I realized the problems with my solution almost as soon as I sent 
the email. But I was on a way to a meeting and there was no more time to 
correct it at that moment.

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

2008-02-11 Thread Roland Rau
Hi,

I think using Emacs+ESS [1,2] is always a good starting point for a 
clear layout with consistent and meaningful indentation.

I don't know how other people think about it, but in my opinion, 
Elements of Programming Style by Kernighan and Plauger is still an 
interesting read -- although their programs are either Fortran or PL/1 
and the book itself is 30 years or old. Of course, I am not always 
successful but at least I try to incorporate their 'mantras':
- write clearly, don't be too clever [3]
- say what you mean, simply and directly
- use library functions
- write clearly -- don't sacrifice clarity for efficiency
- let the machine do the dirty work
- parenthesize to avoid ambiguity
- 10.0 times 0.1 is hardly ever 1.0
- ...

I hope this helps?

Best,
Roland


[1] http://www.gnu.org/software/emacs/
[2] http://ess.r-project.org/
[3] I guess this is what Kernighan meant in his famous(?) quote: 
Everyone knows that debugging is twice as hard as writing a program in 
the first place. So if you're as clever as you can be when you write it, 
how will you ever debug it? 
(http://en.wikiquote.org/wiki/Brian_W._Kernighan )






David Scott wrote:
 I am aware of one (unofficial) guide to style for R programming:
 http://www1.maths.lth.se/help/R/RCC/
 from Henrik Bengtsson.
 
 Can anyone provide further pointers to good style?
 
 Views on Bengtsson's ideas would interest me as well.
 
 David Scott
 
 
 
 _
 David Scott   Department of Statistics, Tamaki Campus
   The University of Auckland, PB 92019
   Auckland 1142,NEW ZEALAND
 Phone: +64 9 373 7599 ext 86830   Fax: +64 9 373 7000
 Email:[EMAIL PROTECTED]
 
 Graduate Officer, Department of Statistics
 Director of Consulting, Department of Statistics
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] R programming style

2008-02-11 Thread Roland Rau
Hi,

Earl F. Glynn wrote:
 Instead of using 1 or 2 in an apply, I'll write something like this 
 trying for some sort of mnemonic
 
 apply(x, BY.ROW-1, sum)
 or
 apply(z, BY.COL-2, mean)
 
It think it makes sense to use those magic numbers in the given case.
Please let me give you several arguments:

- In such a setting, I'd probably also use more mnemonic functions:
rowMeans
rowSums
colMeans
colSums

- The numbering of the MARGINs (the name of the second argument) is what 
I remember from maths: 1 is for rows, 2 index is for columns, ... So I 
don't think the numbering is counter-intuitive. For sure, you have to 
check the help page at least once. But this is also the case for using 
mnemonic arguments.

- The first argument in apply() is an array which is not restricted to 
two dimensions. For example, if you are working with three dimension, 
how would you specify it? BY.LAYER? Maybe, but then four dimensions or 
five dimensions?[1]

Please don't consider this as a personal criticism. I am sure that 
users' criticism improves R. But using mnemonics instead of the margins 
in the apply() case is not a convincing example, I think. Maybe you have 
another example?

Best,
Roland

[1] If you are curious whether there practical applications of four- or 
fivedimensional arrays, I can write to you off-list how useful they were 
in real world projects.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] [OT] emacs / xemacs for unix without compile

2008-01-31 Thread Roland Rau
Hi,

Wensui Liu wrote:
 Dear All,
 Is there a emacs/xemacs for unix without compiling it? If it is
 possible, I prefer something that I can use immediately after putting
 it on the unix server.
 Is it possible or am I too stupid to ask this kind of question?
 
 Thanks for your insight!
 

I guess you might get more answers to your questions if you ask them on 
some different forum, e.g. one of the usenet newsgroups such comp.emacs
It might be also helpful to specify what you mean by unix.
But judging by 
http://upload.wikimedia.org/wikipedia/en/1/11/Unix-history.svg having 
emacs on any of these unix systems should be possible. Well, even Minix 
3 says to have emacs included (http://www.minix3.org/software/).

HTH,
Roland

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

2008-01-31 Thread Roland Rau
Dear all,

is there a possibility to display pictures (jpegs, pngs, ...)  in R?

Maybe the following (hypothetical) code makes it clearer what I have in
mind:

plot(x=0:100, y=0:100, type=n)
rect(xleft=25, xright=75, ybottom=30, ytop=95, fill=apicture.png)

Thank you,
Roland

[[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] display pictures

2008-01-31 Thread Roland Rau
Dear all,

thank you very much for your fast help (via list and also off-list to me).
Once again: the R community rocks!
Fast and absolutely helpful advice.

Thank you all,
Roland

On Jan 31, 2008 7:30 PM, Gabor Grothendieck [EMAIL PROTECTED] wrote:

 See:


 http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:translucency

 On Jan 31, 2008 7:17 PM, Roland Rau [EMAIL PROTECTED] wrote:
  Dear all,
 
  is there a possibility to display pictures (jpegs, pngs, ...)  in R?
 
  Maybe the following (hypothetical) code makes it clearer what I have in
  mind:
 
  plot(x=0:100, y=0:100, type=n)
  rect(xleft=25, xright=75, ybottom=30, ytop=95, fill=apicture.png)
 
  Thank you,
  Roland
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


[[alternative HTML version deleted]]

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


Re: [R] Integer vs numeric

2008-01-28 Thread Roland Rau
Christophe Genolini wrote:
 Hi the list.
 
 I do not understand the philosophy behind numeric and integer.
  - 1 is numeric (which I find surprising)
  - 2 is numeric.
  - 1:2 is integer.
 Why is that ?
 
I hope I can answer your question at least partly:
Numeric means double, i.e. internally stored as a double precision 
floating point number. As far as I know this is the default.
You can, however, force an object to be, e.g. an integer, a single 
prevision float or a double precision float.
as.integer(12)
as.single(12)
as.double(12)

So far I only needed this if I wanted to call some C or Fortran code.
Maybe there are other applications when you need to force the type?

I hope this helps at least a bit further?

Roland

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

2008-01-25 Thread Roland Rau
Hi,

one possibility is to start R in a terminal window by entering
R
then R should be started.
now simply enter:
source(exmaple.r)
and everything should be fine.

Hope this helps,
Roland

Prateek Singh wrote:
 Hi,
 
 I have 'R' code in file. saved it as exmaple.r
 here is the code...
 
 library(hopach)
 GSE - read.table(gene_expression_data,sep=\t,header=TRUE,row.names=TRUE)
 gene.dist - distancematrix(t(GSE),d=euclid)
 gene.hobj - hopach(t(GSE), dmat=gene.dist, mss=med)
 labelstosil(gene.hobj$cluster$label,gene.dist)
 
 
 I dont know how to run it on linux terminal. Can you tell me how to
 execute this file. I am using Debian linux.
 
 Regards,
 Praeek Singh


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Non linear regression with 2 explanatory variables

2008-01-16 Thread Roland Rau
Gavin Simpson wrote:
 hits=-2.6 tests=BAYES_00
 X-USF-Spam-Flag: NO
 
 On Wed, 2008-01-16 at 11:02 +0100, Janice Kielbassa wrote:
 Hello!

 I want to do a non-linear regression with 2 explanatory variables 
 (something like : length ~ a * time * exp( b* temperature)), having a 
 data set (length, time, temperature). Which function could I use (I 
 tried nls but I think it doesn't work)
 
 Janice, I'll start by saying I can't help you as I have never used nls()
 myself and I am not familiar with this type of analysis.
 

maybe it helps if you have a look at Chapter 10 Nonlinear Models by 
Douglas M. Bates and John M. Chambers in: John M. Chambers, Trevor J. 
Hastie (Eds.): Statistical Models in S. Chapman  Hall/CRC , 1992

Best,
Roland

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] things that are difficult/impossible to do in SAS or SPSS but simple in R

2008-01-15 Thread Roland Rau
Hi,

maybe I missed something while using SAS or SPSS. So please make sure 
that I am not talking nonsense here.

- How would you re-use results in SPSS or SAS? If it is possible for SAS 
and SPSS, I am fairly sure it is not as easy as in R:
lmmodel1 - lm(Y~X)
myslope - coef(lmmodel1)[2]
- You have population and death data on the individual level classified 
by year, age, sex, and country. Now you want to calculate the 
probability of dying by year, age, sex, and country.
In R, i would do:
pop.array - tapply(X=popdata$Count,
INDEX=list(Age=popdata$Age,
Year=popdata$Year,
Sex=popdata$Sex,
Country=popdata$Country),
FUN=sum)
dth.array - tapply(X=dthdata$Count,
INDEX=list(Age=dthdata$Age,
Year=dthdata$Year,
Sex=dthdata$Sex,
Country=dthdata$Country),
FUN=sum)
prop.dying.array - dth.array / pop.array

Now you can easily extract a vector of the probability of dying of 85 
year-old men dying in the first year of observation in all countries by 
writing:
prop.dying.array[86,1,1,]
- I hope I am wrong on this one. But when I was using SPSS, I could not 
find any possibility to include left truncated data in survival 
analysis. Maybe I did not find this possibility or maybe it has been 
included since.
- The function outer()
- Data are not always rectangular data frames.


Those are just a few thoughts which came to my mind.
I hope this helps,
Roland



Matthew Keller wrote:
 Hi all,
 
 I'm giving a talk in a few days to a group of psychology faculty and
 grad students re the R statistical language. Most people in my dept.
 use SAS or SPSS. It occurred to me that it would be nice to have a few
 concrete examples of things that are fairly straightforward to do in R
 but that are difficult or impossible to do in SAS or SPSS. However, it
 has been so long since I have used either of those commercial products
 that I am drawing a blank. I've searched the forums and web for a list
 and came up with just Bob Muenchen's comparison of general procedures
 and Patrick Burns' overview of the three. Neither of these give
 concrete examples of statistical problems that are easily solved in R
 but not the commercial packages.
 
 Can anyone more familiar with SAS or SPSS think of some examples of
 problems that they couldn't do in one of those packages but that could
 be done easily in R? Similarly, if there are any examples of the
 converse I would also be interested to know.
 
 Best,
 
 Matt


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] things that are difficult/impossible to do in SAS or SPSS but simple in R

2008-01-15 Thread Roland Rau
Hi Matthew,

something else came to my mind:
why don't you post something similar to the newsgroups:
comp.soft-sys.stat.spss
comp.soft-sys.sas

R-help is obviously biased and maybe there are things we (the R 
community) are just missing. Maybe there are things possible in SPSS or 
SAS which R people are not aware of?

I would be really curious what SPSS or SAS users could give as an 
argument why they prefer their software.

All the best,
Roland


Matthew Keller wrote:
 Hi all,
 
 I'm giving a talk in a few days to a group of psychology faculty and
 grad students re the R statistical language. Most people in my dept.
 use SAS or SPSS. It occurred to me that it would be nice to have a few
 concrete examples of things that are fairly straightforward to do in R
 but that are difficult or impossible to do in SAS or SPSS. However, it
 has been so long since I have used either of those commercial products
 that I am drawing a blank. I've searched the forums and web for a list
 and came up with just Bob Muenchen's comparison of general procedures
 and Patrick Burns' overview of the three. Neither of these give
 concrete examples of statistical problems that are easily solved in R
 but not the commercial packages.
 
 Can anyone more familiar with SAS or SPSS think of some examples of
 problems that they couldn't do in one of those packages but that could
 be done easily in R? Similarly, if there are any examples of the
 converse I would also be interested to know.
 
 Best,
 
 Matt


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

2008-01-09 Thread Roland Rau
Hi,

please have a look at the posting guide (link is at the bottom of your 
message). Most (if not all) of your problems should be solved if you 
follow the advice given there.
Anyway, please have a look below:

[EMAIL PROTECTED] wrote:
  Folks, Two simple questions :
 
 (1) I have a data set (call it data.xls) in a folder in my hard drive. How 
 do I perform a simple regression between two variables from that data set? 
  After I click on 'R', what exactly do I type in?

1.1 getting excel data into R
- please read the manual R Data Import/Export shipped with your R 
distribution or browse online, for example, at 
http://cran.r-project.org/doc/manuals/R-data.html in particular 
http://cran.r-project.org/doc/manuals/R-data.html#Reading-Excel-spreadsheets
- I prefer to use rather CSV files which can be easily read by R using 
read.table()
1.2 simple regression
- function lm() is your friend
- furthermore have a look at An Introduction to R, in particular 
Section 11.2 
http://cran.r-project.org/doc/manuals/R-intro.html#Linear-models

Maybe this code gets you started (not tested, modify according to your 
application):
mydata - read.table(C:\\mypath\\tomyfile\\data.csv, header=TRUE, sep=,)
mymodel1 - lm(mydata$Y ~ mydata$X)
mymodel1
summary(mymodel1)



 
 (2) Where do I get to see the complete library of packages offered by R? 
One possibility is http://stat.ethz.ch/CRAN/src/contrib/PACKAGES.html


 In particular, I am interested in quantile regression and logistic 
 regression.
- There is a package called quantreg written by Roger Koenker.
- Logistic regression: check the function glm()

Hope this helps you to get started,
Roland



 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Result depends on previous result; easy with a loop; but without a loop?

2007-12-14 Thread Roland Rau
Dear all,

I am pretty sure that this has been discussed before. Unfortunately, I 
can not find anything in the archives -- probably because I am 
RSiteSearching for the wrong terms. If I remember correctly, I think I 
even asked this question a few years ago. But I cannot even find this.

The basic problem is that a result depends on a previous result. This is 
easy with a loop--but how can I do this without a loop?

Lets give an example:

initial.matrix - rbind(rep(1,4), matrix(0,ncol=4,nrow=5))
the.other.matrix - matrix(runif(20), ncol=4, nrow=5)

the initial matrix should be filled according to the following 
(pseudo-code) rule:
if (row==1) initial.matrix[1,] - 1
if (row1) initial.matrix[x,] - initial.matrix[x-1,] * 
the.other.matrix[x-1,]

as I said this is easy to do with a loop:
for (i in 2:(nrow(initial.matrix))) {
   initial.matrix[i,] - initial.matrix[i-1,]*the.other.matrix[i-1,]
}
initial.matrix

But how can I do this without a loop?

Thank you already in advance!
Roland

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

2007-12-07 Thread Roland Rau
Hi Jack,

Jack Luo wrote:
 Dear List,
 
 I am trying to modify the xlab and ylab for a current figure that was
 plotted by a package, I searched through the low level plotting command and
 they do not seem to contain how to do this (the only way is to use xlab,
 ylab as arguments in plot command, which I can not do since the plot is
 plotted using some other package, not by my own script). Is there any
 command for doing this? In addition, the package is from CRAN (named Pamr),
 is there any way that I can modify the function used in the package?

I think it would be useful if you are a bit more specific by telling us 
which function you were using.
I assume now that you used
library(pamr)
pamr.geneplot(...)

Is this correct?
If you check the package description, you will see that you are allowed 
to make changes to the software (GPL 2.0).
Now, have a look at
pamr.geneplot

Pretty much in the end, you will find the plotting command. What I did 
now was to basically slightly modify the function by adding two 
arguments for the labels of the x-axis and the y-axis to the function 
definition. As you will see with the provided example, you can make your 
own labels for the x-axis and y-axis now.

I hope this helps,
Roland


pamr.geneplot.modif - function(fit, data, threshold, xlabel=new xlab,
 ylabel=new ylab) {
   # Slightly modified function of pamr.geneplot from package pamr by
   # Trevor Hastie, Robert Tibshirani, Balasubramanian Narasimhan,
   # and Gilbert Chu
   require(pamr)
   par(pch = 1, col = 1)
   geneid - data$geneid
   if (is.null(geneid)) {
 geneid - as.character(1:nrow(data$x))
   }
   if (is.null(fit$newy)) {
 y - factor(data$y[fit$sample.subset])
   }
   else {
 y - factor(fit$newy[fit$sample.subset])
   }
   x - data$x[fit$gene.subset, fit$sample.subset]
   geneid - geneid[fit$gene.subset]
   nc - length(unique(y))
   aa - pamr.predict(fit, x, threshold = threshold, type = nonzero)
   cen - pamr.predict(fit, x, threshold = threshold, type = cen)
   d - (cen - fit$centroid.overall)[aa, ]/fit$sd[aa]
   oo - order(-apply(abs(d), 1, max))
   aa - aa[oo]
   ngenes - length(aa)
   o - order(y)
   xx - x[aa, o]
   geneid - geneid[aa]
   nc - length(unique(y))
   nn - c(0, cumsum(table(y)))
   nrow - trunc(sqrt(ngenes)) + 1
   ncol - trunc(sqrt(ngenes)) + 1
   if (nrow * (ncol - 1) = ngenes) {
 ncol - ncol - 1
   }
   par(mfrow = c(nrow, ncol))
   for (i in 1:ngenes) {
 plot(1:ncol(xx), xx[i, ], type = n, xlab = xlabel,
  ylab = ylabel, axes = FALSE)
 box()
 axis(2)
 for (j in 1:nc) {
   j1 - nn[j] + 1
   j2 - nn[j] + table(y)[j]
   points(j1:j2, xx[i, j1:j2], col = j + 1)
 }
 title(main = as.character(geneid[i]))
 for (j in 1:(nc - 1)) {
   abline(v = cumsum(table(y))[j] + 0.5, lty = 2)
 }
 if (i == 1) {
   h - c(0, table(y))
   for (j in 2:(nc + 1)) {
 text(sum(h[1:(j - 1)]) + 0.5 * h[j], max(xx[i,
 ]), label = 
levels(y)[j - 1], col = j)
   }
 }
   }
   par(mfrow = c(1, 1))
}

library(pamr)
set.seed(120)
x - matrix(rnorm(1000*20),ncol=20)
y - sample(c(1:4),size=20,replace=TRUE)
mydata - list(x=x,y=y)
mytrain -   pamr.train(mydata)
pamr.geneplot.modif(mytrain, mydata, threshold=1.6, xlabel=Hello, 
ylabel=World)

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

2007-12-04 Thread Roland Rau
Hi Tom,

did you check the R for Windows FAQ?

http://cran.r-project.org/bin/windows/base/rw-FAQ.html#Can-I-run-R-from-a-CD-or-USB-drive_003f

Hope this helps,
Roland


Tom Backer Johnsen wrote:
 Recently I came across an interesting web site: 
 http://portableapps.com/.  The idea is simple, this is software that 
 is possible to install and run on some type of USB memory, a stick or 
 one of these hard disks.  I can think of a number of situations where 
 this could be handy.  In addition memory sticks are getting cheaper 
 and more powerful by the day.
 
 So:  Is it possible to run R off one of these sticks?
 
 I am also informed that it is possible to run Latex in this manner.
 
 Tom
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Linux editor for R+LaTeX, but not Emacs

2007-10-05 Thread Roland Rau
Christian Salas wrote:
 I want something like Emacs (of course including auctex and ess), but 
 not Emacs. Something like Tinn-R [http://www.sciviews.org/Tinn-R/] is 
 the best solution, as far as I know for it, unfortunately is only 
 available for Windows.

XEmacs? :-)

If you don't want Emacs, it is probably worth to try vi. I think I read 
somewhere about an R plugin and it should support LaTeX as well.

HTH,
Roland

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