Re: [R] How to open a file with a name changed?

2012-05-24 Thread peter dalgaard

On May 25, 2012, at 02:38 , Rolf Turner wrote:

> ?paste

or ?sprintf, which might lead to more readable code. Also

> format(today, "C:/Bonos/%Y%m%d.csv")
[1] "C:/Bonos/20120525.csv"



> On 25/05/12 11:45, Minerva Mora wrote:
>> Hi, I apologize for my english.
>> 
>> I´m trying to read a file, but the name of this file changes every day, for
>> example: today is May 24, 2012
>> 
>> bonos<- read.table("C:/Bonos/*20120524*.csv", header=TRUE, sep="\t")
>> 
>> So, tomorrow I want to read the file again, but i don´t want to put the date
>> by myself, i want this automatically. I know that if a put day() this
>> instruccion gives me the date.


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

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


Re: [R] R does not recognise columns and rows as they are supposed to be

2012-05-24 Thread Jonsson
Yes I exactly followed what you all suggested: 
X<-(82:92) ; Y<-(364:369) #   for sellected region 
> extract <- double(365) 
> setwd("C:\\Users\\aalyaari\\Desktop\\New folder (10)\\") 
> listfile<-dir() 
> for (i in 1:365) { 
+   conne <- file(listfile[i], "rb") 
+   file1<- readBin(conne, double(),  n=360*720) 
+  file2<-matrix(data=file1,ncol=720,nrow=360) 
+  extract[i]<-mean(file2[X,Y],na.rm=TRUE) 
+   close(conne) }
 write.table(extract,"C:\\Users\\aalyaari\\Desktop\\New folder
(10)\\samregion1.txt") 

But I  am still getting(negative values) all values like:

-3.75E+306 
-1.30E+54 
-1.22E+58 
and the right ones should be like: 
  22.25 
  22.76 
  33.25 

--
View this message in context: 
http://r.789695.n4.nabble.com/R-does-not-recognise-columns-and-rows-as-they-are-supposed-to-be-tp4631217p4631279.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] Filling NA with cumprod?

2012-05-24 Thread Petr Savicky
On Thu, May 24, 2012 at 08:24:38PM -0700, igorre25 wrote:
> Hello,
> 
> I need to build certain interpolation logic using R.  Unfortunately, I just
> started using R, and I'm not familiar with lots of advanced or just
> convenient features of the language to make this simpler.  So I struggled
> for few days and pretty much reduced the whole exercise  to the following
> problem, which I cannot resolve:
> 
> Assume we have a vector of some values with NA:
> a <- c(1, 2, 3, NA, NA, 6, 7, NA, NA, 10)
> 
> and some coefficients as a vector of the same length:
> 
> f <- c(0.9, 1.1, 0.9, 1.1, 0.9, 1.1, 0.9, 1.1, 0.9, 1.1)
> 
> I need to come up with function to get the following output
> 
> o[1] = a[1]
> o[2] = a[2]
> o[3] = a[3]
> o[4] = o[3]*[f3] # Because a[3] is NA
> o[5] = o[4]*[f4] # Because a[4] is NA; This looks like recursive
> calculations;  If the rest of the elements we NA, I would use a * c(rep(1,
> 3), cumprod(f[3:9])), but that's not the case
> o[6] = a[6] # Not NA anymore
> o[7] = a[7]
> o[8] = o[7]*f[7] # Again a[8] is NA
> o[9] = o[8]*f[8]
> o[10] = a[10] # Not NA
> 
> Even though my explanation may seems complex, in reality the requirement is
> pretty simple and in Excel is achieved with a very short formula.
> 
> The need to use R is to demonstrate capabilities of the language and then to
> expand to more complex problems.

Hello:

How is the output defined, if a[1] is NA?

I think, you are not asking for a loop solution. However, in this case,
it can be a reasonable option. For example

  a <- c(1, 2, 3, NA, NA, 6, 7, NA, NA, 10)
  f <- c(0.9, 1.1, 0.9, 1.1, 0.9, 1.1, 0.9, 1.1, 0.9, 1.1)
  n <- length(a)
  o <- rep(NA, times=n)
 
  prev <- 1
  for (i in 1:n) {
  if (is.na(a[i])) {
  o[i] <- f[i]*prev
  } else {
  o[i] <- a[i]
  }
  prev <- o[i]
  }

A more straightforward translation of the Excel formulas is

  getCell <- function(i)
  {
  if (i == 0) return(1)
  if (is.na(a[i])) {
  return(f[i]*getCell(i-1))
  } else {
  return(a[i])
  }
  }

  x <- rep(NA, times=n)
  for (i in 1:n) {
  x[i] <- getCell(i)
  }

  identical(o, x) # [1] TRUE

Petr Savicky.

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


Re: [R] package metafor: specify weights?

2012-05-24 Thread Anke Stein

Dear Wolfgang,

Thank you very much for the quick reply. I already assumed that it might 
get too complicated,

so I will just stick to using a moderator (as you also suggested).

Best,
Anke



On 24.05.2012 17:05, Viechtbauer Wolfgang (STAT) wrote:

At the moment, there is no possibility of specifying the weights with the rma() 
function. While the main model fitting part could be easily adapted to 
incorporate user-specified weights, the problem comes in with all the 
additional statistics that can be computed based on a fitted model. How should 
the predict() function now work? What would be the definition of I^2 now? How 
would one generalize the influence and outlier statistics to that case? Just to 
give some examples.

Of course, I could leave out such things when the user has specified the weights, but 
then things also get confusing for the user. For example, it is already less than ideal 
that you can only use the trim and fill method with models that do not incorporate 
moderators. Nobody has (as of yet) generalized the trim and fill method to that case. But 
when there are too many "special cases", the package becomes unusable.

I did consider user-specified weights at one point, but it opened up so many 
cans of worms that I preferred to quickly put the lid pack on those cans. That 
item is written down in my to-do list, but to be honest, it is somewhere at the 
very end of that list.

If you are hesitant to combine the results from those two types of studies, 
what about simply using a moderator to distinguish the two groups?

Best,

Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Psychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 388-4170 | http://www.wvbauer.com



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Anke Stein
Sent: Thursday, May 24, 2012 15:59
To: r-help@r-project.org
Subject: [R] package metafor: specify weights?

Dear R-experts,
Dear Wolfgang,

Weighted model fitting in metafor uses the inverse of the study specific
variances as weights.
I am wondering if it is possible to specify different weights.

In my meta-analysis, there are two types of studies with (intrinsic)
differences in their range of sample sizes (which are used to calculate
the variances of Fisher's z).
I would like to try normalizing the sample sizes within each set of the
two study types and use these normalized sample sizes as weights.
Would that be possible with rma()? So far, I only found the option
"weighted = TRUE/FALSE", but no possibility to specify which weights
should be used.

Many thanks in advance,
Anke






--
__
Anke Stein (Dipl.-Biol.)

Biodiversity, Macroecology&  Conservation Biogeography Head Prof. Dr.
Holger Kreft Georg-August University of Göttingen Büsgenweg 2 | 37077
Göttingen | Germany

phone +49(0)551-39-13761
fax +49(0)551-39-3618
ast...@uni-goettingen.de
http://www.uni-goettingen.de/biodiversity

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

2012-05-24 Thread igorre25
Hello,

I need to build certain interpolation logic using R.  Unfortunately, I just
started using R, and I'm not familiar with lots of advanced or just
convenient features of the language to make this simpler.  So I struggled
for few days and pretty much reduced the whole exercise  to the following
problem, which I cannot resolve:

Assume we have a vector of some values with NA:
a <- c(1, 2, 3, NA, NA, 6, 7, NA, NA, 10)

and some coefficients as a vector of the same length:

f <- c(0.9, 1.1, 0.9, 1.1, 0.9, 1.1, 0.9, 1.1, 0.9, 1.1)

I need to come up with function to get the following output

o[1] = a[1]
o[2] = a[2]
o[3] = a[3]
o[4] = o[3]*[f3] # Because a[3] is NA
o[5] = o[4]*[f4] # Because a[4] is NA; This looks like recursive
calculations;  If the rest of the elements we NA, I would use a * c(rep(1,
3), cumprod(f[3:9])), but that's not the case
o[6] = a[6] # Not NA anymore
o[7] = a[7]
o[8] = o[7]*f[7] # Again a[8] is NA
o[9] = o[8]*f[8]
o[10] = a[10] # Not NA

Even though my explanation may seems complex, in reality the requirement is
pretty simple and in Excel is achieved with a very short formula.

The need to use R is to demonstrate capabilities of the language and then to
expand to more complex problems.

Any idea?

Thank you.

--
View this message in context: 
http://r.789695.n4.nabble.com/Filling-NA-with-cumprod-tp4631269.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] How to open a file with a name changed?

2012-05-24 Thread Rolf Turner


?paste

On 25/05/12 11:45, Minerva Mora wrote:

Hi, I apologize for my english.

I´m trying to read a file, but the name of this file changes every day, for
example: today is May 24, 2012

bonos<- read.table("C:/Bonos/*20120524*.csv", header=TRUE, sep="\t")

So, tomorrow I want to read the file again, but i don´t want to put the date
by myself, i want this automatically. I know that if a put day() this
instruccion gives me the date.

My problem is, I don´t know how to concatenate these:
-"C:/Bonos/
-the date
-.csv"

I tried this:
bonos<- read.table(cat(cit,dia,extension), header=TRUE, sep="\t")
where
--cit is *"\"C:/Bonos/"*
--dia is *dia<-format(today, "%Y%m%d")*
--extension is *extension<-".csv\""*

but i have this problem:
"C:/Bonos/ 20120524 .csv"*Error in read.table(cat(cit, dia, extension),
header = TRUE, sep = "\t") : * * 'file' must be a character string or
connection*

What can i do?

Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-open-a-file-with-a-name-changed-tp4631261.html
Sent from the R help mailing list archive at Nabble.com.

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


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


[R] levels of comma separated data

2012-05-24 Thread analys...@hotmail.com
I have a data set that has some comma separated strings in each row.
I'd like to create a vector consisting of all distinct strings that
occur.  The number of strings in each row may vary.

Thanks 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] Manually modifying an hclust dendrogram to remove singletons

2012-05-24 Thread Peter Langfelder
On Thu, May 24, 2012 at 9:31 AM,   wrote:
> Dear R-Help,
>
> I have a clustering problem with hclust that I hope someone can help
> me with. Consider the classic hclust example:
>
>     hc <- hclust(dist(USArrests), "ave")
>     plot(hc)
>
> I would like to cut the tree up in such a way so as to avoid small
> clusters, so that we get a minimum number of items in each cluster,
> and therefore avoid singletons. e.g. in this example, you can see that
> Hawaii is split off onto its own at quite a high level. I would like
> to avoid having a single item clustered on its own like this. How can
> I achieve this?
>
> I have tried manually modifying the tree using dendrapply but have not
> been able to produce a valid solution thus far..
>
> Suggestions are welcome.
>
> Best wishes,
>
> Mark

Hi Mark,

I'm not sure how you want to handle the singletons if you don't want
them in a separate cluster. The package WGCNA (I'm the maintainer) and
its dependency dynamicTreeCut contain a few ways of avoiding
singletons as separate clusters.

One way is to remove them from the resulting clusters. To this end,
use function cutreeStatic, specify the cut height and the minimum
number of elements in the cluster. For example,

clusters1 = cutreeStatic(hc, cutHeight = 35, minSize = 3);

This way all branches that have size below 3 are labeled 0.

To see what you get, use the function plotDendroAndColors like this:

plotDendroAndColors(hc, clusters1, rowText = clusters1 );

Each color corresponds to a cluster, and the cluster label is shown by
the numbers (each number is at the start of the corresponding
cluster).

If you'd like to assign everything but want to avoid cluster that are
too small, use the dynamic tree cut approach
(http://www.genetics.ucla.edu/labs/horvath/CoexpressionNetwork/BranchCutting/).
For example:

clusters2 = cutreeDynamic(hc, distM = as.matrix(dist(USArrests)),
minClusterSize = 3, deepSplit = 2)

To show the clusters:
plotDendroAndColors(hc, clusters2, rowText = clusters2 );

If you think the clusters are too big, try setting deepSplit=3 in the
cutreeDynamic call.

The dynamic tree cut basically assigns all singletons and branches
with size less than minClusterSize to the nearest existing cluster
(notice Hawai and the Florida/North Carolina branch), thus basically
combining hierarchical clustering and a PAM-like step Whether that's a
good approach for your research goal is a question you need to answer.

HTH,

Peter

>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Manually modifying an hclust dendrogram to remove singletons

2012-05-24 Thread ilai
Can't put my finger on it but something about your idea rubs me the
wrong way. Maybe it's that the tree depends on the hierarchical
clustering algorithm and the choice on how to trim it should be based
on something more defensible than "avoid singletons". In this example
Hawaii is really different than New Hampshire, why would you want them
clustered together ?

But, it's your work, field of study, whatever. If you are going to do
it anyway, one way would be to loop over cut heights:

 hc <- hclust(dist(USArrests), "ave")
 plot(hc)
 hr <- range(hc$height)
 tol<- diff(hr)/100# set tolerance level
 for(i in seq(1e-4+hr[1],hr[2],tol)){
 hcc <- rect.hclust(hc,h=i)
 if(all(sapply(hcc,length)>1)) break
 }
 str(hcc)

# or if you prefer dendrogram
 dend1<- as.dendrogram(hc)
 for(i in seq(1e-4+hr[1],hr[2],tol)){
 dend2 <- cut(dend1,h=i)
 if(all(sapply(dend2$lower,function(x) attr(x,'members'))>1)) break
 }
 dend2

Cheers

On Thu, May 24, 2012 at 10:31 AM,   wrote:
> Dear R-Help,
>
> I have a clustering problem with hclust that I hope someone can help
> me with. Consider the classic hclust example:
>
>     hc <- hclust(dist(USArrests), "ave")
>     plot(hc)
>
> I would like to cut the tree up in such a way so as to avoid small
> clusters, so that we get a minimum number of items in each cluster,
> and therefore avoid singletons. e.g. in this example, you can see that
> Hawaii is split off onto its own at quite a high level. I would like
> to avoid having a single item clustered on its own like this. How can
> I achieve this?
>
> I have tried manually modifying the tree using dendrapply but have not
> been able to produce a valid solution thus far..
>
> Suggestions are welcome.
>
> Best wishes,
>
> Mark
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 open a file with a name changed?

2012-05-24 Thread David Winsemius


On May 24, 2012, at 7:45 PM, Minerva Mora wrote:


Hi, I apologize for my english.

I´m trying to read a file, but the name of this file changes every  
day, for

example: today is May 24, 2012

bonos<- read.table("C:/Bonos/*20120524*.csv", header=TRUE, sep="\t")

So, tomorrow I want to read the file again, but i don´t want to put  
the date

by myself, i want this automatically. I know that if a put day() this
instruccion gives me the date.

My problem is, I don´t know how to concatenate these:
-"C:/Bonos/
-the date
-.csv"



or even :

paste( gsub("-", "", Sys.Date() ) )
[1] "20120524"

filname <- paste("C:/Bonos/", gsub("-", "", Sys.date() ) , sep="")

--
David.



I tried this:
bonos<- read.table(cat(cit,dia,extension), header=TRUE, sep="\t")
where
--cit is *"\"C:/Bonos/"*
--dia is *dia<-format(today, "%Y%m%d")*
--extension is *extension<-".csv\""*

but i have this problem:
"C:/Bonos/ 20120524 .csv"*Error in read.table(cat(cit, dia,  
extension),

header = TRUE, sep = "\t") : * * 'file' must be a character string or
connection*

What can i do?

Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-open-a-file-with-a-name-changed-tp4631261.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] How to open a file with a name changed?

2012-05-24 Thread David Winsemius


On May 24, 2012, at 7:45 PM, Minerva Mora wrote:


Hi, I apologize for my english.

I´m trying to read a file, but the name of this file changes every  
day, for

example: today is May 24, 2012

bonos<- read.table(*20120524*.csv", header=TRUE, sep="\t")



yr = "2012"
mo = "01
dt = "25"
filnam =paste("C:/Bonos/" , yr, mo, dt,sep="")

bonos <- read.table(filnam, header=TRUE, sep="\t")


So, tomorrow I want to read the file again, but i don´t want to put  
the date

by myself, i want this automatically. I know that if a put day() this
instruccion gives me the date.

My problem is, I don´t know how to concatenate these:
-"C:/Bonos/
-the date
-.csv"

I tried this:
bonos<- read.table(cat(cit,dia,extension), header=TRUE, sep="\t")
where
--cit is *"\"C:/Bonos/"*
--dia is *dia<-format(today, "%Y%m%d")*
--extension is *extension<-".csv\""*

but i have this problem:
"C:/Bonos/ 20120524 .csv"*Error in read.table(cat(cit, dia,  
extension),

header = TRUE, sep = "\t") : * * 'file' must be a character string or
connection*

What can i do?

Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-open-a-file-with-a-name-changed-tp4631261.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] R Error: System is computationally singular

2012-05-24 Thread Nathan Svoboda
Thank you both, 
 
I will try using a zero inflated negative binomial as suggested. I had success 
with negative binomial on previous runs but only when I had fewer covariates 
and only ran a portion (10%) of the data. 
 
I may also try to reduce the number of covariates in the model (i.e., combine 
some of my landcover [LCOVER] classifications). 
 
I have considered using logistic regression and may end up trying that.   
 
I appreciate both of your input and will let you know (i.e., post) the results 
of these suggestions and what ends up working for the benefit of you and others.
 
Thank you for your time and quick responses!!
 
Nate
 
 
Nathan Svoboda
Graduate Research Assistant
Carnivore Ecology Lab
Mississippi State University
 



From: Marc Schwartz [mailto:marc_schwa...@me.com]
Sent: Thu 5/24/2012 3:09 PM
To: Nathan Svoboda
Cc: David Winsemius; r-help@r-project.org
Subject: Re: [R] R Error: System is computationally singular



Nathan,

This does help, as in the first cut you provided, there was no variability in 
LOCS for LCOVER >= 5 and you have very few values of LOCS > 0 (you still do, 
relative to the scale of the total).

Have you tried using a zero inflated negative binomial model (dist = "negbin") 
rather than poisson? I am not sure that the assumption of a zero inflated 
poisson distribution is reasonable with your data. Also, at least in this cut 
of the data, you have no 4's in LOCS and no 8's in LCOVER (same as before).

If my math is correct only 0.006% of your LOCS values are > 0. I am also not 
convinced that you have enough data to differentiate between 1 and >=1 of 
whatever it is you are counting in LOCS.

If that is the case, you might want to consider using logistic regression with 
a dichotomous response variable of LOCS == 0 versus LOCS >= 1. You seem to be 
in the general realm of very rare events given the distribution of LOCS in your 
data.

Regards,

Marc Schwartz


On May 24, 2012, at 2:41 PM, Nathan Svoboda wrote:

> Hi David,
>
> My apologies, I am not sure if this makes a big difference in your assessment 
> of the problem, but the results I just sent were only from a portion (1/15) 
> of the data. The dataset is rather large and the computer I am currently 
> using to set up the models is limited in its capabilities to analyze large 
> datasets. When I run the code you provided on a larger portion of the data 
> (1/2) this is the output I receive:
>
> LCOVER
> LOCS   1   2   3   4   5   6   7   9
>   0 1692196  630659  550623 6140352  180896  255512  785929   63756
>   1 141  30  48 279   9  14  36   1
>   2  17   4   5  14   3   3   4   1
>   3   0   0   0   3   0   0   1   0
>   5   2   0   0   0   0   0   0   0
>
> Thanks again for your time and assistance,
>
> Nate
>
> Nathan Svoboda
> Graduate Research Assistant
> Mississippi State University
>
>
> On May 24, 2012, at 1:57 PM, Nathan Svoboda wrote:
>
>> Greetings,
>>
>> I am trying to fit a zero-inflated Poisson model using zeroinfl()
>> from the
>> pscl library. I have 5 covariates (4 continuous, 1 categorical); the
>> categorical variable has 7 levels.  I have had success fitting
>> models that
>> contain only the continuous covariates; however, when I add the
>> categorical
>> variable to any of the models (or if I run it by itself) I get the
>> following
>> error:
>>
>> Error in solve.default(as.matrix(fit$hessian)) :
>>
>> system is computationally singular: reciprocal condition number =
>> 3.46934e-20
>>
>> The code I am using is:
>>
>> library(pscl)
>> f1 <- formula(LOCS ~ as.factor(LCOVER) + D_ROADS + D_WATER + D_EDGE +
>> D_GRASS)
>> ZIP1 <- zeroinfl(f1, dist="poisson", link = "logit", data = FAWNS)
>>
>> There is no correlation between my covariates. Also, I tried
>> reducing my
>> categorical covariate to 3 levels and still receive the same error.
>> Can
>> anyone suggest why I may be getting this error when I add the
>> categorical
>> covariate?
>>
>
> What does this show:
>
> with( FAWNS, table(LOCS, LCOVER) )
>
> --
> David Winsemius, MD
> West Hartford, CT




[[alternative HTML version deleted]]

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


Re: [R] How to open a file with a name changed?

2012-05-24 Thread Steve Taylor
You probably want to use paste or paste0 instead of cat.
paste0(cit,dia,extension)

Also, this might work: 
tail(dir("C:/Bonos/",patt="csv$"),1)


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Minerva Mora
Sent: Friday, 25 May 2012 11:45a
To: r-help@r-project.org
Subject: [R] How to open a file with a name changed?

Hi, I apologize for my english.

I´m trying to read a file, but the name of this file changes every day, for
example: today is May 24, 2012

bonos<- read.table("C:/Bonos/*20120524*.csv", header=TRUE, sep="\t")

So, tomorrow I want to read the file again, but i don´t want to put the date
by myself, i want this automatically. I know that if a put day() this
instruccion gives me the date.

My problem is, I don´t know how to concatenate these:
-"C:/Bonos/
-the date
-.csv"
 
I tried this:
bonos<- read.table(cat(cit,dia,extension), header=TRUE, sep="\t")
where
--cit is *"\"C:/Bonos/"*
--dia is *dia<-format(today, "%Y%m%d")*
--extension is *extension<-".csv\""*

but i have this problem:
"C:/Bonos/ 20120524 .csv"*Error in read.table(cat(cit, dia, extension),
header = TRUE, sep = "\t") : * * 'file' must be a character string or
connection*

What can i do?

Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-open-a-file-with-a-name-changed-tp4631261.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] applying cbind (or any function) across all components in a list

2012-05-24 Thread David Winsemius


On May 24, 2012, at 6:37 PM, Hans Thompson wrote:

The function I am giving for context is cbind.  Are you asking how I  
would

like to apply the answer to my question?

I am trying to take the results of a Fluidigm SNP microarray,  
organized by

assay into a list (each component is the results of one assay), find
coordinate midpoints ([1,] and [2,] of my XX, XY, and YY clusters  
(these are
genotypes) and is represented by l1.  l2 is the midpoint between XX/ 
XY and
XY/YY although I did not give this in my example for simplicity, and  
I am

now trying to find the midpoint between these new midpoints and their
closest genotype clusters. This is represented as

cbind( l1[[1]][,1]+l2[[1]][,1])/2, (l1[[1]][,2]+l2[[1]][,1])/2,
(l1[[1]][,2]+l2[[1]][,2])/2, (l1[[1]][,3]+l2[[1]][,2])/2 )


cbind would not be much different than c() in this case.



but only works for one assay in the list of 96.


It's not really a function, but rather an expression that will be  
evaluated. If you had a function it might look like :


bindfn <- function(l1, l1) { c( l1[[1]][,1]+l2[[1]][,1])/2, (l1[[1]][, 
2]+l2[[1]][,1])/2,

(l1[[1]][,2]+l2[[1]][,2])/2, (l1[[1]][,3]+l2[[1]][,2])/2 ) }

And you could perhaps (depending on whether l1 and l2 were  
constructed) properly execute:


do.call(bindfn, list(l1,l2))

perhaps:

mapply(bindfn, l1, l2)

You posted an example higher up in the thread but my wife is calling  
me to dinner. Will return later.



 I want to apply this to the
entire list.  My entire code so far is:

## OPEN .CSV and ORGANIZE BY ASSAY


file=""
   {
   rawdata <- read.csv(file, skip = 15)
   OrgAssay <- split(rawdata, rawdata$Assay)


   ## RETURN MIDPOINTS FOR EACH CLUSTER WITHOUT NO CALLS

   #for loop
   ClustMidPts <-list()

   for(locus in 1:length(names(OrgAssay))){
   ClustMidPts[[locus]]<-t(cbind(tapply(OrgAssay[[locus]][,"Allele.X. 
1"],

OrgAssay[[locus]][,"Final"], mean,na.rm=T),
  tapply(OrgAssay[[locus]][,"Allele.Y.1"],
OrgAssay[[locus]][,"Final"], mean,na.rm=T)))}

   names(ClustMidPts)=names(OrgAssay)


## CREATE CLUSTER-CLUSTER MIDPOINT

   #for loop
   ClustClustMidPts <- list()

   for(locus in 1:length(names(ClustMidPts))){
   ClustClustMidPts[[locus]] <-
cbind(XXYX=(ClustMidPts[[locus]][,"XX"]+ClustMidPts[[locus]][,"YX"])/ 
2,

YXYY=(ClustMidPts[[locus]][,"YX"]+ClustMidPts[[locus]][,"YY"])/2)
}

   names(ClustClustMidPts)=names(ClustMidPts)


Please also let me know how I messed up the formatting because it  
shows up
fine in gmail even when I post on Nabble.  How did I assume you were  
using

Nabble?


Because you included no context. We cannot see your earlier postings.  
Expecting us to page out to Nabble or refer back to other item s in  
the thread is considered presumptuous on your part.



 Is this topic included in the posting guide?

YES. It is. And you were asked to read the Posting Guide about 10  
times by now.



--
View this message in context: 
http://r.789695.n4.nabble.com/applying-cbind-or-any-function-across-all-components-in-a-list-tp4631128p4631260.html
Sent from the R help mailing list archive at Nabble.com.

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


David Winsemius, MD
West Hartford, CT

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


Re: [R] R Error: System is computationally singular

2012-05-24 Thread David Winsemius


On May 24, 2012, at 3:41 PM, Nathan Svoboda wrote:


Re: [R] R Error: System is computationally singular
Hi David,

My apologies, I am not sure if this makes a big difference in your  
assessment of the problem, but the results I just sent were only  
from a portion (1/15) of the data. The dataset is rather large and  
the computer I am currently using to set up the models is limited in  
its capabilities to analyze large datasets. When I run the code you  
provided on a larger portion of the data (1/2) this is the output I  
receive:


 LCOVER
LOCS   1   2   3   4   5   6   7   9
   0 1692196  630659  550623 6140352  180896  255512  785929   63756
   1 141  30  48 279   9  14  36   1
   2  17   4   5  14   3   3   4   1
   3   0   0   0   3   0   0   1   0
   5   2   0   0   0   0   0   0   0


I do not see linear dependence (aka computational singularity) in that  
data, but if there are no LOCS values of 4, an missing levels has been  
reported as a show-stopper with zinf models with pscl in the past.  
There could also easily emerge linear dependence if you tabulated the  
entire data set. If level 4 had 3 at level 4 of LCOVER or 1 at level 7  
then there would be linear dependence.


Marc Schwartz, a smarter guy than I,  has already suggested to you  
that your Poisson error structure might not be a good description of  
the data.





Thanks again for your time and assistance,

Nate

Nathan Svoboda
Graduate Research Assistant
Mississippi State University


From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Thu 5/24/2012 1:54 PM
To: Nathan Svoboda
Cc: r-help@r-project.org
Subject: Re: [R] R Error: System is computationally singular


On May 24, 2012, at 1:57 PM, Nathan Svoboda wrote:

> Greetings,
>
> I am trying to fit a zero-inflated Poisson model using zeroinfl()
> from the
> pscl library. I have 5 covariates (4 continuous, 1 categorical); the
> categorical variable has 7 levels.  I have had success fitting
> models that
> contain only the continuous covariates; however, when I add the
> categorical
> variable to any of the models (or if I run it by itself) I get the
> following
> error:
>
> Error in solve.default(as.matrix(fit$hessian)) :
>
>  system is computationally singular: reciprocal condition number =
> 3.46934e-20
>
> The code I am using is:
>
> library(pscl)
> f1 <- formula(LOCS ~ as.factor(LCOVER) + D_ROADS + D_WATER +  
D_EDGE +

> D_GRASS)
> ZIP1 <- zeroinfl(f1, dist="poisson", link = "logit", data = FAWNS)
>
> There is no correlation between my covariates. Also, I tried
> reducing my
> categorical covariate to 3 levels and still receive the same error.
> Can
> anyone suggest why I may be getting this error when I add the
> categorical
> covariate?
>

What does this show:

with( FAWNS, table(LOCS, LCOVER) )

--
David Winsemius, MD
West Hartford, CT




David Winsemius, MD
West Hartford, CT

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


[R] How to open a file with a name changed?

2012-05-24 Thread Minerva Mora
Hi, I apologize for my english.

I´m trying to read a file, but the name of this file changes every day, for
example: today is May 24, 2012

bonos<- read.table("C:/Bonos/*20120524*.csv", header=TRUE, sep="\t")

So, tomorrow I want to read the file again, but i don´t want to put the date
by myself, i want this automatically. I know that if a put day() this
instruccion gives me the date.

My problem is, I don´t know how to concatenate these:
-"C:/Bonos/
-the date
-.csv"
 
I tried this:
bonos<- read.table(cat(cit,dia,extension), header=TRUE, sep="\t")
where
--cit is *"\"C:/Bonos/"*
--dia is *dia<-format(today, "%Y%m%d")*
--extension is *extension<-".csv\""*

but i have this problem:
"C:/Bonos/ 20120524 .csv"*Error in read.table(cat(cit, dia, extension),
header = TRUE, sep = "\t") : * * 'file' must be a character string or
connection*

What can i do?

Thanks!

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-open-a-file-with-a-name-changed-tp4631261.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] applying cbind (or any function) across all components in a list

2012-05-24 Thread Hans Thompson
The function I am giving for context is cbind.  Are you asking how I would
like to apply the answer to my question?

I am trying to take the results of a Fluidigm SNP microarray, organized by
assay into a list (each component is the results of one assay), find
coordinate midpoints ([1,] and [2,] of my XX, XY, and YY clusters (these are
genotypes) and is represented by l1.  l2 is the midpoint between XX/XY and
XY/YY although I did not give this in my example for simplicity, and I am
now trying to find the midpoint between these new midpoints and their
closest genotype clusters. This is represented as

cbind((l1[[1]][,1]+l2[[1]][,1])/2, (l1[[1]][,2]+l2[[1]][,1])/2,
(l1[[1]][,2]+l2[[1]][,2])/2, (l1[[1]][,3]+l2[[1]][,2])/2)

but only works for one assay in the list of 96.  I want to apply this to the
entire list.  My entire code so far is:

## OPEN .CSV and ORGANIZE BY ASSAY


file=""
{
rawdata <- read.csv(file, skip = 15)
OrgAssay <- split(rawdata, rawdata$Assay)


## RETURN MIDPOINTS FOR EACH CLUSTER WITHOUT NO CALLS

#for loop
ClustMidPts <-list()

for(locus in 1:length(names(OrgAssay))){
ClustMidPts[[locus]]<-t(cbind(tapply(OrgAssay[[locus]][,"Allele.X.1"],
OrgAssay[[locus]][,"Final"], mean,na.rm=T),
   tapply(OrgAssay[[locus]][,"Allele.Y.1"],
OrgAssay[[locus]][,"Final"], mean,na.rm=T)))}

names(ClustMidPts)=names(OrgAssay)


## CREATE CLUSTER-CLUSTER MIDPOINT

#for loop
ClustClustMidPts <- list()

for(locus in 1:length(names(ClustMidPts))){
ClustClustMidPts[[locus]] <-
cbind(XXYX=(ClustMidPts[[locus]][,"XX"]+ClustMidPts[[locus]][,"YX"])/2,
YXYY=(ClustMidPts[[locus]][,"YX"]+ClustMidPts[[locus]][,"YY"])/2)
}

names(ClustClustMidPts)=names(ClustMidPts)


Please also let me know how I messed up the formatting because it shows up
fine in gmail even when I post on Nabble.  How did I assume you were using
Nabble?  Is this topic included in the posting guide?

--
View this message in context: 
http://r.789695.n4.nabble.com/applying-cbind-or-any-function-across-all-components-in-a-list-tp4631128p4631260.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] applying cbind (or any function) across all components in a list

2012-05-24 Thread Hans Thompson
Yes. This gives me:

 [,1] [,2] [,3] [,4]
[1,]1234
[2,]2345
 [,1] [,2] [,3] [,4]
[1,]6789
[2,]789   10

BUT, how can I have it still within components like

[[1]]
 [,1] [,2] [,3] [,4]
[1,]1234
[2,]2345

[[2]]
 [,1] [,2] [,3] [,4]
[1,]6789
[2,]789   10

How should I have phrased my question to be specific to this result?

Thanks.

--
View this message in context: 
http://r.789695.n4.nabble.com/applying-cbind-or-any-function-across-all-components-in-a-list-tp4631128p4631258.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] R base package grid does not output raster image

2012-05-24 Thread Patrick Nicholson
I am running 64-bit R 2.15.0 on a Windows Server 2008 R2 Amazon EC2 instance. 
grid does not produce output. For example, the following code should print the 
R logo to the window() device:


library(grid)
library(png)

img.path <- system.file("img", "Rlogo.png", package="png")
bg <- readPNG(img.path)
background <- rasterGrob(unclass(bg))

grid.draw(background)


I, however, see nothing. Is there a flag or option I should be using on Windows 
Server 2008 R2 to enable grid output?

For clarity, the following is how I am actually using images in R plots. This 
code works on my laptop (R 2.15.0, ggplot2 0.8.9):


library(ggplot2)
library(grid)
library(maps)
library(mapproj)
library(png)
library(RgoogleMaps)

counties <- map_data("county", region="virginia")
states <- map_data("state")

tmp <- tempfile(fileext=".png")
bg <- GetMap.bbox(range(counties$long), range(counties$lat), destfile=tmp, 
maptype="satellite", format="png32")
background <- readPNG(tmp)
background <- rasterGrob(unclass(background))

ggplot(counties, aes(long, lat)) + 
  coord_map(xlim=c(bg$BBOX$ll[2], bg$BBOX$ur[2]), ylim=c(bg$BBOX$ll[1], 
bg$BBOX$ur[1])) +
  geom_path(aes(group=group), color="darkgrey") +
  geom_path(data=states, aes(group=group), color="white", size=1) +
  opts(axis.line=theme_blank(), 
   axis.text.x=theme_blank(), 
   axis.text.y=theme_blank(),
   axis.ticks=theme_blank(), 
   axis.title.x=theme_blank(), 
   axis.title.y=theme_blank(),
   axis.ticks.length=unit(0, "lines"), 
   axis.ticks.margin=unit(0, "lines"),
   panel.border=theme_blank(), 
   panel.background=function(...)background,
   panel.grid.major=theme_blank(), 
   panel.grid.minor=theme_blank(),
   panel.margin=unit(0, "lines"), 
   legend.position="none", 
   legend.title=theme_blank(),
   legend.background=theme_blank(),
   plot.margin=unit(0*c(-1.5, -1.5, -1.5, -1.5), "lines"))


Thank you,
Patrick

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


Re: [R] svychisq using two frames

2012-05-24 Thread Thomas Lumley
On Fri, May 25, 2012 at 4:10 AM, lasciel  wrote:

>
> So, I could use ‘rbind’ to stack the two years of data together with their
> appropriate weights into a single data frame.
> svychisq(~MyVar+MyVar, BothYears, statistic=”Chisq”)
>
> But now I have a problem that the variable name is the same across years, so
> how do I differentiate the different time periods in the syntax for the
> formula?  Do I need to also create two new variables per:
> MyVar.1 [year = 1] <- MyVar
> MyVar.2 [year = 2] <- MyVar
> svychisq(~MyVar.1+MyVar.2, BothYears, statistic=”Chisq”, na.rm= TRUE)
>
>
> (I feel like I may be overthinking this and the answer is much simpler)
>
>


You don't need to create two new variables; you just need a year variable

 svychisq(~MyVar+Year, BothYears, statistic=”Chisq”, na.rm= TRUE)

tests whether MyVar is independent of Year.

   -thomas

-- 
Thomas Lumley
Professor of Biostatistics
University of Auckland

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

2012-05-24 Thread Marc Schwartz
Nathan,

This does help, as in the first cut you provided, there was no variability in 
LOCS for LCOVER >= 5 and you have very few values of LOCS > 0 (you still do, 
relative to the scale of the total).

Have you tried using a zero inflated negative binomial model (dist = "negbin") 
rather than poisson? I am not sure that the assumption of a zero inflated 
poisson distribution is reasonable with your data. Also, at least in this cut 
of the data, you have no 4's in LOCS and no 8's in LCOVER (same as before).

If my math is correct only 0.006% of your LOCS values are > 0. I am also not 
convinced that you have enough data to differentiate between 1 and >=1 of 
whatever it is you are counting in LOCS.

If that is the case, you might want to consider using logistic regression with 
a dichotomous response variable of LOCS == 0 versus LOCS >= 1. You seem to be 
in the general realm of very rare events given the distribution of LOCS in your 
data. 

Regards,

Marc Schwartz


On May 24, 2012, at 2:41 PM, Nathan Svoboda wrote:

> Hi David,
> 
> My apologies, I am not sure if this makes a big difference in your assessment 
> of the problem, but the results I just sent were only from a portion (1/15) 
> of the data. The dataset is rather large and the computer I am currently 
> using to set up the models is limited in its capabilities to analyze large 
> datasets. When I run the code you provided on a larger portion of the data 
> (1/2) this is the output I receive:
> 
> LCOVER
> LOCS   1   2   3   4   5   6   7   9
>   0 1692196  630659  550623 6140352  180896  255512  785929   63756
>   1 141  30  48 279   9  14  36   1
>   2  17   4   5  14   3   3   4   1
>   3   0   0   0   3   0   0   1   0
>   5   2   0   0   0   0   0   0   0
> 
> Thanks again for your time and assistance,
> 
> Nate
> 
> Nathan Svoboda
> Graduate Research Assistant
> Mississippi State University
> 
> 
> On May 24, 2012, at 1:57 PM, Nathan Svoboda wrote:
> 
>> Greetings,
>> 
>> I am trying to fit a zero-inflated Poisson model using zeroinfl() 
>> from the
>> pscl library. I have 5 covariates (4 continuous, 1 categorical); the
>> categorical variable has 7 levels.  I have had success fitting 
>> models that
>> contain only the continuous covariates; however, when I add the 
>> categorical
>> variable to any of the models (or if I run it by itself) I get the 
>> following
>> error:
>> 
>> Error in solve.default(as.matrix(fit$hessian)) :
>> 
>> system is computationally singular: reciprocal condition number =
>> 3.46934e-20
>> 
>> The code I am using is:
>> 
>> library(pscl)
>> f1 <- formula(LOCS ~ as.factor(LCOVER) + D_ROADS + D_WATER + D_EDGE +
>> D_GRASS)
>> ZIP1 <- zeroinfl(f1, dist="poisson", link = "logit", data = FAWNS)
>> 
>> There is no correlation between my covariates. Also, I tried 
>> reducing my
>> categorical covariate to 3 levels and still receive the same error. 
>> Can
>> anyone suggest why I may be getting this error when I add the 
>> categorical
>> covariate?
>> 
> 
> What does this show:
> 
> with( FAWNS, table(LOCS, LCOVER) )
> 
> --
> David Winsemius, MD
> West Hartford, CT

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


Re: [R] R Error: System is computationally singular

2012-05-24 Thread Nathan Svoboda
Hi David,
 
My apologies, I am not sure if this makes a big difference in your assessment 
of the problem, but the results I just sent were only from a portion (1/15) of 
the data. The dataset is rather large and the computer I am currently using to 
set up the models is limited in its capabilities to analyze large datasets. 
When I run the code you provided on a larger portion of the data (1/2) this is 
the output I receive:
 
 LCOVER
LOCS   1   2   3   4   5   6   7   9
   0 1692196  630659  550623 6140352  180896  255512  785929   63756
   1 141  30  48 279   9  14  36   1
   2  17   4   5  14   3   3   4   1
   3   0   0   0   3   0   0   1   0
   5   2   0   0   0   0   0   0   0
 
Thanks again for your time and assistance,
 
Nate
 
Nathan Svoboda
Graduate Research Assistant
Mississippi State University
 
 


From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Thu 5/24/2012 1:54 PM
To: Nathan Svoboda
Cc: r-help@r-project.org
Subject: Re: [R] R Error: System is computationally singular




On May 24, 2012, at 1:57 PM, Nathan Svoboda wrote:

> Greetings,
>
> I am trying to fit a zero-inflated Poisson model using zeroinfl() 
> from the
> pscl library. I have 5 covariates (4 continuous, 1 categorical); the
> categorical variable has 7 levels.  I have had success fitting 
> models that
> contain only the continuous covariates; however, when I add the 
> categorical
> variable to any of the models (or if I run it by itself) I get the 
> following
> error:
>
> Error in solve.default(as.matrix(fit$hessian)) :
>
>  system is computationally singular: reciprocal condition number =
> 3.46934e-20
>
> The code I am using is:
>
> library(pscl)
> f1 <- formula(LOCS ~ as.factor(LCOVER) + D_ROADS + D_WATER + D_EDGE +
> D_GRASS)
> ZIP1 <- zeroinfl(f1, dist="poisson", link = "logit", data = FAWNS)
>
> There is no correlation between my covariates. Also, I tried 
> reducing my
> categorical covariate to 3 levels and still receive the same error. 
> Can
> anyone suggest why I may be getting this error when I add the 
> categorical
> covariate?
>

What does this show:

with( FAWNS, table(LOCS, LCOVER) )

--
David Winsemius, MD
West Hartford, CT




[[alternative HTML version deleted]]

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


Re: [R] R Error: System is computationally singular

2012-05-24 Thread Nathan Svoboda
Thank you for your quick reply, 

When I run the code you provide I get this output:

LCOVER
LOCS  1  2  3  4  5  6  7  9
   0 214507  79939  69803 778359  22932  32391  99630   8082
   1 15  7  1 32  0  0  0  0
   2  2  1  0  0  0  0  0  0
   3  0  0  0  1  0  0  0  0

Nate



--
View this message in context: 
http://r.789695.n4.nabble.com/R-Error-System-is-computationally-singular-tp4631242p4631251.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] R Error: System is computationally singular

2012-05-24 Thread Nathan Svoboda
Thank you for your quick reply! 
 
When I run the code you provide I get this output:
 
LCOVER
LOCS  1  2  3  4  5  6  7  9
   0 214507  79939  69803 778359  22932  32391  99630   8082
   1 15  7  1 32  0  0  0  0
   2  2  1  0  0  0  0  0  0
   3  0  0  0  1  0  0  0  0
 
Nate
 
 
 



From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: Thu 5/24/2012 1:54 PM
To: Nathan Svoboda
Cc: r-help@r-project.org
Subject: Re: [R] R Error: System is computationally singular




On May 24, 2012, at 1:57 PM, Nathan Svoboda wrote:

> Greetings,
>
> I am trying to fit a zero-inflated Poisson model using zeroinfl() 
> from the
> pscl library. I have 5 covariates (4 continuous, 1 categorical); the
> categorical variable has 7 levels.  I have had success fitting 
> models that
> contain only the continuous covariates; however, when I add the 
> categorical
> variable to any of the models (or if I run it by itself) I get the 
> following
> error:
>
> Error in solve.default(as.matrix(fit$hessian)) :
>
>  system is computationally singular: reciprocal condition number =
> 3.46934e-20
>
> The code I am using is:
>
> library(pscl)
> f1 <- formula(LOCS ~ as.factor(LCOVER) + D_ROADS + D_WATER + D_EDGE +
> D_GRASS)
> ZIP1 <- zeroinfl(f1, dist="poisson", link = "logit", data = FAWNS)
>
> There is no correlation between my covariates. Also, I tried 
> reducing my
> categorical covariate to 3 levels and still receive the same error. 
> Can
> anyone suggest why I may be getting this error when I add the 
> categorical
> covariate?
>

What does this show:

with( FAWNS, table(LOCS, LCOVER) )

--
David Winsemius, MD
West Hartford, CT




[[alternative HTML version deleted]]

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


Re: [R] R Error: System is computationally singular

2012-05-24 Thread David Winsemius


On May 24, 2012, at 1:57 PM, Nathan Svoboda wrote:


Greetings,

I am trying to fit a zero-inflated Poisson model using zeroinfl()  
from the

pscl library. I have 5 covariates (4 continuous, 1 categorical); the
categorical variable has 7 levels.  I have had success fitting  
models that
contain only the continuous covariates; however, when I add the  
categorical
variable to any of the models (or if I run it by itself) I get the  
following

error:

Error in solve.default(as.matrix(fit$hessian)) :

 system is computationally singular: reciprocal condition number =
3.46934e-20

The code I am using is:

library(pscl)
f1 <- formula(LOCS ~ as.factor(LCOVER) + D_ROADS + D_WATER + D_EDGE +
D_GRASS)
ZIP1 <- zeroinfl(f1, dist="poisson", link = "logit", data = FAWNS)

There is no correlation between my covariates. Also, I tried  
reducing my
categorical covariate to 3 levels and still receive the same error.  
Can
anyone suggest why I may be getting this error when I add the  
categorical

covariate?



What does this show:

with( FAWNS, table(LOCS, LCOVER) )

--
David Winsemius, MD
West Hartford, CT

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


[R] R Error: System is computationally singular

2012-05-24 Thread Nathan Svoboda
Greetings,

I am trying to fit a zero-inflated Poisson model using zeroinfl() from the
pscl library. I have 5 covariates (4 continuous, 1 categorical); the
categorical variable has 7 levels.  I have had success fitting models that
contain only the continuous covariates; however, when I add the categorical
variable to any of the models (or if I run it by itself) I get the following
error: 

Error in solve.default(as.matrix(fit$hessian)) : 

  system is computationally singular: reciprocal condition number =
3.46934e-20

 The code I am using is:

library(pscl)
f1 <- formula(LOCS ~ as.factor(LCOVER) + D_ROADS + D_WATER + D_EDGE +
D_GRASS)
ZIP1 <- zeroinfl(f1, dist="poisson", link = "logit", data = FAWNS)
 
There is no correlation between my covariates. Also, I tried reducing my
categorical covariate to 3 levels and still receive the same error. Can
anyone suggest why I may be getting this error when I add the categorical
covariate?
 
I appreciate your time and input. Thank you,
 
Nate
 
Nathan Svoboda
Graduate Research Assistant
Carnivore Ecology Lab
Mississippi State University

--
View this message in context: 
http://r.789695.n4.nabble.com/R-Error-System-is-computationally-singular-tp4631242.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] R does not recognise columns and rows as they are supposed to be

2012-05-24 Thread William Dunlap
> >   X<-c(364:369) ; Y<-c(82:92) #   for sellected region
> >   ...
> >  file2<-matrix(data=file,ncol=720,nrow=360)
> > extract[i]<-mean(file2[X,Y],na.rm=TRUE)

Note that 2-dimensional subscripts are given as
mat[ROWS, COLUMNS]
and you are using the reverse order, hence you get the
error message that you are asking for rows 364:369 of
a 360-row matrix.

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Rui Barradas
> Sent: Thursday, May 24, 2012 9:48 AM
> To: r-help@r-project.org
> Subject: Re: [R] R does not recognise columns and rows as they are supposed 
> to be
> 
> Hello,
> 
> There are several things with your code, most of which are not errors.
> 
> 1. X<-c(364:369) ; Y<-c(82:92 and later c(1:365)
> Expressions of the form m:n are integer sequences, the c() is not needed.
> 
> 2. extract<-vector()
> First you create the vector, then keep extending it throughout the loop.
> This is much slower.
> If you know the final length (and type), create it like this:
> extract <- numeric(365)   # or double(365)
> 
> 3. 'dir1' is not used.
> 
> 4. Now the readBin instruction:
> 4.1. 'file' is the name of a function, use, say, 'file1' instead.
> 4.2. Option 'signed' defaults to TRUE but it's only valid for integer types.
> 
> 5. And, maybe this is the problem, in R, doubles are 8 bytes, not 4. Get rid
> of option 'size', like the help page says,
> 
> "If size is specified and not the natural size of the object, each element
> of the vector is coerced to an appropriate type before being written or as
> it is read."
> 
> You are NOT reading doubles.

The file may well contain single precision numbers and using
  what="double", size=4
will read them and convert them to doubles so other functions
in R can use them.  (Likewise, readBin can read files containing
1- or 2-byte signed or unsigned integers and store them as the
4-byte signed integers that the rest of R can deal with.)

If the file was created on another sort of machine, then you may
have worry about the byte order - try adding endian="big" or
endian="little".

> 
> As for the rest, it seems ok to me. (Keep option 'n' in readBin.)
> 
> Hope this helps,
> 
> Rui Barradas
> 
> Jonsson wrote
> >
> > Dear All,
> > The code given bellow is to extract  values of one region and write that
> > to a text file(there are 365 binary files in the directory).
> > The problem which I am facing is that all my files are binary with size of
> > 360 rows and 720 columns.
> > I specified that in this line:
> > file2<-matrix(data=file,ncol=720,nrow=360) but I got an error : Error in
> > mean(file2[X, Y], na.rm = TRUE) : subscript out of bounds.
> > and then I rewrote the above line as
> > :file2<-matrix(data=file,ncol=360,nrow=720.I put ncol=360 and nrows =720
> > which is not right.But that worked and I didn't get any error.however,the
> > results were not correct.
> > Any help please
> >  X<-c(364:369) ; Y<-c(82:92) #   for sellected region
> > extract<-vector()
> > dir1<- list.files("C:\\Users\\aalyaari\\Desktop\\New folder
> > (10)\\Climate_Rad_f_GAMMA_%d.img", full.names = TRUE)
> > listfile<-dir()
> > for (i in c(1:365)) {
> >   conne <- file(listfile[i], "rb")
> >   file<- readBin(conne, double(), size=4,  n=720*360, signed=T)
> >  file2<-matrix(data=file,ncol=720,nrow=360)
> > extract[i]<-mean(file2[X,Y],na.rm=TRUE)
> >   close(conne)
> > write.table(extract,"C:\\Users\\aalyaari\\Desktop\\New folder
> > (10)\\sam.txt")}
> >
> 
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/R-does-not-recognise-
> columns-and-rows-as-they-are-supposed-to-be-tp4631217p4631227.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] applying cbind (or any function) across all components in a list

2012-05-24 Thread David Winsemius


On May 24, 2012, at 12:49 PM, Hans Thompson wrote:


I'm confused why I haven't made clear what I am asking for help with.

I have two different lists with two (or many) components, [[1]] and  
[[2]].
One of the list has components with dim=c(2,3) and the other has  
dim=c(2,2).
I want to create a new list with components dim=c(2,4) by binding  
together

the averages of the columns using


cbind((l1[[1]][,1]+l2[[1]][,1])/2, (l1[[1]][,2]+l2[[1]][,1])/2,
(l1[[1]][,2]+l2[[1]][,2])/2, (l1[[1]][,3]+l2[[1]][,2])/2 )


which should put out:

[,1] [,2] [,3] [,4]
[1,]1234
[2,]2345

my problem is finding out how I can apply this function to all the
components within the list in the same function.


Well, it's not clear what "function" you want applied to "what". In  
fact, it's even less clear in this posting than it was in your first  
one (since you assume, incorrectly, that we are looking at this on  
Nabble. Readers of this list expect you to include context.)  I could  
not figure out in your first posting how we should be considering the  
fourth expression


  {(l1[[1]][,3]+l2[[1]][,2])/2 }

... to be an "average" of anything since its indices do not match?  
Perhaps equivalently, why should a 2 x 3 structure merged  to  
a 2 x 2 structure yield a 2 x 4 structure?


--
David Winsemius, MD
West Hartford, CT

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


Re: [R] plot(summary) quantreg - Not all outputs needed

2012-05-24 Thread Peter Ehlers

On 2012-05-24 03:26, stefan23 wrote:

Hi Folks,
I am currently trying to present some results I obtained by using the
quantreg package developed by Roger Koenker. After calculating
fit<-summary(rq(Y~X1+X2, tau=2:98/100) ) the function plot(fit) presents a
really nice the results by showing the values for all "regressors" in the
given interval tau. But in my case, I only need the output of a single
variable, say X1 and I am not interested in plotting the others. Is there a
way to hide the other graphics?


Isn't this accomplished by specifying the argument 'parm'?

  plot(fit, parm = 2)

etc.

Peter Ehlers


Thank you very much for your help,

Cheers
Stefan

--
View this message in context: 
http://r.789695.n4.nabble.com/plot-summary-quantreg-Not-all-outputs-needed-tp4631184.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] applying cbind (or any function) across all components in a list

2012-05-24 Thread David L Carlson
You don't make it clear if you want the two lists processed in parallel, but
if so, this may be a step toward the function you want:

Combine <- function(l1, l2) {
  pattern <- cbind(c(1, 2, 2, 3), c(1, 1, 2, 2))
  for (i in 1:length(l1)) {
print((l1[[i]][,pattern[,1]]+l2[[i]][,pattern[,2]])/2)
  }
}
Combine(l1, l2)

This simply prints the results, but you didn't indicate how you wanted the
output organized.

--
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Greg Snow
> Sent: Thursday, May 24, 2012 10:17 AM
> To: Hans Thompson
> Cc: r-help@r-project.org
> Subject: Re: [R] applying cbind (or any function) across all components
> in a list
> 
> The "do.call" function may be what you want, but it is not completely
> clear.  If that does not solve your problem then try giving us an
> example of what your list looks like (the dput function can help) and
> what you want your end result to look like.
> 
> On Thu, May 24, 2012 at 5:38 AM, Hans Thompson
>  wrote:
> > The combination of column means in cbind is what I am trying to do.
>  I just
> > don't know how to do it for every component (2 in this case) of the
> list.
> > I've been able to work with R to apply a function across all
> components when
> > there is just one list but I am having trouble working with multiple
> lists
> > at the same time.
> >
> > --
> > View this message in context: http://r.789695.n4.nabble.com/applying-
> cbind-or-any-function-across-all-components-in-a-list-
> tp4631128p4631187.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.
> 
> 
> 
> --
> Gregory (Greg) L. Snow Ph.D.
> 538...@gmail.com
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] R does not recognise columns and rows as they are supposed to be

2012-05-24 Thread Jonsson
Yes this helped a lot .
I exactly followed what you suggested:
X<-(82:92) ; Y<-(364:369) #   for sellected region
> extract <- double(365) 
> setwd("C:\\Users\\aalyaari\\Desktop\\New folder (10)\\")
> listfile<-dir()
> for (i in 1:365) {
+   conne <- file(listfile[i], "rb")
+   file1<- readBin(conne, double(),  n=360*720)
+  file2<-matrix(data=file1,ncol=720,nrow=360)
+  extract[i]<-mean(file2[X,Y],na.rm=TRUE)
+   close(conne)
+ write.table(extract,"C:\\Users\\aalyaari\\Desktop\\New folder
(10)\\samregion1.txt")}

But I wonder why  I got all values like

-3.75E+306
-1.30E+54
-1.22E+58
and the right ones should be like:
22.25
22.76
33.25



--
View this message in context: 
http://r.789695.n4.nabble.com/R-does-not-recognise-columns-and-rows-as-they-are-supposed-to-be-tp4631217p4631241.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] inner_perc_table?

2012-05-24 Thread Charles Determan Jr
Thank you William,

Does this mean I should use "" when inner_perc_table is called in the code
then or am I supposed to define a full path?

Regards,
Charles

On Thu, May 24, 2012 at 12:31 PM, William Dunlap  wrote:

> You need to supply a character string, e.g., "inner_perc_table", that names
> the C entry point.  If you supply a name, e.g., entry_point,  or a more
> general expression,
> e.g, entry_points[j], then it will be evaluated with the usual R evaluation
> rules and the result must be a character string.
>
>  > getNativeSymbolInfo("inner_perc_table")
>  $name
>  [1] "inner_perc_table"
>
>  $address
>  
>  attr(,"class")
>  [1] "NativeSymbol"
>
>  $package
>  DLL name: nlme
>  Filename: c:/Program Files/R/R-2.15.0/library/nlme/libs/x64/nlme.dll
>  Dynamic lookup: FALSE
>
>  $numParameters
>  [1] 6
>
>  attr(,"class")
>  [1] "CRoutine" "NativeSymbolInfo"
>
> or
>  > entry_point <- "inner_perc_table"
>  > entry_points <- c("outer_perc_table", "inner_perc_table")
>  > identical(getNativeSymbolInfo(entry_point),
> getNativeSymbolInfo("inner_perc_table"))
>  [1] TRUE
>  > identical(getNativeSymbolInfo(entry_points[2]),
> getNativeSymbolInfo("inner_perc_table"))
>  [1] TRUE
>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf
> > Of Charles Determan Jr
> > Sent: Thursday, May 24, 2012 10:02 AM
> > To: Duncan Murdoch
> > Cc: r-help@r-project.org
> > Subject: Re: [R] inner_perc_table?
> >
> > Thank you Duncan,
> >
> > I used the R function getNativeSymbolInfo(inner_perc_table) and the
> object
> > is not found:
> >
> > Error in is.vector(X) : object 'inner_perc_table' not found
> > Done.
> >
> > I also tried the defining the directory to the nlme.dll file and it had
> the
> > same error.
> > Is there something I missed while doing this?
> >
> > Thanks,
> > Charles
> >
> >
> > On Thu, May 24, 2012 at 11:51 AM, Duncan Murdoch
> > wrote:
> >
> > > On 24/05/2012 11:35 AM, Charles Determan Jr wrote:
> > >
> > >> Hello,
> > >>
> > >> Does anyone on this list know what inner_perc_table is or where it is
> > >> typically found?  I am trying to modify some source code and it is
> used
> > >> with the .C() function.  When I try and run it, it states that
> > >> 'inner_perc_table is not found'.  It is only called in such a way and
> > >> isn't
> > >> defined at any point in the previous code in which the function works.
> > >> Should this be in some other directory of the source code files?  I
> have
> > >> been scouring through them and have continue to come up empty.
> > >>
> > >
> > > Look for the C function R_registerRoutines and/or the R function
> > > getNativeSymbolInfo.
> > >
> > > Duncan Murdoch
> > >
> >
> >   [[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] inner_perc_table?

2012-05-24 Thread William Dunlap
You need to supply a character string, e.g., "inner_perc_table", that names
the C entry point.  If you supply a name, e.g., entry_point,  or a more general 
expression,
e.g, entry_points[j], then it will be evaluated with the usual R evaluation
rules and the result must be a character string.

  > getNativeSymbolInfo("inner_perc_table")
  $name
  [1] "inner_perc_table" 

  $address
  
  attr(,"class")
  [1] "NativeSymbol"

  $package
  DLL name: nlme
  Filename: c:/Program Files/R/R-2.15.0/library/nlme/libs/x64/nlme.dll
  Dynamic lookup: FALSE

  $numParameters
  [1] 6

  attr(,"class")
  [1] "CRoutine" "NativeSymbolInfo"

or
  > entry_point <- "inner_perc_table"
  > entry_points <- c("outer_perc_table", "inner_perc_table")
  > identical(getNativeSymbolInfo(entry_point), 
getNativeSymbolInfo("inner_perc_table"))
  [1] TRUE
  > identical(getNativeSymbolInfo(entry_points[2]), 
getNativeSymbolInfo("inner_perc_table"))
  [1] TRUE

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Charles Determan Jr
> Sent: Thursday, May 24, 2012 10:02 AM
> To: Duncan Murdoch
> Cc: r-help@r-project.org
> Subject: Re: [R] inner_perc_table?
> 
> Thank you Duncan,
> 
> I used the R function getNativeSymbolInfo(inner_perc_table) and the object
> is not found:
> 
> Error in is.vector(X) : object 'inner_perc_table' not found
> Done.
> 
> I also tried the defining the directory to the nlme.dll file and it had the
> same error.
> Is there something I missed while doing this?
> 
> Thanks,
> Charles
> 
> 
> On Thu, May 24, 2012 at 11:51 AM, Duncan Murdoch
> wrote:
> 
> > On 24/05/2012 11:35 AM, Charles Determan Jr wrote:
> >
> >> Hello,
> >>
> >> Does anyone on this list know what inner_perc_table is or where it is
> >> typically found?  I am trying to modify some source code and it is used
> >> with the .C() function.  When I try and run it, it states that
> >> 'inner_perc_table is not found'.  It is only called in such a way and
> >> isn't
> >> defined at any point in the previous code in which the function works.
> >> Should this be in some other directory of the source code files?  I have
> >> been scouring through them and have continue to come up empty.
> >>
> >
> > Look for the C function R_registerRoutines and/or the R function
> > getNativeSymbolInfo.
> >
> > Duncan Murdoch
> >
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] R does not recognise columns and rows as they are supposed to be

2012-05-24 Thread Rui Barradas
Sorry, forgot the last line in the op code.

write.table(extract, ...) is called every time through the loop, not just
one time after it. Put it after closing '}'.

Rui Barradas



Rui Barradas wrote
> 
> Hello,
> 
> There are several things with your code, most of which are not errors.
> 
> 1. X<-c(364:369) ; Y<-c(82:92 and later c(1:365)
> Expressions of the form m:n are integer sequences, the c() is not needed.
> 
> 2. extract<-vector()
> First you create the vector, then keep extending it throughout the loop.
> This is much slower.
> If you know the final length (and type), create it like this:
> extract <- numeric(365)   # or double(365)
> 
> 3. 'dir1' is not used.
> 
> 4. Now the readBin instruction:
> 4.1. 'file' is the name of a function, use, say, 'file1' instead.
> 4.2. Option 'signed' defaults to TRUE but it's only valid for integer
> types.
> 
> 5. And, maybe this is the problem, in R, doubles are 8 bytes, not 4. Get
> rid of option 'size', like the help page says,
> 
> "If size is specified and not the natural size of the object, each element
> of the vector is coerced to an appropriate type before being written or as
> it is read."
> 
> You are NOT reading doubles.
> 
> As for the rest, it seems ok to me. (Keep option 'n' in readBin.)
> 
> Hope this helps,
> 
> Rui Barradas
> 
> Jonsson wrote
>> 
>> Dear All,
>> The code given bellow is to extract  values of one region and write that
>> to a text file(there are 365 binary files in the directory).
>> The problem which I am facing is that all my files are binary with size
>> of 360 rows and 720 columns.
>> I specified that in this line:   
>> file2<-matrix(data=file,ncol=720,nrow=360) but I got an error : Error in
>> mean(file2[X, Y], na.rm = TRUE) : subscript out of bounds.
>> and then I rewrote the above line as
>> :file2<-matrix(data=file,ncol=360,nrow=720.I put ncol=360 and nrows =720
>> which is not right.But that worked and I didn't get any error.however,the
>> results were not correct.
>> Any help please
>>  X<-c(364:369) ; Y<-c(82:92) #   for sellected region
>> extract<-vector()
>> dir1<- list.files("C:\\Users\\aalyaari\\Desktop\\New folder
>> (10)\\Climate_Rad_f_GAMMA_%d.img", full.names = TRUE)
>> listfile<-dir()
>> for (i in c(1:365)) {
>>   conne <- file(listfile[i], "rb")
>>   file<- readBin(conne, double(), size=4,  n=720*360, signed=T)
>>  file2<-matrix(data=file,ncol=720,nrow=360)  
>>  extract[i]<-mean(file2[X,Y],na.rm=TRUE)
>>   close(conne)
>> write.table(extract,"C:\\Users\\aalyaari\\Desktop\\New folder
>> (10)\\sam.txt")}
>> 
> 


--
View this message in context: 
http://r.789695.n4.nabble.com/R-does-not-recognise-columns-and-rows-as-they-are-supposed-to-be-tp4631217p4631229.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] R does not recognise columns and rows as they are supposed to be

2012-05-24 Thread Rui Barradas
Hello,

There are several things with your code, most of which are not errors.

1. X<-c(364:369) ; Y<-c(82:92 and later c(1:365)
Expressions of the form m:n are integer sequences, the c() is not needed.

2. extract<-vector()
First you create the vector, then keep extending it throughout the loop.
This is much slower.
If you know the final length (and type), create it like this:
extract <- numeric(365)   # or double(365)

3. 'dir1' is not used.

4. Now the readBin instruction:
4.1. 'file' is the name of a function, use, say, 'file1' instead.
4.2. Option 'signed' defaults to TRUE but it's only valid for integer types.

5. And, maybe this is the problem, in R, doubles are 8 bytes, not 4. Get rid
of option 'size', like the help page says,

"If size is specified and not the natural size of the object, each element
of the vector is coerced to an appropriate type before being written or as
it is read."

You are NOT reading doubles.

As for the rest, it seems ok to me. (Keep option 'n' in readBin.)

Hope this helps,

Rui Barradas

Jonsson wrote
> 
> Dear All,
> The code given bellow is to extract  values of one region and write that
> to a text file(there are 365 binary files in the directory).
> The problem which I am facing is that all my files are binary with size of
> 360 rows and 720 columns.
> I specified that in this line:   
> file2<-matrix(data=file,ncol=720,nrow=360) but I got an error : Error in
> mean(file2[X, Y], na.rm = TRUE) : subscript out of bounds.
> and then I rewrote the above line as
> :file2<-matrix(data=file,ncol=360,nrow=720.I put ncol=360 and nrows =720
> which is not right.But that worked and I didn't get any error.however,the
> results were not correct.
> Any help please
>  X<-c(364:369) ; Y<-c(82:92) #   for sellected region
> extract<-vector()
> dir1<- list.files("C:\\Users\\aalyaari\\Desktop\\New folder
> (10)\\Climate_Rad_f_GAMMA_%d.img", full.names = TRUE)
> listfile<-dir()
> for (i in c(1:365)) {
>   conne <- file(listfile[i], "rb")
>   file<- readBin(conne, double(), size=4,  n=720*360, signed=T)
>  file2<-matrix(data=file,ncol=720,nrow=360)  
>   extract[i]<-mean(file2[X,Y],na.rm=TRUE)
>   close(conne)
> write.table(extract,"C:\\Users\\aalyaari\\Desktop\\New folder
> (10)\\sam.txt")}
> 


--
View this message in context: 
http://r.789695.n4.nabble.com/R-does-not-recognise-columns-and-rows-as-they-are-supposed-to-be-tp4631217p4631227.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] applying cbind (or any function) across all components in a list

2012-05-24 Thread Hans Thompson
I'm confused why I haven't made clear what I am asking for help with.  

I have two different lists with two (or many) components, [[1]] and [[2]]. 
One of the list has components with dim=c(2,3) and the other has dim=c(2,2). 
I want to create a new list with components dim=c(2,4) by binding together
the averages of the columns using 

> cbind((l1[[1]][,1]+l2[[1]][,1])/2, (l1[[1]][,2]+l2[[1]][,1])/2,
> (l1[[1]][,2]+l2[[1]][,2])/2, (l1[[1]][,3]+l2[[1]][,2])/2)

which should put out:

 [,1] [,2] [,3] [,4]
[1,]1234
[2,]2345

my problem is finding out how I can apply this function to all the
components within the list in the same function.

--
View this message in context: 
http://r.789695.n4.nabble.com/applying-cbind-or-any-function-across-all-components-in-a-list-tp4631128p4631228.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] Fwd: help needed

2012-05-24 Thread QAMAR MUHAMMAD UZAIR




 --- segue il messaggio inoltrato (the forwarded 
message follows) ---
--- Begin Message ---

Dear R users,
i am very new to R. i am working on the following data.

01.01.1967  0.87
02.01.1967  0.87
03.01.1968  0.87
04.01.1968  0.87
05.01.1969  0.87
06.01.1969  0.87
07.01.1970  0.87
08.01.1970  0.87
09.01.1971  0.87
10.01.1971  0.87
11.01.1972  0.87
12.01.1972  0.87
13.01.1973  0.69
14.01.1973  0.70
15.01.1974  0.71
16.01.1974  0.72




I want to reshape it in the following FORMAT

19671968196919701971197219731974
1   0.870.870.870.870.71
2   0.870.870.870.870.72

OBVIOUSLY, I HAVE A LARGE AMOUNT OF DATA TO WORK WITH.i 
would also like to take into account the effect of leap 
year. For example if 1969 in a leap year then the column 
under it, has to have 1 extra reading.




Thanks in advance

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


Re: [R] inner_perc_table?

2012-05-24 Thread Charles Determan Jr
My apologies, feel a little foolish.  I forgot the "" for the object.  This
worked, however, once I have this information, I am not sure what I should
be using to fix the issue.  I can determine the location in  the nlme.dll
file but how can I use this information to have the other function work?

Regards,
Charles

On Thu, May 24, 2012 at 11:51 AM, Duncan Murdoch
wrote:

> On 24/05/2012 11:35 AM, Charles Determan Jr wrote:
>
>> Hello,
>>
>> Does anyone on this list know what inner_perc_table is or where it is
>> typically found?  I am trying to modify some source code and it is used
>> with the .C() function.  When I try and run it, it states that
>> 'inner_perc_table is not found'.  It is only called in such a way and
>> isn't
>> defined at any point in the previous code in which the function works.
>> Should this be in some other directory of the source code files?  I have
>> been scouring through them and have continue to come up empty.
>>
>
> Look for the C function R_registerRoutines and/or the R function
> getNativeSymbolInfo.
>
> Duncan Murdoch
>

[[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] set tkscale by tkentry

2012-05-24 Thread j verzani
Greg Snow <538280  gmail.com> writes:

> 
> I believe that what is happening is that when you try to edit the
> entry widget any intermediate values get sent to the slider widget
> which then checks to see if they are in the allowable range and if it
> is not then it sets the value to either the minimum and maximum and
> sends that back to the entry widget while you are still trying to edit
> it.  Even if you highlight a single digit and try to replace it with a
> different digit it first deletes the highlighted digit resulting in a
> number smaller than the minimum of the slider which then updates the
> entry widget to the minimum before the new digit can go in, then
> adding the new digit makes it larger than the slider maximum.
> 

Greg is right. You might try validating on focusout, rather than the key, 
but this is easy enough to do in R code, rather than let tcl do that work:

a <- 306870; b <- 3026741

tt<-tktoplevel()
varalpha <- tclVar(a)
charalpha <- tclVar(as.character(a))


scale <- tkscale(tt, from=a, to=b, resolution=1, label="alpha",
  variable=varalpha,
  showvalue=TRUE, orient="horiz")
ed <- tkentry(tt, textvariable=charalpha)

tkpack(ed)
tkpack(scale)

## connect
tkconfigure(scale, command=function(...) {
  tclvalue(charalpha) <- as.character(tclvalue(varalpha))
})

valid_input <- function(...) {
  val <- as.numeric(tclvalue(charalpha))
  if(a <= val & val <= b) {
message("set to ", val)
tclvalue(varalpha) <- val
  } else {
message("not valid...")
tkfocus(ed)
  }
}

tkbind(ed, "", valid_input)
tkbind(ed, "", valid_input)

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


Re: [R] Exclude when sd=0

2012-05-24 Thread David L Carlson
Assuming you mean that the column is constant so that the sd is 0

test <- matrix(rnorm(50), nrow=10, ncol=5)
test[,2] <- 1
test[,4] <- 2
# test[,which(apply(test, 2, sd) > 0)] could fail on rounding errors
Test2 <- test[, which(apply(test, 2, sd) > 1e-10)] 


--
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Chris Burns
> Sent: Wednesday, May 23, 2012 7:45 PM
> To: r-help@r-project.org
> Subject: [R] Exclude when sd=0
> 
> How do I trim a matrix to exclude columns that have no standard
> deviation?
> 
> Thanks,
> 
> Chris
> 
>   [[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] inner_perc_table?

2012-05-24 Thread Charles Determan Jr
Thank you Duncan,

I used the R function getNativeSymbolInfo(inner_perc_table) and the object
is not found:

Error in is.vector(X) : object 'inner_perc_table' not found
Done.

I also tried the defining the directory to the nlme.dll file and it had the
same error.
Is there something I missed while doing this?

Thanks,
Charles


On Thu, May 24, 2012 at 11:51 AM, Duncan Murdoch
wrote:

> On 24/05/2012 11:35 AM, Charles Determan Jr wrote:
>
>> Hello,
>>
>> Does anyone on this list know what inner_perc_table is or where it is
>> typically found?  I am trying to modify some source code and it is used
>> with the .C() function.  When I try and run it, it states that
>> 'inner_perc_table is not found'.  It is only called in such a way and
>> isn't
>> defined at any point in the previous code in which the function works.
>> Should this be in some other directory of the source code files?  I have
>> been scouring through them and have continue to come up empty.
>>
>
> Look for the C function R_registerRoutines and/or the R function
> getNativeSymbolInfo.
>
> Duncan Murdoch
>

[[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] inner_perc_table?

2012-05-24 Thread Duncan Murdoch

On 24/05/2012 11:35 AM, Charles Determan Jr wrote:

Hello,

Does anyone on this list know what inner_perc_table is or where it is
typically found?  I am trying to modify some source code and it is used
with the .C() function.  When I try and run it, it states that
'inner_perc_table is not found'.  It is only called in such a way and isn't
defined at any point in the previous code in which the function works.
Should this be in some other directory of the source code files?  I have
been scouring through them and have continue to come up empty.


Look for the C function R_registerRoutines and/or the R function 
getNativeSymbolInfo.


Duncan Murdoch

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


[R] transform 1 col to 2 col

2012-05-24 Thread arun
Hi,

Just an addendum.

Suppose if you want to add more columns and do the split, you can try,

inscrutable.df2<-data.frame(inscrutable.df1,V2=(c(rnorm(1),"GTDF","SQ:1234","DFFD","DFDSE")[rep(c(1,2,3,4,5),times=4)]))
inscrutable3.df3<-data.frame(matrix(inscrutable.df1$V1,ncol=2,byrow=TRUE),matrix(inscrutable.df2$V2,ncol=2,byrow=TRUE))  

A.K.



- Original Message -
From: "MacQueen, Don" 
To: Soheila Khodakarim 
Cc: "r-help@r-project.org" 
Sent: Thursday, May 24, 2012 10:19 AM
Subject: Re: [R] transform 1 col to 2 col

See insertion below

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 5/24/12 1:43 AM, "Jim Lemon"  wrote:

>On 05/24/2012 05:10 PM, Soheila Khodakarim wrote:
>> Dear All
>>
>> How can I transform 1 column to 2 columns in R?
>>
>> 211217_s_at
>>
>> GO:0005249
>>
>> 211217_s_at
>>
>> GO:0005251
>>
>> 211217_s_at
>>
>>     GO:0005515
>>
>> 211217_s_at
>>
>> GO:0015271
>>
>>    211217_s_at
>>
>>    GO:0030955
>>
>>
>>
>>
>>
>> 211217_s_at
>>
>> GO:0005249
>>
>> 211217_s_at
>>
>> GO:0005251
>>
>>    211217_s_at
>>
>>     GO:0005515
>>
>> 211217_s_at
>>
>> GO:0015271
>>
>>    211217_s_at
>>
>> GO:0030955
>>
>Hi Soheila,
>Let us begin with the assumption that your "col" is roughly what you
>posted, and that text resides in a file named "inscrutable.dat". Let us
>first read that text into a data frame in R:
>
>inscrutatble.df<-read.table("inscrutable.dat")
>  inscrutable.df
>             V1 
>
>1 211217_s_at
>2  GO:0005249
>3  211217_s_at
>4   GO:0005251
>5  211217_s_at
>6   GO:0005515
>7  211217_s_at
>8   GO:0015271
>9  211217_s_at
>10  GO:0030955
>11 211217_s_at
>12  GO:0005249
>13 211217_s_at
>14  GO:0005251
>15 211217_s_at
>16  GO:0005515
>17 211217_s_at
>18  GO:0015271
>19 211217_s_at
>20  GO:0030955
>
>Now we will further assume that you want to place every odd element in
>one "col" and every even element in the other "col".


Or perhaps:

  matrix(inscrutable.df$V1, ncol=2, byrow=TRUE)

or
  data.frame(matrix(inscrutable.df$V1, ncol=2, byrow=TRUE))

to get a data frame.

-Don

>
>inscrutable2.df<-data.frame(
>  col1=inscrutable.df$V1[seq(1,length(inscrutable.df$V1),by=2)],
>  col2=inscrutable.df$V1[seq(2,length(inscrutable.df$V1),by=2)])
>inscrutable2.df
>           col1       col2
>1  211217_s_at GO:0005249
>2  211217_s_at GO:0005251
>3  211217_s_at GO:0005515
>4  211217_s_at GO:0015271
>5  211217_s_at GO:0030955
>6  211217_s_at GO:0005249
>7  211217_s_at GO:0005251
>8  211217_s_at GO:0005515
>9  211217_s_at GO:0015271
>10 211217_s_at GO:0030955
>
>There we are - easy as pie.
>
>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.


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


Re: [R] Upper an lower bound in linear programing

2012-05-24 Thread Petr Savicky
On Thu, May 24, 2012 at 07:16:20AM -0700, Haio wrote:
> Hello everyone!
> I´m trying to solve a linear optimization problem with r using the LPsolve
> function and i want to set upper and lower bounds for the obejctive
> function.  Any idea´s on how to do this??

Hello:

The formulation of an LP problem allows to use the objective
function also as a row in the constraint matrix. So, it is
possible to set a constraint on it. For example,
maximizing x + y
under the constraints
  x/4 <= y <= 2 + x/3
  x + y <= 9  (constraint on the objective function)
may be done as follows

  library(lpSolve)
 
  crit <- c(1, 1)
  mat <- rbind(
  c(-1/4, 1),
  c(-1/3, 1),
  c( 1,   1))
  dir <- c(">=", "<=", "<=")
  rhs <- c(0, 2, 9)
 
  out <- lp("max", objective.in=crit, const.mat=mat, const.dir=dir, 
const.rhs=rhs)
  out

  Success: the objective function is 9

  out$solution

  [1] 7.2 1.8

Hope this helps.

Petr Savicky.

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

2012-05-24 Thread lasciel
Hello,

I’m hoping you have a few minutes to help out someone very new to R.  I’ve
done some searching, but cannot find this particular issue.

I have survey data from two different time periods (years).  Both years are
stratified samples and have the same variables (and variable names), but are
different people in the community answering in the different years. 
Everything loads into the survey design fine and I can calculate the means
and CIs I need.

I want to calculate whether there was a change in a single variable between
years.  The variable of interest has binary yes/no answers.  I was planning
to use the ‘svychisq’ function, but cannot figure out how to do this across
what is currently two data frames.  I haven’t actually tried to run a
svychisq with the two frames yet as I am waiting on the data for the second
frame.  I’m trying to plan out the logic ahead of time.

So, let’s say I have survey design frame Year1 with variables Wt1 and MyVar,
and survey design frame Year2 with variables Wt2 and MyVar – remember the
variable name is the same in both frames.

My first inclination is that I would use a statement like:
svychisq(~MyVar+MyVar, Year1+Year2, statistic=”Chisq”)

However, it seems from reading the help files that I can only use the
‘svychisq’ function if I declare a single data frame in the design
statement, rather than referencing a frame for Year1 and a different frame
for Year2.  

So, I could use ‘rbind’ to stack the two years of data together with their
appropriate weights into a single data frame.  
svychisq(~MyVar+MyVar, BothYears, statistic=”Chisq”)

But now I have a problem that the variable name is the same across years, so
how do I differentiate the different time periods in the syntax for the
formula?  Do I need to also create two new variables per:
MyVar.1 [year = 1] <- MyVar
MyVar.2 [year = 2] <- MyVar
svychisq(~MyVar.1+MyVar.2, BothYears, statistic=”Chisq”, na.rm= TRUE) 


(I feel like I may be overthinking this and the answer is much simpler)


--
View this message in context: 
http://r.789695.n4.nabble.com/svychisq-using-two-frames-tp4631220.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] How to evaluate R things from Visual Studio?

2012-05-24 Thread Giannis Mamalikidis

I'll answer line by line so:


"You ask for help from people who have used R.NET, give them time to
answer."
I have.. I'm not sure why you seem so certain I didn't. But it is beside the 
point anyway



"Also, what about folks who have not used it?  "Does not work"
is not enough information. What did you try? Give enough detail so
that someone might follow your footsteps, including VS versions, R
location and version, assumptions made, and links to resources used on
the way."

Folks who haven't used it won't be able to help me anyway.
People who did get it working will be able to help me, and those are the 
people I'm counting on.
The sole reason I did not disclose any R.NET related info is to avoid making 
an already large message, larger.
When I find someone, if I find someone who does have R.NET and can help me, 
I will gladly give any and all needed information



"FWIW, I got the R.NET example to work on Windows 7 (64-bit OS) with
Visual Studio 10 Express (32-bit only) with their example program
here:

 http://rdotnet.codeplex.com/

I downloaded this file, and set the VS reference to it:

  http://rdotnet.codeplex.com/downloads/get/211446

I used R-2.12.0 as per their example

   REngine.SetDllDirectory(@"C:\Program Files\R\R-2.12.0\bin\i386");"


It's worth much, believe me. I really needed another person who got R.NET 
working.


It does work on R 2.12.0, I agree. but i need it to work any latest R.
I can't make my users use old and obsolete versions of R. And people have 
made it work on 2.15.0 (currently latest version) as well.



"I set R_HOME and R_LIBS to paths for the R-2.12.0 installation."
Can you please tell me exactly what string you put inside R_HOME and R_LIBS 
environment variables? (i.e. "C:\Progs\R\R-2.15.0\bin"? 
"C:\Progs\R\R-2.15.0"? what exactly?)
Also, it was YOU who created those Environmental Variables, right? Because 
they do not exist in my computer and i didn't delete them.
Safe to assume that we're talking about System -> Advanced -> Environment 
Variables -> System Variables. correct?



"I read this page:

  http://rdotnet.codeplex.com/documentation?referringTitle=Home

I had a quick stab at using a recent R build, but dropped it to try
the stated version in their example.  There are error messages printed
from the Windows application when it fails and they are worth reading
(and reporting when asking for help)."


I've already read every page on rdotnet.codeplex.com

Of course there are. I need not repeat myself. I explained above why no 
direct R.NET info were given.


Now that I have found one guy who has R.NET working, I shall :)

My R version is: 2.15.0 and is installed on "C:\Progs\R\R-2.15.0" instead of 
"C:\Program Files\R\R-2.15.0" (but it doesnt work on that either, tried it)


The code I try to run on R.NET version 1.4.1 (changeset 6d2c3f161801) is the 
example they have on the official page:


   Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) 
Handles MyBase.Load
   Dim Rdo As REngine = REngine.CreateInstance("RDotNet", "-q") ' 
quiet mode


   ' .NET Framework array to R vector.
   Dim group1 As NumericVector = Rdo.CreateNumericVector(New 
Double() {30.02, 29.99, 30.11, 29.97, 30.01, 29.99})

   Rdo.SetSymbol("group1", group1)

   ' Direct parsing from R script.
   Dim group2 As NumericVector = Rdo.Evaluate("group2 <- c(29.89, 
29.93, 29.72, 29.98, 30.02, 29.98)").AsNumeric()


   ' Test difference of mean and get the P-value.
   Dim testResult As GenericVector = Rdo.Evaluate("t.test(group1, 
group2)").AsList()


   Dim p As Double = testResult("p.value").AsNumeric().First()
   End Sub

The Error i get is this:
System.DllNotFoundException: Dll was not found.
  at RDotNet.NativeLibrary.UnmanagedDll..ctor(String dllName) in 
C:\Users\N1h1l1sT\Downloads\rdotnet_6d2c3f161801\RDotNet.NativeLibrary\UnmanagedDll.cs:line 
42

  at RDotNet.REngine..ctor(String id, String dll)
  at RDotNet.REngine.CreateInstance(String id, String dll)
  at RAttemptFour.Form1.Form1_Load(Object sender, EventArgs e) in 
C:\Users\N1h1l1sT\Dropbox\Visual Basic 2010\Test 
Projects\RAttemptFour\RAttemptFour\Form1.vb:line 35


No matter what i put inside the HOME or R_Home environment variables on my 
windows, it just won't work...
the line 35 refers to this line: "Dim Rdo As REngine = 
REngine.CreateInstance("RDotNet", "-q") ' quiet mode"


---
Giannis Mamalikidis
e-mail: giannis_mamaliki...@msn.com
Member of the STAINS Research Group
(STAtistics & INformation Systems Group) of the
Aristotle University of Thessaloniki
Site: http://stains.csd.auth.gr
B.Sc Student in Electrical and Mechanical Engineering

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

[R] Manually modifying an hclust dendrogram to remove singletons

2012-05-24 Thread r-help . 20 . trevva
Dear R-Help,

I have a clustering problem with hclust that I hope someone can help
me with. Consider the classic hclust example:

 hc <- hclust(dist(USArrests), "ave")
 plot(hc)

I would like to cut the tree up in such a way so as to avoid small
clusters, so that we get a minimum number of items in each cluster,
and therefore avoid singletons. e.g. in this example, you can see that
Hawaii is split off onto its own at quite a high level. I would like
to avoid having a single item clustered on its own like this. How can
I achieve this?

I have tried manually modifying the tree using dendrapply but have not
been able to produce a valid solution thus far..

Suggestions are welcome.

Best wishes,

Mark

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


Re: [R] use list as function arguments

2012-05-24 Thread Greg Snow
?do.call

On Thu, May 24, 2012 at 9:32 AM, Alexander Shenkin  wrote:
> Hello Folks,
>
> Is there any way to pass a list into a function such that the function
> will use the list as its arguments?  I haven't been able to figure that out.
>
> The background: I'm trying to build a function that will apply another
> function multiple times, each time with a different set of specified
> arguments.  I'm trying to figure out how to pass in a list of argument
> lists, then loop through the top-level list, passing in the lower-level
> list as function arguments.
>
> pseudocode:
>
> b = list( list( arg1 = 1, arg2 = 2 ),
>          list( arg1 = 3, arg2 = 4 )
>        )
>
> a <- apply_function(arglist) {
>        for (i in length(arglist)) {
>                b(arglist[i])
>        }
> }
>
>
> Specifically, the actual use I'm trying to implement is a function to
> format columns of data frames and matrices independently.  What I have
> so far is below, but it's not working.  Perhaps I'm going about this the
> wrong way?
>
>
> format_cols <- function(x, format_list = list()) {
>    # usage: length(format_list) must equal ncol(x)
>    #        format list should be a list of lists of key=value pairs
> corresponding to format settings for each column
>
>    if (is.data.frame(x)) {
>        newout = data.frame()
>    } else if (is.matrix(x)) {
>        newout = matrix()
>    }
>
>    for (i in 1:ncol(x)){
>        newout = cbind(newout, format(x,format_list[[i]]))
>        x[,i] = format(x,format_list[[i]])
>    }
>    return(newout)
> }
>
> Thanks,
> Allie
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

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


Re: [R] R does not recognise columns and rows as they are supposed to be

2012-05-24 Thread David Winsemius


On May 24, 2012, at 11:51 AM, Jonsson wrote:


Dear All,
The code given bellow is to extract  values of one region and write  
that to

a text file(there are 365 binary files in the directory).
The problem which I am facing is that all my files are binary with  
size of

360 rows and 720 columns.
I specified that in this line:file2<- 
matrix(data=file,ncol=720,nrow=360)
but I got an error : Error in mean(file2[X, Y], na.rm = TRUE) :  
subscript

out of bounds.
and then I rewrote the above line as
:file2<-matrix(data=file,ncol=360,nrow=720.I put ncol=360 and nrows  
=720
which is not right.But that worked and I didn't get any  
error.however,the

results were not correct.
Any help please

dir1<- list.files("C:\\Users\\aalyaari\\Desktop\\New folder
(10)\\Climate_Rad_f_GAMMA_%d.img", full.names = TRUE)
listfile<-dir()
for (i in c(1:365)) {
 conne <- file(listfile[i], "rb")
 file<- readBin(conne, double(), size=4,  n=720*360, signed=T)
file2<-matrix(data=file,ncol=720,nrow=360)
extract[i]<-mean(file2[X,Y],na.rm=TRUE)
 close(conne)
write.table(extract,"C:\\Users\\aalyaari\\Desktop\\New folder
(10)\\sam.txt")}


Please do not cross post to SO and Rhelp. (See Posting Guide.)

(But if you do, rhelp generally expects reproducible examples which  
this is not.)


--
David Winsemius, MD
West Hartford, CT

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


[R] R does not recognise columns and rows as they are supposed to be

2012-05-24 Thread Jonsson
Dear All,
The code given bellow is to extract  values of one region and write that to
a text file(there are 365 binary files in the directory).
The problem which I am facing is that all my files are binary with size of
360 rows and 720 columns.
I specified that in this line:file2<-matrix(data=file,ncol=720,nrow=360)
but I got an error : Error in mean(file2[X, Y], na.rm = TRUE) : subscript
out of bounds.
and then I rewrote the above line as
:file2<-matrix(data=file,ncol=360,nrow=720.I put ncol=360 and nrows =720
which is not right.But that worked and I didn't get any error.however,the
results were not correct.
Any help please

dir1<- list.files("C:\\Users\\aalyaari\\Desktop\\New folder
(10)\\Climate_Rad_f_GAMMA_%d.img", full.names = TRUE)
listfile<-dir()
for (i in c(1:365)) {
  conne <- file(listfile[i], "rb")
  file<- readBin(conne, double(), size=4,  n=720*360, signed=T)
 file2<-matrix(data=file,ncol=720,nrow=360)  
extract[i]<-mean(file2[X,Y],na.rm=TRUE)
  close(conne)
write.table(extract,"C:\\Users\\aalyaari\\Desktop\\New folder
(10)\\sam.txt")}


--
View this message in context: 
http://r.789695.n4.nabble.com/R-does-not-recognise-columns-and-rows-as-they-are-supposed-to-be-tp4631217.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] inner_perc_table?

2012-05-24 Thread Charles Determan Jr
Hello,

Does anyone on this list know what inner_perc_table is or where it is
typically found?  I am trying to modify some source code and it is used
with the .C() function.  When I try and run it, it states that
'inner_perc_table is not found'.  It is only called in such a way and isn't
defined at any point in the previous code in which the function works.
Should this be in some other directory of the source code files?  I have
been scouring through them and have continue to come up empty.

Many thanks for any assistance,
Charles

[[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] use list as function arguments

2012-05-24 Thread Alexander Shenkin
Hello Folks,

Is there any way to pass a list into a function such that the function
will use the list as its arguments?  I haven't been able to figure that out.

The background: I'm trying to build a function that will apply another
function multiple times, each time with a different set of specified
arguments.  I'm trying to figure out how to pass in a list of argument
lists, then loop through the top-level list, passing in the lower-level
list as function arguments.

pseudocode:

b = list( list( arg1 = 1, arg2 = 2 ),
  list( arg1 = 3, arg2 = 4 )
)

a <- apply_function(arglist) {
for (i in length(arglist)) {
b(arglist[i])
}
}


Specifically, the actual use I'm trying to implement is a function to
format columns of data frames and matrices independently.  What I have
so far is below, but it's not working.  Perhaps I'm going about this the
wrong way?


format_cols <- function(x, format_list = list()) {
# usage: length(format_list) must equal ncol(x)
#format list should be a list of lists of key=value pairs
corresponding to format settings for each column

if (is.data.frame(x)) {
newout = data.frame()
} else if (is.matrix(x)) {
newout = matrix()
}

for (i in 1:ncol(x)){
newout = cbind(newout, format(x,format_list[[i]]))
x[,i] = format(x,format_list[[i]])
}
return(newout)
}

Thanks,
Allie

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

2012-05-24 Thread swaraj basu
Dear All,

I am running R in a system with the following configuration

*Processor: Intel(R) Xeon(R) CPU   X5650  @ 2.67GHz
OS: Ubuntu X86_64 10.10
RAM: 24 GB*

The R session info is
*
R version 2.14.1 (2011-12-22)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=C LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   *


I have a matrix of dimensions 12 rows X  29318 columns. The matrix contains
numeric as well as NA values. I am using the* rcorr *function from the *
Hmisc* package to get correlation information from the matrix (*
rcorr(matrix)*). During the calculation I get the error "*cannot allocate
vector of size 6.7 GB*". When I check the memory allocation of my R session
I get the following information

*gc()
  used (Mb) gc trigger (Mb) limit (Mb) max used (Mb)
Ncells  249638 13.4 467875 25.0 NA   407500 21.8
Vcells 1499217 11.52335949 17.9   7000  1970005 15.1

*Can someone please help me in finding a workaround to the problem.

-Regards
-- 
Swaraj Basu
PhD Student (Bioinformatics - Functional Genomics)
Animal Physiology and Evolution
Stazione Zoologica Anton Dohrn
Naples

[[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 NA as a break point for indicator variable?

2012-05-24 Thread Max Brondfield
This method worked perfectly! The rle() function was key and I was
completely unfamiliar with it. Thanks so much,
Max

On Thu, May 24, 2012 at 8:52 AM, Rui Barradas  wrote:

> Hello,
>
> Assuming that 'd' is your original data.frame and that you've set entire
> rows to NA, try this
>
>
> d$leak_num <- NA
> ix <- !is.na(d[, 1])  # any column will do, entire row is NA
> ## alternative, if other rows may have NAs, due to something else
> #ix <- apply(d, 1, function(x) all(!is.na(x)))
> r <- rle(ix)
> v <- cumsum(r$values)
> d$leak_num[ix] <- rep(v[r$values], r$lengths[r$values])
> d
>
>
> Hope this helps,
>
> Rui Barradas
>
> Em 24-05-2012 11:00, Max Brondfield  escreveu:
>
>> Date: Wed, 23 May 2012 16:42:02 -0400
>> From: Max Brondfield
>> >
>> To:r-help@r-project.org
>> Subject: [R] Using NA as a break point for indicator variable?
>> Message-ID:
>>> gmail.com
>> >
>> Content-Type: text/plain
>>
>>
>> Hi all,
>> I am working with a spatial data set for which I am only interested in
>> high
>> concentration values ("leaks"). The low values (<  90th percentile) have
>> already been turned into NA's, leaving me with a matrix like this:
>>
>> <  CH4_leak
>>
>>   lonlatCH4
>> 1  -71.11954 42.35068 2.595834
>> 2  -71.11954 42.35068 2.595688
>> 3   NA   NA   NA
>> 4   NA   NA   NA
>> 5   NA   NA   NA
>> 6  -71.11948 42.35068 2.435762
>> 7  -71.11948 42.35068 2.491003
>> 8  NANA   NA
>> 9  -71.11930 42.35068 2.464475
>> 10 -71.11932 42.35068 2.470865
>>
>> Every time an NA comes up, it means the "leak" is gone, and the next valid
>> value would represent a different leak (at a different location). My goal
>> is to tag all of the remaining values with an indicator variable to
>> spatially distinguish the leaks. I am envisioning a simple numeric
>> indicator such as:
>>
>>  lonlatCH4leak_num
>> 1  -71.11954 42.35068 2.595834   1
>> 2  -71.11954 42.35068 2.595688   1
>> 3   NA   NA   NA NA
>> 4   NA   NA   NA NA
>> 5   NA   NA   NA NA
>> 6  -71.11948 42.35068 2.435762   2
>> 7  -71.11948 42.35068 2.491003   2
>> 8  NANA   NA NA
>> 9  -71.11930 42.35068 2.064475   3
>> 10 -71.11932 42.35068 2.070865  3
>>
>> Does anyone have any thoughts on how to code this, perhaps using the NA
>> values as a "break point"? The data set is far too large to do this
>> manually, and I must admit I'm completely at a loss. Any help would be
>> much
>> appreciated! Best,
>>
>> Max
>>
>>[[alternative HTML version deleted]]
>>
>>
>>


-- 
Max Brondfield
Research Assistant
Department of Geography & Environment
Boston University

[[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] applying cbind (or any function) across all components in a list

2012-05-24 Thread Greg Snow
The "do.call" function may be what you want, but it is not completely
clear.  If that does not solve your problem then try giving us an
example of what your list looks like (the dput function can help) and
what you want your end result to look like.

On Thu, May 24, 2012 at 5:38 AM, Hans Thompson  wrote:
> The combination of column means in cbind is what I am trying to do.  I just
> don't know how to do it for every component (2 in this case) of the list.
> I've been able to work with R to apply a function across all components when
> there is just one list but I am having trouble working with multiple lists
> at the same time.
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/applying-cbind-or-any-function-across-all-components-in-a-list-tp4631128p4631187.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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

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


Re: [R] package metafor: specify weights?

2012-05-24 Thread Viechtbauer Wolfgang (STAT)
At the moment, there is no possibility of specifying the weights with the rma() 
function. While the main model fitting part could be easily adapted to 
incorporate user-specified weights, the problem comes in with all the 
additional statistics that can be computed based on a fitted model. How should 
the predict() function now work? What would be the definition of I^2 now? How 
would one generalize the influence and outlier statistics to that case? Just to 
give some examples.

Of course, I could leave out such things when the user has specified the 
weights, but then things also get confusing for the user. For example, it is 
already less than ideal that you can only use the trim and fill method with 
models that do not incorporate moderators. Nobody has (as of yet) generalized 
the trim and fill method to that case. But when there are too many "special 
cases", the package becomes unusable.

I did consider user-specified weights at one point, but it opened up so many 
cans of worms that I preferred to quickly put the lid pack on those cans. That 
item is written down in my to-do list, but to be honest, it is somewhere at the 
very end of that list.

If you are hesitant to combine the results from those two types of studies, 
what about simply using a moderator to distinguish the two groups?

Best,

Wolfgang

--   
Wolfgang Viechtbauer, Ph.D., Statistician   
Department of Psychiatry and Psychology   
School for Mental Health and Neuroscience   
Faculty of Health, Medicine, and Life Sciences   
Maastricht University, P.O. Box 616 (VIJV1)   
6200 MD Maastricht, The Netherlands   
+31 (43) 388-4170 | http://www.wvbauer.com   


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Anke Stein
> Sent: Thursday, May 24, 2012 15:59
> To: r-help@r-project.org
> Subject: [R] package metafor: specify weights?
> 
> Dear R-experts,
> Dear Wolfgang,
> 
> Weighted model fitting in metafor uses the inverse of the study specific
> variances as weights.
> I am wondering if it is possible to specify different weights.
> 
> In my meta-analysis, there are two types of studies with (intrinsic)
> differences in their range of sample sizes (which are used to calculate
> the variances of Fisher's z).
> I would like to try normalizing the sample sizes within each set of the
> two study types and use these normalized sample sizes as weights.
> Would that be possible with rma()? So far, I only found the option
> "weighted = TRUE/FALSE", but no possibility to specify which weights
> should be used.
> 
> Many thanks in advance,
> Anke
> 
> 
> 
> 
> 
> 
> --
> __
> Anke Stein (Dipl.-Biol.)
> 
> Biodiversity, Macroecology & Conservation Biogeography Head Prof. Dr.
> Holger Kreft Georg-August University of Göttingen Büsgenweg 2 | 37077
> Göttingen | Germany
> 
> phone +49(0)551-39-13761
> fax +49(0)551-39-3618
> ast...@uni-goettingen.de
> http://www.uni-goettingen.de/biodiversity
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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 tkscale by tkentry

2012-05-24 Thread Greg Snow
I believe that what is happening is that when you try to edit the
entry widget any intermediate values get sent to the slider widget
which then checks to see if they are in the allowable range and if it
is not then it sets the value to either the minimum and maximum and
sends that back to the entry widget while you are still trying to edit
it.  Even if you highlight a single digit and try to replace it with a
different digit it first deletes the highlighted digit resulting in a
number smaller than the minimum of the slider which then updates the
entry widget to the minimum before the new digit can go in, then
adding the new digit makes it larger than the slider maximum.

There may be a way to slow down the updates or validations so that you
can edit the entry before the slider tries to validate and change the
value.  Or you can just include 0 as the minimum of the slider so that
the intermediate values in the entry widget are in the allowable
range.

On Thu, May 24, 2012 at 2:20 AM, Alexander  wrote:
> Hi, I am working under Windows and I am using R2.11
> I want to use tkscale in my GUI. As the interval is quite big, I can't set
> the scale to a certain specific value. Therefore I want to add tkentry to
> allow the user to set tkscale to a certain value.
>
> Here is the code
>
> library(tcltk)
>
> tt<-tktoplevel()
> tkpack(m1<-tkscale(tt,from=306870.00, to=3026741, label="alpha",
> variable="varalpha",showvalue=TRUE, resolution=1,
> orient="horiz"),side="bottom")
> tkpack(tkentry(tt,width="10",textvariable="varalpha",validate="key",validatecommand="string
> is double %P"),side="bottom")
>
> As you can see, varalpha is a global variable (I think in tcl, not in R),
> and if you change the parameter by the scale, the value in tkentry is
> updated. If I want to set now the value of varalpha by tkentry, it bugs.
> Does anyone have an idea, why? I already tried the interval from 0 to any
> number, which works fine...
>
> library(tcltk)
>
> tt<-tktoplevel()
> tkpack(m1<-tkscale(tt,from=0.00, to=1000, label="alpha",
> variable="varalpha",showvalue=TRUE, resolution=1,
> orient="horiz"),side="bottom")
> tkpack(tkentry(tt,width="10",textvariable="varalpha",validate="key",validatecommand="string
> is double %P"),side="bottom")
>
> Thanks in advance,
> Alexander
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/set-tkscale-by-tkentry-tp4631174.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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

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


Re: [R] Using NA as a break point for indicator variable?

2012-05-24 Thread William Dunlap
> Does anyone have any thoughts on how to code this, perhaps using the NA
> values as a "break point"?

You can count the cumulative number of NA breakpoints in a vector
with cumsum(is.na(vector)), as in

  > cbind(d, LeakNo=with(d, cumsum(is.na(lon)|is.na(lat)|is.na(CH4
   lon  lat  CH4 LeakNo
  1  -71.11954 42.35068 2.595834  0
  2  -71.11954 42.35068 2.595688  0
  3 NA   NA   NA  1
  4 NA   NA   NA  2
  5 NA   NA   NA  3
  6  -71.11948 42.35068 2.435762  3
  7  -71.11948 42.35068 2.491003  3
  8 NA   NA   NA  4
  9  -71.11930 42.35068 2.464475  4
  10 -71.11932 42.35068 2.470865  4

Add 1 if you want to start with 1.  If you only want to increase the count
after each sequence of NA's then you could use rle() or
  > na <- with(d, is.na(lon)|is.na(lat)|is.na(CH4))
  > cbind(d, LeakNo=cumsum(c(TRUE, na[-1] < na[-length(na)])))
   lon  lat  CH4 LeakNo
  1  -71.11954 42.35068 2.595834  1
  2  -71.11954 42.35068 2.595688  1
  3 NA   NA   NA  1
  4 NA   NA   NA  1
  5 NA   NA   NA  1
  6  -71.11948 42.35068 2.435762  2
  7  -71.11948 42.35068 2.491003  2
  8 NA   NA   NA  2
  9  -71.11930 42.35068 2.464475  3
  10 -71.11932 42.35068 2.470865  3

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
> Behalf
> Of Max Brondfield
> Sent: Wednesday, May 23, 2012 1:42 PM
> To: r-help@r-project.org
> Subject: [R] Using NA as a break point for indicator variable?
> 
> Hi all,
> I am working with a spatial data set for which I am only interested in high
> concentration values ("leaks"). The low values (< 90th percentile) have
> already been turned into NA's, leaving me with a matrix like this:
> 
> < CH4_leak
> 
>   lonlatCH4
> 1  -71.11954 42.35068 2.595834
> 2  -71.11954 42.35068 2.595688
> 3   NA   NA   NA
> 4   NA   NA   NA
> 5   NA   NA   NA
> 6  -71.11948 42.35068 2.435762
> 7  -71.11948 42.35068 2.491003
> 8  NANA   NA
> 9  -71.11930 42.35068 2.464475
> 10 -71.11932 42.35068 2.470865
> 
> Every time an NA comes up, it means the "leak" is gone, and the next valid
> value would represent a different leak (at a different location). My goal
> is to tag all of the remaining values with an indicator variable to
> spatially distinguish the leaks. I am envisioning a simple numeric
> indicator such as:
> 
>  lonlatCH4leak_num
> 1  -71.11954 42.35068 2.595834   1
> 2  -71.11954 42.35068 2.595688   1
> 3   NA   NA   NA NA
> 4   NA   NA   NA NA
> 5   NA   NA   NA NA
> 6  -71.11948 42.35068 2.435762   2
> 7  -71.11948 42.35068 2.491003   2
> 8  NANA   NA NA
> 9  -71.11930 42.35068 2.064475   3
> 10 -71.11932 42.35068 2.070865  3
> 
> Does anyone have any thoughts on how to code this, perhaps using the NA
> values as a "break point"? The data set is far too large to do this
> manually, and I must admit I'm completely at a loss. Any help would be much
> appreciated! Best,
> 
> Max
> 
>   [[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] transform 1 col to 2 col

2012-05-24 Thread MacQueen, Don
See insertion below

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 5/24/12 1:43 AM, "Jim Lemon"  wrote:

>On 05/24/2012 05:10 PM, Soheila Khodakarim wrote:
>> Dear All
>>
>> How can I transform 1 column to 2 columns in R?
>>
>> 211217_s_at
>>
>> GO:0005249
>>
>> 211217_s_at
>>
>> GO:0005251
>>
>> 211217_s_at
>>
>> GO:0005515
>>
>> 211217_s_at
>>
>> GO:0015271
>>
>>211217_s_at
>>
>>GO:0030955
>>
>>
>>
>>
>>
>> 211217_s_at
>>
>> GO:0005249
>>
>> 211217_s_at
>>
>> GO:0005251
>>
>>211217_s_at
>>
>> GO:0005515
>>
>> 211217_s_at
>>
>> GO:0015271
>>
>>211217_s_at
>>
>> GO:0030955
>>
>Hi Soheila,
>Let us begin with the assumption that your "col" is roughly what you
>posted, and that text resides in a file named "inscrutable.dat". Let us
>first read that text into a data frame in R:
>
>inscrutatble.df<-read.table("inscrutable.dat")
>  inscrutable.df
> V1 
>
>1 211217_s_at
>2  GO:0005249
>3  211217_s_at
>4   GO:0005251
>5  211217_s_at
>6   GO:0005515
>7  211217_s_at
>8   GO:0015271
>9  211217_s_at
>10  GO:0030955
>11 211217_s_at
>12  GO:0005249
>13 211217_s_at
>14  GO:0005251
>15 211217_s_at
>16  GO:0005515
>17 211217_s_at
>18  GO:0015271
>19 211217_s_at
>20  GO:0030955
>
>Now we will further assume that you want to place every odd element in
>one "col" and every even element in the other "col".


Or perhaps:

  matrix(inscrutable.df$V1, ncol=2, byrow=TRUE)

or
  data.frame(matrix(inscrutable.df$V1, ncol=2, byrow=TRUE))

to get a data frame.

-Don

>
>inscrutable2.df<-data.frame(
>  col1=inscrutable.df$V1[seq(1,length(inscrutable.df$V1),by=2)],
>  col2=inscrutable.df$V1[seq(2,length(inscrutable.df$V1),by=2)])
>inscrutable2.df
>   col1   col2
>1  211217_s_at GO:0005249
>2  211217_s_at GO:0005251
>3  211217_s_at GO:0005515
>4  211217_s_at GO:0015271
>5  211217_s_at GO:0030955
>6  211217_s_at GO:0005249
>7  211217_s_at GO:0005251
>8  211217_s_at GO:0005515
>9  211217_s_at GO:0015271
>10 211217_s_at GO:0030955
>
>There we are - easy as pie.
>
>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.


[R] Upper an lower bound in linear programing

2012-05-24 Thread Haio
Hello everyone!
I´m trying to solve a linear optimization problem with r using the LPsolve
function and i want to set upper and lower bounds for the obejctive
function.  Any idea´s on how to do this??


--
View this message in context: 
http://r.789695.n4.nabble.com/Upper-an-lower-bound-in-linear-programing-tp4631202.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] package metafor: specify weights?

2012-05-24 Thread Anke Stein

Dear R-experts,
Dear Wolfgang,

Weighted model fitting in metafor uses the inverse of the study specific 
variances as weights.
I am wondering if it is possible to specify different weights.

In my meta-analysis, there are two types of studies with (intrinsic) 
differences in their range of sample sizes (which are used to calculate the 
variances of Fisher's z).
I would like to try normalizing the sample sizes within each set of the two 
study types and use these normalized sample sizes as weights.
Would that be possible with rma()? So far, I only found the option "weighted = 
TRUE/FALSE", but no possibility to specify which weights should be used.

Many thanks in advance,
Anke






--
__
Anke Stein (Dipl.-Biol.)

Biodiversity, Macroecology & Conservation Biogeography
Head Prof. Dr. Holger Kreft
Georg-August University of Göttingen
Büsgenweg 2 | 37077 Göttingen | Germany

phone +49(0)551-39-13761
fax +49(0)551-39-3618
ast...@uni-goettingen.de
http://www.uni-goettingen.de/biodiversity

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 on if i am allowed to do something

2012-05-24 Thread Giannis Mamalikidis
I see. It is decided then. As it might be possible that the license might be 
violated, I certainly will not include R in my programme.


Thank you all for your help, you've been very helpful.

---
Giannis Mamalikidis
e-mail: giannis_mamaliki...@msn.com
Member of the STAINS Research Group
(STAtistics & INformation Systems Group) of the
Aristotle University of Thessaloniki
Site: http://stains.csd.auth.gr
B.Sc Student in Electrical and Mechanical Engineering

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


Re: [R] building transformation macro

2012-05-24 Thread David Winsemius


On May 24, 2012, at 9:06 AM, David Winsemius wrote:



On May 24, 2012, at 4:43 AM, davv.vikas wrote:


Hi All,

I am writing a macro which perform following functionality
1) take a file say excel or csv
2)read all the labels
3) dynamically genrate square,square-root,log  of each column with
appropiate column name and write it to a new file,

i am stuck at dynamically genrateing the column names like  
Revenue_square

etc.

Exmaple " i have a excel with 3 columns Revenue, cost & profit
Now my Macro should be able to  read the values and for each coulmn  
and
perform square,square root and log of   Revenue, cost & profit and  
write to
excel with column names as Revenue_square,Revenue_squareroot,  
Revenue_log

cost_square etc...

Below is my code

test$Rev_square = test[c(1)]^2

I would use test[[1]]^2. Generally one wants to pull the vector out  
of the list "container".


data=read.delim2("//ARLMSAN01/CTRX_Data/vikasK.sharma/Desktop/ 
balancesheet_example.csv",header=T,sep=",")


headings = names(data)
show (headings)
HEADINGS = toupper(headings)
# Perhaps replacing your for-loop body with this

for ( i in 1:length(HEADINGS))

{


assign(paste(HEADINGS[i],  "Rev_Sqr", sep=""), data[[i]]^2)


}


The generalization to additional transformations seems obvious.


The solution offered in StackOverflow by Greg Snow is better.

AND please stop cross-posting. It is not specifically deprecated on  
SO, but it is on Rhelp.


--

David Winsemius, MD
West Hartford, CT

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


Re: [R] How to avoid numbering while printing list element?

2012-05-24 Thread jim holtman
Will this do it for you:

> x <- list(1,2,3)
> x[[1]]
[1] 1
> cat(x[[1]], '\n')
1
>


On Thu, May 24, 2012 at 5:50 AM, Manish Gupta  wrote:
> HI,
>
> I am printing list element.
>
> print(desc[[2]])
> [1] XXXxx
>
> I want to remove [1]
> Output should be
> XXXxx
>
> How can i implement it?
>
> Thanks
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/How-to-avoid-numbering-while-printing-list-element-tp4631180.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
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 retrieve value form dataframe by Key?

2012-05-24 Thread Rui Barradas

Hello,

Try

?subset
subset(dtfr, Col1 == "xxx")
?"["
dtfr[Col1 == "xxy", ]

Hope this helps,

Rui Barradas

Em 24-05-2012 11:00, Manish Gupta  escreveu:

Date: Thu, 24 May 2012 01:09:58 -0700 (PDT)
From: Manish Gupta
To:r-help@r-project.org
Subject: [R] How to retrieve value form dataframe by Key?
Message-ID:<1337846998835-4631173.p...@n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hi,

I have one datagrame

Col1  Col2Col3
Col3
xxx erThis is third record of 1st line.
This is 4th record of first line.
xxy erThis is third record of 1st line.
This is 4th record of second line
xyx erThis is third record of 1st line.
This is 4th record of third line

I want to get records corresponding to key (here Col1). How can i implement
it?

e.g.
if i key in xxx i should get
xxx erThis is third record of 1st line.
This is 4th record of first line.

if i key in xxy i should get
xxy erThis is third record of 1st line.
This is 4th record of second line

Regards


--
View this message in 
context:http://r.789695.n4.nabble.com/How-to-retrieve-value-form-dataframe-by-Key-tp4631173.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] Question on if i am allowed to do something

2012-05-24 Thread Giannis Mamalikidis

Your answers were very helpful, thanks :)

But, you see, the program I'm writing will be a team effort - and while I 
have not problem on making this program an open source - we don't really see 
eye to eye with the team on this.

So no source code will be available - just freeware.

R will not be at all altered! the only thing that R will do is be used to 
show a couple of plots, and make some t.test and ks.test.


Does that qualify as a derivative work of R? Or would derivative work be if 
I altered R's Source code?
I've read the license but English is not my Native language, hence some 
terminology is unclear to me.


And I'm just an undergraduate with no income in the middle of an economy 
crisis. I don't really see me paying a lawyer to ask the question.


---
Giannis Mamalikidis
e-mail: giannis_mamaliki...@msn.com
Member of the STAINS Research Group
(STAtistics & INformation Systems Group) of the
Aristotle University of Thessaloniki
Site: http://stains.csd.auth.gr
B.Sc Student in Electrical and Mechanical Engineering
---
-Original Message- 
From: Marc Schwartz

Sent: Thursday, May 24, 2012 3:58 AM
To: Duncan Murdoch
Cc: Giannis Mamalikidis ; r-help@r-project.org
Subject: Re: [R] Question on if i am allowed to do something


On May 23, 2012, at 6:51 PM, Duncan Murdoch wrote:


On 12-05-23 1:31 PM, Giannis Mamalikidis wrote:

Hello all.

I would like to know: provided that I absolutely state that R is not mine
and I also include the R’s License which will be shown so people know R 
and

R’s license,
(provided the above) am I allowed to include R’s folder (the folder that 
has

its binaries) on my freeware program or not?


R is licensed under the GPL v 2 or 3.  The recommended packages that come 
with it are separately licensed, but are also (mainly) GPL.  So just 
follow the terms of that license, which is included with R.


Duncan Murdoch



Just to add on to Duncan's reply, you might want to review the GPL FAQ (and 
possibly consult a lawyer):


 http://www.gnu.org/licenses/gpl-faq.html

The use and distribution of R within your 'freeware' can place certain 
obligations on you, including possibly requiring that you license your 
application with a GPL compatible license and make the source code of your 
application available in situations where your application is 'linked' to R. 
If you do not intend to make your own source code available, you should be 
very clear on what the GPL requires of you before proceeding.


Regards,

Marc Schwartz

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


Re: [R] edgeR: design matrix setup

2012-05-24 Thread Martin Morgan

On 05/23/2012 07:24 AM, rmje wrote:

I have a data frame like this:

T0h T0.25h T0.5h  T1h  T2h  T3h  T6h T12h T24h T48h
C0h C0.25h C0.5h  C1h  C2h  C3h  C6h C12h C24h C48h
NM_001001130   68 9556   43   66   62   68   90   63   89   65
8558   49 81   49   76   73   48   77
NM_001001152   7912952   50   24   45  130  154  112  147   56
8567   33 52   31   93   77   65  109
...
...
...


It has about 29000 rows and 20 columns (incl col.name).
How would you set this up in edgeR if you want to compare the 10 first with
the 10 last?


Please ask questions about Bioconductor packages on the Bioconductor 
mailing list


  http://bioconductor.org/help/mailing-list/

There have been recent time-course questions on the mailing list, so 
it's good to browse recents posts. Remember to include sessionInfo(). 
Have you looked at the extensive vignette for this package


  http://bioconductor.org/packages/2.10/bioc/html/edgeR.html

and limma, and taken a stab at answering your own question? It helps to 
see where you're coming from...; for this particular question and if 
you're statistically naive it might help to have a conversation with 
someone local who is a little versed in statistics.


Martin




--
View this message in context: 
http://r.789695.n4.nabble.com/edgeR-design-matrix-setup-tp4631094.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.



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

Location: M1-B861
Telephone: 206 667-2793

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


Re: [R] building transformation macro

2012-05-24 Thread David Winsemius


On May 24, 2012, at 4:43 AM, davv.vikas wrote:


Hi All,

I am writing a macro which perform following functionality
1) take a file say excel or csv
2)read all the labels
3) dynamically genrate square,square-root,log  of each column with
appropiate column name and write it to a new file,

i am stuck at dynamically genrateing the column names like  
Revenue_square

etc.

Exmaple " i have a excel with 3 columns Revenue, cost & profit
Now my Macro should be able to  read the values and for each coulmn  
and
perform square,square root and log of   Revenue, cost & profit and  
write to
excel with column names as Revenue_square,Revenue_squareroot,  
Revenue_log

cost_square etc...

Below is my code

test$Rev_square = test[c(1)]^2

I would use test[[1]]^2. Generally one wants to pull the vector out of  
the list "container".


data=read.delim2("//ARLMSAN01/CTRX_Data/vikasK.sharma/Desktop/ 
balancesheet_example.csv",header=T,sep=",")


headings = names(data)
show (headings)
HEADINGS = toupper(headings)
# Perhaps replacing your for-loop body with this

for ( i in 1:length(HEADINGS))

{


assign(paste(HEADINGS[i],  "Rev_Sqr", sep=""), data[[i]]^2)


}


The generalization to additional transformations seems obvious.

--

David Winsemius, MD
West Hartford, CT

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


Re: [R] Question on if i am allowed to do something

2012-05-24 Thread Marc Schwartz
Giannis,

While your economic situation is appreciated, that you plan to give away your 
application and not generate any income from it, is irrelevant to the question.

The nuances as to how you are interfacing with R and that you plan to include R 
(importantly, possibly only a part of it) as a component of your application 
are. Not altering R's source code is similarly only one part of the issue, 
though if you were, you would be clearly crossing the line to a derivative 
work. However, even in that scenario there are other considerations as to 
whether or not those changes impact your application versus just the modified R 
code.

You are asking a legal question on a list that is focused on technical 
considerations and expecting the list participants to provide free legal 
advice, based upon which you may be making life altering decisions. While you 
may not be able to afford to pay a lawyer now, you and you partners may find 
yourselves needing to pay a lawyer in the future to defend yourselves against a 
lawsuit for copyright and licensing infringement. A situation, by the way, that 
won't be at all helpful to your future career.

You may wish to see if there are any lawyers locally or at your institution 
with specific experience in this domain who may be will to provide you with pro 
bono advice. Lacking expert legal advice, the only thing we can tell you is 
"don't do it" because you may be violating the GPL license and therefore may 
expose yourself and your partners to future legal risk.

Regards,

Marc

On May 24, 2012, at 7:23 AM, Giannis Mamalikidis wrote:

> Your answers were very helpful, thanks :)
> 
> But, you see, the program I'm writing will be a team effort - and while I 
> have not problem on making this program an open source - we don't really see 
> eye to eye with the team on this.
> So no source code will be available - just freeware.
> 
> R will not be at all altered! the only thing that R will do is be used to 
> show a couple of plots, and make some t.test and ks.test.
> 
> Does that qualify as a derivative work of R? Or would derivative work be if I 
> altered R's Source code?
> I've read the license but English is not my Native language, hence some 
> terminology is unclear to me.
> 
> And I'm just an undergraduate with no income in the middle of an economy 
> crisis. I don't really see me paying a lawyer to ask the question.
> 
> ---
> Giannis Mamalikidis
> e-mail: giannis_mamaliki...@msn.com
> Member of the STAINS Research Group
> (STAtistics & INformation Systems Group) of the
> Aristotle University of Thessaloniki
> Site: http://stains.csd.auth.gr
> B.Sc Student in Electrical and Mechanical Engineering
> ---
> -Original Message- From: Marc Schwartz
> Sent: Thursday, May 24, 2012 3:58 AM
> To: Duncan Murdoch
> Cc: Giannis Mamalikidis ; r-help@r-project.org
> Subject: Re: [R] Question on if i am allowed to do something
> 
> 
> On May 23, 2012, at 6:51 PM, Duncan Murdoch wrote:
> 
>> On 12-05-23 1:31 PM, Giannis Mamalikidis wrote:
>>> Hello all.
>>> 
>>> I would like to know: provided that I absolutely state that R is not mine
>>> and I also include the R’s License which will be shown so people know R and
>>> R’s license,
>>> (provided the above) am I allowed to include R’s folder (the folder that has
>>> its binaries) on my freeware program or not?
>> 
>> R is licensed under the GPL v 2 or 3.  The recommended packages that come 
>> with it are separately licensed, but are also (mainly) GPL.  So just follow 
>> the terms of that license, which is included with R.
>> 
>> Duncan Murdoch
> 
> 
> Just to add on to Duncan's reply, you might want to review the GPL FAQ (and 
> possibly consult a lawyer):
> 
> http://www.gnu.org/licenses/gpl-faq.html
> 
> The use and distribution of R within your 'freeware' can place certain 
> obligations on you, including possibly requiring that you license your 
> application with a GPL compatible license and make the source code of your 
> application available in situations where your application is 'linked' to R. 
> If you do not intend to make your own source code available, you should be 
> very clear on what the GPL requires of you before proceeding.
> 
> Regards,
> 
> Marc Schwartz
> 

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


Re: [R] Using NA as a break point for indicator variable?

2012-05-24 Thread Rui Barradas

Hello,

Assuming that 'd' is your original data.frame and that you've set entire 
rows to NA, try this



d$leak_num <- NA
ix <- !is.na(d[, 1])  # any column will do, entire row is NA
## alternative, if other rows may have NAs, due to something else
#ix <- apply(d, 1, function(x) all(!is.na(x)))
r <- rle(ix)
v <- cumsum(r$values)
d$leak_num[ix] <- rep(v[r$values], r$lengths[r$values])
d


Hope this helps,

Rui Barradas

Em 24-05-2012 11:00, Max Brondfield  escreveu:

Date: Wed, 23 May 2012 16:42:02 -0400
From: Max Brondfield
To:r-help@r-project.org
Subject: [R] Using NA as a break point for indicator variable?
Message-ID:

Content-Type: text/plain

Hi all,
I am working with a spatial data set for which I am only interested in high
concentration values ("leaks"). The low values (<  90th percentile) have
already been turned into NA's, leaving me with a matrix like this:

<  CH4_leak

   lonlatCH4
1  -71.11954 42.35068 2.595834
2  -71.11954 42.35068 2.595688
3   NA   NA   NA
4   NA   NA   NA
5   NA   NA   NA
6  -71.11948 42.35068 2.435762
7  -71.11948 42.35068 2.491003
8  NANA   NA
9  -71.11930 42.35068 2.464475
10 -71.11932 42.35068 2.470865

Every time an NA comes up, it means the "leak" is gone, and the next valid
value would represent a different leak (at a different location). My goal
is to tag all of the remaining values with an indicator variable to
spatially distinguish the leaks. I am envisioning a simple numeric
indicator such as:

  lonlatCH4leak_num
1  -71.11954 42.35068 2.595834   1
2  -71.11954 42.35068 2.595688   1
3   NA   NA   NA NA
4   NA   NA   NA NA
5   NA   NA   NA NA
6  -71.11948 42.35068 2.435762   2
7  -71.11948 42.35068 2.491003   2
8  NANA   NA NA
9  -71.11930 42.35068 2.064475   3
10 -71.11932 42.35068 2.070865  3

Does anyone have any thoughts on how to code this, perhaps using the NA
values as a "break point"? The data set is far too large to do this
manually, and I must admit I'm completely at a loss. Any help would be much
appreciated! Best,

Max

[[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 on if i am allowed to do something

2012-05-24 Thread Duncan Murdoch

On 12-05-24 8:23 AM, Giannis Mamalikidis wrote:

Your answers were very helpful, thanks :)

But, you see, the program I'm writing will be a team effort - and while I
have not problem on making this program an open source - we don't really see
eye to eye with the team on this.
So no source code will be available - just freeware.

R will not be at all altered! the only thing that R will do is be used to
show a couple of plots, and make some t.test and ks.test.

Does that qualify as a derivative work of R? Or would derivative work be if
I altered R's Source code?


I would say that makes your program a derivative work, so you should not 
distribute R as part of it.


But I am not a lawyer; in fact, I'm an interested party:  a copyright 
holder on parts of R.  So I don't know if the law is on my side, but you 
can be assured that you are violating the wishes of at least one R 
copyright holder if you do distribute it in a closed source package.


Duncan Murdoch



I've read the license but English is not my Native language, hence some
terminology is unclear to me.

And I'm just an undergraduate with no income in the middle of an economy
crisis. I don't really see me paying a lawyer to ask the question.

---
Giannis Mamalikidis
e-mail: giannis_mamaliki...@msn.com
Member of the STAINS Research Group
(STAtistics&  INformation Systems Group) of the
Aristotle University of Thessaloniki
Site: http://stains.csd.auth.gr
B.Sc Student in Electrical and Mechanical Engineering
---
-Original Message-
From: Marc Schwartz
Sent: Thursday, May 24, 2012 3:58 AM
To: Duncan Murdoch
Cc: Giannis Mamalikidis ; r-help@r-project.org
Subject: Re: [R] Question on if i am allowed to do something


On May 23, 2012, at 6:51 PM, Duncan Murdoch wrote:


On 12-05-23 1:31 PM, Giannis Mamalikidis wrote:

Hello all.

I would like to know: provided that I absolutely state that R is not mine
and I also include the R’s License which will be shown so people know R
and
R’s license,
(provided the above) am I allowed to include R’s folder (the folder that
has
its binaries) on my freeware program or not?


R is licensed under the GPL v 2 or 3.  The recommended packages that come
with it are separately licensed, but are also (mainly) GPL.  So just
follow the terms of that license, which is included with R.

Duncan Murdoch



Just to add on to Duncan's reply, you might want to review the GPL FAQ (and
possibly consult a lawyer):

   http://www.gnu.org/licenses/gpl-faq.html

The use and distribution of R within your 'freeware' can place certain
obligations on you, including possibly requiring that you license your
application with a GPL compatible license and make the source code of your
application available in situations where your application is 'linked' to R.
If you do not intend to make your own source code available, you should be
very clear on what the GPL requires of you before proceeding.

Regards,

Marc Schwartz



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


Re: [R] applying cbind (or any function) across all components in a list

2012-05-24 Thread Hans Thompson
The combination of column means in cbind is what I am trying to do.  I just
don't know how to do it for every component (2 in this case) of the list. 
I've been able to work with R to apply a function across all components when
there is just one list but I am having trouble working with multiple lists
at the same time.  

--
View this message in context: 
http://r.789695.n4.nabble.com/applying-cbind-or-any-function-across-all-components-in-a-list-tp4631128p4631187.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] quotes in Rscript -e through system

2012-05-24 Thread abhagwat
I figured out how to use quotes and parentheses when using Rscript -e (on a 
bash shell):
Rscript -e write\(1,\"a.txt\"\)

--> Question 1: why do the parentheses need to be escaped in the shell?
(More a shell than an R question)

Then I figured out how to use quotes and parentheses when calling Rscript
through system:
system('Rscript -e write\\(1,\\\'a.txt\\\'\\)')

--> Question 2: why exactly is it necessary to use double and triple
escapes? I kinda understand it, but not completely.

Thanks for your insights!

Adi





--
View this message in context: 
http://r.789695.n4.nabble.com/quotes-in-Rscript-e-through-system-tp4631186.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How to avoid numbering while printing list element?

2012-05-24 Thread Manish Gupta
HI, 

I am printing list element. 

print(desc[[2]])
[1] XXXxx

I want to remove [1]
Output should be 
XXXxx

How can i implement it? 

Thanks


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-avoid-numbering-while-printing-list-element-tp4631180.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] set tkscale by tkentry

2012-05-24 Thread Alexander
Hi, I am working under Windows and I am using R2.11
I want to use tkscale in my GUI. As the interval is quite big, I can't set
the scale to a certain specific value. Therefore I want to add tkentry to
allow the user to set tkscale to a certain value.

Here is the code

library(tcltk)

tt<-tktoplevel()
tkpack(m1<-tkscale(tt,from=306870.00, to=3026741, label="alpha",
variable="varalpha",showvalue=TRUE, resolution=1,
orient="horiz"),side="bottom")
tkpack(tkentry(tt,width="10",textvariable="varalpha",validate="key",validatecommand="string
is double %P"),side="bottom")

As you can see, varalpha is a global variable (I think in tcl, not in R),
and if you change the parameter by the scale, the value in tkentry is
updated. If I want to set now the value of varalpha by tkentry, it bugs.
Does anyone have an idea, why? I already tried the interval from 0 to any
number, which works fine...

library(tcltk)

tt<-tktoplevel()
tkpack(m1<-tkscale(tt,from=0.00, to=1000, label="alpha",
variable="varalpha",showvalue=TRUE, resolution=1,
orient="horiz"),side="bottom")
tkpack(tkentry(tt,width="10",textvariable="varalpha",validate="key",validatecommand="string
is double %P"),side="bottom")

Thanks in advance,
Alexander

--
View this message in context: 
http://r.789695.n4.nabble.com/set-tkscale-by-tkentry-tp4631174.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] building transformation macro

2012-05-24 Thread davv.vikas
Hi All,

I am writing a macro which perform following functionality
1) take a file say excel or csv
2)read all the labels
3) dynamically genrate square,square-root,log  of each column with
appropiate column name and write it to a new file,

i am stuck at dynamically genrateing the column names like Revenue_square
etc.

Exmaple " i have a excel with 3 columns Revenue, cost & profit
Now my Macro should be able to  read the values and for each coulmn and
perform square,square root and log of   Revenue, cost & profit and write to
excel with column names as Revenue_square,Revenue_squareroot, Revenue_log
cost_square etc...

Below is my code

test$Rev_square = test[c(1)]^2


data=read.delim2("//ARLMSAN01/CTRX_Data/vikasK.sharma/Desktop/balancesheet_example.csv",header=T,sep=",")

headings = names(data)
 show (headings)
HEADINGS = toupper(headings)

for ( i in 1:length(HEADINGS))
{
show(i)
data$Rev_square=data[c(i)]^2



show(data$Rev_square)
names(data)
}


--
View this message in context: 
http://r.789695.n4.nabble.com/building-transformation-macro-tp4631175.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] plot(summary) quantreg - Not all outputs needed

2012-05-24 Thread stefan23
Hi Folks,
I am currently trying to present some results I obtained by using the
quantreg package developed by Roger Koenker. After calculating
fit<-summary(rq(Y~X1+X2, tau=2:98/100) ) the function plot(fit) presents a
really nice the results by showing the values for all "regressors" in the
given interval tau. But in my case, I only need the output of a single
variable, say X1 and I am not interested in plotting the others. Is there a
way to hide the other graphics?
Thank you very much for your help,

Cheers
Stefan

--
View this message in context: 
http://r.789695.n4.nabble.com/plot-summary-quantreg-Not-all-outputs-needed-tp4631184.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] Mistake:number of cluster centres must lie between 1 and nrow(x)

2012-05-24 Thread Gaomeng
Dear List:
I write codes to get"Mean and standard deviations (Std.) for EM
estimates—500 samples from the FM-ST model"(R package mixsmsn).It has a
mistake:"number of cluster centres must lie between 1 and nrow(x) ". my
codes below:

mu1 <- c(2,2)
Sigma1 <- matrix(c(1.5,0,0,1.5), 2,2)
shape1 <-c(-5,10)
nu1 <- 4
mu2 <- c(-2,-1)
Sigma2 <- matrix(c(1.5,0,0,1.5), 2,2)
shape2 <-c(-5,10)
nu2 <- 4
pii<-c(0.6,0.4)
arg1 = list(mu=mu1, Sigma=Sigma1, shape=shape1, nu=nu1)
arg2 = list(mu=mu2, Sigma=Sigma2, shape=shape2, nu=nu2)
y <- rmmix(n=500, p = pii, "Skew.t", list(arg1,arg2))
St.analysis <- smsn.mmix(y, nu=3, g=2, get.init = TRUE, criteria = TRUE,
group = TRUE, family = "Skew.t",calc.im=TRUE)
St.analysis 
##skew t fit giving intial values
for(i in 1:500){
mu1 <- c(0,0)
Sigma1 <- matrix(c(1,0,0,1), 2,2)
shape1 <-c(-1,5)
nu1 <- 10
mu2 <- c(0,0)
Sigma2 <- matrix(c(1,0,0,1), 2,2)
shape2 <-c(-1,5)
nu2 <- 10
pii<-c(0.5,0.5)
mu<-list(mu1,mu2)
#nu<-list(nu1,nu2)
Sigma<-list(Sigma1,Sigma2)
shape<-list(shape1,shape2)
St.analysis[i] <- smsn.mix(y[i,],g=2,nu=10,mu=mu,shape=shape,pii =
pii,get.init = TRUE, criteria = TRUE,group = TRUE, family =
"Skew.t",calc.im=TRUE)
print(St.analysis[i])
}

--
View this message in context: 
http://r.789695.n4.nabble.com/Mistake-number-of-cluster-centres-must-lie-between-1-and-nrow-x-tp4631177.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

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


Re: [R] select part of files from a list.files

2012-05-24 Thread jeff6868
Hi again Joshua.

I tried your function. I think it's what I need. It works well in the small
example of my first post. But I have difficulties to adapt it to my data.
I'll try to give you another fake example with my real script and kind of
data (you can just copy and paste it to try):

ST1 <-
data.frame(sensor1=rnorm(1:10),sensor2=c(NA,NA,NA,NA,NA,rnorm(6:10)),sensor3=c(1,NA,NA,4:10),sensor4=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),date_time=(date()))
write.table(ST1,"ST1_2012.csv",sep=";",quote=F, row.names = TRUE)
ST2 <-
data.frame(sensor1=c(NA,NA,NA,NA,NA,6:10),sensor2=rnorm(1:10),sensor3=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),sensor4=c(1,NA,NA,4:10),date_time=(date()))
write.table(ST2,"ST2_2012.csv",sep=";",quote=F, row.names = TRUE)
ST3 <-
data.frame(sensor1=c(1,NA,NA,4:10),sensor2=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),sensor3=rnorm(1:10),sensor4=c(NA,NA,NA,NA,NA,6:10),date_time=(date()))
write.table(ST3,"ST3_2012.csv",sep=";",quote=F, row.names = TRUE)
ST4 <-
data.frame(sensor1=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA),sensor2=c(1,NA,NA,4:10),sensor3=c(NA,NA,NA,NA,NA,6:10),sensor4=rnorm(1:10),date_time=(date()))
write.table(ST4,"ST4_2012.csv",sep=";",quote=F, row.names = TRUE)

filenames <- list.files(pattern="\\_2012.csv$")

Sensors <- paste("sensor", 1:4,sep="")

Stations <-substr(filenames,1,3)

nsensors <- length(Sensors)
nstations <- length(Stations)

nobs <- nrow(read.table(filenames[1], header=TRUE,sep=";"))

yr2008 <- array(NA,dim=c(nobs, nsensors, nstations))

for(i in seq_len(nstations)){
tmp <- read.table(filenames[i], header=TRUE, sep=";")
yr2008[ , , i] <- as.matrix(tmp[, Sensors])
}

dimnames(yr2008) <- list(seq.int(nobs), Sensors, Stations)

cor1_5 <- lapply(Sensors, function(s) cor(yr2008[1:5, s,
],use="pairwise.complete.obs"))
names(cor1_5) <- Sensors
cor1_5

For the moment, it makes correlations between the same sensors of each file
(only for a part of my data), whatever the number of NA or numeric data.
I want it to do the same, but with your function: 
if (sum(!is.na(data[rows, ])) >= minpresent){
data
  } else {NULL}
} 

I want it to give me the same correlation matrices for each sensors between
my files, but I want it to calculate the correlation coefficient only if I
have at least 3 numeric values (out of 5 in the example), and not whatever
the number of these numeric values (just 1 or 2 for example). If there're
less than 3 numeric values (1 or 2), give NA for correlation in the matrix.
And if there're only NAs in the sensor data, do nothing with it (keep it and
go to the next sensor).

I tried to combinate your function with mine but it doesn't work. Hope
you've understood. Thanks for your help!




--
View this message in context: 
http://r.789695.n4.nabble.com/select-part-of-files-from-a-list-files-tp4630769p4631185.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Optimizing problem R

2012-05-24 Thread Petr Savicky
On Wed, May 23, 2012 at 10:56:43PM -0700, kylmala wrote:
> Hi,
> 
> and thanks for replying this. Yes, you are right that the term
> min(24/bb,26/cc) is actually min(bb/24,cc/26) - my mistake. But still I
> don't get it. If the objective function is 
> 
> #min(m1,m2,m3)
> f.obj <- c(1, 1, 1)
> 
> #and we now that 
> # a+aa<=15 
> # b+bb+bbb<=35 
> # cc+ccc<=40 
> 
> # so
> 
> # 1a + 0b + 0c + 1aa + 0bb + 0cc + 0aaa + 0bbb + 0ccc <=15
> # 0a + 1b + 0c + 0aa + 1bb + 0cc + 0aaa + 1bbb + 0ccc <=35
> # 0a + 0b + 0c + 0aa + 0bb + 1cc + 0aaa + 0bbb + 1ccc <=40
> # and the matrix of numeric constraint coefficients is 
> 
> C = matrix(nrow=3, data=c(1,0,0,0,1,0,0,0,0,1,1,0,0,0,1,0,1,0,0,0,1))
> 
> #Constraits are: 
> 
> f.rhs <- c(15, 35, 40)
> 
> #and 
> 
> f_dir = c("<=", "<=", "<=")
> 
> Because the command lp is form lp ("max", f.obj, f.con, f.dir, f.rhs), how
> can I get those other constraints in
> 
>  m1 <= a/10 
>   m1 <= b/11 
>   m2 <= aa/13 
>   m2 <= bb/12 
>   m2 <= cc/10 
>   m3 <= bb/24 
>   m3 <= cc/26

Hi.

There are 12 variables, namely a, b, c, aa, bb, cc, aaa, bbb, ccc, m1, m2, m3
and 3 + 7 constraints. So, the matrix should be 10 times 12 and may be created
as follows

  C11 <- rbind(
  c(1, 0, 0, 1, 0, 0, 0, 0, 0),
  c(0, 1, 0, 0, 1, 0, 0, 1, 0),
  c(0, 0, 0, 0, 0, 1, 0, 0, 1))
 
  C12 <- matrix(0, nrow=3, ncol=3)
 
  A <- matrix(0, nrow=7, ncol=12)
  colnames(A) <- c("a", "b", "c", "aa", "bb", "cc", "aaa", "bbb", "ccc", "m1", 
"m2", "m3")
 
  A[1, c( "a", "m1")] <- c(1/10, -1)
  A[2, c( "b", "m1")] <- c(1/11, -1)
  A[3, c("aa", "m2")] <- c(1/13, -1)
  A[4, c("bb", "m2")] <- c(1/12, -1)
  A[5, c("cc", "m2")] <- c(1/10, -1)
  A[6, c("bb", "m3")] <- c(1/24, -1)
  A[7, c("cc", "m3")] <- c(1/26, -1)
 
  f.mat <- rbind(cbind(C11, C12), A)

The variables "c" and "aaa" are not used at all. Is this correct?

The other parameters and the call are

  library(lpSolve)

  f.obj <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1)
  f.rhs <- c(15, 35, 40, 0, 0, 0, 0, 0, 0, 0)
  f.dir = c("<=", "<=", "<=", rep(">=", times=7))

  out <- lp("max", f.obj, f.mat, f.dir, f.rhs)
  out

  Success: the objective function is 2.612179 

  out$solution

  [1]  0.00  0.00  0.00 15.00 35.00 37.916667  0.00
  [8]  0.00  0.00  0.00  1.153846  1.458333

The constraint on m1 requires only m1 <= min(a/10,b/11), however, since
we maximize m1 + m2 + m3, the optimum will satisfy m1 = min(a/10,b/11).
Similarly for m2, m3.

Hope this helps.

Petr Savicky.

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


Re: [R] transform 1 col to 2 col

2012-05-24 Thread Jim Lemon

On 05/24/2012 05:10 PM, Soheila Khodakarim wrote:

Dear All

How can I transform 1 column to 2 columns in R?

211217_s_at

GO:0005249

211217_s_at

GO:0005251

211217_s_at

GO:0005515

211217_s_at

GO:0015271

   211217_s_at

   GO:0030955





211217_s_at

GO:0005249

211217_s_at

GO:0005251

   211217_s_at

GO:0005515

211217_s_at

GO:0015271

   211217_s_at

GO:0030955


Hi Soheila,
Let us begin with the assumption that your "col" is roughly what you 
posted, and that text resides in a file named "inscrutable.dat". Let us 
first read that text into a data frame in R:


inscrutatble.df<-read.table("inscrutable.dat")
 inscrutable.df
V1 


1 211217_s_at
2  GO:0005249
3  211217_s_at
4   GO:0005251
5  211217_s_at
6   GO:0005515
7  211217_s_at
8   GO:0015271
9  211217_s_at
10  GO:0030955
11 211217_s_at
12  GO:0005249
13 211217_s_at
14  GO:0005251
15 211217_s_at
16  GO:0005515
17 211217_s_at
18  GO:0015271
19 211217_s_at
20  GO:0030955

Now we will further assume that you want to place every odd element in 
one "col" and every even element in the other "col".


inscrutable2.df<-data.frame(
 col1=inscrutable.df$V1[seq(1,length(inscrutable.df$V1),by=2)],
 col2=inscrutable.df$V1[seq(2,length(inscrutable.df$V1),by=2)])
inscrutable2.df
  col1   col2
1  211217_s_at GO:0005249
2  211217_s_at GO:0005251
3  211217_s_at GO:0005515
4  211217_s_at GO:0015271
5  211217_s_at GO:0030955
6  211217_s_at GO:0005249
7  211217_s_at GO:0005251
8  211217_s_at GO:0005515
9  211217_s_at GO:0015271
10 211217_s_at GO:0030955

There we are - easy as pie.

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] How to retrieve value form dataframe by Key?

2012-05-24 Thread Manish Gupta
Hi, 

I have one datagrame 

Col1  Col2Col3  
   
Col3
xxx erThis is third record of 1st line.   
This is 4th record of first line.
xxy erThis is third record of 1st line.   
This is 4th record of second line
xyx erThis is third record of 1st line.   
This is 4th record of third line

I want to get records corresponding to key (here Col1). How can i implement
it?

e.g. 
if i key in xxx i should get 
xxx erThis is third record of 1st line.   
This is 4th record of first line.

if i key in xxy i should get 
xxy erThis is third record of 1st line.   
This is 4th record of second line

Regards


--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-retrieve-value-form-dataframe-by-Key-tp4631173.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] Error while conecting to database.

2012-05-24 Thread Manish Gupta
Hi, 

I am getting following error message while retrieving records from mysql.

*Error in if (count > 0L) { : missing value where TRUE/FALSE needed
Calls:  -> do.call ->  -> 
Execution halted*


con2 <- dbConnect(MySQL(), user="XXX", password="",dbname="",
host="XXX.X.X.X")
#if(nchar(disname) == 2)
{
disQuery= "select Desc from Tablename where Tableanem.field = " 
cat(paste("*",disname,"*","\n",sep=""))
disQuery<-paste(disQuery, "'", disname ,"'", sep = "")
cat(disQuery,"\n")
cat(paste("\\textbf{",Col3[i],"?}\n",sep=""))
cat("\\leavevmode","\n")
cat("\\newline","\n")  
#cat(disQuery,"\n")

#print(dbListTables(con2))
disres <- dbSendQuery(con2, disQuery)
dout <- fetch(disres, n = 1)
dataout <- ifelse(is.na(dout), "-" ,dout)
cat(paste(dataout),"\n")  * // getting error
message here*

}
dbDisconnect(con2)


May i know why I am getting above error message. 

Regards


--
View this message in context: 
http://r.789695.n4.nabble.com/Error-while-conecting-to-database-tp4631169.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] Convolve 2 uniform distributed variables

2012-05-24 Thread Prof. Dr. Matthias Kohl

take a look at the distr package

library(distr)
U <- Unif()
U2 <- U + U
# or
U2 <- convpow(U, 2)
plot(U2)
# or
curve(d(U2)(x), from = 0, to = 2)


Best
Matthias

On 24.05.2012 08:29, c...@mail.tu-berlin.de wrote:

Hi,
I want to convolve 2 uniform distributed [0,1] variables, so that I get
this graphic:
http://de.wikipedia.org/wiki/Benutzer:Alfred_Heiligenbrunner/Liste_von_Verteilungsdichten_der_Summe_gleichverteilter_Zufallsvariabler
(second graphic)

if I do

u1<-seq(0,1,length=100)
fu1=dunif(u1,min=0,max=1)

plot(u1,fu1,type="l",xlim=c(-2,2))


u2<-seq(0,1,length=100)
fu2=dunif(u2,min=0,max=1)

u1u2<-convolve(u1,rev(u1),typ="o")

plot(u1u2)

it does not work, could you help me please? The point is the convolve
function I think, what do I have to type, to get the correct convolution
of two uniform distributed [0,1] variables as to be seen in the second
graphic in the given link?

Thanks a lot

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


--
Prof. Dr. Matthias Kohl
www.stamats.de

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

2012-05-24 Thread Soheila Khodakarim
Dear All

How can I transform 1 column to 2 columns in R?

211217_s_at

GO:0005249

211217_s_at

GO:0005251

211217_s_at

   GO:0005515

211217_s_at

GO:0015271

  211217_s_at

  GO:0030955





211217_s_at

GO:0005249

211217_s_at

GO:0005251

  211217_s_at

   GO:0005515

211217_s_at

GO:0015271

  211217_s_at

GO:0030955

 Best Wishes,

Soheila

[[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] Convolve 2 uniform distributed variables

2012-05-24 Thread corn

Hi,
I want to convolve 2 uniform distributed [0,1] variables, so that I  
get this graphic:  
http://de.wikipedia.org/wiki/Benutzer:Alfred_Heiligenbrunner/Liste_von_Verteilungsdichten_der_Summe_gleichverteilter_Zufallsvariabler (second  
graphic)


if I do

u1<-seq(0,1,length=100)
fu1=dunif(u1,min=0,max=1)

plot(u1,fu1,type="l",xlim=c(-2,2))


u2<-seq(0,1,length=100)
fu2=dunif(u2,min=0,max=1)

u1u2<-convolve(u1,rev(u1),typ="o")

plot(u1u2)

it does not work, could you help me please? The point is the convolve  
function I think, what do I have to type, to get the correct  
convolution of two uniform distributed [0,1] variables as to be seen  
in the second graphic in the given link?


Thanks a lot

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


Re: [R] Optimizing problem R

2012-05-24 Thread kylmala
Hi,

and thanks for replying this. Yes, you are right that the term
min(24/bb,26/cc) is actually min(bb/24,cc/26) - my mistake. But still I
don't get it. If the objective function is 

#min(m1,m2,m3)
f.obj <- c(1, 1, 1)

#and we now that 
# a+aa<=15 
# b+bb+bbb<=35 
# cc+ccc<=40 

# so

# 1a + 0b + 0c + 1aa + 0bb + 0cc + 0aaa + 0bbb + 0ccc <=15
# 0a + 1b + 0c + 0aa + 1bb + 0cc + 0aaa + 1bbb + 0ccc <=35
# 0a + 0b + 0c + 0aa + 0bb + 1cc + 0aaa + 0bbb + 1ccc <=40
# and the matrix of numeric constraint coefficients is 

C = matrix(nrow=3, data=c(1,0,0,0,1,0,0,0,0,1,1,0,0,0,1,0,1,0,0,0,1))

#Constraits are: 

f.rhs <- c(15, 35, 40)

#and 

f_dir = c("<=", "<=", "<=")

Because the command lp is form lp ("max", f.obj, f.con, f.dir, f.rhs), how
can I get those other constraints in

 m1 <= a/10 
  m1 <= b/11 
  m2 <= aa/13 
  m2 <= bb/12 
  m2 <= cc/10 
  m3 <= bb/24 
  m3 <= cc/26



--
View this message in context: 
http://r.789695.n4.nabble.com/Optimizing-problem-R-tp4631048p4631168.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] Issues while using “lift.chart” and “adjProbScore” function from ”BCA” library

2012-05-24 Thread aajit75
Dear List,

Couple of issues while using functions from “BCA” library:

1. I am trying to use “lift.chart” function from “BCA” library, but facing
issues while using model where model formula is passed as formula object in
glm.

When model formula is written as text, then it works fine. In my case input
variables and target variables are going to change dynamically, so have to
used formula as formula object as derived.

Below is the sample code, taken from the package document to illustrate the
issues

library(BCA)
data(CCS)
CCS$Sample <- create.samples(CCS, est=0.4, val=0.4)
CCSEst <- CCS[CCS$Sample == "Estimation",]

#Fit glm model with formula written as text

CCS.glm <- glm(MonthGive ~ DonPerYear + LastDonAmt + Region + YearsGive,
family=binomial(logit), data=CCSEst)

CCSVal <- CCS[CCS$Sample == "Validation",]

lift.chart(c("CCS.glm"), data=CCSVal, targLevel="Yes",
trueResp=0.01, type="incremental", sub="Validation")


#Fit glm model with formula passed as formula object

fm <- as.formula("MonthGive ~ DonPerYear + LastDonAmt + Region + YearsGive")

CCS.glm12 <- glm(fm,family=binomial(logit), data=CCSEst)

lift.chart(c("CCS.glm12"), data=CCSVal, targLevel="Yes",
trueResp=0.01, type="incremental", sub="Validation")

Following error occurs,
Error in if (any(yvar1 != yvar1[1])) { : 
  missing value where TRUE/FALSE needed

Is there any way out to use formula object in the model and using
“lift.chart” function

2. Issue using “adjProbScore” function from the “BCA” library.

(adjProbScore(model="CCS.glm", data=CCSVal1, targLevel="Yes",
trueResp=0.01))

Error in parse(text = paste("as.character(", ActiveDataSet(), "$", yvar,  : 
  :1:16: unexpected '$'
1: as.character(  $
  ^
Above error is thrown, am I doing anything wrong? Please correct.
Also, as in the case-1 above, can we use model fitted with formula object in
“adjProbScore” function.

Thanks in advance!
Ajit


--
View this message in context: 
http://r.789695.n4.nabble.com/Issues-while-using-lift-chart-and-adjProbScore-function-from-BCA-library-tp4631158.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.