Re: [R] textbox in lattice

2010-06-01 Thread Deepayan Sarkar
On Wed, Jun 2, 2010 at 12:37 AM, baptiste auguie
 wrote:
> Please do read the posting guide, in particular regarding reproducible 
> examples.
>
> You can use a Grid layout to place the lattice plot and a table in the
> same page. For example,
>
> library(lattice)
>  library(coda)
>  library(gridExtra)
>   x <- matrix(runif(2200),ncol=22)
>   m <- as.mcmc(x)
>  p = xyplot(m, layout = c(2, 11))
>
>  pdf(,height=15)
>  arrange(p, tableGrob(as.matrix(summary(iris)), theme=theme.white()),
> heights= unit(c(3,1),"null"))
>  dev.off()

Something like this should also work, except that the grob produced by
tableGrob() doesn't seem to know its height.

splom(iris,
  sub = tableGrob(as.matrix(summary(iris)),
  gp=gpar(cex = 0.5)))

A quick alternative using lattice::draw.key() is

tableKey <- function(x)
{
key <- list()
for (i in 1:ncol(x))
{
labels <- c(colnames(x)[i], x[,i])
font <- c(2, rep(1, nrow(x)))
key <- c(key, list(text = list(labels, font = font)))
}
draw.key(key, draw = FALSE)
}

splom(iris, sub = tableKey(as.matrix(summary(iris

-Deepayan

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

2010-06-01 Thread Joshua Wiley
Hello,

I was hunting for something else and came across your old message, and
I noticed that it had never received an answer (at least on the list).
 I really tried to figure out what might be going on just by looking
at your code, but I could not get enough information from your email
and your code is not reproducible.  For instance, in your function,
you reference other functions that are not part of base R (e.g.,
calculateGroupMean() ).  Also, your data, plan1, plan2, etc. and
u_proj.  If you still have a question about your function, please
provide a reproducible example.

Best regards,

Josh

On Wed, Feb 10, 2010 at 4:06 PM, Chaehan So  wrote:
> Dear R-helpers,
>
> my little function below calculates the group score (tmpGroupMean) of an
> item,
> appends a "_mean" on its name and stores its value on this name.
> However, it does not calculate the mean of these scores (LVMean) in the same
> row correctly,
> as you can see in the below output which strangely also contains NAs.
> What is wrong??
>
> Thanks for any hint!!!
>
> ##
> ## start
>
> groupMeanForAllItems <- function(inputDataFrame, groupVector)
> {
> # build up result dataframe starting with group means
> result <- data.frame(unique(groupVector));
> # build up result column labels starting with group name
> resultNames <- "groupname";
> for (itemName in names(inputDataFrame))
> {
> # compute mean by group
> tmpGroupMean <- calculateGroupMean(inputDataFrame[, itemName], groupVector);
> result <- cbind(result, tmpGroupMean);
> # generate new column name
> newColumnName <- sprintf("%s_mean", itemName);
> resultNames <- c(resultNames, newColumnName)
> }
>
> LVMean = mean(result, na.rm=TRUE);
> result <- cbind(result, LVMean)
> resultNames <- c(resultNames, "LVMean")
>
> names(result) <- resultNames;
> return(result)
> }
>
> rPlanning <- data.frame(plan1, plan2, plan3, plan4, plan5, plan6, plan7)
> a <- groupMeanForAllItems(rPlanning, u_proj)
> print(a)
>
> ## end
> 
>
> Output:
>
>  groupname plan1_mean plan2_mean plan3_mean plan4_mean plan5_mean
> plan6_mean plan7_mean  LVMean 1 a 4.375.000 5.625.000 5.500.000 5.250.000
> 6.500.000 4.375.000 5.125.000 NA 2 b 6.400.000 6.200.000 6.600.000 6.600.000
> 6.000.000 4.000.000 5.600.000 5.890.628 3 c 6.400.000 6.400.000 6.600.000
> 6.800.000 5.400.000 6.200.000 5.600.000 5.789.459 4 d 6.000.000 5.666.667
> 5.000.000 5.666.667 5.333.333 4.333.333 5.000.000 5.821.688 5 e 4.750.000
> 3.250.000 4.000.000 4.500.000 4.500.000 2.250.000 2.250.000 5.866.753 6 f
> 3.000.000 4.250.000 3.500.000 5.000.000 4.500.000 2.000.000 4.750.000
> 5.943.680 7 g  6.000.000 6.750.000 6.000.000 5.750.000 5.000.000 5.250.000
> 3.750.000 5.091.667 8 h 6.000.000 5.666.667 5.666.667 6.000.000 5.000.000
> 3.666.667 5.666.667 5.260.368 9 i 7.000.000 3.000.000 3.500.000 6.500.000
> 4.500.000 5.000.000 6.500.000 NA 10 j 6.400.000 5.800.000 6.400.000
> 6.200.000 6.600.000 5.400.000 6.200.000 5.890.628 11 k 6.000.000 6.000.000
> 6.000.000 4.000.000 5.000.000 6.000.000 6.000.000 5.789.459 12 l 6.500.000
> 6.750.000 7.000.000 6.750.000 7.000.000 6.250.000 7.000.000 5.821.688 13 m
> 6.666.667 6.500.000 6.666.667 6.500.000 6.500.000 5.833.333 5.500.000
> 5.866.753 14 n 6.571.429 6.142.857 6.142.857 5.857.143 5.714.286 5.428.571
> 4.714.286 5.943.680 15 o 6.666.667 6.666.667 5.666.667 4.666.667 5.666.667
> 4.666.667 5.000.000 5.091.667 16 p 5.857.143 6.000.000 6.142.857 5.857.143
> 5.571.429 5.571.429 6.142.857 5.260.368
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

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


Re: [R] Faster union of polygons?

2010-06-01 Thread baptiste auguie
Hi,

I think you could use a concave hull from the alphahull package,

http://yihui.name/en/2010/04/alphahull-an-r-package-for-alpha-convex-hull/

It may be difficult to find the right parameters if the polygons
differ widely in edge lengths, though.


HTH,

baptiste

On 2 June 2010 03:53, Remko Duursma  wrote:
> Dear R-helpers,
>
> thanks for yesterday's speeding-up tip. Here is my next query:
>
> I have lots of polygons (not necessarily convex ones, and they never
> have holes) given by x,y coordinates.
>
> I want to get the polygon that is the union of these polygons. This is
> my current method, but I am hoping there is a faster method (up to
> thousands of polygons, each with ca. 40 xy points).
>
> Example:
>
> library(gpclib)
>
> # A polygon
> leaf <- structure(c(0, 1, 12.9, 16.5, 18.8, 17, 16.8, 15.5, 12.1, 8.2,
> 6.3, 5, 2, 0, -1.5, -4.3, -6.6, -10.3, -14.8, -19.4, -22.2, -23.5,
> -22.2, -17.6, -7.8, 0, 0, -2.4, 2.8, 8.9, 19.9, 33.9, 34.8, 40.4,
> 49.7, 69.2, 77.4, 83.4, 91.4, 99, 92.8, 87.3, 81.2, 71.1, 57.6,
> 45.4, 39.2, 26, 15.6, 5.3, 0.6, 0), .Dim = c(26L, 2L), .Dimnames = list(
>    NULL, c("X", "Y")))
>
> # Lots of polygons:
> releaf <- function(leaf)cbind(leaf[,1]+rnorm(1,0,50),leaf[,2]+rnorm(1,0,50))
> leaves <- replicate(500, releaf(leaf), simplify=FALSE)
>
> # Make into gpc.poly class:
> leaves <- lapply(leaves, as, "gpc.poly")
>
> # Make union .
> system.time({
> leavesoutline <- union(leaves[[1]], leaves[[2]])
> for(i in 3:length(leaves))leavesoutline <- union(leavesoutline, leaves[[i]])
> })
> # about 1sec here.
>
> # Check it:
> plot(leavesoutline)
>
>
>
> thanks!
>
> Remko
>
>
> -
> Remko Duursma
> Research Lecturer
>
> Centre for Plants and the Environment
> University of Western Sydney
> Hawkesbury Campus
> Richmond NSW 2753
>
> Dept of Biological Science
> Macquarie University
> North Ryde NSW 2109
> Australia
>
> Mobile: +61 (0)422 096908
> www.remkoduursma.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] code for power and suffix for x,y labels in plot( ).

2010-06-01 Thread Shant Ch
Hi 

I was trying to have a graph whose axes are X axis: m, Y axis: var[X ((a,b) in 
suffix, and (n,d) in the power)]. 

X ((a,b) in suffix, and (n,d) in the power)-X^(n,d) _ (a,b).

Actually I require many plots involving different values of a,b,n,d, so need to 
keep this complicated notation. 
The expression() didn't work out for this case. Can anyone help me out. 
Thanks, in advance.
Shant






uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower = -2, upper = 2, 
tol = 0.001 )

While using this I am getting the following error. Can anyone please help me 
out.
Error in uniroot(function(x) x * (3^x) * log(4) - x * log(4/3) - (3^x) +  :   
f() values at end points not of opposite sign.

Thanks in advance.

Shant


  
[[alternative HTML version deleted]]

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


Re: [R] how to make monthly time series out of daily

2010-06-01 Thread Jeffrey Ryan

library(xts)

to.monthly(x)

The code is all Fortran, and is very fast.  It should work just fine on most
all time-series-like objects/classes, including timeSeries.

Documentation in the vignette will help, as will ?to.period

A wealth of functions to manipulate/test/transform time-series data is part
of xts. It is compatible with most all other time-series classes, and is
mostly written in C.  Operations nearly as fast as atomic types, and in some
cases faster, and minimize memory usage.

to.period is used by many on tick-data without issue, and can support any
time granularity (seconds, mins, hours, days, weeks, months, quarters,
years, and arbitrary multiples of these)

Additional help is on the r-sig-finance list, as well as in a variety of
slides found:

http://www.quantmod.com/Columbia2008/
http://www.quantmod.com/Rmetrics2008/

As well as:

http://www.quantmod.com/examples/data/

HTH
Jeff

-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-make-monthly-time-series-out-of-daily-tp2196591p2239578.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Help - C Compiler

2010-06-01 Thread Matt Shotwell
Take a look at the R Installation and Administration manual
, under the section
with header "The standalone Rmath library".



Matt Shotwell
Graduate Student
Division of Biostatistics and Epidemiology
Medical University of South Carolina

On Tue, 2010-06-01 at 21:43 -0400, Ali Makhmali wrote:
> Dear Group Members,
> 
> First of all thanks for all the great work and effort.
> 
> I am trying to compile a part of the Project R, 'pnorm.c' in visual studio
> 6.0 c++ language.
> 
> First i downloaded the standalone R-2.11.0 and tried to compile it. Some
> files were missing here such as 'Rconfig.h'.
> 
> Then i downloaded the Binary for Windows, and in the installation folder i
> found those missing files like 'Rconfig.h'.
> 
> The problem is that i still need some other files to compile the pnorm.c
> that are not neither in R-2.11.0 or in installed binary folder. Files like
> 'R_ext/RS.h', 'R_ext/Print.h',
> 'R_ext/Error.h' and etc.
> 
> 
> I will appreciate it if you can instruct me how do i compile the pnorm.c in
> visual studio C++ 6.0.
> 
> 
> 
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 label the som notes by the majority vote

2010-06-01 Thread Changbin Du
library("kohonen")
data(nir)
attach(nir)

#SOM, the supervised learning, train the map using temperature as the class
variable.
set.seed(13)
nir.xyf<- xyf(data=spectra, Y=classvec2classmat(temperature), xweight = 0.9,
grid=somgrid(4, 4, "hexagonal"))


temp.xyf <- predict(nir.xyf)$unit.prediction #get prediction
temp.predict<- as.numeric(classmat2classvec(temp.xyf)) #change matrix to
vectors.

par(mfrow=c(1,2))

plot(nir.xyf, type="property", property=temp.predict, palette.name =rainbow,
main="Prediction ")

cl <- colors()
bgcols <- cl[2:14]
plot(nir.xyf, type="mapping", labels=nir$temperature,
bgcol=bgcols[as.integer(temp.predict)],
  main="Mapping plot")

par(mfrow=c(1,1))



HI, Joris,

Thanks so much for your suggestion!   I have modified the above codes, and
what I want  is to label the notes by the temperature.
if a note has 3 objects mapped to it (the temperature are 30, 40, 30), then
I want the 30 be labeled on the note.

the right plot is the mapping plot, I want it to be labeled by only one
temperature.

Thanks so much!










On Tue, Jun 1, 2010 at 5:36 PM, Joris Meys  wrote:

> Dear Changbin,
>
> Please provide a self-contained, minimal example, meaning the whole code
> should run and create the plot as it is now, without having to load your
> dataset (which we don't have). Otherwise it's impossible to see what's going
> on and help you.
>
> Cheers
> Joris
>
> On Wed, Jun 2, 2010 at 2:21 AM, Changbin Du  wrote:
>
>> HI, Dear R community,
>>
>> I am using the following codes to do the som. I tried to label the notes
>> by
>> the majority vote. either through mapping or prediction.
>> I attached my output, the left one dont have any labels in the note, the
>> right one has  more than one label in each note. I need to have only one
>> label for each note either by majority vote or prediction.
>>
>> Can anyone give some suggestions or advice? Thanks so much!
>>
>>
>>
>> alex<-read.table("/home/cdu/operon/alex2.txt", , sep="\t", skip=0,
>> header=T,
>> fill=T)
>> alex1<-alex[,c(1:257)]
>> levels(alex1$Label)
>>
>> alex1$outcome<-as.numeric(alex1$Label)
>> alex1$outcome[1:20]
>>
>>
>> #self-organizing maps(unsupervised learning)
>> library("kohonen")
>>
>>
>> #SOM, the supervised learning, train the map using outcome as the class
>> variable.
>> set.seed(13)
>> final.xyf<- xyf(data=as.matrix(alex1[,c(1:256)]),
>> Y=classvec2classmat(alex1$outcome), xweight = 0.99, grid=somgrid(20, 30,
>> "hexagonal"))
>>
>>
>> outcome.xyf <- predict(final.xyf)$unit.prediction#get prediction
>> outcome.predict<- as.numeric(classmat2classvec(outcome.xyf)) #change
>> matrix
>> to vectors.
>>
>> outcome.label<-LETTERS[outcome.predict] #conver the numeric value to
>> letters.
>>
>>
>> plot(final.xyf, type="property", property=outcome.predict,
>> labels=outcome.label, palette.name =rainbow, main="Prediction ")
>>
>>
>>
>> cl <- colors()
>> bgcols <- cl[2:14]
>> plot(final.xyf, type="mapping", labels=outcome.label, col="black",
>> bgcol=bgcols[as.integer(outcome.predict)],
>>  main="Mapping plot")
>>
>>
>>
>>
>> --
>> Sincerely,
>> Changbin
>> --
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>
> --
> Joris Meys
> Statistical Consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> Coupure Links 653
> B-9000 Gent
>
> tel : +32 9 264 59 87
> joris.m...@ugent.be
> ---
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>



-- 
Sincerely,
Changbin
--

[[alternative HTML version deleted]]

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


Re: [R] Reading file

2010-06-01 Thread David Winsemius


On Jun 1, 2010, at 3:19 PM, Robert Tsutakawa wrote:

I am trying to read a source program into a mac pro laptop, which  
uses Snow Leopard.  R is unable to find the file containing my  
source program.  I'm using the function  source(" file name").  I  
need some examples or detailed instructions.  I have no problem  
reading the file using PC.

Bob


Just drag the file from a Finder window to the console to get the full  
path name.


A cross-platform solution would be file.choose()

--
David

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

2010-06-01 Thread Ali Makhmali
Dear Group Members,

First of all thanks for all the great work and effort.

I am trying to compile a part of the Project R, 'pnorm.c' in visual studio
6.0 c++ language.

First i downloaded the standalone R-2.11.0 and tried to compile it. Some
files were missing here such as 'Rconfig.h'.

Then i downloaded the Binary for Windows, and in the installation folder i
found those missing files like 'Rconfig.h'.

The problem is that i still need some other files to compile the pnorm.c
that are not neither in R-2.11.0 or in installed binary folder. Files like
'R_ext/RS.h', 'R_ext/Print.h',
'R_ext/Error.h' and etc.


I will appreciate it if you can instruct me how do i compile the pnorm.c in
visual studio C++ 6.0.




-- 
Thank you,


Best regards.

[[alternative HTML version deleted]]

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


Re: [R] How to get a list of subdirectories in the wd?

2010-06-01 Thread Henrique Dallazuanna
Try this:

dir()[file.info(dir())$isdir]


On Tue, Jun 1, 2010 at 11:06 PM, Nevil Amos  wrote:

> How do I get a list of subdirectories only, not files, in a directory
>
>
> dir.create("test")
> setwd("test")
> dir.create("adir")
> dir.create("bdir")
> file.create("afile")
> dir()
>
> returns [1] "adir"  "afile" "bdir"
>
> in need to return [1] "adir"  "bdir"
>
> cheers
>
> Nevil Amos
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

[[alternative HTML version deleted]]

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


[R] How to get a list of subdirectories in the wd?

2010-06-01 Thread Nevil Amos

How do I get a list of subdirectories only, not files, in a directory


dir.create("test")
setwd("test")
dir.create("adir")
dir.create("bdir")
file.create("afile")
dir()

returns [1] "adir"  "afile" "bdir"

in need to return [1] "adir"  "bdir"

cheers

Nevil Amos

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

2010-06-01 Thread Remko Duursma
Dear R-helpers,

thanks for yesterday's speeding-up tip. Here is my next query:

I have lots of polygons (not necessarily convex ones, and they never
have holes) given by x,y coordinates.

I want to get the polygon that is the union of these polygons. This is
my current method, but I am hoping there is a faster method (up to
thousands of polygons, each with ca. 40 xy points).

Example:

library(gpclib)

# A polygon
leaf <- structure(c(0, 1, 12.9, 16.5, 18.8, 17, 16.8, 15.5, 12.1, 8.2,
6.3, 5, 2, 0, -1.5, -4.3, -6.6, -10.3, -14.8, -19.4, -22.2, -23.5,
-22.2, -17.6, -7.8, 0, 0, -2.4, 2.8, 8.9, 19.9, 33.9, 34.8, 40.4,
49.7, 69.2, 77.4, 83.4, 91.4, 99, 92.8, 87.3, 81.2, 71.1, 57.6,
45.4, 39.2, 26, 15.6, 5.3, 0.6, 0), .Dim = c(26L, 2L), .Dimnames = list(
NULL, c("X", "Y")))

# Lots of polygons:
releaf <- function(leaf)cbind(leaf[,1]+rnorm(1,0,50),leaf[,2]+rnorm(1,0,50))
leaves <- replicate(500, releaf(leaf), simplify=FALSE)

# Make into gpc.poly class:
leaves <- lapply(leaves, as, "gpc.poly")

# Make union .
system.time({
leavesoutline <- union(leaves[[1]], leaves[[2]])
for(i in 3:length(leaves))leavesoutline <- union(leavesoutline, leaves[[i]])
})
# about 1sec here.

# Check it:
plot(leavesoutline)



thanks!

Remko


-
Remko Duursma
Research Lecturer

Centre for Plants and the Environment
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753

Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia

Mobile: +61 (0)422 096908
www.remkoduursma.com

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


Re: [R] MacOS X binary for lme4 not available on CRAN

2010-06-01 Thread Ben Madin
Armin,

On Tue, 1 Jun 2010, Armin Goralczyk wrote:

> I have noticed that the MacOS X binary for lme4 is not available on
> CRAN at the moment. I am aware that it may be possible to install from
> source but I am not very familiar with that procedure and would rather
> avoid it. But I need the package for a statistics course next week. So
> can anybody give an update about the situation with the MacOS X
> binaries? Will it be resolved within the next days or should I rather
> install from source (in that case: is my assumption correct that it is
> possible or will it fail (I read the the check log and it seems that
> there is some error ?)

If it helps to know, installing it from source seems to have worked fine for 
me, and I am no expert at this stuff.

If you have Mac problems, you should try the R-sig-mac list, most of these 
issues have already been asked there, and you will get responses quite quickly 
normally.

cheers

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


Re: [R] Fancy Page layout

2010-06-01 Thread Dejian Zhao
 I think you can use grid.layout() to create the appropriate layout, 
allocating proper space for the upper plotting area and the bottom text 
region, and then use viewport() with the layout parameter to control the 
output by pushing the viewport at the proper region on the graphical device.
Viewport alone can solve your three quesions, but with grid.layout 
the layout is better controlled.
The above-mentioned functions, or grid.layout(), viewport() and 
pushViewport(), are in the grid package. Possibly the work can be done 
by combining lattice with grid.


On 2010-6-2 1:10, Noah Silverman wrote:

Thanks Jim,

That helps.

Ben Bolker had a nice suggestion on how to get the lattice package to
easily plot all 22 variables in one window.

Ultimately, I'd like to generate a PDF that will print on a standard
(8.5 x 11) page.

A few things I'm still stuck are:
 1) How to use the lattice command AND leave room at the bottom for a
text block
 2) How to tell lattice the size of the window
 3) How to integrate all this together - draw a big window, plot
trellis in the top half and then text box in the bottom.

Any thoughts?

-N


On 6/1/10 4:53 AM, Jim Lemon wrote:
   

On 06/01/2010 04:16 AM, Noah Silverman wrote:
 

Hi,

Working on a report that is going to have a large number of graphs and
summaries.  We have 80 "groups" with 20 variables each.

Ideally, I'd like to produce ONE page for each group.  It would have two
columns of 10 graphs and then the 5 number summary of the variables at
the bottom.
So, perhaps the top 2/3 of the page has the graphs and the bottom third
has 20 rows of data summary(maybe a table of sorts.)
This COULD be done in Latex, but would have to be hand coded for each of
the 80 groups which would be painfully slow.

I can easily do the graphs with par(mfrow=c(5,2))  band then draw the
graphs in a loop.

But I am stuck from here:

1) How do I control the size of the plot window.  (Ideally, it should
print to fill an 8.5 x 11 piece of paper)
2) Is there a way to "easily" insert a 5 number summary (summary
command) into the lower half of the page.

Does anybody have any ideas??

   

Hi Noah,
One easy way is to leave some space at the bottom, either by using:

par(mfrow=c(6,2))

or the more flexible "layout" function, and then use "text" or a
fancier function (textbox, boxed.labels, addtable2plot, etc.) to add
your text after:

par(xpd=NA)

allows you to display the text anywhere you please. If you use a
bitmap graphics device, make it big:

png("numberoneofeighty.png",850,1100)

so that it won't look lumpy on the printed page.

Jim

 

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






__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 label the som notes by the majority vote

2010-06-01 Thread Joris Meys
Dear Changbin,

Please provide a self-contained, minimal example, meaning the whole code
should run and create the plot as it is now, without having to load your
dataset (which we don't have). Otherwise it's impossible to see what's going
on and help you.

Cheers
Joris

On Wed, Jun 2, 2010 at 2:21 AM, Changbin Du  wrote:

> HI, Dear R community,
>
> I am using the following codes to do the som. I tried to label the notes by
> the majority vote. either through mapping or prediction.
> I attached my output, the left one dont have any labels in the note, the
> right one has  more than one label in each note. I need to have only one
> label for each note either by majority vote or prediction.
>
> Can anyone give some suggestions or advice? Thanks so much!
>
>
>
> alex<-read.table("/home/cdu/operon/alex2.txt", , sep="\t", skip=0,
> header=T,
> fill=T)
> alex1<-alex[,c(1:257)]
> levels(alex1$Label)
>
> alex1$outcome<-as.numeric(alex1$Label)
> alex1$outcome[1:20]
>
>
> #self-organizing maps(unsupervised learning)
> library("kohonen")
>
>
> #SOM, the supervised learning, train the map using outcome as the class
> variable.
> set.seed(13)
> final.xyf<- xyf(data=as.matrix(alex1[,c(1:256)]),
> Y=classvec2classmat(alex1$outcome), xweight = 0.99, grid=somgrid(20, 30,
> "hexagonal"))
>
>
> outcome.xyf <- predict(final.xyf)$unit.prediction#get prediction
> outcome.predict<- as.numeric(classmat2classvec(outcome.xyf)) #change matrix
> to vectors.
>
> outcome.label<-LETTERS[outcome.predict] #conver the numeric value to
> letters.
>
>
> plot(final.xyf, type="property", property=outcome.predict,
> labels=outcome.label, palette.name =rainbow, main="Prediction ")
>
>
>
> cl <- colors()
> bgcols <- cl[2:14]
> plot(final.xyf, type="mapping", labels=outcome.label, col="black",
> bgcol=bgcols[as.integer(outcome.predict)],
>  main="Mapping plot")
>
>
>
>
> --
> Sincerely,
> Changbin
> --
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>


-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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] regexpr help (match.length=0)

2010-06-01 Thread Joris Meys
Dear all,

It sounds as if regexp works according to the same rules as Perl, very
nicely explained in:
http://blob.perl.org/books/beginning-perl/3145_Chap05.pdf

Yet, I couldn't help but wonder if there are also differences in behaviour.
I couldn't find any yet, but there must be some. Anybody care to elaborate
on this?

Cheers
Joris

On Wed, Jun 2, 2010 at 1:05 AM, Matt Shotwell  wrote:

> On Tue, 2010-06-01 at 16:43 -0400, Erik Iverson wrote:
> >
> > McGehee, Robert wrote:
> > > R-help,
> > > Sorry if this is more of a regex question than an R question. However,
> > > help would be appreciated on my use of the regexpr function.
> > >
> > > In the first example below, I ask for all characters (a-z) in 'abc123';
> > > regexpr returns a 3-character match beginning at the first character.
> > >
> > >> regexpr("[[:alpha:]]*", "abc123")
> > > [1] 1
> > > attr(,"match.length")
> > > [1] 3
> > >
> > > However, when the text is flipped regexpr, and I ask for a match of all
> > > characters in '123abc', regexpr returns a zero-character match
> beginning
> > > at the first character. Can someone explain what a zero length match
> > > means (i.e. why not return -1), and why the result isn't 4,
> > > match.length=3?
> >
> > It means it matches 0 characters, which is fine since you use *, which
> > means match 0 or more occurrences of the regex.  It sounds like you want
> > + instead of *.  Also see gregexpr.
>
> Also, regular expressions try to match as early as possible. That's why
> the match is at position one of length zero, and not at position four of
> length three.
>
> Matt Shotwell
> Graduate Student
> Division of Biostatistics and Epidemiology
> Medical University of South Carolina
>
> > >
> > >> regexpr("[[:alpha:]]*", "123abc")
> > > [1] 1
> > > attr(,"match.length")
> > > [1] 0
> > >
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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.
>



-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

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

2010-06-01 Thread jim holtman
try this:

> x <- readLines(textConnection("V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
+ TP53 Dis1 Dis2 Dis3 Dis4 Dis5 Dis6
+ DCI New1 New2 New3 New4
+ FDI Hi2 H3 H4
+ GHD I1 I3 I4 I5 I6 I7 I8"))[-1]  # drop the first line
> output <- do.call(rbind, lapply(x, function(.line){
+ # split the data
+ parms <- strsplit(.line, '\\s+')[[1]]
+ # create the indices
+ indx <- combn(length(parms) - 1, 2)
+ # now create the output
+ cbind(parms[1], parms[indx[1,] + 1], parms[indx[2,] + 1])
+ }))
>
>
>
> output
  [,1]   [,2]   [,3]
 [1,] "TP53" "Dis1" "Dis2"
 [2,] "TP53" "Dis1" "Dis3"
 [3,] "TP53" "Dis1" "Dis4"
 [4,] "TP53" "Dis1" "Dis5"
 [5,] "TP53" "Dis1" "Dis6"
 [6,] "TP53" "Dis2" "Dis3"
 [7,] "TP53" "Dis2" "Dis4"
 [8,] "TP53" "Dis2" "Dis5"
 [9,] "TP53" "Dis2" "Dis6"
[10,] "TP53" "Dis3" "Dis4"
[11,] "TP53" "Dis3" "Dis5"
[12,] "TP53" "Dis3" "Dis6"
[13,] "TP53" "Dis4" "Dis5"
[14,] "TP53" "Dis4" "Dis6"
[15,] "TP53" "Dis5" "Dis6"
[16,] "DCI"  "New1" "New2"
[17,] "DCI"  "New1" "New3"
[18,] "DCI"  "New1" "New4"
[19,] "DCI"  "New2" "New3"
[20,] "DCI"  "New2" "New4"
[21,] "DCI"  "New3" "New4"
[22,] "FDI"  "Hi2"  "H3"
.

On Tue, Jun 1, 2010 at 5:12 AM, mhalsham  wrote:
>
> Can any one help it will be very kind, loop statements
> I have this table and some more records, I want to reshape it
>
> V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
> TP53 Dis1 Dis2 Dis3 Dis4 Dis5 Dis6
> DCI New1 New2 New3 New4
> FDI Hi2 H3 H4
> GHD I1 I3 I4 I5 I6 I7 I8
>
> I want my new table or matrix to be some thing like this
>
> V1 V2 V3
> Tp53 Dis1 Dis2
> Tp53 Dis1 Dis3
> Tp53 Dis1 Dis4
> Tp53 Dis1 Dis5
> Tp53 Dis1 Dis6
> Tp53 Dis2 Dis3
> Tp53 Dis2 Dis4
> Tp53 Dis2 Dis5
> Tp53 Dis2 Dis6
> Tp53 Dis3 Dis4
> Tp53 Dis3 Dis5
> Tp53 Dis3 Dis6
> Tp53 Dis4 Dis5
> Tp53 Dis4 Dis6
> Tp53 Dis5 Dis6
> DCI New1 New2
> DCI New1 New3
> DCI New1 New4
> DCI New2 New3
> DCI New2 New4
> DCI New3 New4
>
>
> And so on for the rest of the table.
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/loop-tp2238209p2238209.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

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


Re: [R] R on the iPhone/iPad? Not so much....a GPL violation

2010-06-01 Thread Marc Schwartz
Ken,

See comments inline.

On Jun 1, 2010, at 2:25 PM, Ken Williams wrote:

> Hi Marc,
> 
> I want to debate a couple points from your post:
> 
>> 1. Distribution of GPL covered applications is not permissible via the App
> 
>> Store due to the Apple Terms of Service language, which infringes upon
> rights
>> granted under the GPL.
>> 
>> 'Nuff said.
> 
> I'm not sure I agree with this, but there's so much wiggle room in
> interpreting what the GPL means that there would probably be no way to
> decide without a courtroom & judge, so I'll leave this part alone. =)  I
> also haven't yet read your other post where you discuss this.


Please do, including the links therein. It's not my interpretation, it is the 
FSF's action and Apple's response to that action, which sets at least an 
operational precedence, if not one that could also affect any future litigation 
pertaining to GPL'd apps in the App Store. That all just took place within the 
past week or so, which is what prompted my initial post on the matter, since it 
would be relevant to any R offering via that channel.


>> 3.3.1Applications may only use Documented APIs in the manner
> prescribed by
>> Apple and must not use or call any private APIs.
> 
> I believe that language only refers to *Apple's* APIs.  In other words, they
> don't want you to call hidden functions that aren't supposed to be exposed
> to developers.  If it meant no use of any APIs private to the developer, it
> would rule out pretty much every application in existence, considering that
> a call from one function to any other is an API call.


I am not in disagreement on that point. The key issue to date has been the lack 
of a compatible FORTRAN compiler, at least off the shelf, based upon what I can 
tell. Arguably, that is at least a notable deterrent to use FORTRAN on the 
iPhone for now.

There are other programming language tools for current iPhone development, but 
nothing for FORTRAN that I can find.

I can find no references to anyone building iPhone apps using FORTRAN (even in 
part) and the few queries that I can find that even mention an interest in 
doing so, reference the same issues that I have. Some have referenced f2c, but 
it is not clear to me that such an approach would work for R, not to mention 
the development overhead and the extensive testing of any conversion of 
critical functionality.

That all changes with the new language in 4.x.


>> However, the beta release of the 4.x version of the iPhone SDK has the
>> following language in the same section:
>> 
>> 3.3.1 ˜ Applications may only use Documented APIs in the manner prescribed
> by
>> Apple and must not use or call any private APIs. Applications must be
>> originally written in Objective-C, C, C++, or JavaScript as executed by
> the
>> iPhone OS WebKit engine, and only code written in C, C++, and Objective-C
> may
>> compile and directly link against the Documented APIs (e.g., Applications
> that
>> link to Documented APIs through an intermediary translation or
> compatibility
>> layer or tool are prohibited).
> 
> Here again I believe the "private" API language refers to
> unsanctioned-but-exposed pieces of Apple's platform that you're not supposed
> to touch.  The language restrictions I interpret to mean that if you call
> their Official API hooks, you must do it from one of the Official Languages.
> 
> However, FORTRAN code will never call Apple's API hooks, it just does its
> little matrixy/FFT/etc. stuff and returns the results.  In the call stack,
> FORTRAN is always a dead end.  It doesn't call Apple's APIs, and it doesn't
> call a translation layer that calls Apple's APIs.  So again, R may be in the
> clear here, under this interpretation.
> 
> Note that Java & Flash applications, under this interpretation, are *NOT* in
> the clear, because they do call GUI APIs (among others).


The key wording change relevant to R (and of course for other iPhone developers 
and tool providers) in 4.x is:

"Applications must be originally written in Objective-C, C, C++, or JavaScript 
as executed by the iPhone OS WebKit engine"

Ignore the other wording pertaining to API's and other layers for the time 
being.

The app must be written natively in one of those four languages. There appears 
to be no interpretation that I can find that differentiates a scenario where a 
library of low level functions, written in a language such as FORTRAN, may be 
called from a higher level language such as those listed above.

Unless there is some subtlety in differentiating the abstraction layers within 
which the application is executed on the iPhone, I see no recourse here.

Note that the entities that provide iPhone cross-compilation/framework tools 
(eg. MonoTouch, Titanium, unity3D, Rhodes, etc.) which convert other code 
directly to native iPhone apps are also trying to figure out where they stand. 
Similarly, folks who develop natively in other languages are also having 
headaches over the new SDK wording.

There 

Re: [R] regexpr help (match.length=0)

2010-06-01 Thread Matt Shotwell
On Tue, 2010-06-01 at 16:43 -0400, Erik Iverson wrote:
> 
> McGehee, Robert wrote:
> > R-help,
> > Sorry if this is more of a regex question than an R question. However,
> > help would be appreciated on my use of the regexpr function.
> > 
> > In the first example below, I ask for all characters (a-z) in 'abc123';
> > regexpr returns a 3-character match beginning at the first character. 
> > 
> >> regexpr("[[:alpha:]]*", "abc123")
> > [1] 1
> > attr(,"match.length")
> > [1] 3
> > 
> > However, when the text is flipped regexpr, and I ask for a match of all
> > characters in '123abc', regexpr returns a zero-character match beginning
> > at the first character. Can someone explain what a zero length match
> > means (i.e. why not return -1), and why the result isn't 4,
> > match.length=3?
> 
> It means it matches 0 characters, which is fine since you use *, which 
> means match 0 or more occurrences of the regex.  It sounds like you want 
> + instead of *.  Also see gregexpr.

Also, regular expressions try to match as early as possible. That's why
the match is at position one of length zero, and not at position four of
length three.

Matt Shotwell
Graduate Student 
Division of Biostatistics and Epidemiology
Medical University of South Carolina

> > 
> >> regexpr("[[:alpha:]]*", "123abc")
> > [1] 1
> > attr(,"match.length")
> > [1] 0
> >
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Problem using apply

2010-06-01 Thread Sarah Goslee
As far as I can tell, your code works perfectly. It's just that the mean of
your rows is the same as the mean of your columns because the matrix
is symmetric.

Compare these two examples (the first one is yours):

> m = matrix( c(1,4,7,4,5,8,7,8,9), nrow = 3 )
> m
 [,1] [,2] [,3]
[1,]147
[2,]458
[3,]789
> apply(m, 1, sum)
[1] 12 17 24
> apply(m, 2, sum)
[1] 12 17 24
> apply(m, 1, mean)
[1] 4.00 5.67 8.00
> apply(m, 2, mean)
[1] 4.00 5.67 8.00
>
>
> m <- matrix(1:9, nrow=3)
> apply(m, 1, sum)
[1] 12 15 18
> apply(m, 2, sum)
[1]  6 15 24
> apply(m, 1, mean)
[1] 4 5 6
> apply(m, 2, mean)
[1] 2 5 8
>

Henrique provides methods for doing the same thing
without using apply(), which may be useful if this isn't
a test case for solving a larger problem.

If your problem is something other than that, you'll need to
explain more clearly.

Sarah

On Tue, Jun 1, 2010 at 3:21 PM, Joachim de Lezardiere
 wrote:
> Thank you Henrique,
>
>
>
> I still don’t understand why my code doesn’t work ?  According to the
> definition of apply function it should work no ?
>
>
>
> From: Henrique Dallazuanna [mailto:www...@gmail.com]
> Sent: Tuesday, June 01, 2010 7:34 PM
> To: Joachim de Lezardiere
> Cc: r-help@r-project.org
> Subject: Re: [R] Problem using apply
>
>
>
> The mean by col and by row are the same:
>
> colMeans(m) == rowMeans(m)
>
> So:
>
> m / rowMeans(m) # You don't need apply here
> m / colMeans(m)
>
> On Tue, Jun 1, 2010 at 2:26 PM, Joachim de Lezardiere
>  wrote:
>
> Hello ,
>
>
>
> I can not get apply function to do what I want when doing stuff on rows.
> Let's say I want to divide the rows of matrix by their mean, the below show
> you get the same result weather you use 1 or 2, i.e. same result for columns
> than for means..:(
>
>
>
> Thanks a lot for the help,
>
>
>
>
>
>
>
> m = matrix( c(1,4,7,4,5,8,7,8,9), nrow = 3 )
>
>
>
> divideByMean  = function( v ){
>
> return( v/mean(v))
>
> }
>
>
>
> rowMean = c( mean( m[1,]),mean( m[2,]),mean( m[3,]) )
>
> rowMean
>
>
>
> colMean = c( mean( m[,1]),mean( m[,2]),mean( m[,3]) )
>
> colMean
>
>
>
> m
>
> print("ByRow")
>
> apply( m, 1, divideByMean)
>
>
>
> print("ByCol")
>
> apply( m, 2, divideByMean)
>
>
>
>
>
>
>


-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] how to make monthly time series out of daily

2010-06-01 Thread Jannis
I am not sure about specific timeseries objects, but using an ordinary 
vector with the values the aggregate() function works fine:


monthly.means <- aggregate(timeseries, mean, by=months)

months now only has to be a vector of length(timeseries) with numbers 
relating each entry in timeseries to a unique month. My (not very 
elegant) way would be to create a unique index by extracting the year 
and the month from a time vector and combining them into one number, so 
that 10.2001 would result in 200110. I am sure there are more elegant 
ways using timeseries objects or something similar.



HTH
Jannis


Reto Baumgartner schrieb:

I am using the Rmetrics package and would like to convert a daily
price time serie into a monthly one. In SPlus I could use:
aggregateSeries(timeSerie, by="months",FUN=first).

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

2010-06-01 Thread Erik Iverson



Bunny, lautloscrew.com wrote:

Dear all,

I am trying to avoid a for loop here and wonder if the following is
possible:

I have a data.frame with 6 columns and i want to get a
cross-correlogram (by using ccf) . Obivously ccf only accepts two
columns at once and then returms a list. In fact, with a for loop i´d
do the following


for (i in 1:6) {

x[[i]]=ccf(mydf[,i],mydf[,6])


}

Is there any chance to the same with lapply? e.g. lapply(mydf,"ccf",
 ) with ... respresenting the changing arguments for ccf
functions (note only the first argument does actually change)


You don't give a reproducible example, but since you want to apply a 
function to a list, the answer is yes.  Just defining the function and 
the list is the trick, untested:


lapply(mydf[, 1:5], function(x) ccf(x, mydf[, 6]))

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


Re: [R] lapply with functions with changing parameters

2010-06-01 Thread Henrique Dallazuanna
Try this:

 lapply(mydf[-6], ccf, y = mydf[6])

On Tue, Jun 1, 2010 at 5:50 PM, Bunny, lautloscrew.com <
bu...@lautloscrew.com> wrote:

> Dear all,
>
> I am trying to avoid a for loop here and wonder if the following is
> possible:
>
> I have a data.frame with 6 columns and i want to get a cross-correlogram
> (by using ccf) . Obivously ccf only accepts two columns at once and then
> returms a list.
> In fact, with a for loop i´d do the following
>
>
> for (i in 1:6) {
>
>  x[[i]]=ccf(mydf[,i],mydf[,6])
>
>
> }
>
> Is there any chance to the same with lapply? e.g. lapply(mydf,"ccf",  )
> with ... respresenting the changing arguments for ccf functions (note only
> the first argument does actually change)
>
> thx for any suggestions in advance
>
> 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.
>



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

[[alternative HTML version deleted]]

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


Re: [R] Using R with Web services

2010-06-01 Thread Charles C. Berry

On Tue, 1 Jun 2010, marcos carvajalino wrote:


Hello list helpers,

I'm working at a research institute and I've been asked to develop a way of
using R as a scripting and analysis tool which takes information from users
via web forms, perform a query to an Oracle Database running on a Linux
server and finally return formatted reports to the user via web. I'm sort of
a newbie in web forms and web services so i've been reading about ROracle,
RWeb and CGIwithR with little or no results so far, I need to know which is
the easiest way of merging R with web services to solve my problem and if
theres a manual or book that explains this kind of R use.

Could someone enlighten me?


Seen this?

http://blogs.oracle.com/datamining/2010/05/new_r_interface_to_oracle_data_mining_available_for_download.html

HTH,

Chuck




Many thanks in advance and sorry for the typos...
--
Marcos Antonio Carvajalino Fern?ndez
Ingeniero Ambiental y Sanitario
Santa Marta, Colombia

[[alternative HTML version deleted]]




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

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


Re: [R] problem with intToChar

2010-06-01 Thread Changbin Du
Thanks to all!

Yes,   LETTERS[outcome.predict] works!


I appreciated your guys help!



On Tue, Jun 1, 2010 at 1:53 PM, Henrique Dallazuanna wrote:

> use "[" not "("
>
>
> On Tue, Jun 1, 2010 at 5:50 PM, Changbin Du  wrote:
>
>> It does not work.
>>
>>
>> > outcome.label<-LETTERS(outcome.predict)
>> Error: could not find function "LETTERS"
>>
>>
>>
>>
>> On Tue, Jun 1, 2010 at 1:48 PM, Henrique Dallazuanna wrote:
>>
>>> Try this:
>>>
>>> LETTERS[outcome.predict]
>>>
>>> On Tue, Jun 1, 2010 at 5:43 PM, Changbin Du  wrote:
>>>
  Hi, Dear R- community,

 I am use the intToChar function to convert the integers to letters. But
 the
 output is mess. Can you guys give some suggestions?   Thanks!

 > outcome.predict
  [1]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4
  4
 4  4
  [26]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4  7  4
  4
 4  4
  [51]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4
  4
 4  4
  [76]  4  4  4  4  7  4  4  4  4  4  4  4  7  4  4  4  4  4  4  4  4  4
  7
 4  4
 [101]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  7  4  4
  4
 4  4
 [126]  2  2  2 10  4  4  4  4  4  4  4  4  7  7  7  4  4  4  4  4 10 10
 13
 3 13
 [151]  2  4  4  4  4  4  4  4  4  4  4  4  4  4 10  3 13  3  2  2 11  3
  4
 4  4
 [176] 13  4  4  4  4 13 13  4  2 10 13 13  2  3  3 13 10  2  4  4  4  1
  1
 4  4
 [201] 13 13  2  2 13  2  3 13 13  2  2  3 11 13  3  2  1  4  4  4 13 13
 13
 2 10
 [226] 10  2  2 10 11 13 13 10 10  2  3  1  4  1  4 13  3 10 10 10 13  3
 11
 11 11
 [251] 10  2 10  3  5  5  4  4  4 11  6 12  3 10  3  3  1  2  2 11  3  3
  3
 10 12
 [276]  5  5  4  4  4  6  6  5 12  2  1  2 13 11  4 11 10 12 12 12  5 12
  5
 12 12
 [301]  6  6  6 12 12  3  2  3  2  1 12 12 12  5 12 12 12  9  9 12  6  6
  6
 12  2
 [326]  2 10 10 12 12 12 12 12 12  5  5 12 12 12 12  6  6  6  6  6  2  2
  5
 12 12
 [351] 12 12 12 12  9 12 12 12 12 12  6  6  6  6  6  6  6 12 12 12 12 12
 12
 9  5
 [376]  5 12 12  5 12  6  6  6  6  6  6  6  6 12 12 12 12 12  9  9 12  5
 12
 12 12
 [401]  6  6  6  6  6  6  5  9  5  5 12 12  9  9  9 12  9 12 12 12  6  6
  6
 6  6
 [426]  6  5  5  5 12  9  9 12  9 12 12  9 12 12 12 12  6  6  6 12 12  5
  5
 12  9
 [451]  5 12  6 12 12 12 12 12 12 12  6  6  5  6  5  5  5  5  5  5  5  5
 12
 12 12
 [476]  9  9  5  9  9 12  5  5  5  5  5  5  5  5  5  5 12 12 12 12  5  5
  5
 5 12
 [501]  5  9  5  5  5  5  5  5  5  5  5  5 12 12  5  5  5  5  9  5  5  5
  5
 5  5
 [526]  5  5  5  5  5  5  5  5  5  5  9 12  5  5  5  5  5  5  5  5  5  5
  5
 5  5
 [551]  5  5  5  9  5  5  5  5  9  5  5  5  5  5  5  5  5  5  5  9  9  5
  5
 5  5
 [576]  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  9
  5
 9  5
 > outcome.label<-intToChar(outcome.predict)
 > outcome.label
  [1] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 "\004"
  [11] "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004"
 "\004"
  [21] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 "\004"
  [31] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 "\a"
  [41] "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004" "\004"
 "\004"
  [51] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 "\004"
  [61] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 "\004"
  [71] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 "\a"
  [81] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004"
 "\004"
  [91] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004"
 "\004"
 [101] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 "\004"
 [111] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"
 "\a"
 [121] "\004" "\004" "\004" "\004" "\004" "\002" "\002" "\002" "\n"
 "\004"
 [131] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\a"
 "\a"
 [141] "\004" "\004" "\004" "\004" "\004" "\n"   "\n"   "\r"   "\003"
 "\r"
 [151] "\002" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 "\004"
 [161] "\004" "\004" "\004" "\004" "\n"   "\003" "\r"   "\003" "\002"
 "\002"
 [171] "\v"   "\003" "\004" "\004" "\004" "\r"   "\004" "\004" "\004"
 "\004"
 [181] "\r"   "\r"   "\004" "\002" "\n"   "\r"   "\r"   "\002" "\003"
 "\003"
 [191] "\r"   "\n"   "\002" "\004" "\004" "\004" "\001" "\001" "\004"
 "\004"
 [201] "\r"   "\r"   "\002" "\002" "\r"   "\002" "\003" "\r"   "\r"
 "\002"
 [211] "\002" "\003" "\v"   "\r"   "\003" "\002" "\001" "\004" "\004"
 "\004"
 [221] "\r"   "\

Re: [R] problem with intToChar

2010-06-01 Thread Changbin Du
the intToChar function is in the package "R.oo"

I AM try to plot the SOM result, use the outcome.labels as labels in the
following plot command.




outcome.xyf <- predict(final.xyf)$unit.prediction
outcome.predict<- as.numeric(classmat2classvec(outcome.xyf))


?outcome.label<-intToChar(as.integer(outcome.predict))

?outcome.label<-LETTERS(outcome.predict)

plot(final.xyf, type="property", property=outcome.predict,
labels=outcome.label, palette.name =rainbow, main="Supervised:Prediction ")


Thanks so much!



On Tue, Jun 1, 2010 at 1:50 PM, Erik Iverson  wrote:

>
>
> Changbin Du wrote:
>
>> Hi, Dear R- community,
>>
>> I am use the intToChar function to convert the integers to letters. But
>> the
>> output is mess. Can you guys give some suggestions?   Thanks!
>>
>>
> I suggest you tell us what you were expecting to happen, that is, what do
> you actually want?  It looks like it's doing something reasonable based in
> its name, but I can't be sure since you don't say what package intToChar is
> located in.
>



-- 
Sincerely,
Changbin
--

Changbin Du
DOE Joint Genome Institute
Bldg 400 Rm 457
2800 Mitchell Dr
Walnut Creet, CA 94598
Phone: 925-927-2856

[[alternative HTML version deleted]]

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


Re: [R] Reading file

2010-06-01 Thread Stephan Kolassa

Have you set the correct working directory?

?setwd
?getwd

HTH
Stephan


Robert Tsutakawa schrieb:
I am trying to read a source program into a mac pro laptop, which uses 
Snow Leopard.  R is unable to find the file containing my source 
program.  I'm using the function  source(" file name").  I need some 
examples or detailed instructions.  I have no problem reading the file 
using PC.

Bob

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

2010-06-01 Thread Erik Iverson



Changbin Du wrote:

Hi, Dear R- community,

I am use the intToChar function to convert the integers to letters. But the
output is mess. Can you guys give some suggestions?   Thanks!



I suggest you tell us what you were expecting to happen, that is, what 
do you actually want?  It looks like it's doing something reasonable 
based in its name, but I can't be sure since you don't say what package 
intToChar is located in.


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

2010-06-01 Thread Henrique Dallazuanna
use "[" not "("

On Tue, Jun 1, 2010 at 5:50 PM, Changbin Du  wrote:

> It does not work.
>
>
> > outcome.label<-LETTERS(outcome.predict)
> Error: could not find function "LETTERS"
>
>
>
>
> On Tue, Jun 1, 2010 at 1:48 PM, Henrique Dallazuanna wrote:
>
>> Try this:
>>
>> LETTERS[outcome.predict]
>>
>> On Tue, Jun 1, 2010 at 5:43 PM, Changbin Du  wrote:
>>
>>>  Hi, Dear R- community,
>>>
>>> I am use the intToChar function to convert the integers to letters. But
>>> the
>>> output is mess. Can you guys give some suggestions?   Thanks!
>>>
>>> > outcome.predict
>>>  [1]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4  4
>>> 4  4
>>>  [26]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4  7  4
>>>  4
>>> 4  4
>>>  [51]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4
>>>  4
>>> 4  4
>>>  [76]  4  4  4  4  7  4  4  4  4  4  4  4  7  4  4  4  4  4  4  4  4  4
>>>  7
>>> 4  4
>>> [101]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  7  4  4
>>>  4
>>> 4  4
>>> [126]  2  2  2 10  4  4  4  4  4  4  4  4  7  7  7  4  4  4  4  4 10 10
>>> 13
>>> 3 13
>>> [151]  2  4  4  4  4  4  4  4  4  4  4  4  4  4 10  3 13  3  2  2 11  3
>>>  4
>>> 4  4
>>> [176] 13  4  4  4  4 13 13  4  2 10 13 13  2  3  3 13 10  2  4  4  4  1
>>>  1
>>> 4  4
>>> [201] 13 13  2  2 13  2  3 13 13  2  2  3 11 13  3  2  1  4  4  4 13 13
>>> 13
>>> 2 10
>>> [226] 10  2  2 10 11 13 13 10 10  2  3  1  4  1  4 13  3 10 10 10 13  3
>>> 11
>>> 11 11
>>> [251] 10  2 10  3  5  5  4  4  4 11  6 12  3 10  3  3  1  2  2 11  3  3
>>>  3
>>> 10 12
>>> [276]  5  5  4  4  4  6  6  5 12  2  1  2 13 11  4 11 10 12 12 12  5 12
>>>  5
>>> 12 12
>>> [301]  6  6  6 12 12  3  2  3  2  1 12 12 12  5 12 12 12  9  9 12  6  6
>>>  6
>>> 12  2
>>> [326]  2 10 10 12 12 12 12 12 12  5  5 12 12 12 12  6  6  6  6  6  2  2
>>>  5
>>> 12 12
>>> [351] 12 12 12 12  9 12 12 12 12 12  6  6  6  6  6  6  6 12 12 12 12 12
>>> 12
>>> 9  5
>>> [376]  5 12 12  5 12  6  6  6  6  6  6  6  6 12 12 12 12 12  9  9 12  5
>>> 12
>>> 12 12
>>> [401]  6  6  6  6  6  6  5  9  5  5 12 12  9  9  9 12  9 12 12 12  6  6
>>>  6
>>> 6  6
>>> [426]  6  5  5  5 12  9  9 12  9 12 12  9 12 12 12 12  6  6  6 12 12  5
>>>  5
>>> 12  9
>>> [451]  5 12  6 12 12 12 12 12 12 12  6  6  5  6  5  5  5  5  5  5  5  5
>>> 12
>>> 12 12
>>> [476]  9  9  5  9  9 12  5  5  5  5  5  5  5  5  5  5 12 12 12 12  5  5
>>>  5
>>> 5 12
>>> [501]  5  9  5  5  5  5  5  5  5  5  5  5 12 12  5  5  5  5  9  5  5  5
>>>  5
>>> 5  5
>>> [526]  5  5  5  5  5  5  5  5  5  5  9 12  5  5  5  5  5  5  5  5  5  5
>>>  5
>>> 5  5
>>> [551]  5  5  5  9  5  5  5  5  9  5  5  5  5  5  5  5  5  5  5  9  9  5
>>>  5
>>> 5  5
>>> [576]  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  9
>>>  5
>>> 9  5
>>> > outcome.label<-intToChar(outcome.predict)
>>> > outcome.label
>>>  [1] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>>> "\004"
>>>  [11] "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004"
>>> "\004"
>>>  [21] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>>> "\004"
>>>  [31] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"
>>>  [41] "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004" "\004"
>>> "\004"
>>>  [51] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>>> "\004"
>>>  [61] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>>> "\004"
>>>  [71] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"
>>>  [81] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004"
>>> "\004"
>>>  [91] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004"
>>> "\004"
>>> [101] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>>> "\004"
>>> [111] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\a"
>>> [121] "\004" "\004" "\004" "\004" "\004" "\002" "\002" "\002" "\n"
>>> "\004"
>>> [131] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\a"   "\a"
>>> [141] "\004" "\004" "\004" "\004" "\004" "\n"   "\n"   "\r"   "\003" "\r"
>>> [151] "\002" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>>> "\004"
>>> [161] "\004" "\004" "\004" "\004" "\n"   "\003" "\r"   "\003" "\002"
>>> "\002"
>>> [171] "\v"   "\003" "\004" "\004" "\004" "\r"   "\004" "\004" "\004"
>>> "\004"
>>> [181] "\r"   "\r"   "\004" "\002" "\n"   "\r"   "\r"   "\002" "\003"
>>> "\003"
>>> [191] "\r"   "\n"   "\002" "\004" "\004" "\004" "\001" "\001" "\004"
>>> "\004"
>>> [201] "\r"   "\r"   "\002" "\002" "\r"   "\002" "\003" "\r"   "\r"
>>> "\002"
>>> [211] "\002" "\003" "\v"   "\r"   "\003" "\002" "\001" "\004" "\004"
>>> "\004"
>>> [221] "\r"   "\r"   "\r"   "\002" "\n"   "\n"   "\002" "\002" "\n"   "\v"
>>> [231] "\r"   "\r"   "\n"   "\n"   "\002" "\003" "\001" "\004" "\001"
>>> "\004"
>>> [241] "\r"   "\003" "\n"   "\n"   "\n"   "\r"   "\003" "\v"   "\v"   "\v"
>>> [251] "\n"   "\002" "\n"   "\003" "\005" "\005" "\004" "\004" "\004" "\v"
>>> [261] "\006" "\f"  

[R] lapply with functions with changing parameters

2010-06-01 Thread Bunny, lautloscrew.com
Dear all, 

I am trying to avoid a for loop here and wonder if the following is possible: 

I have a data.frame with 6 columns and i want to get a cross-correlogram (by 
using ccf) . Obivously ccf only accepts two columns at once and then returms a 
list. 
In fact, with a for loop i´d do the following


for (i in 1:6) {

 x[[i]]=ccf(mydf[,i],mydf[,6])


}

Is there any chance to the same with lapply? e.g. lapply(mydf,"ccf",  ) 
with ... respresenting the changing arguments for ccf functions (note only the 
first argument does actually change)

thx for any suggestions in advance

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] problem with intToChar

2010-06-01 Thread Erik Iverson



Changbin Du wrote:

It does not work.



outcome.label<-LETTERS(outcome.predict)

Error: could not find function "LETTERS"


That is not when Henrique typed.  LETTERS is a vector, and must be 
indexed as such, i.e., with "[]".


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

2010-06-01 Thread Sarah Goslee
That isn't really enough information to answer your question, since you
don't tell us where intToChar comes from or what you are trying to do,
but here are a couple of possibilities:

> ?intToChar
No documentation for 'intToChar' in specified packages and libraries:
you could try '??intToChar'
> testdata <- sample(1:6, 10, replace=TRUE)
> testdata
 [1] 5 3 2 5 6 3 4 5 4 4
> as.character(testdata)
 [1] "5" "3" "2" "5" "6" "3" "4" "5" "4" "4"
> letters[testdata]
 [1] "e" "c" "b" "e" "f" "c" "d" "e" "d" "d"

Sarah

On Tue, Jun 1, 2010 at 4:43 PM, Changbin Du  wrote:
> Hi, Dear R- community,
>
> I am use the intToChar function to convert the integers to letters. But the
> output is mess. Can you guys give some suggestions?   Thanks!
>
>> outcome.predict
>  [1]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4  4
> 4  4
>  [26]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4  7  4  4
> 4  4
>> outcome.label<-intToChar(outcome.predict)
>> outcome.label
>  [1] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>  [11] "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004" "\004"
>  [21] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>  [31] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"
> --
> Sincerely,
> Changbin
> --


-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] problem with intToChar

2010-06-01 Thread Changbin Du
It does not work.


> outcome.label<-LETTERS(outcome.predict)
Error: could not find function "LETTERS"



On Tue, Jun 1, 2010 at 1:48 PM, Henrique Dallazuanna wrote:

> Try this:
>
> LETTERS[outcome.predict]
>
> On Tue, Jun 1, 2010 at 5:43 PM, Changbin Du  wrote:
>
>> Hi, Dear R- community,
>>
>> I am use the intToChar function to convert the integers to letters. But
>> the
>> output is mess. Can you guys give some suggestions?   Thanks!
>>
>> > outcome.predict
>>  [1]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4  4
>> 4  4
>>  [26]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4  7  4  4
>> 4  4
>>  [51]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4
>> 4  4
>>  [76]  4  4  4  4  7  4  4  4  4  4  4  4  7  4  4  4  4  4  4  4  4  4  7
>> 4  4
>> [101]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  7  4  4  4
>> 4  4
>> [126]  2  2  2 10  4  4  4  4  4  4  4  4  7  7  7  4  4  4  4  4 10 10 13
>> 3 13
>> [151]  2  4  4  4  4  4  4  4  4  4  4  4  4  4 10  3 13  3  2  2 11  3  4
>> 4  4
>> [176] 13  4  4  4  4 13 13  4  2 10 13 13  2  3  3 13 10  2  4  4  4  1  1
>> 4  4
>> [201] 13 13  2  2 13  2  3 13 13  2  2  3 11 13  3  2  1  4  4  4 13 13 13
>> 2 10
>> [226] 10  2  2 10 11 13 13 10 10  2  3  1  4  1  4 13  3 10 10 10 13  3 11
>> 11 11
>> [251] 10  2 10  3  5  5  4  4  4 11  6 12  3 10  3  3  1  2  2 11  3  3  3
>> 10 12
>> [276]  5  5  4  4  4  6  6  5 12  2  1  2 13 11  4 11 10 12 12 12  5 12  5
>> 12 12
>> [301]  6  6  6 12 12  3  2  3  2  1 12 12 12  5 12 12 12  9  9 12  6  6  6
>> 12  2
>> [326]  2 10 10 12 12 12 12 12 12  5  5 12 12 12 12  6  6  6  6  6  2  2  5
>> 12 12
>> [351] 12 12 12 12  9 12 12 12 12 12  6  6  6  6  6  6  6 12 12 12 12 12 12
>> 9  5
>> [376]  5 12 12  5 12  6  6  6  6  6  6  6  6 12 12 12 12 12  9  9 12  5 12
>> 12 12
>> [401]  6  6  6  6  6  6  5  9  5  5 12 12  9  9  9 12  9 12 12 12  6  6  6
>> 6  6
>> [426]  6  5  5  5 12  9  9 12  9 12 12  9 12 12 12 12  6  6  6 12 12  5  5
>> 12  9
>> [451]  5 12  6 12 12 12 12 12 12 12  6  6  5  6  5  5  5  5  5  5  5  5 12
>> 12 12
>> [476]  9  9  5  9  9 12  5  5  5  5  5  5  5  5  5  5 12 12 12 12  5  5  5
>> 5 12
>> [501]  5  9  5  5  5  5  5  5  5  5  5  5 12 12  5  5  5  5  9  5  5  5  5
>> 5  5
>> [526]  5  5  5  5  5  5  5  5  5  5  9 12  5  5  5  5  5  5  5  5  5  5  5
>> 5  5
>> [551]  5  5  5  9  5  5  5  5  9  5  5  5  5  5  5  5  5  5  5  9  9  5  5
>> 5  5
>> [576]  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  9  5
>> 9  5
>> > outcome.label<-intToChar(outcome.predict)
>> > outcome.label
>>  [1] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>>  [11] "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004"
>> "\004"
>>  [21] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>> "\004"
>>  [31] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"
>>  [41] "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004" "\004"
>> "\004"
>>  [51] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>> "\004"
>>  [61] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>> "\004"
>>  [71] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"
>>  [81] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004"
>> "\004"
>>  [91] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004"
>> "\004"
>> [101] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>> "\004"
>> [111] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\a"
>> [121] "\004" "\004" "\004" "\004" "\004" "\002" "\002" "\002" "\n"
>> "\004"
>> [131] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\a"   "\a"
>> [141] "\004" "\004" "\004" "\004" "\004" "\n"   "\n"   "\r"   "\003" "\r"
>> [151] "\002" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>> "\004"
>> [161] "\004" "\004" "\004" "\004" "\n"   "\003" "\r"   "\003" "\002"
>> "\002"
>> [171] "\v"   "\003" "\004" "\004" "\004" "\r"   "\004" "\004" "\004"
>> "\004"
>> [181] "\r"   "\r"   "\004" "\002" "\n"   "\r"   "\r"   "\002" "\003"
>> "\003"
>> [191] "\r"   "\n"   "\002" "\004" "\004" "\004" "\001" "\001" "\004"
>> "\004"
>> [201] "\r"   "\r"   "\002" "\002" "\r"   "\002" "\003" "\r"   "\r"
>> "\002"
>> [211] "\002" "\003" "\v"   "\r"   "\003" "\002" "\001" "\004" "\004"
>> "\004"
>> [221] "\r"   "\r"   "\r"   "\002" "\n"   "\n"   "\002" "\002" "\n"   "\v"
>> [231] "\r"   "\r"   "\n"   "\n"   "\002" "\003" "\001" "\004" "\001"
>> "\004"
>> [241] "\r"   "\003" "\n"   "\n"   "\n"   "\r"   "\003" "\v"   "\v"   "\v"
>> [251] "\n"   "\002" "\n"   "\003" "\005" "\005" "\004" "\004" "\004" "\v"
>> [261] "\006" "\f"   "\003" "\n"   "\003" "\003" "\001" "\002" "\002" "\v"
>> [271] "\003" "\003" "\003" "\n"   "\f"   "\005" "\005" "\004" "\004"
>> "\004"
>> [281] "\006" "\006" "\005" "\f"   "\002" "\001" "\002" "\r"   "\v"
>> "\004"
>> [291] "\v"   "\n"   "\f"   "\f"   "\f"   "\005" "\f"   "\005" "\f"   "

Re: [R] Using R with Web services

2010-06-01 Thread Tal Galili
I refer to several resources on the subject here:
http://www.r-statistics.com/category/r-and-the-web/

But the first I would suggest you to look at is this:
http://www.r-statistics.com/2010/02/web-development-with-r-an-hd-video-tutorial-of-jeroen-ooms-talk/

It won't answer all of yor questions but would help you start out.


Best,
Tal


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




On Tue, Jun 1, 2010 at 10:05 PM, marcos carvajalino
wrote:

> Hello list helpers,
>
> I'm working at a research institute and I've been asked to develop a way of
> using R as a scripting and analysis tool which takes information from users
> via web forms, perform a query to an Oracle Database running on a Linux
> server and finally return formatted reports to the user via web. I'm sort
> of
> a newbie in web forms and web services so i've been reading about ROracle,
> RWeb and CGIwithR with little or no results so far, I need to know which is
> the easiest way of merging R with web services to solve my problem and if
> theres a manual or book that explains this kind of R use.
>
> Could someone enlighten me?
>
> Many thanks in advance and sorry for the typos...
> --
> Marcos Antonio Carvajalino Fernández
> Ingeniero Ambiental y Sanitario
> Santa Marta, Colombia
>
>[[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] Using R with Web services

2010-06-01 Thread Ista Zahn
Hi Marcos,
If your server is running Apache I highly recommend looking at RApache (see 
http://biostat.mc.vanderbilt.edu/rapache/).

This will not help with the database connection part though.

Best,
Ista
On Tuesday 01 June 2010 3:05:27 pm marcos carvajalino wrote:
> Hello list helpers,
> 
> I'm working at a research institute and I've been asked to develop a way of
> using R as a scripting and analysis tool which takes information from users
> via web forms, perform a query to an Oracle Database running on a Linux
> server and finally return formatted reports to the user via web. I'm sort
> of a newbie in web forms and web services so i've been reading about
> ROracle, RWeb and CGIwithR with little or no results so far, I need to
> know which is the easiest way of merging R with web services to solve my
> problem and if theres a manual or book that explains this kind of R use.
> 
> Could someone enlighten me?
> 
> Many thanks in advance and sorry for the typos...

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

2010-06-01 Thread Henrique Dallazuanna
Try this:

LETTERS[outcome.predict]

On Tue, Jun 1, 2010 at 5:43 PM, Changbin Du  wrote:

> Hi, Dear R- community,
>
> I am use the intToChar function to convert the integers to letters. But the
> output is mess. Can you guys give some suggestions?   Thanks!
>
> > outcome.predict
>  [1]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4  4
> 4  4
>  [26]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4  7  4  4
> 4  4
>  [51]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4
> 4  4
>  [76]  4  4  4  4  7  4  4  4  4  4  4  4  7  4  4  4  4  4  4  4  4  4  7
> 4  4
> [101]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  7  4  4  4
> 4  4
> [126]  2  2  2 10  4  4  4  4  4  4  4  4  7  7  7  4  4  4  4  4 10 10 13
> 3 13
> [151]  2  4  4  4  4  4  4  4  4  4  4  4  4  4 10  3 13  3  2  2 11  3  4
> 4  4
> [176] 13  4  4  4  4 13 13  4  2 10 13 13  2  3  3 13 10  2  4  4  4  1  1
> 4  4
> [201] 13 13  2  2 13  2  3 13 13  2  2  3 11 13  3  2  1  4  4  4 13 13 13
> 2 10
> [226] 10  2  2 10 11 13 13 10 10  2  3  1  4  1  4 13  3 10 10 10 13  3 11
> 11 11
> [251] 10  2 10  3  5  5  4  4  4 11  6 12  3 10  3  3  1  2  2 11  3  3  3
> 10 12
> [276]  5  5  4  4  4  6  6  5 12  2  1  2 13 11  4 11 10 12 12 12  5 12  5
> 12 12
> [301]  6  6  6 12 12  3  2  3  2  1 12 12 12  5 12 12 12  9  9 12  6  6  6
> 12  2
> [326]  2 10 10 12 12 12 12 12 12  5  5 12 12 12 12  6  6  6  6  6  2  2  5
> 12 12
> [351] 12 12 12 12  9 12 12 12 12 12  6  6  6  6  6  6  6 12 12 12 12 12 12
> 9  5
> [376]  5 12 12  5 12  6  6  6  6  6  6  6  6 12 12 12 12 12  9  9 12  5 12
> 12 12
> [401]  6  6  6  6  6  6  5  9  5  5 12 12  9  9  9 12  9 12 12 12  6  6  6
> 6  6
> [426]  6  5  5  5 12  9  9 12  9 12 12  9 12 12 12 12  6  6  6 12 12  5  5
> 12  9
> [451]  5 12  6 12 12 12 12 12 12 12  6  6  5  6  5  5  5  5  5  5  5  5 12
> 12 12
> [476]  9  9  5  9  9 12  5  5  5  5  5  5  5  5  5  5 12 12 12 12  5  5  5
> 5 12
> [501]  5  9  5  5  5  5  5  5  5  5  5  5 12 12  5  5  5  5  9  5  5  5  5
> 5  5
> [526]  5  5  5  5  5  5  5  5  5  5  9 12  5  5  5  5  5  5  5  5  5  5  5
> 5  5
> [551]  5  5  5  9  5  5  5  5  9  5  5  5  5  5  5  5  5  5  5  9  9  5  5
> 5  5
> [576]  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  9  5
> 9  5
> > outcome.label<-intToChar(outcome.predict)
> > outcome.label
>  [1] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>  [11] "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004" "\004"
>  [21] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>  [31] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"
>  [41] "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004" "\004" "\004"
>  [51] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>  [61] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
>  [71] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"
>  [81] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004"
>  [91] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004"
> [101] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
> [111] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\a"
> [121] "\004" "\004" "\004" "\004" "\004" "\002" "\002" "\002" "\n"   "\004"
> [131] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\a"   "\a"
> [141] "\004" "\004" "\004" "\004" "\004" "\n"   "\n"   "\r"   "\003" "\r"
> [151] "\002" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
> [161] "\004" "\004" "\004" "\004" "\n"   "\003" "\r"   "\003" "\002" "\002"
> [171] "\v"   "\003" "\004" "\004" "\004" "\r"   "\004" "\004" "\004" "\004"
> [181] "\r"   "\r"   "\004" "\002" "\n"   "\r"   "\r"   "\002" "\003" "\003"
> [191] "\r"   "\n"   "\002" "\004" "\004" "\004" "\001" "\001" "\004" "\004"
> [201] "\r"   "\r"   "\002" "\002" "\r"   "\002" "\003" "\r"   "\r"   "\002"
> [211] "\002" "\003" "\v"   "\r"   "\003" "\002" "\001" "\004" "\004" "\004"
> [221] "\r"   "\r"   "\r"   "\002" "\n"   "\n"   "\002" "\002" "\n"   "\v"
> [231] "\r"   "\r"   "\n"   "\n"   "\002" "\003" "\001" "\004" "\001" "\004"
> [241] "\r"   "\003" "\n"   "\n"   "\n"   "\r"   "\003" "\v"   "\v"   "\v"
> [251] "\n"   "\002" "\n"   "\003" "\005" "\005" "\004" "\004" "\004" "\v"
> [261] "\006" "\f"   "\003" "\n"   "\003" "\003" "\001" "\002" "\002" "\v"
> [271] "\003" "\003" "\003" "\n"   "\f"   "\005" "\005" "\004" "\004" "\004"
> [281] "\006" "\006" "\005" "\f"   "\002" "\001" "\002" "\r"   "\v"   "\004"
> [291] "\v"   "\n"   "\f"   "\f"   "\f"   "\005" "\f"   "\005" "\f"   "\f"
> [301] "\006" "\006" "\006" "\f"   "\f"   "\003" "\002" "\003" "\002" "\001"
> [311] "\f"   "\f"   "\f"   "\005" "\f"   "\f"   "\f"   "\t"   "\t"   "\f"
> [321] "\006" "\006" "\006" "\f"   "\002" "\002" "\n"   "\n"   "\f"   "\f"
> [331] "\f"   "\f"   "\f"   "\f"   "\005" "\005" "\f"   "\f"   "\f"   "\f"
> [341

[R] problem with intToChar

2010-06-01 Thread Changbin Du
Hi, Dear R- community,

I am use the intToChar function to convert the integers to letters. But the
output is mess. Can you guys give some suggestions?   Thanks!

> outcome.predict
  [1]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4  4
4  4
 [26]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  4  4  4  4  4  7  4  4
4  4
 [51]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4
4  4
 [76]  4  4  4  4  7  4  4  4  4  4  4  4  7  4  4  4  4  4  4  4  4  4  7
4  4
[101]  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  4  7  7  4  4  4
4  4
[126]  2  2  2 10  4  4  4  4  4  4  4  4  7  7  7  4  4  4  4  4 10 10 13
3 13
[151]  2  4  4  4  4  4  4  4  4  4  4  4  4  4 10  3 13  3  2  2 11  3  4
4  4
[176] 13  4  4  4  4 13 13  4  2 10 13 13  2  3  3 13 10  2  4  4  4  1  1
4  4
[201] 13 13  2  2 13  2  3 13 13  2  2  3 11 13  3  2  1  4  4  4 13 13 13
2 10
[226] 10  2  2 10 11 13 13 10 10  2  3  1  4  1  4 13  3 10 10 10 13  3 11
11 11
[251] 10  2 10  3  5  5  4  4  4 11  6 12  3 10  3  3  1  2  2 11  3  3  3
10 12
[276]  5  5  4  4  4  6  6  5 12  2  1  2 13 11  4 11 10 12 12 12  5 12  5
12 12
[301]  6  6  6 12 12  3  2  3  2  1 12 12 12  5 12 12 12  9  9 12  6  6  6
12  2
[326]  2 10 10 12 12 12 12 12 12  5  5 12 12 12 12  6  6  6  6  6  2  2  5
12 12
[351] 12 12 12 12  9 12 12 12 12 12  6  6  6  6  6  6  6 12 12 12 12 12 12
9  5
[376]  5 12 12  5 12  6  6  6  6  6  6  6  6 12 12 12 12 12  9  9 12  5 12
12 12
[401]  6  6  6  6  6  6  5  9  5  5 12 12  9  9  9 12  9 12 12 12  6  6  6
6  6
[426]  6  5  5  5 12  9  9 12  9 12 12  9 12 12 12 12  6  6  6 12 12  5  5
12  9
[451]  5 12  6 12 12 12 12 12 12 12  6  6  5  6  5  5  5  5  5  5  5  5 12
12 12
[476]  9  9  5  9  9 12  5  5  5  5  5  5  5  5  5  5 12 12 12 12  5  5  5
5 12
[501]  5  9  5  5  5  5  5  5  5  5  5  5 12 12  5  5  5  5  9  5  5  5  5
5  5
[526]  5  5  5  5  5  5  5  5  5  5  9 12  5  5  5  5  5  5  5  5  5  5  5
5  5
[551]  5  5  5  9  5  5  5  5  9  5  5  5  5  5  5  5  5  5  5  9  9  5  5
5  5
[576]  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  5  9  5
9  5
> outcome.label<-intToChar(outcome.predict)
> outcome.label
  [1] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 [11] "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004" "\004"
 [21] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 [31] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"
 [41] "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004" "\004" "\004"
 [51] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 [61] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
 [71] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"
 [81] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004"
 [91] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\004" "\004"
[101] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
[111] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\a"
[121] "\004" "\004" "\004" "\004" "\004" "\002" "\002" "\002" "\n"   "\004"
[131] "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\a"   "\a"   "\a"
[141] "\004" "\004" "\004" "\004" "\004" "\n"   "\n"   "\r"   "\003" "\r"
[151] "\002" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004" "\004"
[161] "\004" "\004" "\004" "\004" "\n"   "\003" "\r"   "\003" "\002" "\002"
[171] "\v"   "\003" "\004" "\004" "\004" "\r"   "\004" "\004" "\004" "\004"
[181] "\r"   "\r"   "\004" "\002" "\n"   "\r"   "\r"   "\002" "\003" "\003"
[191] "\r"   "\n"   "\002" "\004" "\004" "\004" "\001" "\001" "\004" "\004"
[201] "\r"   "\r"   "\002" "\002" "\r"   "\002" "\003" "\r"   "\r"   "\002"
[211] "\002" "\003" "\v"   "\r"   "\003" "\002" "\001" "\004" "\004" "\004"
[221] "\r"   "\r"   "\r"   "\002" "\n"   "\n"   "\002" "\002" "\n"   "\v"
[231] "\r"   "\r"   "\n"   "\n"   "\002" "\003" "\001" "\004" "\001" "\004"
[241] "\r"   "\003" "\n"   "\n"   "\n"   "\r"   "\003" "\v"   "\v"   "\v"
[251] "\n"   "\002" "\n"   "\003" "\005" "\005" "\004" "\004" "\004" "\v"
[261] "\006" "\f"   "\003" "\n"   "\003" "\003" "\001" "\002" "\002" "\v"
[271] "\003" "\003" "\003" "\n"   "\f"   "\005" "\005" "\004" "\004" "\004"
[281] "\006" "\006" "\005" "\f"   "\002" "\001" "\002" "\r"   "\v"   "\004"
[291] "\v"   "\n"   "\f"   "\f"   "\f"   "\005" "\f"   "\005" "\f"   "\f"
[301] "\006" "\006" "\006" "\f"   "\f"   "\003" "\002" "\003" "\002" "\001"
[311] "\f"   "\f"   "\f"   "\005" "\f"   "\f"   "\f"   "\t"   "\t"   "\f"
[321] "\006" "\006" "\006" "\f"   "\002" "\002" "\n"   "\n"   "\f"   "\f"
[331] "\f"   "\f"   "\f"   "\f"   "\005" "\005" "\f"   "\f"   "\f"   "\f"
[341] "\006" "\006" "\006" "\006" "\006" "\002" "\002" "\005" "\f"   "\f"
[351] "\f"   "\f"   "\f"   "\f"   "\t"   "\f"   "\f"   "\f"   "\f"   "\f"
[361] "\006" "\006" "\006" "\006" "\006" "\006" "\006" "\f"   "\f"   "\f"
[371] "\f"   "\f"   "\f"   "\t"   "\005" "\005" "\

Re: [R] When normality test violate and sample size is large(n=400) can I use t-test

2010-06-01 Thread Robert A LaBudde

At 11:45 AM 6/1/2010, Kourosh Ks wrote:

Dears
 When normality test  violate and sample size is large(n=400) can I 
use t-test?

best gards kourosh


Generally "yes", unless there is something really pathological about 
the distribution.


You should note that, for n = 400, even the simplest 
distribution-free tests should have near perfect power, so which test 
you use is not important.



Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: r...@lcfltd.com
Least Cost Formulations, Ltd.URL: http://lcfltd.com/
824 Timberlake Drive Tel: 757-467-0954
Virginia Beach, VA 23464-3239Fax: 757-467-2947

"Vere scire est per causas scire"

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


Re: [R] regexpr help (match.length=0)

2010-06-01 Thread Erik Iverson



McGehee, Robert wrote:

R-help,
Sorry if this is more of a regex question than an R question. However,
help would be appreciated on my use of the regexpr function.

In the first example below, I ask for all characters (a-z) in 'abc123';
regexpr returns a 3-character match beginning at the first character. 


regexpr("[[:alpha:]]*", "abc123")

[1] 1
attr(,"match.length")
[1] 3

However, when the text is flipped regexpr, and I ask for a match of all
characters in '123abc', regexpr returns a zero-character match beginning
at the first character. Can someone explain what a zero length match
means (i.e. why not return -1), and why the result isn't 4,
match.length=3?


It means it matches 0 characters, which is fine since you use *, which 
means match 0 or more occurrences of the regex.  It sounds like you want 
+ instead of *.  Also see gregexpr.



regexpr("[[:alpha:]]*", "123abc")

[1] 1
attr(,"match.length")
[1] 0



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


[R] Reading file

2010-06-01 Thread Robert Tsutakawa
I am trying to read a source program into a mac pro laptop, which uses  
Snow Leopard.  R is unable to find the file containing my source  
program.  I'm using the function  source(" file name").  I need some  
examples or detailed instructions.  I have no problem reading the file  
using PC.

Bob

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] regexpr help (match.length=0)

2010-06-01 Thread McGehee, Robert
R-help,
Sorry if this is more of a regex question than an R question. However,
help would be appreciated on my use of the regexpr function.

In the first example below, I ask for all characters (a-z) in 'abc123';
regexpr returns a 3-character match beginning at the first character. 

> regexpr("[[:alpha:]]*", "abc123")
[1] 1
attr(,"match.length")
[1] 3

However, when the text is flipped regexpr, and I ask for a match of all
characters in '123abc', regexpr returns a zero-character match beginning
at the first character. Can someone explain what a zero length match
means (i.e. why not return -1), and why the result isn't 4,
match.length=3?

> regexpr("[[:alpha:]]*", "123abc")
[1] 1
attr(,"match.length")
[1] 0

Thanks, Robert

> R.version
   _
platform   x86_64-apple-darwin9.8.0
arch   x86_64
os darwin9.8.0
system x86_64, darwin9.8.0
status Patched
major  2
minor  11.0
year   2010
month  05
day11
svn rev51984
language   R
version.string R version 2.11.0 Patched (2010-05-11 r51984)

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


[R] Using R with Web services

2010-06-01 Thread marcos carvajalino
Hello list helpers,

I'm working at a research institute and I've been asked to develop a way of
using R as a scripting and analysis tool which takes information from users
via web forms, perform a query to an Oracle Database running on a Linux
server and finally return formatted reports to the user via web. I'm sort of
a newbie in web forms and web services so i've been reading about ROracle,
RWeb and CGIwithR with little or no results so far, I need to know which is
the easiest way of merging R with web services to solve my problem and if
theres a manual or book that explains this kind of R use.

Could someone enlighten me?

Many thanks in advance and sorry for the typos...
-- 
Marcos Antonio Carvajalino Fernández
Ingeniero Ambiental y Sanitario
Santa Marta, Colombia

[[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] When normality test violate and sample size is large(n=400) can I use t-test

2010-06-01 Thread Kourosh Ks
Dears
 When normality test  violate and sample size is large(n=400) can I use t-test?
best gards kourosh


  
[[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] Problem using apply

2010-06-01 Thread Joachim de Lezardiere
Thank you Henrique, 

 

I still don’t understand why my code doesn’t work ?  According to the
definition of apply function it should work no ?

 

From: Henrique Dallazuanna [mailto:www...@gmail.com] 
Sent: Tuesday, June 01, 2010 7:34 PM
To: Joachim de Lezardiere
Cc: r-help@r-project.org
Subject: Re: [R] Problem using apply

 

The mean by col and by row are the same:

colMeans(m) == rowMeans(m)

So:

m / rowMeans(m) # You don't need apply here
m / colMeans(m)

On Tue, Jun 1, 2010 at 2:26 PM, Joachim de Lezardiere
 wrote:

Hello ,



I can not get apply function to do what I want when doing stuff on rows.
Let's say I want to divide the rows of matrix by their mean, the below show
you get the same result weather you use 1 or 2, i.e. same result for columns
than for means..:(



Thanks a lot for the help,







m = matrix( c(1,4,7,4,5,8,7,8,9), nrow = 3 )



divideByMean  = function( v ){

return( v/mean(v))

}



rowMean = c( mean( m[1,]),mean( m[2,]),mean( m[3,]) )

rowMean



colMean = c( mean( m[,1]),mean( m[,2]),mean( m[,3]) )

colMean



m

print("ByRow")

apply( m, 1, divideByMean)



print("ByCol")

apply( m, 2, divideByMean)








   [[alternative HTML version deleted]]

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




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


[[alternative HTML version deleted]]

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


Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
Maybe not the cleanest way, but I create a fake data frame with one row so
ddply() is happy!!
> if (nrow(futures)==0) futures<-data.frame(...)





> -Original Message-
> From: Peter Ehlers [mailto:ehl...@ucalgary.ca]
> Sent: Tuesday, June 01, 2010 12:07 PM
> To: arnaud Gaboury
> Cc: 'Prof Brian Ripley'; r-help@r-project.org
> Subject: Re: [R] data frame manipulation with zero rows
> 
> On 2010-06-01 1:53, arnaud Gaboury wrote:
> > Brian,
> >
> > If I do understand correctly, I must use in my function something
> else than
> > ddply() if I want to avoid any error each time my df has zero rows?
> > Am I correct?
> >
> 
> You could define a function to handle the zero-rows case:
> 
> f <- function(x){
>   if(nrow(x) < 1) out <- x[, c(1,3,2)]  # or whatever
>   else
> out <- ddply(x, c("DESCRIPTION","SETTLEMENT"), summarise,
>  POSITION=sum(QUANTITY))[,c(1,3,2)]
>   out
> }
> f(futures)
> 
>   -Peter Ehlers
> 
> >
> >
> >> -Original Message-
> >> From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
> >> Sent: Tuesday, June 01, 2010 9:47 AM
> >> To: arnaud Gaboury
> >> Subject: Re: [R] data frame manipulation with zero rows
> >>
> >> On Tue, 1 Jun 2010, arnaud Gaboury wrote:
> >>
> >>> Dear group,
> >>>
> >>> Here is the kind of data.frame I obtain every day with my function
> :
> >>>
> >>> futures<-
> >>> structure(list(DESCRIPTION = c("CORN Jul/10", "CORN Jul/10",
> >>> "CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "LIVE CATTLE Aug/10",
> >>> "LIVE CATTLE Aug/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10",
> >>> "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10"
> >>> ), CREATED.DATE = structure(c(18403, 18406, 18406, 18406, 18406,
> >>> 18407, 18408, 18406, 18407, 18407, 18407, 18407), class = "Date"),
> >>> QUANTITY = c(1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1), SETTLEMENT =
> >>> c("373.2500",
> >>> "373.2500", "373.2500", "373.2500", "373.2500", "90.7750",
> >>> "90.7750", "14.9200", "14.9200", "14.9200", "14.9200",
> "14.9200"
> >>> )), .Names = c("DESCRIPTION", "CREATED.DATE", "QUANTITY",
> >>> "SETTLEMENT"), row.names = c(NA, 12L), class = "data.frame")
> >>>
> >>> I need then to apply to the df this following code line :
> >>>
>  PosFut=ddply(futures, c("DESCRIPTION","SETTLEMENT"), summarise,
> >> POSITION=
> >>> sum(QUANTITY))[,c(1,3,2)]
> >>>
> >>> It works perfectly in most of case, BUT I have a new problem: it
> can
> >>> sometime occurs that my df "futures" is empty, with zero rows.
> >>>
> >>>
> >>> futures<-
> >>> structure(list(DESCRIPTION = character(0), CREATED.DATE =
> >>> structure(numeric(0), class = "Date"),
> >>> QUANTITY = numeric(0), SETTLEMENT = character(0)), .Names =
> >>> c("DESCRIPTION",
> >>> "CREATED.DATE", "QUANTITY", "SETTLEMENT"), row.names = integer(0),
> >> class =
> >>> "data.frame")
> >>>
> >>> It is not the usual case, but it can happen. With this df, when I
> >> pass the
> >>> above mentione line, I get an error :
> >>>
>  PosFut=ddply(futures, c("DESCRIPTION","SETTLEMENT"), summarise,
> >> POSITION=
> >>> sum(QUANTITY))[,c(1,3,2)]
> >>> Error in tapply(1:nrow(data), splitv, list) :
> >>>   arguments must have same length
> >>>
> >>>
> >>> How can I avoid this when my df is empty?
> >>
> >> Ask the author of the (missing) function ddply() to correct the
> error
> >> of using 1:nrow(data) by replacing it by seq_len(nrow(data)).
> >>
> >> It's helpful to give example code, but much more helpful if you test
> >> it: yours cannot work without the function ddply() -- this is what
> >> 'self-contained' means in the footer here.
> >>
> >>
> >>>
> >>> Any help is appreciated
> >>>
> >>> __
> >>> R-help@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide http://www.R-project.org/posting-
> >> guide.html
> >>> and provide commented, minimal, self-contained, reproducible code.
> >>
> >>
> >> --
> >> Brian D. Ripley,  rip...@stats.ox.ac.uk
> >> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> >> University of Oxford, Tel:  +44 1865 272861 (self)
> >> 1 South Parks Road, +44 1865 272866 (PA)
> >> Oxford OX1 3TG, UKFax:  +44 1865 272595
> >

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

2010-06-01 Thread array chip
Hi, I am wondering if there is a way to extract studentized residues from a 
nls() object? I searched archive, someone posted a similar question before 
(http://tolstoy.newcastle.edu.au/R/e6/help/09/04/10845.html), but didn't get an 
answer.

Thanks for any suggestions,

John

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


Re: [R] R on the iPhone/iPad? Not so much....a GPL violation

2010-06-01 Thread Ken Williams
Hi Marc,

I want to debate a couple points from your post:

> 1. Distribution of GPL covered applications is not permissible via the App

> Store due to the Apple Terms of Service language, which infringes upon
rights
> granted under the GPL.
>
> 'Nuff said.

I'm not sure I agree with this, but there's so much wiggle room in
interpreting what the GPL means that there would probably be no way to
decide without a courtroom & judge, so I'll leave this part alone. =)  I
also haven't yet read your other post where you discuss this.

> 3.3.1Applications may only use Documented APIs in the manner
prescribed by
> Apple and must not use or call any private APIs.

I believe that language only refers to *Apple's* APIs.  In other words, they
don't want you to call hidden functions that aren't supposed to be exposed
to developers.  If it meant no use of any APIs private to the developer, it
would rule out pretty much every application in existence, considering that
a call from one function to any other is an API call.

> However, the beta release of the 4.x version of the iPhone SDK has the
> following language in the same section:
>
> 3.3.1 — Applications may only use Documented APIs in the manner prescribed
by
> Apple and must not use or call any private APIs. Applications must be
> originally written in Objective-C, C, C++, or JavaScript as executed by
the
> iPhone OS WebKit engine, and only code written in C, C++, and Objective-C
may
> compile and directly link against the Documented APIs (e.g., Applications
that
> link to Documented APIs through an intermediary translation or
compatibility
> layer or tool are prohibited).

Here again I believe the "private" API language refers to
unsanctioned-but-exposed pieces of Apple's platform that you're not supposed
to touch.  The language restrictions I interpret to mean that if you call
their Official API hooks, you must do it from one of the Official Languages.

However, FORTRAN code will never call Apple's API hooks, it just does its
little matrixy/FFT/etc. stuff and returns the results.  In the call stack,
FORTRAN is always a dead end.  It doesn't call Apple's APIs, and it doesn't
call a translation layer that calls Apple's APIs.  So again, R may be in the
clear here, under this interpretation.

Note that Java & Flash applications, under this interpretation, are *NOT* in
the clear, because they do call GUI APIs (among others).

> 3.3.2An Application may not itself install or launch other executable
code
> by any means, including without limitation through the use of a plug-in
> architecture, calling other frameworks, other APIs or otherwise. No
> interpreted code may be downloaded or used in an Application except for
code
> that is interpreted and run by Apple's Documented APIs and built-in
> interpreter(s).

I think this indeed pretty effectively rules out installation of packages
from CRAN, which is a bummer - unless those modules are downloaded &
installed through the app store.  Not sure if that would even work though,
since they're not apps.

As for the "interpreted code" stuff, there's so much murkiness about what
constitutes interpreted code that I don't know if this is a deal-breaker or
not.  At one extreme, it could prohibit pressing buttons in an app and then
"interpreting" those presses as commands for the app to "do something."  At
the other extreme,  Somewhere in the middle, it would seem to cover language
translation apps.  The notion of "interpreted" is just not very
well-defined.  For instance, most people think of Perl as an interpreted
language, but it compiles to bytecode before executing just like Java (it
just doesn't typically save it to a bytecode file).

Finally, I do agree with the general tone implied in your post - it is a
major major hassle that Apple's overlords control the distribution channel
for software on non-jailbroken iDevices.  I don't like it at all, for the
exact reason that people like you & me & the rest of the world now have to
sit around speculating whether our helpful apps will pass muster with the
cabal.

 -Ken

[[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] textbox in lattice

2010-06-01 Thread Erik Iverson



Noah Silverman wrote:

That's amazing.  (It would have taken me many hours to figure this out
on my own.)

Two quick last questions and then I'm off to plotting:
1) How can I reduce the font size of the table. (It is huge on my plot.)
2) How can I control the ratio of "plot area" to "table area" in the grid?


For 1), you usually specify something like

textGrob(... , gp = gpar(cex = .8))

For 2), you may have to use something other than arrange, like creating 
your own grid viewport and using grid.layout.


For the long term, I would suggest getting a copy of the book 'R 
Graphics', which will get you very familiar with all these concepts and 
much more!


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


Re: [R] textbox in lattice

2010-06-01 Thread baptiste auguie
On 1 June 2010 21:12, Noah Silverman  wrote:
> That's amazing.  (It would have taken me many hours to figure this out
> on my own.)
>
> Two quick last questions and then I'm off to plotting:
> 1) How can I reduce the font size of the table. (It is huge on my plot.)

try this,

grid.table(head(iris), gp=gpar(cex = 0.5), padding.h = unit(1, "mm"),
padding.v = unit(1, "mm"))

You can also fine tune individually the header vs. core text elements.
Try reading ?tableGrob and ?gpar
> 2) How can I control the ratio of "plot area" to "table area" in the grid?

If you decide to use arrange() rather than lower-level Grid functions,
you can use the heights argument. "null" units give you control over
the relative size of the two objects on the page,

unit(c(3,1),"null")

means that the first object (plot) will take up 3 times more space in
the vertical direction than the table. For more control, see
?grid.layout ?viewport etc.

baptiste

>
> Thanks a million!
>
> -N
>
>
> On 6/1/10 12:07 PM, baptiste auguie wrote:
>> Please do read the posting guide, in particular regarding reproducible 
>> examples.
>>
>> You can use a Grid layout to place the lattice plot and a table in the
>> same page. For example,
>>
>> library(lattice)
>>  library(coda)
>>  library(gridExtra)
>>    x <- matrix(runif(2200),ncol=22)
>>    m <- as.mcmc(x)
>>   p = xyplot(m, layout = c(2, 11))
>>
>>  pdf(,height=15)
>>  arrange(p, tableGrob(as.matrix(summary(iris)), theme=theme.white()),
>> heights= unit(c(3,1),"null"))
>>  dev.off()
>>
>> HTH,
>>
>> baptiste
>> On 1 June 2010 20:52, Noah Silverman  wrote:
>>
>>> Hi,
>>>
>>> It is a matrix.  Exactly the output of summary(foo)
>>>
>>> Would you call the gridExtra command before the xyplot command or after?
>>>
>>> Now I have:
>>>
>>> temp <- as.mcmc(foo)
>>> xyplot(temp, layout=c(2,11), main="plot title")
>>>
>>>
>>> THANKS!!
>>>
>>>
>>> On 6/1/10 11:35 AM, baptiste auguie wrote:
>>>
 Hi,

 It's not clear what you mean by summary text without a minimal
 reproducible example. If your text is ordered as a matrix or a
 data.frame, you might want to try this grid function,

 gridExtra::grid.table(as.matrix(summary(iris)), theme=theme.white())

 If your text has the form of a paragraph, the RGraphics::splitTextGrob
 function might help.

 HTH,

 baptiste



 On 1 June 2010 19:37, Noah Silverman  wrote:


> Hi,
>
> I want to add a box at the bottom of a lattice window (device/page?).
>
> Lattice has drawn a nice group of panels with all the plots I need.  How
> do I add my own summary text at the bottom (several lines worth?)
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] textbox in lattice

2010-06-01 Thread Noah Silverman
That's amazing.  (It would have taken me many hours to figure this out
on my own.)

Two quick last questions and then I'm off to plotting:
1) How can I reduce the font size of the table. (It is huge on my plot.)
2) How can I control the ratio of "plot area" to "table area" in the grid?

Thanks a million!

-N


On 6/1/10 12:07 PM, baptiste auguie wrote:
> Please do read the posting guide, in particular regarding reproducible 
> examples.
>
> You can use a Grid layout to place the lattice plot and a table in the
> same page. For example,
>
> library(lattice)
>  library(coda)
>  library(gridExtra)
>x <- matrix(runif(2200),ncol=22)
>m <- as.mcmc(x)
>   p = xyplot(m, layout = c(2, 11))
>
>  pdf(,height=15)
>  arrange(p, tableGrob(as.matrix(summary(iris)), theme=theme.white()),
> heights= unit(c(3,1),"null"))
>  dev.off()
>
> HTH,
>
> baptiste
> On 1 June 2010 20:52, Noah Silverman  wrote:
>   
>> Hi,
>>
>> It is a matrix.  Exactly the output of summary(foo)
>>
>> Would you call the gridExtra command before the xyplot command or after?
>>
>> Now I have:
>>
>> temp <- as.mcmc(foo)
>> xyplot(temp, layout=c(2,11), main="plot title")
>>
>>
>> THANKS!!
>>
>>
>> On 6/1/10 11:35 AM, baptiste auguie wrote:
>> 
>>> Hi,
>>>
>>> It's not clear what you mean by summary text without a minimal
>>> reproducible example. If your text is ordered as a matrix or a
>>> data.frame, you might want to try this grid function,
>>>
>>> gridExtra::grid.table(as.matrix(summary(iris)), theme=theme.white())
>>>
>>> If your text has the form of a paragraph, the RGraphics::splitTextGrob
>>> function might help.
>>>
>>> HTH,
>>>
>>> baptiste
>>>
>>>
>>>
>>> On 1 June 2010 19:37, Noah Silverman  wrote:
>>>
>>>   
 Hi,

 I want to add a box at the bottom of a lattice window (device/page?).

 Lattice has drawn a nice group of panels with all the plots I need.  How
 do I add my own summary text at the bottom (several lines worth?)

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

2010-06-01 Thread baptiste auguie
Please do read the posting guide, in particular regarding reproducible examples.

You can use a Grid layout to place the lattice plot and a table in the
same page. For example,

library(lattice)
 library(coda)
 library(gridExtra)
   x <- matrix(runif(2200),ncol=22)
   m <- as.mcmc(x)
  p = xyplot(m, layout = c(2, 11))

 pdf(,height=15)
 arrange(p, tableGrob(as.matrix(summary(iris)), theme=theme.white()),
heights= unit(c(3,1),"null"))
 dev.off()

HTH,

baptiste
On 1 June 2010 20:52, Noah Silverman  wrote:
> Hi,
>
> It is a matrix.  Exactly the output of summary(foo)
>
> Would you call the gridExtra command before the xyplot command or after?
>
> Now I have:
>
> temp <- as.mcmc(foo)
> xyplot(temp, layout=c(2,11), main="plot title")
>
>
> THANKS!!
>
>
> On 6/1/10 11:35 AM, baptiste auguie wrote:
>> Hi,
>>
>> It's not clear what you mean by summary text without a minimal
>> reproducible example. If your text is ordered as a matrix or a
>> data.frame, you might want to try this grid function,
>>
>> gridExtra::grid.table(as.matrix(summary(iris)), theme=theme.white())
>>
>> If your text has the form of a paragraph, the RGraphics::splitTextGrob
>> function might help.
>>
>> HTH,
>>
>> baptiste
>>
>>
>>
>> On 1 June 2010 19:37, Noah Silverman  wrote:
>>
>>> Hi,
>>>
>>> I want to add a box at the bottom of a lattice window (device/page?).
>>>
>>> Lattice has drawn a nice group of panels with all the plots I need.  How
>>> do I add my own summary text at the bottom (several lines worth?)
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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] textbox in lattice

2010-06-01 Thread Noah Silverman
Hi,

It is a matrix.  Exactly the output of summary(foo)

Would you call the gridExtra command before the xyplot command or after?

Now I have:

temp <- as.mcmc(foo)
xyplot(temp, layout=c(2,11), main="plot title")


THANKS!!


On 6/1/10 11:35 AM, baptiste auguie wrote:
> Hi,
>
> It's not clear what you mean by summary text without a minimal
> reproducible example. If your text is ordered as a matrix or a
> data.frame, you might want to try this grid function,
>
> gridExtra::grid.table(as.matrix(summary(iris)), theme=theme.white())
>
> If your text has the form of a paragraph, the RGraphics::splitTextGrob
> function might help.
>
> HTH,
>
> baptiste
>
>
>
> On 1 June 2010 19:37, Noah Silverman  wrote:
>   
>> Hi,
>>
>> I want to add a box at the bottom of a lattice window (device/page?).
>>
>> Lattice has drawn a nice group of panels with all the plots I need.  How
>> do I add my own summary text at the bottom (several lines worth?)
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] textbox in lattice

2010-06-01 Thread baptiste auguie
Hi,

It's not clear what you mean by summary text without a minimal
reproducible example. If your text is ordered as a matrix or a
data.frame, you might want to try this grid function,

gridExtra::grid.table(as.matrix(summary(iris)), theme=theme.white())

If your text has the form of a paragraph, the RGraphics::splitTextGrob
function might help.

HTH,

baptiste



On 1 June 2010 19:37, Noah Silverman  wrote:
> Hi,
>
> I want to add a box at the bottom of a lattice window (device/page?).
>
> Lattice has drawn a nice group of panels with all the plots I need.  How
> do I add my own summary text at the bottom (several lines worth?)
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Plot multiple columns

2010-06-01 Thread Noah Silverman
Another thought I had was to use Sweave.

I could, in theory, use Sweave to create a plot only 7 inches high, and
then a summary table 4 inches high below it, all on the same page of a
Latex document.  Could be messy, but might work.



On 6/1/10 11:18 AM, Dennis Murphy wrote:
>
>
> On Tue, Jun 1, 2010 at 10:51 AM, Noah Silverman
> mailto:n...@smartmediacorp.com>> wrote:
>
> You are correct,
>
> I initially missed the "as.mcmc" step.  Without it, R doesn't want
> to squeeze so many plots onto a page. 
>
>
> I've had that problem before with lattice...which makes me wonder
> whether you'll be able to put the plots
> and table on a single page. Here are some haphazard thoughts:
>
>   * The gplots package has functions textplot and sinkplot which IIRC
> will allow you to add a table to a plot.
>  I think you need to use layout() in base graphics to set it up
> properly, but you'd need to get 22 graphs
>  and a table on one graphics page...
>   * Given the number of graphs you want per page, perhaps sparkline
> plots might be less wasteful
> of space (see the YaleToolkit package for one approach to sparklines)
>   * The problem is the time it would take to coordinate all of this...
>   * In a similar vein, there's always grid... :)
>
> Hopefully Deepayan or Felix Andrews can share some of their Lattice
> wisdom and show us how to
> do what you want in their system. That would be the most convenient
> solution.
>
> Dennis
>
>
> Thanks!
>
>
> On 6/1/10 10:48 AM, Dennis Murphy wrote:
>> Hi:
>>
>> Ben's example worked for me as follows:
>>
>> x <- matrix(runif(22000),ncol=22)
>> library(lattice)
>> library(coda)
>> m <- as.mcmc(x)
>> xyplot(m, layout = c(2, 11))
>>
>> layout =  uses columns first, then rows...I always forget that
>> :)  It also has an optional
>> third argument for pages, which might come in handy here. If you
>> want the order of the
>> panels to be reversed, use the additional option as.table = TRUE.
>>
>> HTH,
>> Dennis
>>
>> On Tue, Jun 1, 2010 at 9:37 AM, Noah Silverman
>> mailto:n...@smartmediacorp.com>> wrote:
>>
>> Hi,
>>
>> I used the term "run", as each iteration of the Gibbs sampler
>> produces
>> 22 variables (coefficients for Beta in a regression model)
>>
>>
>> The example wont work
>>
>>
>> On 6/1/10 5:54 AM, Ben Bolker wrote:
>> > Noah Silverman  smartmediacorp.com
>> > writes:
>> >
>> >
>> >> I'm running a long MCMC chain that is generating samples
>> for 22 variables.
>> >>
>> >> I have each run of the chain as a row in a matrix.
>> >>
>> >
>> >> So:  Chain[,1] is the column with all the samples for
>> variable one.
>> >> Chain[,2] is the column with all the samples for variable
>> 2, etc.
>> >>
>> >   The previous 2 paragraphs seemed contradictory until I
>> realized
>> > that in the first paragraph you are using "run" to mean
>> what I would
>> > usually call a "sample" ...
>> >
>> >
>> >> I'd like to fit all 22 on a single page to print a nice
>> summary.  It is
>> >> OK if the graphs are small, I just need to show the
>> overall shape and
>> >> convergence.
>> >>
>> >   How about for example
>> >
>> >
>> >> x <- matrix(runif(22000),ncol=22)
>> >> library(coda)
>> >> m <- as.mcmc(x)
>> >> xyplot(m)
>> >> xyplot(m,layout=c(4,6))
>> >>
>> > __
>> > R-help@r-project.org  mailing list
>> > https://stat.ethz.ch/mailman/listinfo/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.
>>
>>
>

[[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] Plot multiple columns

2010-06-01 Thread Noah Silverman
You are correct,

I initially missed the "as.mcmc" step.  Without it, R doesn't want to
squeeze so many plots onto a page. 

Thanks!

On 6/1/10 10:48 AM, Dennis Murphy wrote:
> Hi:
>
> Ben's example worked for me as follows:
>
> x <- matrix(runif(22000),ncol=22)
> library(lattice)
> library(coda)
> m <- as.mcmc(x)
> xyplot(m, layout = c(2, 11))
>
> layout =  uses columns first, then rows...I always forget that :)  It
> also has an optional
> third argument for pages, which might come in handy here. If you want
> the order of the
> panels to be reversed, use the additional option as.table = TRUE.
>
> HTH,
> Dennis
>
> On Tue, Jun 1, 2010 at 9:37 AM, Noah Silverman
> mailto:n...@smartmediacorp.com>> wrote:
>
> Hi,
>
> I used the term "run", as each iteration of the Gibbs sampler produces
> 22 variables (coefficients for Beta in a regression model)
>
>
> The example wont work
>
>
> On 6/1/10 5:54 AM, Ben Bolker wrote:
> > Noah Silverman  smartmediacorp.com
> > writes:
> >
> >
> >> I'm running a long MCMC chain that is generating samples for 22
> variables.
> >>
> >> I have each run of the chain as a row in a matrix.
> >>
> >
> >> So:  Chain[,1] is the column with all the samples for variable one.
> >> Chain[,2] is the column with all the samples for variable 2, etc.
> >>
> >   The previous 2 paragraphs seemed contradictory until I realized
> > that in the first paragraph you are using "run" to mean what I would
> > usually call a "sample" ...
> >
> >
> >> I'd like to fit all 22 on a single page to print a nice
> summary.  It is
> >> OK if the graphs are small, I just need to show the overall
> shape and
> >> convergence.
> >>
> >   How about for example
> >
> >
> >> x <- matrix(runif(22000),ncol=22)
> >> library(coda)
> >> m <- as.mcmc(x)
> >> xyplot(m)
> >> xyplot(m,layout=c(4,6))
> >>
> > __
> > R-help@r-project.org  mailing list
> > https://stat.ethz.ch/mailman/listinfo/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.
>
>

[[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] Plot multiple columns

2010-06-01 Thread Dennis Murphy
Hi:

Ben's example worked for me as follows:

x <- matrix(runif(22000),ncol=22)
library(lattice)
library(coda)
m <- as.mcmc(x)
xyplot(m, layout = c(2, 11))

layout =  uses columns first, then rows...I always forget that :)  It also
has an optional
third argument for pages, which might come in handy here. If you want the
order of the
panels to be reversed, use the additional option as.table = TRUE.

HTH,
Dennis

On Tue, Jun 1, 2010 at 9:37 AM, Noah Silverman wrote:

> Hi,
>
> I used the term "run", as each iteration of the Gibbs sampler produces
> 22 variables (coefficients for Beta in a regression model)
>
>
> The example wont work
>
>
> On 6/1/10 5:54 AM, Ben Bolker wrote:
> > Noah Silverman  smartmediacorp.com> writes:
> >
> >
> >> I'm running a long MCMC chain that is generating samples for 22
> variables.
> >>
> >> I have each run of the chain as a row in a matrix.
> >>
> >
> >> So:  Chain[,1] is the column with all the samples for variable one.
> >> Chain[,2] is the column with all the samples for variable 2, etc.
> >>
> >   The previous 2 paragraphs seemed contradictory until I realized
> > that in the first paragraph you are using "run" to mean what I would
> > usually call a "sample" ...
> >
> >
> >> I'd like to fit all 22 on a single page to print a nice summary.  It is
> >> OK if the graphs are small, I just need to show the overall shape and
> >> convergence.
> >>
> >   How about for example
> >
> >
> >> x <- matrix(runif(22000),ncol=22)
> >> library(coda)
> >> m <- as.mcmc(x)
> >> xyplot(m)
> >> xyplot(m,layout=c(4,6))
> >>
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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.
>

[[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] Problem using apply

2010-06-01 Thread Peter Langfelder
Well, your example matrix is symmetric, so row and column operations
naturally return the same values.

You may want to note though that if you apply your function to a matrix
along rows, the results will be stored in the __columns__ of the resulting
matrix. Thus, if you want to simply divide the rows of a matrix by their
mean, you need to transpose the result.

Example:

m = matrix(c(0,1,2,5), 2,2)
m
apply( m, 1, divideByMean)
t(apply( m, 1, divideByMean))  # This is what you probably want.

HTH,

Peter

On Tue, Jun 1, 2010 at 10:26 AM, Joachim de Lezardiere <
joachim.lez...@gmail.com> wrote:

> Hello ,
>
>
>
> I can not get apply function to do what I want when doing stuff on rows.
> Let's say I want to divide the rows of matrix by their mean, the below show
> you get the same result weather you use 1 or 2, i.e. same result for
> columns
> than for means..:(
>
>
>
> Thanks a lot for the help,
>
>
>
>
>
>
>
> m = matrix( c(1,4,7,4,5,8,7,8,9), nrow = 3 )
>
>
>
> divideByMean  = function( v ){
>
> return( v/mean(v))
>
> }
>
>
>
> rowMean = c( mean( m[1,]),mean( m[2,]),mean( m[3,]) )
>
> rowMean
>
>
>
> colMean = c( mean( m[,1]),mean( m[,2]),mean( m[,3]) )
>
> colMean
>
>
>
> m
>
> print("ByRow")
>
> apply( m, 1, divideByMean)
>
>
>
> print("ByCol")
>
> apply( m, 2, divideByMean)
>
>
>
>
>
>
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


[R] textbox in lattice

2010-06-01 Thread Noah Silverman
Hi,

I want to add a box at the bottom of a lattice window (device/page?).

Lattice has drawn a nice group of panels with all the plots I need.  How
do I add my own summary text at the bottom (several lines worth?)

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

2010-06-01 Thread Henrique Dallazuanna
The mean by col and by row are the same:

colMeans(m) == rowMeans(m)

So:

m / rowMeans(m) # You don't need apply here
m / colMeans(m)

On Tue, Jun 1, 2010 at 2:26 PM, Joachim de Lezardiere <
joachim.lez...@gmail.com> wrote:

> Hello ,
>
>
>
> I can not get apply function to do what I want when doing stuff on rows.
> Let's say I want to divide the rows of matrix by their mean, the below show
> you get the same result weather you use 1 or 2, i.e. same result for
> columns
> than for means..:(
>
>
>
> Thanks a lot for the help,
>
>
>
>
>
>
>
> m = matrix( c(1,4,7,4,5,8,7,8,9), nrow = 3 )
>
>
>
> divideByMean  = function( v ){
>
> return( v/mean(v))
>
> }
>
>
>
> rowMean = c( mean( m[1,]),mean( m[2,]),mean( m[3,]) )
>
> rowMean
>
>
>
> colMean = c( mean( m[,1]),mean( m[,2]),mean( m[,3]) )
>
> colMean
>
>
>
> m
>
> print("ByRow")
>
> apply( m, 1, divideByMean)
>
>
>
> print("ByCol")
>
> apply( m, 2, divideByMean)
>
>
>
>
>
>
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

[[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] Problem using apply

2010-06-01 Thread Joachim de Lezardiere
Hello ,

 

I can not get apply function to do what I want when doing stuff on rows.
Let's say I want to divide the rows of matrix by their mean, the below show
you get the same result weather you use 1 or 2, i.e. same result for columns
than for means..:( 

 

Thanks a lot for the help,

 

 

 

m = matrix( c(1,4,7,4,5,8,7,8,9), nrow = 3 )

 

divideByMean  = function( v ){

return( v/mean(v))

}

 

rowMean = c( mean( m[1,]),mean( m[2,]),mean( m[3,]) )

rowMean

 

colMean = c( mean( m[,1]),mean( m[,2]),mean( m[,3]) )

colMean

 

m

print("ByRow")

apply( m, 1, divideByMean)

 

print("ByCol")

apply( m, 2, divideByMean)

 

 

 


[[alternative HTML version deleted]]

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


Re: [R] R-help "spam" detection; please help the moderators

2010-06-01 Thread Ted Harding
Hi Joris,
The "matched a filter rule" is the principal reason for holding
messages for moderation. Please don't become anxious about the
situation -- one of the reasons we have become concerned about
the situation is that people whose messages get held up do tend
to become worried about it. This is unnecessary -- they, and you,
are not really doing anything wrong!

As I understand it, the filter rules are set by the ethz.ch admins,
and even Martin does not seem to know, in detail, what they are.
Also, it is likely that the filters "learn", and they may well
be "learning" from a lot of other emails received at eth.ch which
have nothing to do with R-help but which are true spam -- then the
headers of such messages could be folded into "Bayes spam scores"
which can trigger "matched a filter rule".

As far as R-help is concerned, the situation seems to be that
gmail.com and nabble.com are important triggers (though there
are plenty of others). Lots of email addresses which do not have
the username ending in digits are trapped in this way.

In round figures, proportions I have logged myself amongst the
messages held because they "matched a filter rule" are:

non-gmail, non-nabble: 30%
non-gmail, nabble: 25%
gmail, non-nabble: 32%
gmail, nabble: 13%

gmail : 45%
nabble: 52%

The true nature of this situation is still unclear!

Ted.


On 01-Jun-10 16:00:40, Joris Meys wrote:
> Hi all,
> 
> I also couldn't help but notice that some of my messages are bounced
> for following reason:
> 
>The message headers matched a filter rule
> 
> I included the header of one of the messages below, but neither of
> these messages is sent trough Nabble, nor does any mail address has
> digits in it.
> I also never had that before. Did you change some of the rules somehow?
> 
> Cheers
> Joris
> 
> ---
> 
> MIME-Version: 1.0
> Received: by 10.140.173.9 with HTTP; Fri, 28 May 2010 05:32:32 -0700
> (PDT)
> In-Reply-To:
> 
> References:
> 
>   
> Date: Fri, 28 May 2010 14:32:32 +0200
> Delivered-To: jorism...@gmail.com
> Message-ID:
> 
> Subject: Re: [R] How to get values out of a string using regular
> expressions?
> From: Joris Meys 
> To: Gabor Grothendieck 
> Cc: R mailing list 
> Content-Type: multipart/alternative;
> boundary=000e0cd2295481515c0487a6b3be
> 
> --000e0cd2295481515c0487a6b3be
> Content-Type: text/plain; charset=ISO-8859-1
> 
> 
> 
> On Tue, Jun 1, 2010 at 3:25 PM, Martin Maechler
> wrote:
> 
>> Dear readers of R-help
>>
>> as most of you will *not* be aware, R-help has continued to work the
>> way it does, only thanks to a dozen of volunteers,
>> see https://stat.ethz.ch/mailman/listinfo/r-help .
>>
>> The volunteers manually moderate e-mails that "look like spam" (and
>> sometimes are and sometimes are not).
>> While much more than 90% of the spam is filtered out long before
>> a human sees it, with the increasing sophistication of spammers,
>> manual intervention has deemed to be necessary and served the
>> community very well.
>>
>> OTOH, in recent weeks, the amount of work for the volunteers has
>> increased, mainly because an increasingly number of non-spam postings
>> are
>> erronously tagged as "possibly spam".
>> We have discussed about this and done some analysis and found
>> that most of these message that produce a considerable amount of
>> extra work share two properties :
>>  1) they are posted via Nabble  {which *always* attaches a small
>> pro-Nabble spam at the end of the
>> message}
>>  2) the e-mail address of the sender is from a freemail
>>provider, quite often 'at gmail dot com', and often the part
>>*before* the '@' (at-sign) ends with digits.
>>
>> We hereby ask those among you who use a freemail account to
>> please no longer post via nabble.
>>
>> Thank you for your support of R-help, *the* "community mailing
>> list" of the R project since even before that project existed
>> "formally", namely since 1997-04-01,
>> today 13 years and two months.
>>
>> Martin Maechler, ETH Zurich
>> (and R-help creator and principal manager)
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
> 
> -- 
> Joris Meys
> Statistical Consultant
> 
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
> 
> Coupure Links 653
> B-9000 Gent
> 
> tel : +32 9 264 59 87
> joris.m...@ugent.be
> ---
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
> 
>   [[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

Re: [R] Question about the license of an R package

2010-06-01 Thread Mauricio Zambrano
2010/6/1 Duncan Murdoch :
> Mauricio Zambrano wrote:
>>
>> Dear R-users,
>>
>> I'm developing a package that heavily depends on another package
>> released under the GPL-2 license.
>>
>
> Are you including code from that package in yours, or just making use of it?
>  The former requires that you follow all the GPL rules about your own.  If
> you just use their package, then license your package any way you like.

Thank you very much for the information!.

I'm just using the packages, without including a single line of code.

>>
>> In addition, some few functions depends on other packages released
>> under the following licences (as described in the corresponding pages
>> of http://cran.r-project.org/web/packages/):
>>
>> GPL
>> GPL >=2.
>>
>> I want to release my package under a GPL >= 2 license, and after
>> reading the section 1.1.1 of the R-exts manual and looking at the
>> compatibility matrix found on http://gplv3.fsf.org/dd3-faq,  I'm still
>> in doubt if I can do that.
>>
>> I would appreciate if you could tell me if can I release my package
>> under a GPL >= 2 license considering the aforementioned licenses ?
>>
>>
>> Finally, a general question:
>>
>> When a package is released under GPL >=2, does it mean that the terms
>> of the GPL-3 license apply or not ?
>>
>
> I believe that's an offer to license under whatever version of the GPL (from
> 2 up) that the person using your code chooses.  If GPL-3 offers something
> that GPL-2 doesn't (e.g. compatibility with other GPL-3 code), they can use
> that.  If GPL-3 places restrictions they don't like (e.g. incompatibility
> with GPL-2 code), they can use GPL-2.
>
> Duncan Murdoch

Thanks Duncan.

Knds,

Mauricio Zambrano B.

-- 
==
Dept. of Civil and Env. Engineering
University of Trento, Italy

>
> Thanks in advance for any help.
>>
>> Mauricio
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] Fancy Page layout

2010-06-01 Thread Noah Silverman
Thanks Jim,

That helps.

Ben Bolker had a nice suggestion on how to get the lattice package to
easily plot all 22 variables in one window.

Ultimately, I'd like to generate a PDF that will print on a standard
(8.5 x 11) page.

A few things I'm still stuck are:
1) How to use the lattice command AND leave room at the bottom for a
text block
2) How to tell lattice the size of the window
3) How to integrate all this together - draw a big window, plot
trellis in the top half and then text box in the bottom.

Any thoughts?

-N


On 6/1/10 4:53 AM, Jim Lemon wrote:
> On 06/01/2010 04:16 AM, Noah Silverman wrote:
>> Hi,
>>
>> Working on a report that is going to have a large number of graphs and
>> summaries.  We have 80 "groups" with 20 variables each.
>>
>> Ideally, I'd like to produce ONE page for each group.  It would have two
>> columns of 10 graphs and then the 5 number summary of the variables at
>> the bottom.
>> So, perhaps the top 2/3 of the page has the graphs and the bottom third
>> has 20 rows of data summary(maybe a table of sorts.)
>> This COULD be done in Latex, but would have to be hand coded for each of
>> the 80 groups which would be painfully slow.
>>
>> I can easily do the graphs with par(mfrow=c(5,2))  band then draw the
>> graphs in a loop.
>>
>> But I am stuck from here:
>>
>> 1) How do I control the size of the plot window.  (Ideally, it should
>> print to fill an 8.5 x 11 piece of paper)
>> 2) Is there a way to "easily" insert a 5 number summary (summary
>> command) into the lower half of the page.
>>
>> Does anybody have any ideas??
>>
> Hi Noah,
> One easy way is to leave some space at the bottom, either by using:
>
> par(mfrow=c(6,2))
>
> or the more flexible "layout" function, and then use "text" or a
> fancier function (textbox, boxed.labels, addtable2plot, etc.) to add
> your text after:
>
> par(xpd=NA)
>
> allows you to display the text anywhere you please. If you use a
> bitmap graphics device, make it big:
>
> png("numberoneofeighty.png",850,1100)
>
> so that it won't look lumpy on the printed page.
>
> Jim
>

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


Re: [R] BreastCancer Dataset for Classification in kknn

2010-06-01 Thread Joris Meys
Hi Nitin,

It can be solved by splitting your data a bit different. You need more
training data than you have evaluation data, eg :
i1 = 1:400
i2=401:d

Then it works on my computer. No clue as to where the error originates from
though.

Cheers
Joris

On Tue, Jun 1, 2010 at 4:27 PM, Nitin  wrote:

> Dear All,
>
> I'm getting a error while trying to apply the BreastCancer dataset
> (package=mlbench) to kknn (package=kknn) that I don't understand as I'm new
> to R.
> The codes are as follow:
>
> rm = (list = ls())
> library(mlbench)
> data(BreastCancer)
> library(kknn)
>
> BCancer = na.omit(BreastCancer)
> d  = dim(BCancer)[1]
> i1 = seq(1, d, 2)
> i2 = seq(2, d, 2)
>
> t1 = BCancer[i1, ]
> t2 = BCancer[i2, ]
> y2  = BCancer[i2, 11]
>
> x = 10
> k = array(1:x, dim = c(x,1))
> ker = array(c( "rectangular", "triangular", "epanechnikov", "biweight",
>"triweight", "cos", "inv", "gaussian"), dim = c(8,1))
>
> f = function(x, ker){
>
>BreastCancer.kknn  <-  kknn(Class~., train = t1, test = t2, k = x,
>kernel = ker, distance = 1)
>fit = fitted(BreastCancer.kknn)
>
>z <- (fit==y2)
>z.e <- (100 - (length(y2)-length(z[!z]))/length(y2)*100 )
> }
>
> err.k = function(ker){
>error.BreastCancer = apply(k,1,function(y) f(y, ker))
> }
>
> err.ker = apply(ker, 1, err.k)
> colnames(err.ker) = c("rectangular", "triangular", "epanechnikov",
> "biweight",
>"triweight", "cos", "inv", "gaussian")
> print(err.ker)
>
> It throws a error: Error in as.matrix(learn[, ind == i]) :
>  (subscript) logical subscript too long
> In addition: Warning messages:
> 1: In model.matrix.default(mt, mf) : variable 'Id' converted to a factor
> 2: In model.matrix.default(mt, test) : variable 'Id' converted to a factor
>
> I tried the codes with other datasets in mlbench package and most of them
> working. That is the mistake here for this particular dataset and how can I
> solve it?
>
> Thanks
> Nitin
>
>[[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.
>



-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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] library installation problem, invalid regular expression in help indices

2010-06-01 Thread Uwe Ligges
I guess something strange is loaded or changed in your personal startup 
scripts (i.e. through your Renviron or Rprofile settings.


Uwe Ligges




On 27.05.2010 15:34, Rainer Machne wrote:

Hi,

I have a strange package installation problem after update to R 2.11.0
on Fedora Core 12.

A colleague of mine with the very same Fedora and R versions doesn't
have this problem, while logging on to his computer but installing from
my settings and into my local library path also shows the problem, so it
seems to be related to some of my environment settings.

Installation of several packages fails during installation of help
indices. The error is:

"Error: invalid regular expression '^[[:blank:]]*"

The packages for which installation failes, with the respective help
files after which the error occurs:

robustbase: NOxEmissions
tuneR: lilyinput
kernlab: kha
rrcov: CovSest
seewave: wasp


Any ideas?

btw, i just copied my colleague's installation folders to mine, and it
seems to work; for me the problem is solved for now. But it would still
be good to know what the problem is.


Thanks,
Rainer

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Set resolution of embedded plots in pdf() or CairoPDF()

2010-06-01 Thread Uwe Ligges
Both pdf() and CairoPDF() produce vector graphics, hence there is no 
things such as resolution required here.


Uwe Ligges


On 27.05.2010 11:09, Will Eagle wrote:

Dear all,

how can I set the resolution of embedded plots in PDF using pdf() or
CairoPDF() to a value of e.g. 600 dpi to meet journal requirements?

Thanks in advance,

Will

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

2010-06-01 Thread Noah Silverman
Hi,

I used the term "run", as each iteration of the Gibbs sampler produces
22 variables (coefficients for Beta in a regression model)


The example wont work


On 6/1/10 5:54 AM, Ben Bolker wrote:
> Noah Silverman  smartmediacorp.com> writes:
>
>   
>> I'm running a long MCMC chain that is generating samples for 22 variables.
>>
>> I have each run of the chain as a row in a matrix.
>> 
>   
>> So:  Chain[,1] is the column with all the samples for variable one. 
>> Chain[,2] is the column with all the samples for variable 2, etc. 
>> 
>   The previous 2 paragraphs seemed contradictory until I realized
> that in the first paragraph you are using "run" to mean what I would
> usually call a "sample" ...
>
>   
>> I'd like to fit all 22 on a single page to print a nice summary.  It is
>> OK if the graphs are small, I just need to show the overall shape and
>> convergence.
>> 
>   How about for example
>
>   
>> x <- matrix(runif(22000),ncol=22)
>> library(coda)
>> m <- as.mcmc(x)
>> xyplot(m)
>> xyplot(m,layout=c(4,6))
>> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 initial rows in a text file import

2010-06-01 Thread Uwe Ligges



On 01.06.2010 02:19, David Winsemius wrote:


On May 31, 2010, at 8:14 PM, jim holtman wrote:


try this:

input <- readLines("yourfile.txt")
# determine start
start <- grep("\tBegin Main\t", input)[1] # first line if many


Puzzled. I thought backslashes in grepping patterns needed to be
doubled? I guess not.




Well, yes, for a backslash, but here a tab is specified, but no 
backslash at all.


Additionally, see ?regex:
"The current implementation interprets \a as BEL, \e as ESC, \f as FF, 
\n as LF, \r as CR and \t as TAB."


Uwe Ligges

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


Re: [R] discriminant analysis

2010-06-01 Thread Uwe Ligges

Which kind of discriminant analysis?
If you mean LDA, use lda() in package MASS and read the correpsonding 
book "Modern Applied Statistics with S" by Venables and Ripley published 
by Springer.


Uwe Ligges


On 01.06.2010 09:24, suman dhara wrote:

Sir,
Can you suggest  some function for discriminant analysis for Binary response
having continuous as well as categorical regressors.



Thanks,
Suman Dhara

[[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] Help barplots

2010-06-01 Thread khush ........
Dear All,

Thank you  very much for your kind help and support I got it.

Jeet

On Tue, Jun 1, 2010 at 5:32 PM, Jim Lemon  wrote:

> On 06/01/2010 09:01 PM, khush  wrote:
>
>> Dear All,
>>
>> I am newbie to R, and I wanted to plot a barplots with R and in such a way
>> that It will also show me position which I can plot on the bar line.
>>
>> Here is my code that I am using to plot,
>>
>>  chromosome<- c(40.2, 35.6, 36.1, 29.6, 31, 29.6, 31, 29.4, 28.2, 23, 23,
>>>
>> 28.2)
>>
>>> barplot (chromosome, col="purple", xlab="Oryza sativa Chromosomes",
>>> border
>>>
>> = NA, space = 5, ylim = c(0,45))
>>
>> I wanted to mark the position say on chromosome 1 (40.2) I need to mark
>> 10.2
>> and on other also.
>> I also want to set the scale of y axis from 0,5,10,15,20,25,30,35,40,45
>> i.e
>> gap of 5 instead of 10.
>>
>> please help me to solve my querygurus.
>>
>>  Hi Jeet,
> I think you want the x positions of the bars. Get them like this:
>
> xpos<-barplot (chromosome, col="purple",
>
>  xlab="Oryza sativa Chromosomes",
>  border = NA, space = 5, ylim = c(0,45))
>
> Then you can place the extra labels using the values in xpos.
> For the custom y axis, add the argument yaxt="n" to your plot command and
> then add the axis later. I suspect you will have to use something like the
> staxlab function in the plotrix package to get all those labels to display.
>
> Jim
>

[[alternative HTML version deleted]]

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


Re: [R] Help on aggregate method

2010-06-01 Thread Stella Pachidi
Dear Erik,

Thank you very much. Indeed ave did the same job amazingly fast! I did not
know the function before.

Many thanks to all R experts who answer to this mailing list, it's amazing
how much help you offer to the newbies :)

Kind regards,
Stella

On Tue, Jun 1, 2010 at 6:11 PM, Erik Iverson  wrote:

>
>
> Stella Pachidi wrote:
>
>> Dear Erik and R experts,
>>
>> Thank you for the fast response!
>>
>> I include an example with the ChickWeight dataset:
>>
>> ap.dat <- ChickWeight
>>
>> matchMeanEx <- function(ind,dataTable,aggrTable)
>> {
>>   index <- which((aggrTable[,1]==dataTable[["Diet"]][ind]) &
>> (aggrTable[,2]==dataTable[["Chick"]][ind]))
>>   as.numeric(aggrTable[index,3])
>> }
>>
>> avgW <- aggregate(ap.dat[["weight"]], by = list(ap.dat[["Diet"]],
>> ap.dat[["Chick"]]), FUN="mean")
>> meanW <- sapply((1:length(ap.dat[,1])), FUN=matchMeanEx, ap.dat, avgW)
>> ap.dat <- cbind (ap.dat, meanW)
>>
>>
>
> How about simply using ave.
>
> ap.dat$meanW <- ave(ap.dat$weight, list(ap.dat$Diet, ap.dat$Chick))
>



-- 
Stella Pachidi
Master in Business Informatics student
Utrecht University
email: s.pach...@students.uu.nl
tel: +31644478898

[[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] any doc to understand arima state space model?

2010-06-01 Thread Joris Meys
Type in Google

Arima R

Read the first hit, the third, the fifth, and any other that says "tutorial"

Cheers
Joris

On Tue, Jun 1, 2010 at 4:14 PM, shakira M  wrote:

> I am trying to understand R arima function. Any pointers would be
> appreciated.
>
> Thank you,
> Shakira.
>
>[[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.
>



-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[alternative HTML version deleted]]

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


Re: [R] Help on aggregate method

2010-06-01 Thread Erik Iverson



Stella Pachidi wrote:

Dear Erik and R experts,

Thank you for the fast response!

I include an example with the ChickWeight dataset:

ap.dat <- ChickWeight

matchMeanEx <- function(ind,dataTable,aggrTable)
{
   index <- which((aggrTable[,1]==dataTable[["Diet"]][ind]) & 
(aggrTable[,2]==dataTable[["Chick"]][ind]))

   as.numeric(aggrTable[index,3])
}

avgW <- aggregate(ap.dat[["weight"]], by = list(ap.dat[["Diet"]], 
ap.dat[["Chick"]]), FUN="mean")

meanW <- sapply((1:length(ap.dat[,1])), FUN=matchMeanEx, ap.dat, avgW)
ap.dat <- cbind (ap.dat, meanW)




How about simply using ave.

ap.dat$meanW <- ave(ap.dat$weight, list(ap.dat$Diet, ap.dat$Chick))

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


Re: [R] as.date

2010-06-01 Thread arnaud Gaboury
TY for the tip. The lower case is in fact the culprit.





> -Original Message-
> From: Erik Iverson [mailto:er...@ccbr.umn.edu]
> Sent: Tuesday, June 01, 2010 6:05 PM
> To: arnaud Gaboury
> Cc: r-help@r-project.org
> Subject: Re: [R] as.date
> 
> 
> > Where does the problem comes from?? Maybe from my sytem date ??
> 
> Simply from not reading the options carefully enough, from ?strptime,
> 
>   '%y' Year without century (00-99). If you use this on input,
> which
>century you get is system-specific.  So don't!  Most often
>values 00 to 68 are prefixed by 20 and 69 to 99 by 19 - that
>is the behaviour specified by the 2001 POSIX standard, but
> it
>does also say 'it is expected that in a future version of
>IEEE Std 1003.1-2001 the default century inferred from a
>2-digit year will change'.
> 
>   '%Y' Year with century.
> 
> 
> You want %Y, not %y.

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


Re: [R] Issue with assigning text to matrix

2010-06-01 Thread Joris Meys
Hi Jessica,

this tells me that your text is saved as a factor.
Try :
names <- read.csv(file="Names.csv",stringsAsFactors=F)


Cheers
Joris

On Tue, Jun 1, 2010 at 11:04 AM, Jessica Queree
wrote:

> My issue relates to adding text to a matrix and finding that the text is
> converted to a number.
>
>
>
> This is the section of code I'm having trouble with:
>
>
>
> # First, I load in a list of names from a .csv file to 'names'
>
> names <- read.csv(file("Names.csv"))
>
>
>
> # Then I define a matrix which will be populated with various test
> statistics, with several rows for each entry in names
>
>
>
> testOutput <-matrix(nrow = 200, ncol = 5)
>
> for (i in 1:nrow(names)){
>
>
>
>testOutput[i,1] <- names[i,1]
>
>testOutput[i,2] <- names[i,2]
>
>
>
># test statistics code here
>
>
>
> }
>
>
>
>
>
> If I look at names[,1], I get the following:
>
>
>
> names[,1]
>
>  [1] EQ_Level_UK   EQ_Level_EUR  EQ_Level_US   EQ_Level_Far
> East
>
>  [5] IR_PC 1_UKIR_PC 2_UKIR_PC 3_UKSwap_PC 1_UK
>
>  [9] Swap_PC 2_UK  Swap_PC 3_UK  FX_Level_EUR  FX_Level_US
>
> [13] FX_Level_Far East Infl_PC 1_UK  Infl_PC 2_UK  Infl_PC 3_UK
>
> [17] Prop_Level_UK CreditAAA_PC 1_UK CreditAAA_PC 2_UK CreditAAA_PC
> 3_UK
>
> [21] CreditAA_PC 1_UK  CreditAA_PC 2_UK  CreditAA_PC 3_UK  CreditA_PC 1_UK
>
> [25] CreditA_PC 2_UK   CreditA_PC 3_UK   CreditBBB_PC 1_UK CreditBBB_PC
> 2_UK
>
> [29] CreditBBB_PC 3_UK
>
> 29 Levels: CreditA_PC 1_UK CreditA_PC 2_UK CreditA_PC 3_UK ... Swap_PC 3_UK
>
>
>
> But if I look at testOutput[,1], I get:
>
>
>
> testOutput[,1]
>
>  [1] "15" "13" "16" "14" "23" "24" "25" "27" "28" "29" "17" "19" "18" "20"
> "21"
>
>  [16] "22" "26" "7"  "8"  "9"  "4"  "5"  "6"  "1"  "2"  "3"  "10" "11" "12"
> "17"
>
>  [31] NA   NA   "19" "18" NA   NA   NA   "20" NA   NA   "21" NA   NA   "22"
> NA
>
>  [46] NA   "26" NA   NA   "7"  NA   NA   "8"  NA   NA   "9"  NA   NA   "4"
> NA
>
>  [61] NA   "5"  NA   NA   "6"  NA   NA   "1"  NA   NA   "2"  NA   NA   "3"
> NA
>
>  [76] NA   "10" NA   NA   "11" NA   NA   "12" NA   NA   NA   NA   NA   NA
> NA
>
>  [91] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
> NA
>
> [106] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
> NA
>
> [121] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
> NA
>
> [136] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
> NA
>
> [151] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
> NA
>
> [166] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
> NA
>
> [181] NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
> NA
>
> [196] NA   NA   NA   NA   NA
>
>
>
> That is, the names are now converted to numbers. I think this might have
> something to do with the way I've defined the testOutput matrix, but
> haven't
> been able to find any information about how to fix it. Can anyone help?
>
>
>
> Many thanks.
>
>[[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.
>



-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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] as.date

2010-06-01 Thread Joris Meys
Change this line to :

>pose$CREATED.DATE=as.Date(pose$CREATED.DATE,"%d/%m/%Y") # mind the capital
Y
>pose
  DESCRIPTION CREATED.DATE QUANITY CLOSING.PRICE
1 COTTON NO.2 Jul/10   2010-05-13   1   81.2000
2 COTTON NO.2 Jul/10   2010-05-13   1   81.2000
3   PALLADIUM Jun/10   2010-05-14  -1  503.6000
4   PALLADIUM Jun/10   2010-05-14  -1  503.6000
5 SUGAR NO.11 Jul/10   2010-05-10   1   13.8900
6 SUGAR NO.11 Jul/10   2010-05-10   1   13.8900

Cheers
Joris

On Tue, Jun 1, 2010 at 5:57 PM, arnaud Gaboury wrote:

> Dear group,
>
> Here is my df (obtained with a read.csv2()):
>
>
> df <-
> structure(list(DESCRIPTION = c("COTTON NO.2 Jul/10", "COTTON NO.2 Jul/10",
> "PALLADIUM Jun/10", "PALLADIUM Jun/10", "SUGAR NO.11 Jul/10",
> "SUGAR NO.11 Jul/10"), CREATED.DATE = c("13/05/2010", "13/05/2010",
> "14/05/2010", "14/05/2010", "10/05/2010", "10/05/2010"), QUANITY = c(1,
> 1, -1, -1, 1, 1), CLOSING.PRICE = c("81.2000", "81.2000", "503.6000",
> "503.6000", "13.8900", "13.8900")), .Names = c("DESCRIPTION",
> "CREATED.DATE", "QUANITY", "CLOSING.PRICE"), row.names = c(NA,
> 6L), class = "data.frame")
>
> > str(df)
> 'data.frame':   6 obs. of  4 variables:
>  $ DESCRIPTION  : chr  "COTTON NO.2 Jul/10" "COTTON NO.2 Jul/10" "PALLADIUM
> Jun/10" "PALLADIUM Jun/10" ...
>  $ CREATED.DATE : chr  "13/05/2010" "13/05/2010" "14/05/2010" "14/05/2010"
> ...
>  $ QUANITY  : num  1 1 -1 -1 1 1
>  $ CLOSING.PRICE: chr  "81.2000" "81.2000" "503.6000" "503.6000" ...
>
> I want to change the class of df$CREATED.DATE from Chr to Date:
>
>
> >pose$CREATED.DATE=as.Date(pose$CREATED.DATE,"%d/%m/%y")
>
> Here is what I get :
>
> df <-
> structure(list(DESCRIPTION = c("COTTON NO.2 Jul/10", "COTTON NO.2 Jul/10",
> "PALLADIUM Jun/10", "PALLADIUM Jun/10", "SUGAR NO.11 Jul/10",
> "SUGAR NO.11 Jul/10"), CREATED.DATE = structure(c(18395, 18395,
> 18396, 18396, 18392, 18392), class = "Date"), QUANITY = c(1,
> 1, -1, -1, 1, 1), CLOSING.PRICE = c("81.2000", "81.2000", "503.6000",
> "503.6000", "13.8900", "13.8900")), .Names = c("DESCRIPTION",
> "CREATED.DATE", "QUANITY", "CLOSING.PRICE"), row.names = c(NA,
> 6L), class = "data.frame")
>
> Where does the problem comes from?? Maybe from my sytem date ??
>
> TY for any help
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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] as.date

2010-06-01 Thread Joshua Wiley
Hello,

The lowercase 'y' is year without century.  This should work for you:

as.Date(x=df$CREATED.DATE, format="%d/%m/%Y")

HTH,

Josh


On Tue, Jun 1, 2010 at 8:57 AM, arnaud Gaboury  wrote:
> Dear group,
>
> Here is my df (obtained with a read.csv2()):
>
>
> df <-
> structure(list(DESCRIPTION = c("COTTON NO.2 Jul/10", "COTTON NO.2 Jul/10",
> "PALLADIUM Jun/10", "PALLADIUM Jun/10", "SUGAR NO.11 Jul/10",
> "SUGAR NO.11 Jul/10"), CREATED.DATE = c("13/05/2010", "13/05/2010",
> "14/05/2010", "14/05/2010", "10/05/2010", "10/05/2010"), QUANITY = c(1,
> 1, -1, -1, 1, 1), CLOSING.PRICE = c("81.2000", "81.2000", "503.6000",
> "503.6000", "13.8900", "13.8900")), .Names = c("DESCRIPTION",
> "CREATED.DATE", "QUANITY", "CLOSING.PRICE"), row.names = c(NA,
> 6L), class = "data.frame")
>
>> str(df)
> 'data.frame':   6 obs. of  4 variables:
>  $ DESCRIPTION  : chr  "COTTON NO.2 Jul/10" "COTTON NO.2 Jul/10" "PALLADIUM
> Jun/10" "PALLADIUM Jun/10" ...
>  $ CREATED.DATE : chr  "13/05/2010" "13/05/2010" "14/05/2010" "14/05/2010"
> ...
>  $ QUANITY      : num  1 1 -1 -1 1 1
>  $ CLOSING.PRICE: chr  "81.2000" "81.2000" "503.6000" "503.6000" ...
>
> I want to change the class of df$CREATED.DATE from Chr to Date:
>
>
>>pose$CREATED.DATE=as.Date(pose$CREATED.DATE,"%d/%m/%y")
>
> Here is what I get :
>
> df <-
> structure(list(DESCRIPTION = c("COTTON NO.2 Jul/10", "COTTON NO.2 Jul/10",
> "PALLADIUM Jun/10", "PALLADIUM Jun/10", "SUGAR NO.11 Jul/10",
> "SUGAR NO.11 Jul/10"), CREATED.DATE = structure(c(18395, 18395,
> 18396, 18396, 18392, 18392), class = "Date"), QUANITY = c(1,
> 1, -1, -1, 1, 1), CLOSING.PRICE = c("81.2000", "81.2000", "503.6000",
> "503.6000", "13.8900", "13.8900")), .Names = c("DESCRIPTION",
> "CREATED.DATE", "QUANITY", "CLOSING.PRICE"), row.names = c(NA,
> 6L), class = "data.frame")
>
> Where does the problem comes from?? Maybe from my sytem date ??
>
> TY for any help
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

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


Re: [R] as.date

2010-06-01 Thread Erik Iverson



Where does the problem comes from?? Maybe from my sytem date ??


Simply from not reading the options carefully enough, from ?strptime,

 ‘%y’ Year without century (00-99). If you use this on input, which
  century you get is system-specific.  So don't!  Most often
  values 00 to 68 are prefixed by 20 and 69 to 99 by 19 - that
  is the behaviour specified by the 2001 POSIX standard, but it
  does also say ‘it is expected that in a future version of
  IEEE Std 1003.1-2001 the default century inferred from a
  2-digit year will change’.

 ‘%Y’ Year with century.


You want %Y, not %y.

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


Re: [R] using the design matrix to correctly configure contrasts

2010-06-01 Thread RICHARD M. HEIBERGER
Please look at the maiz example, the last example in ?MMC in the HH package.
Follow the example all the way to the end.  It illustrates a problem and
then the resolution
of the problem.

install.packages("HH")  ## if you don't have it yet.
library(HH)
?MMC


Rich

[[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] as.date

2010-06-01 Thread arnaud Gaboury
Dear group,

Here is my df (obtained with a read.csv2()):


df <-
structure(list(DESCRIPTION = c("COTTON NO.2 Jul/10", "COTTON NO.2 Jul/10", 
"PALLADIUM Jun/10", "PALLADIUM Jun/10", "SUGAR NO.11 Jul/10", 
"SUGAR NO.11 Jul/10"), CREATED.DATE = c("13/05/2010", "13/05/2010", 
"14/05/2010", "14/05/2010", "10/05/2010", "10/05/2010"), QUANITY = c(1, 
1, -1, -1, 1, 1), CLOSING.PRICE = c("81.2000", "81.2000", "503.6000", 
"503.6000", "13.8900", "13.8900")), .Names = c("DESCRIPTION", 
"CREATED.DATE", "QUANITY", "CLOSING.PRICE"), row.names = c(NA, 
6L), class = "data.frame")

> str(df)
'data.frame':   6 obs. of  4 variables:
 $ DESCRIPTION  : chr  "COTTON NO.2 Jul/10" "COTTON NO.2 Jul/10" "PALLADIUM
Jun/10" "PALLADIUM Jun/10" ...
 $ CREATED.DATE : chr  "13/05/2010" "13/05/2010" "14/05/2010" "14/05/2010"
...
 $ QUANITY  : num  1 1 -1 -1 1 1
 $ CLOSING.PRICE: chr  "81.2000" "81.2000" "503.6000" "503.6000" ...

I want to change the class of df$CREATED.DATE from Chr to Date:


>pose$CREATED.DATE=as.Date(pose$CREATED.DATE,"%d/%m/%y")

Here is what I get :

df <-
structure(list(DESCRIPTION = c("COTTON NO.2 Jul/10", "COTTON NO.2 Jul/10", 
"PALLADIUM Jun/10", "PALLADIUM Jun/10", "SUGAR NO.11 Jul/10", 
"SUGAR NO.11 Jul/10"), CREATED.DATE = structure(c(18395, 18395, 
18396, 18396, 18392, 18392), class = "Date"), QUANITY = c(1, 
1, -1, -1, 1, 1), CLOSING.PRICE = c("81.2000", "81.2000", "503.6000", 
"503.6000", "13.8900", "13.8900")), .Names = c("DESCRIPTION", 
"CREATED.DATE", "QUANITY", "CLOSING.PRICE"), row.names = c(NA, 
6L), class = "data.frame")

Where does the problem comes from?? Maybe from my sytem date ??

TY for any help

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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-help "spam" detection; please help the moderators

2010-06-01 Thread Joris Meys
Hi all,

I also couldn't help but notice that some of my messages are bounced for
following reason:

   The message headers matched a filter rule

I included the header of one of the messages below, but neither of these
messages is sent trough Nabble, nor does any mail address has digits in it.
I also never had that before. Did you change some of the rules somehow?

Cheers
Joris

---

MIME-Version: 1.0
Received: by 10.140.173.9 with HTTP; Fri, 28 May 2010 05:32:32 -0700 (PDT)
In-Reply-To: 
References: 

Date: Fri, 28 May 2010 14:32:32 +0200
Delivered-To: jorism...@gmail.com
Message-ID: 
Subject: Re: [R] How to get values out of a string using regular expressions?
From: Joris Meys 
To: Gabor Grothendieck 
Cc: R mailing list 
Content-Type: multipart/alternative; boundary=000e0cd2295481515c0487a6b3be

--000e0cd2295481515c0487a6b3be
Content-Type: text/plain; charset=ISO-8859-1



On Tue, Jun 1, 2010 at 3:25 PM, Martin Maechler
wrote:

> Dear readers of R-help
>
> as most of you will *not* be aware, R-help has continued to work the
> way it does, only thanks to a dozen of volunteers,
> see https://stat.ethz.ch/mailman/listinfo/r-help .
>
> The volunteers manually moderate e-mails that "look like spam" (and
> sometimes are and sometimes are not).
> While much more than 90% of the spam is filtered out long before
> a human sees it, with the increasing sophistication of spammers,
> manual intervention has deemed to be necessary and served the
> community very well.
>
> OTOH, in recent weeks, the amount of work for the volunteers has
> increased, mainly because an increasingly number of non-spam postings are
> erronously tagged as "possibly spam".
> We have discussed about this and done some analysis and found
> that most of these message that produce a considerable amount of
> extra work share two properties :
>  1) they are posted via Nabble  {which *always* attaches a small
> pro-Nabble spam at the end of the message}
>  2) the e-mail address of the sender is from a freemail
>provider, quite often 'at gmail dot com', and often the part
>*before* the '@' (at-sign) ends with digits.
>
> We hereby ask those among you who use a freemail account to
> please no longer post via nabble.
>
> Thank you for your support of R-help, *the* "community mailing
> list" of the R project since even before that project existed
> "formally", namely since 1997-04-01,
> today 13 years and two months.
>
> Martin Maechler, ETH Zurich
> (and R-help creator and principal manager)
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[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] Question about the license of an R package

2010-06-01 Thread Duncan Murdoch

Mauricio Zambrano wrote:

Dear R-users,

I'm developing a package that heavily depends on another package
released under the GPL-2 license.
  


Are you including code from that package in yours, or just making use of 
it?  The former requires that you follow all the GPL rules about your 
own.  If you just use their package, then license your package any way 
you like.

In addition, some few functions depends on other packages released
under the following licences (as described in the corresponding pages
of http://cran.r-project.org/web/packages/):

GPL
GPL >=2.

I want to release my package under a GPL >= 2 license, and after
reading the section 1.1.1 of the R-exts manual and looking at the
compatibility matrix found on http://gplv3.fsf.org/dd3-faq,  I'm still
in doubt if I can do that.

I would appreciate if you could tell me if can I release my package
under a GPL >= 2 license considering the aforementioned licenses ?


Finally, a general question:

When a package is released under GPL >=2, does it mean that the terms
of the GPL-3 license apply or not ?
  


I believe that's an offer to license under whatever version of the GPL 
(from 2 up) that the person using your code chooses.  If GPL-3 offers 
something that GPL-2 doesn't (e.g. compatibility with other GPL-3 code), 
they can use that.  If GPL-3 places restrictions they don't like (e.g. 
incompatibility with GPL-2 code), they can use GPL-2.


Duncan Murdoch

Thanks in advance for any help.

Mauricio

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] storing output data from a loop that has varying row numbers

2010-06-01 Thread Ivan Calandra

Hi Ross,

I think Joris answered your question, but to keep with your own code:

To set up a list, you can use:
DIST_LOOP <- list()
Or, if you know the length:
DIST_LOOP <- vector(mode="list", length=11)
You would then fill up with (in your for loop):
DIST_LOOP[[i]] <- SEL_HR ##Actually, what you had at the beginning, but 
DIST_LOOP is now a list so it should work.


Regarding what you're trying to do, wouldn't aggregate() work? Or with 
unique()? I still haven't completely understood what you looking for, so 
I might be completely wrong!


But as I said, I guess (and hope for you) Joris fixed the problem already

Ivan

Le 6/1/2010 16:56, RCulloch a écrit :

Hi Ivan,

Thanks again for your help! I'll just go through your questions...

I'm still really confused about your question.
-Sorry!!!


Let me ask you some specific questions (maybe someone more experienced
would understand at once, but I'm no expert; I hope I can still help
you! In any case, I would like to understand for myself ;) )

- is "seal_dist" the name of your data.frame?
yes
so..
head(seal_dist)

   FROM TODIST ID HR DD MM YY ANIMAL DAY
11  1 2.63981   'A1'  9 30  9  7  1   1
21  2 0.0   'A1'  9 30  9  7  1   1
31  3 6.95836   'A1'  9 30  9  7  1   1
41  4 8.63809   'A1'  9 30  9  7  1   1
51  1 0.0 'A1.1'  9 30  9  7  7   1
61  2 2.63981 'A1.1'  9 30  9  7  7   1


- what do you want to do with
SEL_DAY[i]=dist[i]

That was a (desperate) attempt to do 'something', but didn't work - so
shouldn't have been in the script I posted, sorry!

? What is "dist"?
It is a measure of distance from one point (ID) to another i.e. the distance
between A1 and A1.1

If I understand well, you want to replace the values
in FROM (then TO, then DIST...) with the values from the same column
number in dist?

The problem is that Arc doesn't output the data as I'd like, so I want to
create a new column to add to the data. What Arc has done is taken a
distance between each ID for each hour, but because the number of IDs in
each hour don't match it means that the TO number is not unique to the ID
throughout the entire dataset, only on that given hour. So when distance = 0
in the TO column then that TO number -s equal to the ID i.e. the distance to
A1 to A1 is 0, so I then want to use that information to create a new column
that will tell me the actual ID. If that is any clearer?


- Since I still haven't understood your goal completely, I still don't
understand why you add the column TO_ID to SEL_HR.
see above


- In any case, a matrix cannot work because you want to store data of
different classes in DIST_LOOP (ID is character and the others are
numeric). You can either use a data.frame (if you really want to have
the table-like structure, which is a list) or a list.
I see, can you advise on how to set up a list to write to?

- Moreover, the output from dput(your data) would really help to see
what you have!
I have not long posted it, I hope it helps!!

Thanks again for your help Ivan, much appreciated,

Ross

   


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


Re: [R] Help on aggregate method

2010-06-01 Thread Stella Pachidi
Dear Erik and R experts,

Thank you for the fast response!

I include an example with the ChickWeight dataset:

ap.dat <- ChickWeight

matchMeanEx <- function(ind,dataTable,aggrTable)
{
   index <- which((aggrTable[,1]==dataTable[["Diet"]][ind]) &
(aggrTable[,2]==dataTable[["Chick"]][ind]))
   as.numeric(aggrTable[index,3])
}

avgW <- aggregate(ap.dat[["weight"]], by = list(ap.dat[["Diet"]],
ap.dat[["Chick"]]), FUN="mean")
meanW <- sapply((1:length(ap.dat[,1])), FUN=matchMeanEx, ap.dat, avgW)
ap.dat <- cbind (ap.dat, meanW)


Best regards,
Stella


On Tue, Jun 1, 2010 at 4:58 PM, Erik Iverson  wrote:

> It's easiest for us to help if you give us a reproducible example.  We
> don't have your datasets (ap.dat), so we can't run your code below. It's
> easy to create sample data with the random number generators in R, or use
> ?dput to give us a sample of your actual data.frame.
>
> I would guess your problem is solved by ?ave though.
>
> Stella Pachidi wrote:
>
>> Dear R experts,
>>
>> I would really appreciate if you had an idea on how to use more
>> efficiently the aggregate method:
>>
>> More specifically, I would like to calculate the mean of certain
>> values on a data frame,  grouped by various attributes, and then
>> create a new column in the data frame that will have the corresponding
>> mean for every row. I attach part of my code:
>>
>> matchMean <- function(ind,dataTable,aggrTable)
>> {
>>index <- which((aggrTable[,1]==dataTable[["Attr1"]][ind]) &
>> (aggrTable[,2]==dataTable[["Attr2"]][ind]))
>>as.numeric(aggrTable[index,3])
>> }
>>
>> avgDur <- aggregate(ap.dat[["Dur"]], by = list(ap.dat[["Attr1"]],
>> ap.dat[["Attr2"]]), FUN="mean")
>> meanDur <- sapply((1:length(ap.dat[,1])), FUN=matchMean, ap.dat, avgDur)
>> ap.dat <- cbind (ap.dat, meanDur)
>>
>> As I deal with very large dataset, it takes long time to run my
>> matching function, so if you had an idea on how to automate more this
>> matching process I would be really grateful.
>>
>> Thank you very much in advance!
>>
>> Kind regards,
>> Stella
>>
>>
>>
>> --
>> Stella Pachidi
>> Master in Business Informatics student
>> Utrecht University
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>


-- 
Stella Pachidi
Master in Business Informatics student
Utrecht University
email: s.pach...@students.uu.nl
tel: +31644478898

[[alternative HTML version deleted]]

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


Re: [R] How to make R automatic?

2010-06-01 Thread Nikhil Kaza

?difftime
?file.info
file.info(filename)$mtime
Sys.sleep(20)


Nikhil Kaza
Asst. Professor,
City and Regional Planning
University of North Carolina

nikhil.l...@gmail.com



On Jun 1, 2010, at 10:07 AM, zhangted001 wrote:



Hello, I have a question about how R can run automatically.  Here is  
the

story:

A file called "data.csv" will be generated every couple of minutes  
in a

folder (overwrite itself). What I want R to do is:

1) scan the folder to find the file.
2) if the file is a newly generated file, process the file
3) output some file identifier on the screen, such as the time when  
the file

was generated.
4) pause for 20 seconds (doesnt need to be precise) and repeat 1)

Idealy, I would like R to do this everyday from 9:00am to 6:00pm.

What I got so far is: I can use list.files() and file.info to get 1)  
and 2).
For 4), I can write some trivial loop to kill some time, but I would  
like to
be more accurate tham that, considering different PC running the  
loop.  I

have no idea about 3).

Any suggestion/better solution?

Thank you very much!!

Best regards,
Ted







--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-make-R-automatic-tp2238541p2238541.html
Sent from the R help mailing list archive at Nabble.com.

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


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


Re: [R] storing output data from a loop that has varying row numbers

2010-06-01 Thread Joris Meys
OK, then I was right. It's exactly what my code does.
Enjoy.
Cheers

On Tue, Jun 1, 2010 at 4:25 PM, RCulloch  wrote:

>
> Hi Joris,
>
> Thanks for your help!
>
> The data as requested:
>
> structure(list(FROM = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L),
>TO = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L,
>2L, 3L, 4L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L,
>3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), DIST = c(2.63981,
>0, 6.95836, 8.63809, 0, 2.63981, 8.03071, 8.90896, 8.90896,
>8.63809, 2.85602, 0, 8.03071, 6.95836, 0, 2.85602, 3.53695,
>4.32457, 0, 8.85851, 12.09194, 7.44743, 0, 4.32457, 13.16728,
>16.34761, 6.13176, 13.16728, 8.85851, 0, 3.40726, 9.03345,
>16.34761, 12.09194, 3.40726, 0, 0, 7.44743, 3.53695, 6.13176,
>9.03345), ID = structure(c(12L, 12L, 12L, 12L, 11L, 11L,
>11L, 11L, 14L, 14L, 14L, 14L, 13L, 13L, 13L, 143L, 12L, 12L,
>12L, 12L, 12L, 11L, 11L, 11L, 11L, 11L, 14L, 14L, 14L, 14L,
>14L, 13L, 13L, 13L, 13L, 13L, 94L, 94L, 94L, 94L, 94L), .Label =
> c("'11.1'",
>"'15.1'", "'15.5'", "'18.1'", "'24.2'", "'26.1'", "'26.2'",
>"'28.3'", "'4.2'", "'7.1'", "'A1.1'", "'A1'", "'A2.1'", "'A2'",
>"'B1'", "'C1'", "'D1.1'", "'D1'", "'D2.1'", "'D2'", "'D3.1'",
>"'D3'", "'D4.1'", "'D4'", "'D5.1'", "'D5'", "'D6.1'", "'D6'",
>"'E1.1'", "'E1'", "'E2.1'", "'E2'", "'E4'", "'E5'", "'F1.1'",
>"'F1'", "'F10.1'", "'F10'", "'F11'", "'F2'", "'F3'", "'F4.1'",
>"'F4'", "'F5.1'", "'F5'", "'F7'", "'F8.1'", "'F8'", "'G2.1'",
>"'G2'", "'G3.1'", "'G3'", "'G4.1'", "'G4'", "'G5.1'", "'G5'",
>"'H1.1'", "'H1'", "'H2'", "'H3.1'", "'H3'", "'H8'", "'I1.1'",
>"'I1'", "'I2'", "'I4.1'", "'I4'", "'J1.1'", "'J1'", "'J2.1'",
>"'J2'", "'J3'", "'J6'", "'J7'", "'JUV'", "'K1.1'", "'K1'",
>"'K2'", "'K3'", "'K4.1'", "'K4'", "'L1.1'", "'L1'", "'L2.1'",
>"'L2'", "'L4'", "'M1'", "'M2.1'", "'M2'", "'M3.1'", "'M3'",
>"'M4.1'", "'M4'", "'MALE1'", "'N1.1'", "'N1'", "'N2'", "'N3'",
>"'N4.1'", "'N4'", "'O1'", "'O2'", "'O3.1'", "'O3'", "'O4.1'",
>"'O4'", "'O5'", "'P1.1'", "'P1'", "'Q1'", "'Q2'", "'Q3'",
>"'R1.1'", "'R1'", "'R2'", "'R3.1'", "'R3'", "'R4.1'", "'R4'",
>"'R5.1'", "'R5'", "'S1.1'", "'S1'", "'S2.1'", "'S2'", "'S3.1'",
>"'S3'", "'S4.1'", "'S4'", "'T1'", "'U1.1'", "'U1'", "'U2'",
>"'U3'", "'UKFEM'", "'UKMAL'", "'UKPUP'", "'V1.1'", "'V1'",
>"'W1.1'", "'W1'", "'WR'", "A2.1'"), class = "factor"), HR = c(9L,
>9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
>10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
>10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
>10L), DD = c(30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
>30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
>30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L,
>30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L), MM = c(9L, 9L, 9L,
>9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
>9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L,
>9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L), YY = c(7L, 7L, 7L, 7L, 7L,
>7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
>7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L,
>7L, 7L, 7L, 7L, 7L, 7L), ANIMAL = c(1L, 1L, 1L, 1L, 7L, 7L,
>7L, 7L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L, 1L, 1L, 1L, 1L, 1L,
>7L, 7L, 7L, 7L, 7L, 1L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L, 7L,
>12L, 12L, 12L, 12L, 12L), DAY = c(1L, 1L, 1L, 1L, 1L, 1L,
>1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
>1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
>1L, 1L, 1L, 1L, 1L)), .Names = c("FROM", "TO", "DIST", "ID",
> "HR", "DD", "MM", "YY", "ANIMAL", "DAY"), row.names = c(NA, 41L
> ), class = "data.frame")
>
>
>
> The output should be as the original file is, but it should have an
> additional column for 'TO_ID'
>
> I hope that makes sense?
>
> Cheers,
>
> Ross
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238576.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.
>



-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[alternative HTML version deleted]]

__
R-he

Re: [R] How to make R automatic?

2010-06-01 Thread Peter Ehlers


On 2010-06-01 8:07, zhangted001 wrote:


Hello, I have a question about how R can run automatically.  Here is the
story:

A file called "data.csv" will be generated every couple of minutes in a
folder (overwrite itself). What I want R to do is:

1) scan the folder to find the file.
2) if the file is a newly generated file, process the file
3) output some file identifier on the screen, such as the time when the file
was generated.
4) pause for 20 seconds (doesnt need to be precise) and repeat 1)

Idealy, I would like R to do this everyday from 9:00am to 6:00pm.

What I got so far is: I can use list.files() and file.info to get 1) and 2).
For 4), I can write some trivial loop to kill some time, but I would like to
be more accurate tham that, considering different PC running the loop.  I
have no idea about 3).


For (3), assign the value of file.info:

 fi <- file.info("data.csv")
 print(fi[, "mtime"])

For (4) see help(Sys.sleep)

  -Peter Ehlers



Any suggestion/better solution?

Thank you very much!!

Best regards,
Ted


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

2010-06-01 Thread Charles C. Berry



?Sys.sleep

On Tue, 1 Jun 2010, zhangted001 wrote:



Hello, I have a question about how R can run automatically.  Here is the
story:

A file called "data.csv" will be generated every couple of minutes in a
folder (overwrite itself). What I want R to do is:

1) scan the folder to find the file.
2) if the file is a newly generated file, process the file
3) output some file identifier on the screen, such as the time when the file
was generated.
4) pause for 20 seconds (doesnt need to be precise) and repeat 1)

Idealy, I would like R to do this everyday from 9:00am to 6:00pm.

What I got so far is: I can use list.files() and file.info to get 1) and 2).
For 4), I can write some trivial loop to kill some time, but I would like to
be more accurate tham that, considering different PC running the loop.  I
have no idea about 3).

Any suggestion/better solution?

Thank you very much!!

Best regards,
Ted







--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-make-R-automatic-tp2238541p2238541.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.



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

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


Re: [R] Help on aggregate method

2010-06-01 Thread Joris Meys
Take a look at
?split (and unsplit)

eg:
Dur <- rnorm(100)
Attr1=rep(c("A","B"),each=50)
Attr2=rep(c("A","B"),times=50)

ap.dat <-data.frame(Attr1,Attr2,Dur)

split.fact <- paste(ap.dat$Attr1,ap.dat$Attr2)
ap.list <-split(ap.dat,split.fact)
ap.mean <-lapply(ap.list,function(x){
x$meanDur=rep(mean(x$Dur),dim(x)[1])
return(x)
  })

ap.dat.fast <- unsplit(ap.mean,split.fact)

system.time on 1000 replicates gives :
> system.time(replicate(1000,{
+ split.fact <- paste(ap.dat$Attr1,ap.dat$Attr2)
+ ap.list <-split(ap.dat,split.fact)
+ ap.mean <-lapply(ap.list,functi  [TRUNCATED]
   user  system elapsed
   4.880.004.88
> source(.trPaths[5], echo=TRUE, max.deparse.length=150)

> system.time(replicate(1000,{
+ avgDur <- aggregate(ap.dat[["Dur"]], by = list(ap.dat[["Attr1"]],
+ ap.dat[["Attr2"]]), FUN="mean")
+ meanDur <- sapp  [TRUNCATED]
   user  system elapsed
  58.000.11   58.13
>

It should be a tenfold faster.

Cheers
Joris


On Tue, Jun 1, 2010 at 4:48 PM, Stella Pachidi wrote:

> Dear R experts,
>
> I would really appreciate if you had an idea on how to use more
> efficiently the aggregate method:
>
> More specifically, I would like to calculate the mean of certain
> values on a data frame,  grouped by various attributes, and then
> create a new column in the data frame that will have the corresponding
> mean for every row. I attach part of my code:
>
> matchMean <- function(ind,dataTable,aggrTable)
> {
>index <- which((aggrTable[,1]==dataTable[["Attr1"]][ind]) &
> (aggrTable[,2]==dataTable[["Attr2"]][ind]))
>as.numeric(aggrTable[index,3])
> }
>
> avgDur <- aggregate(ap.dat[["Dur"]], by = list(ap.dat[["Attr1"]],
> ap.dat[["Attr2"]]), FUN="mean")
> meanDur <- sapply((1:length(ap.dat[,1])), FUN=matchMean, ap.dat, avgDur)
> ap.dat <- cbind (ap.dat, meanDur)
>
> As I deal with very large dataset, it takes long time to run my
> matching function, so if you had an idea on how to automate more this
> matching process I would be really grateful.
>
> Thank you very much in advance!
>
> Kind regards,
> Stella
>
>
>
> --
> Stella Pachidi
> Master in Business Informatics student
> Utrecht University
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[alternative HTML version deleted]]

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


[R] using the design matrix to correctly configure contrasts

2010-06-01 Thread Karl Brand

Esteemed R-forum subscribers,

I'm having a tough time configuring contrasts for my 3-way ANOVA. In short:

I don't know how to configure (all) my contrasts correctly in order to 
specify (all) my comparisons of interest.


I succeeded getting my contrasts of interest set up for a simpler 2-way 
ANOVA based on the fairly intuitive logic of the design col.names.


But i'm not able to extend this logic to a more complex three way ANOVA. 
Obviously there *is* a logic to the "0's" and "1's" of R's design 
'treatment contrast' matrix- i see that the "1's" correspond to each of 
the factors that an observation is associated with. But exactly how this 
information can be used to ascribe contrasts of interest remains beyond 
my understanding, especially where interaction is concerned. Googling 
for days didn't yield the help i was looking for.


Can some one point me to a detailed explanation (suitable for R 
dilettantes) how to specify any contrast of interest given a design matrix?


For anyone really needing some diversion, i'd *really* appreciate a 
personal explanation using my design as an example. Warning- its not 
small...


#load limma package to analyse affy gene expression data
library(limma)

targets <- read.delim("targets.txt")

#factors & levels
Time <- factor(targets$Time, levels = c("t1", "t2", "t3", "t4",
"t5", "t6", "t7", "t8",
"t9", "t10", "t11", "t12",
"t13", "t14", "t15", "t16"))
Tissue <- factor(targets$Tissue, levels = c("R", "C"))
Pperiod <- factor(targets$Pperiod, levels = c("E", "L", "S"))

#model excluding the 3-way interaction (written for convenience to
# build on previous 2-way ANOVA
design <- model.matrix(~Time + Tissue + Pperiod + Time:Tissue + 
Time:Pperiod + Tissue:Pperiod)


fit <- lmFit(rma.pp, design)

#how does this design look:

> colnames(design)
 [1] "(Intercept)"  "Timet2"
 [3] "Timet3"   "Timet4"
 [5] "Timet5"   "Timet6"
 [7] "Timet7"   "Timet8"
 [9] "Timet9"   "Timet10"
[11] "Timet11"  "Timet12"
[13] "Timet13"  "Timet14"
[15] "Timet15"  "Timet16"
[17] "TissueC"  "PperiodL"
[19] "PperiodS" "Timet2:TissueC"
[21] "Timet3:TissueC"   "Timet4:TissueC"
[23] "Timet5:TissueC"   "Timet6:TissueC"
[25] "Timet7:TissueC"   "Timet8:TissueC"
[27] "Timet9:TissueC"   "Timet10:TissueC"
[29] "Timet11:TissueC"  "Timet12:TissueC"
[31] "Timet13:TissueC"  "Timet14:TissueC"
[33] "Timet15:TissueC"  "Timet16:TissueC"
[35] "Timet2:PperiodL"  "Timet3:PperiodL"
[37] "Timet4:PperiodL"  "Timet5:PperiodL"
[39] "Timet6:PperiodL"  "Timet7:PperiodL"
[41] "Timet8:PperiodL"  "Timet9:PperiodL"
[43] "Timet10:PperiodL" "Timet11:PperiodL"
[45] "Timet12:PperiodL" "Timet13:PperiodL"
[47] "Timet14:PperiodL" "Timet15:PperiodL"
[49] "Timet16:PperiodL" "Timet2:PperiodS"
[51] "Timet3:PperiodS"  "Timet4:PperiodS"
[53] "Timet5:PperiodS"  "Timet6:PperiodS"
[55] "Timet7:PperiodS"  "Timet8:PperiodS"
[57] "Timet9:PperiodS"  "Timet10:PperiodS"
[59] "Timet11:PperiodS" "Timet12:PperiodS"
[61] "Timet13:PperiodS" "Timet14:PperiodS"
[63] "Timet15:PperiodS" "Timet16:PperiodS"
[65] "TissueC:PperiodL" "TissueC:PperiodS"

#the contrasts that i believe i *can* work out correctly:

cont.matrix <- cbind(

t1.S.RvsAll.S.R.Times =
  c( 0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
 0,  0),

t1.E.RvsAll.E.R.Times =
  c( 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0),

t1.L.RvsAll.L.R.Times =
  c( 0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
 1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
 0,  0)
  )

fit2 <- contrasts.fit(fit, cont.matrix)
fit3 <- eBayes(fit2)

#sensical out put follows suggesting i'm on the right track

BUT! Most basically, the contrasts i can NOT work out are:

t1.S.CvsAll.Times & t1.L.CvsAll.Times

ie., similar to t1.S.RvsAll.Times & t1.S.RvsAll.Times above but for the 
"C" tissue, not the "S".





--
Karl Brand 
Department of Genetics
Erasmus MC
Dr Molewaterplein 50
3015 GE Rotterdam
P +31 (0)10 704 3409 | F +31 (0)10 704 4743 | M +31 (0)642 777 268

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

[R] How to make R automatic?

2010-06-01 Thread zhangted001

Hello, I have a question about how R can run automatically.  Here is the
story:

A file called "data.csv" will be generated every couple of minutes in a
folder (overwrite itself). What I want R to do is:

1) scan the folder to find the file.
2) if the file is a newly generated file, process the file
3) output some file identifier on the screen, such as the time when the file
was generated.
4) pause for 20 seconds (doesnt need to be precise) and repeat 1)

Idealy, I would like R to do this everyday from 9:00am to 6:00pm.

What I got so far is: I can use list.files() and file.info to get 1) and 2). 
For 4), I can write some trivial loop to kill some time, but I would like to
be more accurate tham that, considering different PC running the loop.  I
have no idea about 3).

Any suggestion/better solution?

Thank you very much!!

Best regards,
Ted







-- 
View this message in context: 
http://r.789695.n4.nabble.com/How-to-make-R-automatic-tp2238541p2238541.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] storing output data from a loop that has varying row numbers

2010-06-01 Thread RCulloch

Hi Ivan,

Thanks again for your help! I'll just go through your questions...

I'm still really confused about your question.
-Sorry!!!


Let me ask you some specific questions (maybe someone more experienced
would understand at once, but I'm no expert; I hope I can still help
you! In any case, I would like to understand for myself ;) )

- is "seal_dist" the name of your data.frame?
yes 
so..
head(seal_dist)

  FROM TODIST ID HR DD MM YY ANIMAL DAY
11  1 2.63981   'A1'  9 30  9  7  1   1
21  2 0.0   'A1'  9 30  9  7  1   1
31  3 6.95836   'A1'  9 30  9  7  1   1
41  4 8.63809   'A1'  9 30  9  7  1   1
51  1 0.0 'A1.1'  9 30  9  7  7   1
61  2 2.63981 'A1.1'  9 30  9  7  7   1


- what do you want to do with
SEL_DAY[i]=dist[i]

That was a (desperate) attempt to do 'something', but didn't work - so
shouldn't have been in the script I posted, sorry!

? What is "dist"? 
It is a measure of distance from one point (ID) to another i.e. the distance
between A1 and A1.1

If I understand well, you want to replace the values
in FROM (then TO, then DIST...) with the values from the same column
number in dist?

The problem is that Arc doesn't output the data as I'd like, so I want to
create a new column to add to the data. What Arc has done is taken a
distance between each ID for each hour, but because the number of IDs in
each hour don't match it means that the TO number is not unique to the ID
throughout the entire dataset, only on that given hour. So when distance = 0
in the TO column then that TO number -s equal to the ID i.e. the distance to
A1 to A1 is 0, so I then want to use that information to create a new column
that will tell me the actual ID. If that is any clearer?


- Since I still haven't understood your goal completely, I still don't
understand why you add the column TO_ID to SEL_HR.
see above


- In any case, a matrix cannot work because you want to store data of
different classes in DIST_LOOP (ID is character and the others are
numeric). You can either use a data.frame (if you really want to have
the table-like structure, which is a list) or a list.
I see, can you advise on how to set up a list to write to?

- Moreover, the output from dput(your data) would really help to see
what you have! 
I have not long posted it, I hope it helps!!

Thanks again for your help Ivan, much appreciated,

Ross

-- 
View this message in context: 
http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238630.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] storing output data from a loop that has varying row numbers

2010-06-01 Thread RCulloch

Hi Joris,

Thanks for your help!

The data as requested:

structure(list(FROM = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 
TO = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 
2L, 3L, 4L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 
3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L), DIST = c(2.63981, 
0, 6.95836, 8.63809, 0, 2.63981, 8.03071, 8.90896, 8.90896, 
8.63809, 2.85602, 0, 8.03071, 6.95836, 0, 2.85602, 3.53695, 
4.32457, 0, 8.85851, 12.09194, 7.44743, 0, 4.32457, 13.16728, 
16.34761, 6.13176, 13.16728, 8.85851, 0, 3.40726, 9.03345, 
16.34761, 12.09194, 3.40726, 0, 0, 7.44743, 3.53695, 6.13176, 
9.03345), ID = structure(c(12L, 12L, 12L, 12L, 11L, 11L, 
11L, 11L, 14L, 14L, 14L, 14L, 13L, 13L, 13L, 143L, 12L, 12L, 
12L, 12L, 12L, 11L, 11L, 11L, 11L, 11L, 14L, 14L, 14L, 14L, 
14L, 13L, 13L, 13L, 13L, 13L, 94L, 94L, 94L, 94L, 94L), .Label =
c("'11.1'", 
"'15.1'", "'15.5'", "'18.1'", "'24.2'", "'26.1'", "'26.2'", 
"'28.3'", "'4.2'", "'7.1'", "'A1.1'", "'A1'", "'A2.1'", "'A2'", 
"'B1'", "'C1'", "'D1.1'", "'D1'", "'D2.1'", "'D2'", "'D3.1'", 
"'D3'", "'D4.1'", "'D4'", "'D5.1'", "'D5'", "'D6.1'", "'D6'", 
"'E1.1'", "'E1'", "'E2.1'", "'E2'", "'E4'", "'E5'", "'F1.1'", 
"'F1'", "'F10.1'", "'F10'", "'F11'", "'F2'", "'F3'", "'F4.1'", 
"'F4'", "'F5.1'", "'F5'", "'F7'", "'F8.1'", "'F8'", "'G2.1'", 
"'G2'", "'G3.1'", "'G3'", "'G4.1'", "'G4'", "'G5.1'", "'G5'", 
"'H1.1'", "'H1'", "'H2'", "'H3.1'", "'H3'", "'H8'", "'I1.1'", 
"'I1'", "'I2'", "'I4.1'", "'I4'", "'J1.1'", "'J1'", "'J2.1'", 
"'J2'", "'J3'", "'J6'", "'J7'", "'JUV'", "'K1.1'", "'K1'", 
"'K2'", "'K3'", "'K4.1'", "'K4'", "'L1.1'", "'L1'", "'L2.1'", 
"'L2'", "'L4'", "'M1'", "'M2.1'", "'M2'", "'M3.1'", "'M3'", 
"'M4.1'", "'M4'", "'MALE1'", "'N1.1'", "'N1'", "'N2'", "'N3'", 
"'N4.1'", "'N4'", "'O1'", "'O2'", "'O3.1'", "'O3'", "'O4.1'", 
"'O4'", "'O5'", "'P1.1'", "'P1'", "'Q1'", "'Q2'", "'Q3'", 
"'R1.1'", "'R1'", "'R2'", "'R3.1'", "'R3'", "'R4.1'", "'R4'", 
"'R5.1'", "'R5'", "'S1.1'", "'S1'", "'S2.1'", "'S2'", "'S3.1'", 
"'S3'", "'S4.1'", "'S4'", "'T1'", "'U1.1'", "'U1'", "'U2'", 
"'U3'", "'UKFEM'", "'UKMAL'", "'UKPUP'", "'V1.1'", "'V1'", 
"'W1.1'", "'W1'", "'WR'", "A2.1'"), class = "factor"), HR = c(9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 
10L), DD = c(30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L, 
30L, 30L, 30L, 30L, 30L, 30L, 30L, 30L), MM = c(9L, 9L, 9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 
9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L), YY = c(7L, 7L, 7L, 7L, 7L, 
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 
7L, 7L, 7L, 7L, 7L, 7L), ANIMAL = c(1L, 1L, 1L, 1L, 7L, 7L, 
7L, 7L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L, 1L, 1L, 1L, 1L, 1L, 
7L, 7L, 7L, 7L, 7L, 1L, 1L, 1L, 1L, 1L, 7L, 7L, 7L, 7L, 7L, 
12L, 12L, 12L, 12L, 12L), DAY = c(1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L)), .Names = c("FROM", "TO", "DIST", "ID", 
"HR", "DD", "MM", "YY", "ANIMAL", "DAY"), row.names = c(NA, 41L
), class = "data.frame")



The output should be as the original file is, but it should have an
additional column for 'TO_ID' 

I hope that makes sense? 

Cheers,

Ross 

-- 
View this message in context: 
http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238576.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Issue with assigning text to matrix

2010-06-01 Thread Peter Ehlers

Jessica,

Two further comments:
1. When you read your data, your character vectors are
   stored as factors; is that what you want?
2. You may be better off using a list.

  -Peter Ehlers

On 2010-06-01 7:47, Sarah Goslee wrote:

On Tue, Jun 1, 2010 at 5:04 AM, Jessica Queree
  wrote:

My issue relates to adding text to a matrix and finding that the text is
converted to a number.



A matrix can only hold one type of data. Since you started with character,
that's what you get.

A dataframe can hold different types of data, both character and numeric.
If you convert your matrix to a dataframe with dataf.frame() it can hold
your output in the manner you expect.

testOutput<- data.frame(matrix(nrow = 200, ncol = 5))

Sarah


This is the section of code I'm having trouble with:



# First, I load in a list of names from a .csv file to 'names'

names<- read.csv(file("Names.csv"))



# Then I define a matrix which will be populated with various test
statistics, with several rows for each entry in names



testOutput<-matrix(nrow = 200, ncol = 5)

for (i in 1:nrow(names)){



testOutput[i,1]<- names[i,1]

testOutput[i,2]<- names[i,2]



# test statistics code here



}


That is, the names are now converted to numbers. I think this might have
something to do with the way I've defined the testOutput matrix, but haven't
been able to find any information about how to fix it. Can anyone help?



Many thanks.





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


[R] BreastCancer Dataset for Classification in kknn

2010-06-01 Thread Nitin
Dear All,

I'm getting a error while trying to apply the BreastCancer dataset
(package=mlbench) to kknn (package=kknn) that I don't understand as I'm new
to R.
The codes are as follow:

rm = (list = ls())
library(mlbench)
data(BreastCancer)
library(kknn)

BCancer = na.omit(BreastCancer)
d  = dim(BCancer)[1]
i1 = seq(1, d, 2)
i2 = seq(2, d, 2)

t1 = BCancer[i1, ]
t2 = BCancer[i2, ]
y2  = BCancer[i2, 11]

x = 10
k = array(1:x, dim = c(x,1))
ker = array(c( "rectangular", "triangular", "epanechnikov", "biweight",
"triweight", "cos", "inv", "gaussian"), dim = c(8,1))

f = function(x, ker){

BreastCancer.kknn  <-  kknn(Class~., train = t1, test = t2, k = x,
kernel = ker, distance = 1)
fit = fitted(BreastCancer.kknn)

z <- (fit==y2)
z.e <- (100 - (length(y2)-length(z[!z]))/length(y2)*100 )
}

err.k = function(ker){
error.BreastCancer = apply(k,1,function(y) f(y, ker))
}

err.ker = apply(ker, 1, err.k)
colnames(err.ker) = c("rectangular", "triangular", "epanechnikov",
"biweight",
"triweight", "cos", "inv", "gaussian")
print(err.ker)

It throws a error: Error in as.matrix(learn[, ind == i]) :
  (subscript) logical subscript too long
In addition: Warning messages:
1: In model.matrix.default(mt, mf) : variable 'Id' converted to a factor
2: In model.matrix.default(mt, test) : variable 'Id' converted to a factor

I tried the codes with other datasets in mlbench package and most of them
working. That is the mistake here for this particular dataset and how can I
solve it?

Thanks
Nitin

[[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] Question about the license of an R package

2010-06-01 Thread Mauricio Zambrano
Dear R-users,

I'm developing a package that heavily depends on another package
released under the GPL-2 license.

In addition, some few functions depends on other packages released
under the following licences (as described in the corresponding pages
of http://cran.r-project.org/web/packages/):

GPL
GPL >=2.

I want to release my package under a GPL >= 2 license, and after
reading the section 1.1.1 of the R-exts manual and looking at the
compatibility matrix found on http://gplv3.fsf.org/dd3-faq,  I'm still
in doubt if I can do that.

I would appreciate if you could tell me if can I release my package
under a GPL >= 2 license considering the aforementioned licenses ?


Finally, a general question:

When a package is released under GPL >=2, does it mean that the terms
of the GPL-3 license apply or not ?


Thanks in advance for any help.

Mauricio

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


Re: [R] data frame manipulation with zero rows

2010-06-01 Thread arnaud Gaboury
It is indeed ddply() from package plyr.





> -Original Message-
> From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
> Sent: Tuesday, June 01, 2010 12:24 PM
> To: Peter Ehlers
> Cc: arnaud Gaboury; r-help@r-project.org
> Subject: Re: [R] data frame manipulation with zero rows
> 
> On Tue, 1 Jun 2010, Peter Ehlers wrote:
> 
> > On 2010-06-01 1:53, arnaud Gaboury wrote:
> >> Brian,
> >>
> >> If I do understand correctly, I must use in my function something
> else than
> >> ddply() if I want to avoid any error each time my df has zero rows?
> >> Am I correct?
> >>
> >
> > You could define a function to handle the zero-rows case:
> >
> > f <- function(x){
> > if(nrow(x) < 1) out <- x[, c(1,3,2)]  # or whatever
> > else
> >   out <- ddply(x, c("DESCRIPTION","SETTLEMENT"), summarise,
> >POSITION=sum(QUANTITY))[,c(1,3,2)]
> > out
> > }
> > f(futures)
> 
> Or simply fix ddply.  We don't know what that is or what it should do
> for the case of zero rows: it may or may not be the one in package
> plyr.
> 
> >
> > -Peter Ehlers
> >
> >>
> >>
> >>> -Original Message-
> >>> From: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk]
> >>> Sent: Tuesday, June 01, 2010 9:47 AM
> >>> To: arnaud Gaboury
> >>> Subject: Re: [R] data frame manipulation with zero rows
> >>>
> >>> On Tue, 1 Jun 2010, arnaud Gaboury wrote:
> >>>
>  Dear group,
> 
>  Here is the kind of data.frame I obtain every day with my function
> :
> 
>  futures<-
>  structure(list(DESCRIPTION = c("CORN Jul/10", "CORN Jul/10",
>  "CORN Jul/10", "CORN Jul/10", "CORN Jul/10", "LIVE CATTLE Aug/10",
>  "LIVE CATTLE Aug/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10",
>  "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 Jul/10"
>  ), CREATED.DATE = structure(c(18403, 18406, 18406, 18406, 18406,
>  18407, 18408, 18406, 18407, 18407, 18407, 18407), class = "Date"),
>  QUANTITY = c(1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1), SETTLEMENT =
>  c("373.2500",
>  "373.2500", "373.2500", "373.2500", "373.2500", "90.7750",
>  "90.7750", "14.9200", "14.9200", "14.9200", "14.9200",
> "14.9200"
>  )), .Names = c("DESCRIPTION", "CREATED.DATE", "QUANTITY",
>  "SETTLEMENT"), row.names = c(NA, 12L), class = "data.frame")
> 
>  I need then to apply to the df this following code line :
> 
> > PosFut=ddply(futures, c("DESCRIPTION","SETTLEMENT"), summarise,
> >>> POSITION=
>  sum(QUANTITY))[,c(1,3,2)]
> 
>  It works perfectly in most of case, BUT I have a new problem: it
> can
>  sometime occurs that my df "futures" is empty, with zero rows.
> 
> 
>  futures<-
>  structure(list(DESCRIPTION = character(0), CREATED.DATE =
>  structure(numeric(0), class = "Date"),
>  QUANTITY = numeric(0), SETTLEMENT = character(0)), .Names =
>  c("DESCRIPTION",
>  "CREATED.DATE", "QUANTITY", "SETTLEMENT"), row.names = integer(0),
> >>> class =
>  "data.frame")
> 
>  It is not the usual case, but it can happen. With this df, when I
> >>> pass the
>  above mentione line, I get an error :
> 
> > PosFut=ddply(futures, c("DESCRIPTION","SETTLEMENT"), summarise,
> >>> POSITION=
>  sum(QUANTITY))[,c(1,3,2)]
>  Error in tapply(1:nrow(data), splitv, list) :
>    arguments must have same length
> 
> 
>  How can I avoid this when my df is empty?
> >>>
> >>> Ask the author of the (missing) function ddply() to correct the
> error
> >>> of using 1:nrow(data) by replacing it by seq_len(nrow(data)).
> >>>
> >>> It's helpful to give example code, but much more helpful if you
> test
> >>> it: yours cannot work without the function ddply() -- this is what
> >>> 'self-contained' means in the footer here.
> 
> --
> Brian D. Ripley,  rip...@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel:  +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Help on aggregate method

2010-06-01 Thread Erik Iverson
It's easiest for us to help if you give us a reproducible example.  We 
don't have your datasets (ap.dat), so we can't run your code below. 
It's easy to create sample data with the random number generators in R, 
or use ?dput to give us a sample of your actual data.frame.


I would guess your problem is solved by ?ave though.

Stella Pachidi wrote:

Dear R experts,

I would really appreciate if you had an idea on how to use more
efficiently the aggregate method:

More specifically, I would like to calculate the mean of certain
values on a data frame,  grouped by various attributes, and then
create a new column in the data frame that will have the corresponding
mean for every row. I attach part of my code:

matchMean <- function(ind,dataTable,aggrTable)
{
index <- which((aggrTable[,1]==dataTable[["Attr1"]][ind]) &
(aggrTable[,2]==dataTable[["Attr2"]][ind]))
as.numeric(aggrTable[index,3])
}

avgDur <- aggregate(ap.dat[["Dur"]], by = list(ap.dat[["Attr1"]],
ap.dat[["Attr2"]]), FUN="mean")
meanDur <- sapply((1:length(ap.dat[,1])), FUN=matchMean, ap.dat, avgDur)
ap.dat <- cbind (ap.dat, meanDur)

As I deal with very large dataset, it takes long time to run my
matching function, so if you had an idea on how to automate more this
matching process I would be really grateful.

Thank you very much in advance!

Kind regards,
Stella



--
Stella Pachidi
Master in Business Informatics student
Utrecht University

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


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


Re: [R] storing output data from a loop that has varying row numbers

2010-06-01 Thread Joris Meys
Sorry, forgot to add the sel. This is the first line, then just run the
rest.

sel <- as.factor(paste(seal_dist[,10],"-",seal_dist[,5],sep=""))

cheers
Joris

On Tue, Jun 1, 2010 at 4:56 PM, Joris Meys  wrote:

> Is this what you're looking for?
>
> seal_list <- split(seal_dist,sel)
>
> out <- lapply(seal_list,function(x){
>   indx <- subset(x, x$DIST == 0)
>   x$TO_ID <- indx$ID[match(x$TO, indx$TO)]
>   return(x)
> })
>
> output <- unsplit(out,sel)
>
> Cheers
> Joris
>
> On Tue, Jun 1, 2010 at 3:32 PM, RCulloch  wrote:
>
>>
>> Hi Ivan,
>>
>> Thanks for your help, your initial suggestion did not work, but that is no
>> doubt down to my lack of making sense!
>>
>> Here is a short example of my dataset. Basically the loop is set up to
>> match
>> the ID with the TO column based on DIST = 0. So A1 = 2, A1.1 =1, A2 = 4,
>> A2.1 = 3. That is fine for HR 9, but for HR 10 the numbers no longer match
>> those IDs so I need to loop the data and store each loop - if that makes
>> sense.
>>
>>
>>  FROM TO DIST  ID HR DD MM YY ANIMAL DAY
>> 1 1  1  2.63981'A1'  9 30  9  7  1   1
>> 2 1  2  0.0'A1'  9 30  9  7  1   1
>> 3 1  3  6.95836'A1'  9 30  9  7  1   1
>> 4 1  4  8.63809'A1'  9 30  9  7  1   1
>> 5 1  1  0.0  'A1.1'  9 30  9  7  7   1
>> 6 1  2  2.63981  'A1.1'  9 30  9  7  7   1
>> 7 1  3  8.03071  'A1.1'  9 30  9  7  7   1
>> 8 1  4  8.90896  'A1.1'  9 30  9  7  7   1
>> 9 1  1  8.90896'A2'  9 30  9  7  1   1
>> 101  2  8.63809'A2'  9 30  9  7  1   1
>> 111  3  2.85602'A2'  9 30  9  7  1   1
>> 121  4  0.0'A2'  9 30  9  7  1   1
>> 131  1  8.03071  'A2.1'  9 30  9  7  7   1
>> 141  2  6.95836  'A2.1'  9 30  9  7  7   1
>> 151  3  0.0  'A2.1'  9 30  9  7  7   1
>> 161  4  2.85602   A2.1'  9 30  9  7  7   1
>> 171  1  3.53695'A1' 10 30  9  7  1   1
>> 181  2  4.32457'A1' 10 30  9  7  1   1
>> 191  3  0.0'A1' 10 30  9  7  1   1
>> 201  4  8.85851'A1' 10 30  9  7  1   1
>> 211  5 12.09194'A1' 10 30  9  7  1   1
>> 221  1  7.44743  'A1.1' 10 30  9  7  7   1
>> 231  2  0.0  'A1.1' 10 30  9  7  7   1
>> 241  3  4.32457  'A1.1' 10 30  9  7  7   1
>> 251  4 13.16728  'A1.1' 10 30  9  7  7   1
>> 261  5 16.34761  'A1.1' 10 30  9  7  7   1
>> 271  1  6.13176'A2' 10 30  9  7  1   1
>> 281  2 13.16728'A2' 10 30  9  7  1   1
>> 291  3  8.85851'A2' 10 30  9  7  1   1
>> 301  4  0.0'A2' 10 30  9  7  1   1
>> 311  5  3.40726'A2' 10 30  9  7  1   1
>> 321  1  9.03345  'A2.1' 10 30  9  7  7   1
>> 331  2 16.34761  'A2.1' 10 30  9  7  7   1
>> 341  3 12.09194  'A2.1' 10 30  9  7  7   1
>> 351  4  3.40726  'A2.1' 10 30  9  7  7   1
>> 361  5  0.0  'A2.1' 10 30  9  7  7   1
>> 371  1  0.0 'MALE1' 10 30  9  7 12   1
>> 381  2  7.44743 'MALE1' 10 30  9  7 12   1
>> 391  3  3.53695 'MALE1' 10 30  9  7 12   1
>> 401  4  6.13176 'MALE1' 10 30  9  7 12   1
>> 411  5  9.03345 'MALE1' 10 30  9  7 12   1
>>
>>
>> So the loop is:
>>
>> DIST_LOOP<-matrix(NA,NA,ncol=11)
>>
>> for (i in 1:33){
>>SEL_DAY<-seal_dist[seal_dist[,10]==i,]
>> SEL_DAY[i]=dist[i]
>> print(paste("DAY", i, "of 33"))
>>for (s in 1:11){
>>SEL_HR<-SEL_DAY[SEL_DAY[,5]==s,]
>>print(paste("HR", s, "of 11"))
>>indx <- subset(SEL_HR, SEL_HR$DIST == 0)
>>SEL_HR$TO_ID <- indx$ID[match(SEL_HR$TO, indx$TO)]
>> DIST_LOOP[i,]<-SEL_HR
>>}
>>}
>>
>> But storing the data in the DIST_LOOP matrix doesn't work, I am just told
>> in
>> another post that a list might be better than a matrix?
>>
>> I hope this makes more sense!?
>>
>> Many thanks,
>>
>> Ross
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238483.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.
>>
>
>
>
> --
> Joris Meys
> Statistical Consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> Coupure Links 653
> B-9000 Gent
>
> tel : +32 9 264 59 87
> joris.m...@ugent.be
> ---
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>



-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathemati

Re: [R] storing output data from a loop that has varying row numbers

2010-06-01 Thread Joris Meys
Is this what you're looking for?

seal_list <- split(seal_dist,sel)

out <- lapply(seal_list,function(x){
  indx <- subset(x, x$DIST == 0)
  x$TO_ID <- indx$ID[match(x$TO, indx$TO)]
  return(x)
})

output <- unsplit(out,sel)

Cheers
Joris

On Tue, Jun 1, 2010 at 3:32 PM, RCulloch  wrote:

>
> Hi Ivan,
>
> Thanks for your help, your initial suggestion did not work, but that is no
> doubt down to my lack of making sense!
>
> Here is a short example of my dataset. Basically the loop is set up to
> match
> the ID with the TO column based on DIST = 0. So A1 = 2, A1.1 =1, A2 = 4,
> A2.1 = 3. That is fine for HR 9, but for HR 10 the numbers no longer match
> those IDs so I need to loop the data and store each loop - if that makes
> sense.
>
>
>  FROM TO DIST  ID HR DD MM YY ANIMAL DAY
> 1 1  1  2.63981'A1'  9 30  9  7  1   1
> 2 1  2  0.0'A1'  9 30  9  7  1   1
> 3 1  3  6.95836'A1'  9 30  9  7  1   1
> 4 1  4  8.63809'A1'  9 30  9  7  1   1
> 5 1  1  0.0  'A1.1'  9 30  9  7  7   1
> 6 1  2  2.63981  'A1.1'  9 30  9  7  7   1
> 7 1  3  8.03071  'A1.1'  9 30  9  7  7   1
> 8 1  4  8.90896  'A1.1'  9 30  9  7  7   1
> 9 1  1  8.90896'A2'  9 30  9  7  1   1
> 101  2  8.63809'A2'  9 30  9  7  1   1
> 111  3  2.85602'A2'  9 30  9  7  1   1
> 121  4  0.0'A2'  9 30  9  7  1   1
> 131  1  8.03071  'A2.1'  9 30  9  7  7   1
> 141  2  6.95836  'A2.1'  9 30  9  7  7   1
> 151  3  0.0  'A2.1'  9 30  9  7  7   1
> 161  4  2.85602   A2.1'  9 30  9  7  7   1
> 171  1  3.53695'A1' 10 30  9  7  1   1
> 181  2  4.32457'A1' 10 30  9  7  1   1
> 191  3  0.0'A1' 10 30  9  7  1   1
> 201  4  8.85851'A1' 10 30  9  7  1   1
> 211  5 12.09194'A1' 10 30  9  7  1   1
> 221  1  7.44743  'A1.1' 10 30  9  7  7   1
> 231  2  0.0  'A1.1' 10 30  9  7  7   1
> 241  3  4.32457  'A1.1' 10 30  9  7  7   1
> 251  4 13.16728  'A1.1' 10 30  9  7  7   1
> 261  5 16.34761  'A1.1' 10 30  9  7  7   1
> 271  1  6.13176'A2' 10 30  9  7  1   1
> 281  2 13.16728'A2' 10 30  9  7  1   1
> 291  3  8.85851'A2' 10 30  9  7  1   1
> 301  4  0.0'A2' 10 30  9  7  1   1
> 311  5  3.40726'A2' 10 30  9  7  1   1
> 321  1  9.03345  'A2.1' 10 30  9  7  7   1
> 331  2 16.34761  'A2.1' 10 30  9  7  7   1
> 341  3 12.09194  'A2.1' 10 30  9  7  7   1
> 351  4  3.40726  'A2.1' 10 30  9  7  7   1
> 361  5  0.0  'A2.1' 10 30  9  7  7   1
> 371  1  0.0 'MALE1' 10 30  9  7 12   1
> 381  2  7.44743 'MALE1' 10 30  9  7 12   1
> 391  3  3.53695 'MALE1' 10 30  9  7 12   1
> 401  4  6.13176 'MALE1' 10 30  9  7 12   1
> 411  5  9.03345 'MALE1' 10 30  9  7 12   1
>
>
> So the loop is:
>
> DIST_LOOP<-matrix(NA,NA,ncol=11)
>
> for (i in 1:33){
>SEL_DAY<-seal_dist[seal_dist[,10]==i,]
> SEL_DAY[i]=dist[i]
> print(paste("DAY", i, "of 33"))
>for (s in 1:11){
>SEL_HR<-SEL_DAY[SEL_DAY[,5]==s,]
>print(paste("HR", s, "of 11"))
>indx <- subset(SEL_HR, SEL_HR$DIST == 0)
>SEL_HR$TO_ID <- indx$ID[match(SEL_HR$TO, indx$TO)]
> DIST_LOOP[i,]<-SEL_HR
>}
>}
>
> But storing the data in the DIST_LOOP matrix doesn't work, I am just told
> in
> another post that a list might be better than a matrix?
>
> I hope this makes more sense!?
>
> Many thanks,
>
> Ross
> --
> View this message in context:
> http://r.789695.n4.nabble.com/storing-output-data-from-a-loop-that-has-varying-row-numbers-tp2238396p2238483.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.
>



-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

[[alternative HTML version deleted]]

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


  1   2   >