Re: [R] small negative values instead of zeros in nested loop

2012-09-26 Thread Daniel Nordlund
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
 On Behalf Of Cristina Fdez. Aragón
 Sent: Tuesday, September 25, 2012 4:40 PM
 To: r-help@r-project.org
 Subject: [R] small negative values instead of zeros in nested loop
 
 
 
 
 
 Hi,I am trying to run a code with a series of nested for loops, here is a
 simplified version of it:
 J-seq(0,1,0.2)   D-seq(0,1,0.2)
 
 for (x in 1:10)   {   
 for (j
 in 1:length(J))   {   
 for (d
 in 1:(length(D)-j+1)) {
   x.end-x*(1-J[j]-D[d])
   print(x)print(J[j])
   print(D[d]) print(x.end)
 }
   }}
 The problem is that whenever x.end should be zero it takes a small
 negative value really close to zero instead. Any idea of why this might be
 happening and how can I fix it?Thanks!
 

The reason for why this happens can be found in R FAQ 7.31.

Dan


Daniel Nordlund
Bothell, WA USA

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


[R] Ask for help - how to change WHIRR.117.csv to WHIRR_117.csv

2012-09-26 Thread s.s.m. fauzi
Hi,
I have a script below.

dat - read.table(file=pt.csv, header=T, sep=,, row.names=1,
col.names=1)
dat
for(which_col in seq_len(ncol(dat)))
{
  subset_data - dat[,which_col:ncol(dat)]
  file_name - sprintf('%s.csv', colnames(dat)[which_col])
  write.csv(subset_data, file_name)
  message(sprintf('Saving %s', file_name))
}

dput(head(dat))

structure(list(WHIRR.25 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.28 = c(0L,
0L, 1L, 0L, 0L, 0L), WHIRR.55 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.61 = c(0L,
0L, 1L, 0L, 0L, 0L), WHIRR.76 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.87 = c(0L,
0L, 0L, 0L, 0L, 0L), WHIRR.92 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.115 =
c(0L,
0L, 0L, 0L, 0L, 0L), WHIRR.117 = c(0L, 0L, 0L, 0L, 0L, 0L)), .Names = c(
WHIRR.25,
WHIRR.28, WHIRR.55, WHIRR.61, WHIRR.76, WHIRR.87, WHIRR.92,
WHIRR.115, WHIRR.117), row.names = c(Adrian Cole, Alison Wong,
Andrei Savu, Bruno Dumon, Edward J. Yoon, Eugene Koontz
), class = data.frame)

The script is able to save the file in the directory, but with the
following name:
WHIRR.25.csv
WHIRR.28.csv
WHIRR.55.csv
WHIRR.61.csv
WHIRR.76.csv
WHIRR.87.csv
WHIRR.92.csv
WHIRR.115.csv
WHIRR.117.csv

My first question is:
How can I change or convert the name above to WHIRR_25.csv, WHIRR_28.csv,
WHIRR_55.csv, etc?

My second question is:
The last column which is WHIRR.177.csv is not properly created, the output
for the last column is as below:

   X1
1   0
2   0
3   0
4   0
5   0
6   0
7   0
8   0
9   0
10  0
11  0
12  0
13  0
14  1
15  0

Suppose, the last column should be properly created like this, as below:

  WHIRR.117
Adrian Cole 0
Alison Wong   0
Andrei Savu0
Bruno Dumon  0
Edward J. Yoon   0
Eugene Koontz   0
Jakob Homan  0
Kelvin Kakugawa 0
Kirk True 0
Lars George0
Soren Macbeth0
Stu Hood0
Tibor Kiss   0
Tom White 1
Unassigned0

Appreciate your thought...

[[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] Memory usage in R grows considerably while calculating word frequencies

2012-09-26 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 25/09/12 01:29, mcelis wrote:
 I am working with some large text files (up to 16 GBytes).  I am interested 
 in extracting the 
 words and counting each time each word appears in the text. I have written a 
 very simple R 
 program by following some suggestions and examples I found online.

Just an idea (I have no experience with what you want to do, so it might not 
work):

What about putting the text in a database (sqlite comes to mind) where each 
word is one entry.
Then you could use sql to query the database, which should need much less 
memory.

In addition, it should make further processing much easier.

Cheers,

Rainer

 
 If my input file is 1 GByte, I see that R uses up to 11 GBytes of memory when 
 executing the 
 program on a 64-bit system running CentOS 6.3. Why is R using so much memory? 
 Is there a
 better way to do this that will minimize memory usage.
 
 I am very new to R, so I would appreciate some tips on how to improve my 
 program or a better 
 way to do it.
 
 R program: # Read in the entire file and convert all words in text to lower 
 case 
 words.txt-tolower(scan(text_file,character,sep=\n))
 
 # Extract words pattern - (\\b[A-Za-z]+\\b) match - 
 gregexpr(pattern,words.txt) words.txt 
 - regmatches(words.txt,match)
 
 # Create a vector from the list of words words.txt-unlist(words.txt)
 
 # Calculate word frequencies words.txt-table(words.txt,dnn=words)
 
 # Sort by frequency, not alphabetically 
 words.txt-sort(words.txt,decreasing=TRUE)
 
 # Put into some readable form, Name of word and Number of times it occurs 
 words.txt-paste(names(words.txt),words.txt,sep=\t)
 
 # Results to a file cat(Word\tFREQ,words.txt,file=frequencies,sep=\n)
 
 
 
 -- View this message in context: 
 http://r.789695.n4.nabble.com/Memory-usage-in-R-grows-considerably-while-calculating-word-frequencies-tp4644053.html


 
Sent from the R help mailing list archive at Nabble.com.
 

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBitboACgkQoYgNqgF2egr1pgCgjHxE/E1qIwUbrYzB30qIk9cK
z/oAoILCYn66+c9CF5tzkWeQH3E2utwi
=ahI5
-END PGP SIGNATURE-

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


Re: [R] Help needed on parallel processing

2012-09-26 Thread Milan Bouchet-Valat
Le mercredi 26 septembre 2012 à 13:04 +0530, Anindya Sankar Dey a
écrit :
 Hi All,
 
 If i have a vector say x-1:10 and then use
 
 parLapply(cl,x,function(k){k=k*2;  return(k);}
 
 it works and will also parallel process depending on the number of cores
 and the number of clusters I've built in cl.
 
 
 My query is, if I want this function -
 
 function(k1,k2){ s=k1+k2; return(s);}
 
 to work using parallel processing what will be the procedure.
I think you should have a look at the clusterMap() function. It's the
parallel equivalent of mapply().


My two cents

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


Re: [R] Simulating from probit

2012-09-26 Thread Duncan Murdoch

On 12-09-25 10:16 PM, Tjun Kiat Teo wrote:

Is there anyway to simulate random deviates from probit ?


Use pnorm() to calculate the probabilities, and rbinom() to simulate the 
random values.


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] Broken Links on http://www.r-project.org

2012-09-26 Thread Viechtbauer Wolfgang (STAT)
I was not sure who I should contact about this, so I am posting this here.

There are a few broken links on the R website.

1) http://www.r-project.org/search.html - link to the Nabble R Forum. I belive 
the correct/new URL should be: http://r.789695.n4.nabble.com/

2) http://www.r-project.org/other-docs.html - link to Auswertung ökologischer 
Daten. Not sure if there is a new URL.

3) http://www.r-project.org/other-projects.html - link to Jim Lindsey's R 
page. I believe the correct/new URL should be: 
http://www.commanster.eu/rcode.html

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   

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

2012-09-26 Thread Tammy Ma

Dear R user:


I have got the following problem:

I have imported two data sets into R: one set includes price information, 
another one includes volume information. but I noticed the wrong data order 
problem in the product name,

for instance,

in one data set,

GALAXY ACE S 5830

in another one,

it is S 5830 GALAXY ACE  

both represent same product. how do i map two name into one in R?

there are so many product name having this problem. i hope there is some 
mechanism which can autimatically map those.  thanks for your help..


Kind regards,
Tammy
  
[[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] map two names into one

2012-09-26 Thread Kenn Konstabel
It may be easy or difficult depending on what your data are like.

GALAXY ACE S 5830 vs S 5830 GALAXY ACE

One easy and reasonably general way would be to divide each such bit
into 4 words and then compare if set 2 contains exactly all words in
set 1 but possibly in different order.

x1 - GALAXY ACE S 5830
x2 - S 5830 GALAXY ACE
x3 - S 5830 GALAXY ZOMBIE

divide - function(x) strsplit(x1,  )[[1]]
check - function(x, y) all(divide(x) %in% divide(y))
check(x1,x2)
# [1] TRUE
check(x1,x3)
#FALSE

Or you could try reading in your data in a different way so that S,
GALAXY, ACE, and 5830 would be in different variables (if all
product names have identical structure i.e 4 elements, or is S 5830
supposed to be the price?). Or build a catalogue of all possible
product names and then compare each name to it. etc

htmh





On 9/26/12, Tammy Ma metal_lical...@live.com wrote:

 Dear R user:


 I have got the following problem:

 I have imported two data sets into R: one set includes price information,
 another one includes volume information. but I noticed the wrong data order
 problem in the product name,

 for instance,

 in one data set,

 GALAXY ACE S 5830

 in another one,

 it is S 5830 GALAXY ACE

 both represent same product. how do i map two name into one in R?

 there are so many product name having this problem. i hope there is some
 mechanism which can autimatically map those.  thanks for your help..


 Kind regards,
 Tammy
   
   [[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] map two names into one

2012-09-26 Thread Sarah Goslee
Hi Tammy,

I think we need more information.

Are the names always four parts?
Does the fix always involve moving two parts from the back to the front?
For that matter, which of the two you gave is correct?
Or does it matter what order the parts are in as long as it's consistent?
Sorting them would be easiest, and would work regardless of number of parts
and how they were entered. That could be done, for instance, with
strsplit(), sort() and paste().

Sarah

On Wednesday, September 26, 2012, Tammy Ma wrote:


 Dear R user:


 I have got the following problem:

 I have imported two data sets into R: one set includes price information,
 another one includes volume information. but I noticed the wrong data order
 problem in the product name,

 for instance,

 in one data set,

 GALAXY ACE S 5830

 in another one,

 it is S 5830 GALAXY ACE

 both represent same product. how do i map two name into one in R?

 there are so many product name having this problem. i hope there is some
 mechanism which can autimatically map those.  thanks for your help..


 Kind regards,
 Tammy

 [[alternative HTML version deleted]]

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



-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

[[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] Ask for help - how to change WHIRR.117.csv to WHIRR_117.csv

2012-09-26 Thread Rui Barradas

Hello,

Maybe the code below answers to both your questions (Q1 and Q2)


cnames - colnames(dat)
cnames - sub(WHIRR\\., WHIRR_, cnames)

for(which_col in seq_len(ncol(dat)))
{
  subset_data - dat[which_col:ncol(dat)]  # change 1, Q2
  file_name - sprintf('%s.csv', cnames[which_col])  # change 2, Q1
  #write.csv(subset_data, file_name)  # debug 1
  message(sprintf('Saving %s', file_name))
  if(which_col == ncol(dat)) print(subset_data)  # debug 2
}


Em 26-09-2012 07:43, s.s.m. fauzi escreveu:

Hi,
I have a script below.

dat - read.table(file=pt.csv, header=T, sep=,, row.names=1,
col.names=1)
dat
for(which_col in seq_len(ncol(dat)))
{
   subset_data - dat[,which_col:ncol(dat)]
   file_name - sprintf('%s.csv', colnames(dat)[which_col])
   write.csv(subset_data, file_name)
   message(sprintf('Saving %s', file_name))
}

dput(head(dat))

structure(list(WHIRR.25 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.28 = c(0L,
0L, 1L, 0L, 0L, 0L), WHIRR.55 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.61 = c(0L,
0L, 1L, 0L, 0L, 0L), WHIRR.76 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.87 = c(0L,
0L, 0L, 0L, 0L, 0L), WHIRR.92 = c(0L, 0L, 0L, 0L, 0L, 0L), WHIRR.115 =
c(0L,
0L, 0L, 0L, 0L, 0L), WHIRR.117 = c(0L, 0L, 0L, 0L, 0L, 0L)), .Names = c(
WHIRR.25,
WHIRR.28, WHIRR.55, WHIRR.61, WHIRR.76, WHIRR.87, WHIRR.92,
WHIRR.115, WHIRR.117), row.names = c(Adrian Cole, Alison Wong,
Andrei Savu, Bruno Dumon, Edward J. Yoon, Eugene Koontz
), class = data.frame)

The script is able to save the file in the directory, but with the
following name:
WHIRR.25.csv
WHIRR.28.csv
WHIRR.55.csv
WHIRR.61.csv
WHIRR.76.csv
WHIRR.87.csv
WHIRR.92.csv
WHIRR.115.csv
WHIRR.117.csv

My first question is:
How can I change or convert the name above to WHIRR_25.csv, WHIRR_28.csv,
WHIRR_55.csv, etc?

My second question is:
The last column which is WHIRR.177.csv is not properly created, the output
for the last column is as below:

X1
1   0
2   0
3   0
4   0
5   0
6   0
7   0
8   0
9   0
10  0
11  0
12  0
13  0
14  1
15  0

Suppose, the last column should be properly created like this, as below:

   WHIRR.117
Adrian Cole 0
Alison Wong   0
Andrei Savu0
Bruno Dumon  0
Edward J. Yoon   0
Eugene Koontz   0
Jakob Homan  0
Kelvin Kakugawa 0
Kirk True 0
Lars George0
Soren Macbeth0
Stu Hood0
Tibor Kiss   0
Tom White 1
Unassigned0

Appreciate your thought...

[[alternative HTML version deleted]]

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


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


[R] create new column in a DF according to values from another column

2012-09-26 Thread jeff6868
Hi everyone,

I have a small problem in my R-code.

Imagine this DF for example:

DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10))

I would like to add a new column Station in this DF. This new column must
be automatically filled with: V1 or V2 or V3.
The choice must be done on the numbers (1st column).

For example, I would like to have V1 in the column Station in the rows
where the numbers of the 1st column are: 1,7,11,16 ; then I would like to
have V2 in the rows where the numbers are: 4,14,20 and finally V3 in the
rows where the numbers are: 3,17,19.

I'm trying with if and something like this, but it's not working yet:
# For V1:
if(DF$number %in% c(1,7,11,16)) {test$Station==V1}
# For V2:
... 

So my final DF should look like this:

FINALDF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10),
Station=c(V1,V2,V1,V3,V1,V1,V2,V3,V2,V3))

Could someone help me to finish this?

Thank you very much!!!





--
View this message in context: 
http://r.789695.n4.nabble.com/create-new-column-in-a-DF-according-to-values-from-another-column-tp4644217.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 for commercial use

2012-09-26 Thread kk414
cool, im none the wiser now, but thanks anyway



--
View this message in context: 
http://r.789695.n4.nabble.com/R-for-commercial-use-tp4644027p4644204.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] Running different Regressions using for loops

2012-09-26 Thread Krunal Nanavati
Hi,



I am trying to run many different regressions using a FOR Loop.



The input data that is read into R has the following variables



· Volume

· Price1

· Price2

· Price3

· Price4

· Price5

· Trend

· Seasonality



I want to run 5 regressions, with the Volume as an dependent variable and
Price, Trend  Seasonality as independent variables. I have read the above
mentioned variables in a variable called “tryout”



I am entering the following syntax in R



 for(i in 1:5)

+ {

+ result[i]=lm(Volume~Price[i]+Trend+Seasonaliy,data=tryout)

+ summary(result[i])

+ }



After running these lines…I am getting the following error message



Error in eval(expr, envir, enclos) : object 'Price' not found



Can someone help me out with this error message. Appreciate for your time
and consideration.







Thanks  Regards,



Krunal Nanavati

Solutions Manager - Cogitaas

9769-919198

[[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] lattice dotplot reorder contiguous levels

2012-09-26 Thread maxbre
sorry for my slow reply, this is what I worked out so far…

my reproducible example and the code

test-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c(A, 
B, C, D, E), class = factor), conc = c(2.32, 0.902, 
0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442, 
10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315, 
30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30, 
0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61, 
3.39, 20, 4.59), samp.time = structure(c(2L, 4L, 4L, 4L, 4L, 
4L, 5L, 4L, 8L, 8L, 8L, 8L, 8L, 9L, 8L, 7L, 8L, 8L, 8L, 8L, 3L, 
3L, 2L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 6L, 4L, 8L, 4L, 8L, 4L, 3L, 
8L, 4L, 8L, 4L, 8L, 4L, 9L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 1L), .Label = c(2, 
4, 12, 24, 96, 135, 167, 168, 169), class = factor)),
.Names = c(site, 
conc, samp.time), row.names = c(NA, 52L), class = data.frame)

test$samp.time.new - with(test, reorder(samp.time:site, as.numeric(site)))

m-match(unique(droplevels(test$samp.time.new)),test$samp.time.new)
lab-as.character(test$samp.time[m])

dotplot(samp.time.new~conc|site, data=test,
ylim=lab,
scales=list(x=list(log=10), y = list(relation = free)),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)

Now labels are correctly spaced and sorted out but still a “slight” problem
persist: i.e. the reordering of samp.time.new within each site; in fact, I
would like to have an ascending order of sampling time but for some reason
I’m not able to work it out properly…

any help much appreciated

max



--
View this message in context: 
http://r.789695.n4.nabble.com/lattice-dotplot-reorder-contiguous-levels-tp4643741p4644215.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] add a data frame to my data frame

2012-09-26 Thread Tagmarie
Thanks to all of you. 
The three advices helped me a lot - solved my problem and thank you Sarah
for the hint with rseek.org. Didn't know that one. 
Have a great day, 
Tagmarie



--
View this message in context: 
http://r.789695.n4.nabble.com/add-a-data-frame-to-my-data-frame-tp4644122p4644206.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] average environmental data if AnimalID and Time is duplicated

2012-09-26 Thread Tagmarie
Hello,
I tried for about three hours now to solve this problem but I can't figure
it out. I am sure someone knows how do it. At least I hope so. 

I have a data frame somewhat like this: 

myframe - data.frame (ID=c(Ernie, Ernie, Bert, Bert),
Timestamp=c(24.09.2012 09:00, 24.09.2012 09:00, 24.09.2012 10:00,
25.09.2012 10:00), Hunger=c(1,5,2,2), Temp=c(25,30,27,28)
)
myframe

As you can see for Ernie I do have different data for 24.09.2012 9:00. Now I
would like to average the Hunger and Temp value for this timestamp to get a
data frame without duplicated Times and the respective average Temp and
Hunger. 

I tried something like 
Meanframe-  by(myframe[, 3:4], duplicated(myframe$ID,
Zusatzdaten3$Timestamp) == TRUE, mean)
but it doesn't work and I guess that it is also totally crap ;-)

Tagmarie




--
View this message in context: 
http://r.789695.n4.nabble.com/average-environmental-data-if-AnimalID-and-Time-is-duplicated-tp4644218.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] Change in order of names after applying plyr package

2012-09-26 Thread Vincy Pyne
Dear R helpers

I have following two data.frames viz. equity_data and param.

equity_data = data.frame(security_id = c(Air, Air, Air, Air, Air, 
Air, Air, Air, Air, Air, Air, Air, AB, AB, AB, AB, AB, 
AB, AB, AB, AB, AB, AB, AB, AD,  AD, AD, AD, AD, AD, 
AD, AD, AD, AD, AD, AD), ason_date = 
c(10-Jan-12,9-Jan-12,8-Jan-12, 7-Jan-12, 
6-Jan-12,5-Jan-12,4-Jan-12,3-Jan-12,2-Jan-12,1-Jan-12, 31-Dec-11, 
30-Dec-11, 10-Jan-12,9-Jan-12,8-Jan-12, 7-Jan-12, 
6-Jan-12,5-Jan-12,4-Jan-12,3-Jan-12,2-Jan-12,1-Jan-12, 31-Dec-11, 
30-Dec-11, 10-Jan-12,9-Jan-12,8-Jan-12, 7-Jan-12, 
6-Jan-12,5-Jan-12,4-Jan-12,3-Jan-12,2-Jan-12,1-Jan-12, 31-Dec-11,
 30-Dec-11), security_rate = c(0.597,0.61,0.6,0.63,0.67,0.7,0.74,0.735, 
7.61,0.795,0.796, 0.84, 8.5,8.1,8.9,8.9,8.9,9,9,9,9,9,9,9,3.21,3.22,3.12, 3.51, 
3.5, 3.37, 3.25, 3, 3.07, 3, 2.94, 2.6))

param = data.frame(confidence_level = c(0.99), holding_period = c(10),  
calculation_method = MC, no_simulation_mc = c(100))


library(plyr)
library(reshape2)

attach(equity_data)
attach(param)

security_names = unique(equity_data$security_id)  
# (security_names are used further in R code not included here)

alpha = param$confidence_level
t = param$holding_period
n = param$no_simulation_mc
method = param$calculation_method


  mc_VaR = function(security_id, ason_date, security_rate)
    {
    security_rate_returns - NULL
    for (i
 in(1:length(ason_date)-1))
    {
  security_rate_returns[i] = log(security_rate[i]/security_rate[i+1])
    }
        
    return_mean = mean(security_rate_returns)
    return_sd = sd(security_rate_returns)
    simulation = rnorm(n, return_mean, return_sd)
    qq = sort(simulation, decreasing = TRUE)
    VaR_mc = -qq[alpha * n]*sqrt(t)
    return(VaR_mc)
    }

    
result_method_other - dlply(.data = equity_data, .variables = security_id, 
.fun = function(x)
 
  mc_VaR(ason_date = x$ason_date, security_id = 
x$security_id, 
                  security_rate = x$security_rate))

    
 result_method_other
$AB
[1] 0.2657424

$AD
[1] 0.212061

$Air
[1] 6.789733

attr(,split_type)
[1] data.frame
attr(,split_labels)
  security_id
1  AB
2  AD
3 Air


MY PROBLEM :

My original data (i.e. equity_data) has the order of Air, AB and AD. 
However, after applying plyr, my order (and corresponding result) has changed 
to AB, AD Air.


I need to
 maintain my original order of Air, AB and AD. How do I modify my R code 
for this?

Kindly guide


Vincy


[[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] create new column in a DF according to values from another column

2012-09-26 Thread Berend Hasselman

On 26-09-2012, at 12:49, jeff6868 geoffrey_kl...@etu.u-bourgogne.fr wrote:

 Hi everyone,
 
 I have a small problem in my R-code.
 
 Imagine this DF for example:
 
 DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10))
 
 I would like to add a new column Station in this DF. This new column must
 be automatically filled with: V1 or V2 or V3.
 The choice must be done on the numbers (1st column).
 
 For example, I would like to have V1 in the column Station in the rows
 where the numbers of the 1st column are: 1,7,11,16 ; then I would like to
 have V2 in the rows where the numbers are: 4,14,20 and finally V3 in the
 rows where the numbers are: 3,17,19.
 
 I'm trying with if and something like this, but it's not working yet:
 # For V1:
 if(DF$number %in% c(1,7,11,16)) {test$Station==V1}
 # For V2:
 ... 
 
 So my final DF should look like this:
 
 FINALDF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10),
 Station=c(V1,V2,V1,V3,V1,V1,V2,V3,V2,V3))
 

DF[DF$number %in% c(1,7,11,16),Station] - V1
DF[DF$number %in% c(4,14,20),Station] - V2
DF[DF$number %in% c(3,17,19),Station] - V3
DF

The Station column is of type character.
To make FINALDF identical you should add stringsAsFactors=FALSE to the 
arguments of data.frame.

Berend

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


Re: [R] lattice dotplot reorder contiguous levels

2012-09-26 Thread Deepayan Sarkar
On Wed, Sep 26, 2012 at 3:36 PM, maxbre mbres...@arpa.veneto.it wrote:
 sorry for my slow reply, this is what I worked out so far…

 my reproducible example and the code

 test-structure(list(site = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L,
 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L), .Label = c(A,
 B, C, D, E), class = factor), conc = c(2.32, 0.902,
 0.468, 5.51, 1.49, 0.532, 0.72, 0.956, 0.887, 20, 30, 2.12, 0.442,
 10, 50, 110, 3.36, 2.41, 20, 70, 3610, 100, 4.79, 20, 0.0315,
 30, 60, 1, 3.37, 80, 1.21, 0.302, 0.728, 1.29, 30, 40, 90, 30,
 0.697, 6.25, 0.576, 0.335, 20, 10, 620, 40, 9.98, 4.76, 2.61,
 3.39, 20, 4.59), samp.time = structure(c(2L, 4L, 4L, 4L, 4L,
 4L, 5L, 4L, 8L, 8L, 8L, 8L, 8L, 9L, 8L, 7L, 8L, 8L, 8L, 8L, 3L,
 3L, 2L, 4L, 4L, 4L, 4L, 4L, 1L, 4L, 6L, 4L, 8L, 4L, 8L, 4L, 3L,
 8L, 4L, 8L, 4L, 8L, 4L, 9L, 3L, 8L, 8L, 8L, 8L, 8L, 8L, 1L), .Label = c(2,
 4, 12, 24, 96, 135, 167, 168, 169), class = factor)),
 .Names = c(site,
 conc, samp.time), row.names = c(NA, 52L), class = data.frame)

 test$samp.time.new - with(test, reorder(samp.time:site, as.numeric(site)))

 m-match(unique(droplevels(test$samp.time.new)),test$samp.time.new)
 lab-as.character(test$samp.time[m])

 dotplot(samp.time.new~conc|site, data=test,
 ylim=lab,
 scales=list(x=list(log=10), y = list(relation = free)),
 layout=c(1,5), strip=FALSE, strip.left=TRUE
 )

 Now labels are correctly spaced and sorted out but still a “slight” problem
 persist: i.e. the reordering of samp.time.new within each site; in fact, I
 would like to have an ascending order of sampling time but for some reason
 I’m not able to work it out properly…

For that, it should be enough to just reorder again by samp.time. Your
label code doesn't work then (I haven't tried to figure out why), but
your earlier idea using strsplit() does:


test$samp.time.new -
with(test, reorder(reorder(samp.time:site, as.numeric(site)),
as.numeric(samp.time)))

lab - sapply(strsplit(levels(test$samp.time.new), :, fixed=TRUE), [, 1)

dotplot(samp.time.new~conc|site, data=test,
ylim=lab,
scales=list(x=list(log=10), y = list(relation = free)),
layout=c(1,5), strip=FALSE, strip.left=TRUE
)

-Deepayan

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


Re: [R] average environmental data if AnimalID and Time is duplicated

2012-09-26 Thread Jim Lemon

On 09/26/2012 08:53 PM, Tagmarie wrote:

Hello,
I tried for about three hours now to solve this problem but I can't figure
it out. I am sure someone knows how do it. At least I hope so.

I have a data frame somewhat like this:

myframe- data.frame (ID=c(Ernie, Ernie, Bert, Bert),
Timestamp=c(24.09.2012 09:00, 24.09.2012 09:00, 24.09.2012 10:00,
25.09.2012 10:00), Hunger=c(1,5,2,2), Temp=c(25,30,27,28)
)
myframe

As you can see for Ernie I do have different data for 24.09.2012 9:00. Now I
would like to average the Hunger and Temp value for this timestamp to get a
data frame without duplicated Times and the respective average Temp and
Hunger.

I tried something like
Meanframe-  by(myframe[, 3:4], duplicated(myframe$ID,
Zusatzdaten3$Timestamp) == TRUE, mean)
but it doesn't work and I guess that it is also totally crap ;-)


Hi Tagmarie,
Your problem is that both Hunger and Temp are read in as factors. If you 
try it like this:


by(as.numeric(as.character(myframe[,3])),myframe[,ID],mean)
by(as.numeric(as.character(myframe[,4])),myframe[,ID],mean)

You might get what you want. The as.character call is necessary, 
otherwise you will get the wrong mean values.


Jim

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


Re: [R] Running different Regressions using for loops

2012-09-26 Thread Rui Barradas
Hello,

Try the following.


#cnames - names(tryout)  # in your code, use this one
cnames - c(Volume, Price1, Price2, Price3, Price4, Price5, 
Trend, Seasonaliy)

price - cnames[grep(Price, cnames)]
resp - cnames[1]
regr - cnames[7:8]

#lm.list - vector(list, 5)
for(i in 1:5){
 regress - paste(price[i], paste(regr, collapse = +), sep = +)
 fmla - paste(resp, regress, sep = ~)
 print(fmla)
 #lm.list[[i]] - lm(as.formula(fmla), data = tryout)
}

Hope this helps,

Rui Barradas
Em 26-09-2012 08:08, Krunal Nanavati escreveu:
 Hi,



 I am trying to run many different regressions using a FOR Loop.



 The input data that is read into R has the following variables



 · Volume

 · Price1

 · Price2

 · Price3

 · Price4

 · Price5

 · Trend

 · Seasonality



 I want to run 5 regressions, with the Volume as an dependent variable and
 Price, Trend  Seasonality as independent variables. I have read the above
 mentioned variables in a variable called tryout



 I am entering the following syntax in R



 for(i in 1:5)
 + {

 + result[i]=lm(Volume~Price[i]+Trend+Seasonaliy,data=tryout)

 + summary(result[i])

 + }



 After running these lines...I am getting the following error message



 Error in eval(expr, envir, enclos) : object 'Price' not found



 Can someone help me out with this error message. Appreciate for your time
 and consideration.







 Thanks  Regards,



 Krunal Nanavati

 Solutions Manager - Cogitaas

 9769-919198

   [[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] Creating x*y different contigency tables

2012-09-26 Thread Berend Hasselman

On 26-09-2012, at 09:59, Loukia Spineli spinelilouki...@gmail.com wrote:

 Dear all,
 
 I am trying to construct  25x31 different matrices of 2x2 dimension. Here
 is the problem:
 
 we have the following matrix
   matrix(c(54+s0,
 43+s1, 56-s0, 67-s1), nrow=2, ncol=2, byrow=T)
 
 the values for s0 and s1 are c(0:24) and c(0:31), respectively.
 
 I wrote the following code without the desired results
 
x-0:24
y-0:30
 
  results-array(matrix(0,nrow=2,ncol=2,byrow=T),dim=c(2,2,25*31))
   for(i in 1:25){
for(j in 1:31){
 for(k in
 1:25*31){
 
 results[,,k]-array(matrix(c(54+x[i], 43+y[j], 56-x[i],
 67-y[j]),nrow=2,ncol=2,byrow=T),dim=c(2,2,25*31))
 }
 }
 }
 results
 
 I am trying to figure out what I am missing.

You don't need the third loop for( k in …
With for loops you can do this

x-0:3
y-0:5

mat.start -  matrix(c(54, 43, 56, 67), nrow=2, ncol=2, byrow=T)
mat.start

Nx - length(x)
Ny - length(y)

results-array(matrix(0,nrow=2,ncol=2,byrow=T),dim=c(2,2,Nx*Ny))
k - 1
for(i in 1:Nx){
for(j in 1:Ny){
results[,,k] - mat.start + matrix(c(x[i], y[j], 
-x[i],-y[j]),nrow=2,ncol=2,byrow=T)
k - k+1
}
}
results

Berend

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


Re: [R] average environmental data if AnimalID and Time is duplicated

2012-09-26 Thread Rui Barradas

Hello,

Why do you have Hunger and Temp recorded as characters? Between double 
quotes?



myframe - data.frame (ID=c(Ernie, Ernie, Bert, Bert),
Timestamp=c(24.09.2012 09:00, 24.09.2012 09:00, 24.09.2012 10:00,
25.09.2012 10:00), Hunger=c(1,5,2,2), Temp=c(25,30,27,28)
)
str(myframe)

myframe$Hunger - as.numeric(levels(myframe$Hunger)[myframe$Hunger])
myframe$Temp - as.numeric(levels(myframe$Temp)[myframe$Temp])

aggregate(cbind(Hunger, Temp) ~ ID, data = myframe, FUN = mean)

Hope this helps,

Rui Barradas

Em 26-09-2012 11:53, Tagmarie escreveu:

Hello,
I tried for about three hours now to solve this problem but I can't figure
it out. I am sure someone knows how do it. At least I hope so.

I have a data frame somewhat like this:

myframe - data.frame (ID=c(Ernie, Ernie, Bert, Bert),
Timestamp=c(24.09.2012 09:00, 24.09.2012 09:00, 24.09.2012 10:00,
25.09.2012 10:00), Hunger=c(1,5,2,2), Temp=c(25,30,27,28)
)
myframe

As you can see for Ernie I do have different data for 24.09.2012 9:00. Now I
would like to average the Hunger and Temp value for this timestamp to get a
data frame without duplicated Times and the respective average Temp and
Hunger.

I tried something like
Meanframe-  by(myframe[, 3:4], duplicated(myframe$ID,
Zusatzdaten3$Timestamp) == TRUE, mean)
but it doesn't work and I guess that it is also totally crap ;-)

Tagmarie




--
View this message in context: 
http://r.789695.n4.nabble.com/average-environmental-data-if-AnimalID-and-Time-is-duplicated-tp4644218.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] create new column in a DF according to values from another column

2012-09-26 Thread jim holtman
Here is another technique to use, especially if you have a long list
of replacement values:


 DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10))

 # create a list of replacement values; if you have a lot and
 # you can create them automagically, then it is easier
 replace - list(list(c(1, 7, 11, 16), V1)
+   , list(c(4, 14, 20), V2)
+   , list(c(3, 17, 19), V3)
+   )
 for (i in replace){
+ DF$Station[DF$number %in% i[[1L]]] - i[[2L]]
+ }
 DF
   number data Station
1   11  V1
2   42  V2
3   73  V1
4   34  V3
5  115  V1
6  166  V1
7  147  V2
8  178  V3
9  209  V2
10 19   10  V3


On Wed, Sep 26, 2012 at 6:49 AM, jeff6868
geoffrey_kl...@etu.u-bourgogne.fr wrote:
 Hi everyone,

 I have a small problem in my R-code.

 Imagine this DF for example:

 DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10))

 I would like to add a new column Station in this DF. This new column must
 be automatically filled with: V1 or V2 or V3.
 The choice must be done on the numbers (1st column).

 For example, I would like to have V1 in the column Station in the rows
 where the numbers of the 1st column are: 1,7,11,16 ; then I would like to
 have V2 in the rows where the numbers are: 4,14,20 and finally V3 in the
 rows where the numbers are: 3,17,19.

 I'm trying with if and something like this, but it's not working yet:
 # For V1:
 if(DF$number %in% c(1,7,11,16)) {test$Station==V1}
 # For V2:
 ...

 So my final DF should look like this:

 FINALDF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10),
 Station=c(V1,V2,V1,V3,V1,V1,V2,V3,V2,V3))

 Could someone help me to finish this?

 Thank you very much!!!





 --
 View this message in context: 
 http://r.789695.n4.nabble.com/create-new-column-in-a-DF-according-to-values-from-another-column-tp4644217.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] Change in order of names after applying plyr package

2012-09-26 Thread jim holtman
Here is one of the places that you need a 'factor' to create the
ordering you want; notice the statement that I added:

 equity_data = data.frame(security_id = c(Air, Air, Air, Air
+ , Air, Air, Air, Air, Air, Air, Air, Air, AB
+ , AB, AB, AB, AB, AB, AB, AB, AB, AB, AB
+ , AB, AD,  AD, AD, AD, AD, AD, AD, AD, AD
+ , AD, AD, AD)
+ , ason_date = c(10-Jan-12,9-Jan-12,8-Jan-12, 7-Jan-12
+ , 6-Jan-12,5-Jan-12,4-Jan-12,3-Jan-12,2-Jan-12
+ ,1-Jan-12, 31-Dec-11, 30-Dec-11, 10-Jan-12,9-Jan-12
+ ,8-Jan-12, 7-Jan-12, 6-Jan-12,5-Jan-12,4-Jan-12
+ ,3-Jan-12,2-Jan-12,1-Jan-12, 31-Dec-11, 30-Dec-11
+ , 10-Jan-12,9-Jan-12,8-Jan-12, 7-Jan-12, 6-Jan-12
+ ,5-Jan-12,4-Jan-12,3-Jan-12,2-Jan-12,1-Jan-12
+ , 31-Dec-11, 30-Dec-11)
+ , security_rate = c(0.597,0.61,0.6,0.63,0.67,0.7,0.74,0.735
+ , 7.61,0.795,0.796, 0.84, 8.5,8.1,8.9,8.9,8.9,9,9,9,9,9,9,9
+ ,3.21,3.22,3.12, 3.51, 3.5, 3.37, 3.25, 3, 3.07, 3, 2.94, 2.6)
+ )

 # create a factor with the specified ordering
 equity_data$security_id - factor(equity_data$security_id
+ , levels = c(Air, AB, AD)
+ )


Here are the results:

 result_method_other
$Air
[1] 6.229422

$AB
[1] 0.2355425

$AD
[1] 0.2918782

attr(,split_type)
[1] data.frame
attr(,split_labels)
  security_id
1 Air
2  AB
3  AD


On Wed, Sep 26, 2012 at 4:55 AM, Vincy Pyne vincy_p...@yahoo.ca wrote:
 Dear R helpers

 I have following two data.frames viz. equity_data and param.

 equity_data = data.frame(security_id = c(Air, Air, Air, Air, Air, 
 Air, Air, Air, Air, Air, Air, Air, AB, AB, AB, AB, 
 AB, AB, AB, AB, AB, AB, AB, AB, AD,  AD, AD, AD, 
 AD, AD, AD, AD, AD, AD, AD, AD), ason_date = 
 c(10-Jan-12,9-Jan-12,8-Jan-12, 7-Jan-12, 
 6-Jan-12,5-Jan-12,4-Jan-12,3-Jan-12,2-Jan-12,1-Jan-12, 
 31-Dec-11, 30-Dec-11, 10-Jan-12,9-Jan-12,8-Jan-12, 7-Jan-12, 
 6-Jan-12,5-Jan-12,4-Jan-12,3-Jan-12,2-Jan-12,1-Jan-12, 
 31-Dec-11, 30-Dec-11, 10-Jan-12,9-Jan-12,8-Jan-12, 7-Jan-12, 
 6-Jan-12,5-Jan-12,4-Jan-12,3-Jan-12,2-Jan-12,1-Jan-12, 
 31-Dec-11,
  30-Dec-11), security_rate = c(0.597,0.61,0.6,0.63,0.67,0.7,0.74,0.735, 
 7.61,0.795,0.796, 0.84, 8.5,8.1,8.9,8.9,8.9,9,9,9,9,9,9,9,3.21,3.22,3.12, 
 3.51, 3.5, 3.37, 3.25, 3, 3.07, 3, 2.94, 2.6))

 param = data.frame(confidence_level = c(0.99), holding_period = c(10),  
 calculation_method = MC, no_simulation_mc = c(100))


 library(plyr)
 library(reshape2)

 attach(equity_data)
 attach(param)

 security_names = unique(equity_data$security_id)
 # (security_names are used further in R code not included here)

 alpha = param$confidence_level
 t = param$holding_period
 n = param$no_simulation_mc
 method = param$calculation_method


   mc_VaR = function(security_id, ason_date, security_rate)
 {
 security_rate_returns - NULL
 for (i
  in(1:length(ason_date)-1))
 {
   security_rate_returns[i] = log(security_rate[i]/security_rate[i+1])
 }

 return_mean = mean(security_rate_returns)
 return_sd = sd(security_rate_returns)
 simulation = rnorm(n, return_mean, return_sd)
 qq = sort(simulation, decreasing = TRUE)
 VaR_mc = -qq[alpha * n]*sqrt(t)
 return(VaR_mc)
 }


 result_method_other - dlply(.data = equity_data, .variables = security_id, 
 .fun = function(x)

   mc_VaR(ason_date = x$ason_date, security_id = 
 x$security_id,
   security_rate = x$security_rate))


 result_method_other
 $AB
 [1] 0.2657424

 $AD
 [1] 0.212061

 $Air
 [1] 6.789733

 attr(,split_type)
 [1] data.frame
 attr(,split_labels)
   security_id
 1  AB
 2  AD
 3 Air


 MY PROBLEM :

 My original data (i.e. equity_data) has the order of Air, AB and AD. 
 However, after applying plyr, my order (and corresponding result) has changed 
 to AB, AD Air.


 I need to
  maintain my original order of Air, AB and AD. How do I modify my R 
 code for this?

 Kindly guide


 Vincy


 [[alternative HTML version deleted]]


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




-- 
Jim Holtman
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] Extrapolating Cox predicted risk

2012-09-26 Thread Terry Therneau



On 09/26/2012 05:00 AM, r-help-requ...@r-project.org wrote:

I generated predicted risk of death for each subject in the study by
means of Cox proportional hazards model at 8 year of follow-up, a time
point at which follow-up was more than 90% complete. It is possible to
extrapolate to 10-year the predicted risk of each subjet  by assuming
an exponential distribution?
Any help would be greatly appreciated.
Thanks for your consideration.



The ability to extrapolate over long distances is exactly why industrial reliability work 
uses parametric models (weibull or log-normal, see survreg) instead of the Cox model.


If any of your data goes out to 10 years, then the predictions for coxph will go out that 
far, just like they would for a Kaplan-Meier.  But, just like the KM, if there are only a 
handful of people out that far the extrapolated curve will be very noisy.


Terry Therneau

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


[R] RV: problems for making grids from lmer models

2012-09-26 Thread MARIA OLGA VIEDMA SILLERO
Dear colleagues:
 
I am working with binary mixed models using lme4 package and everything works 
fine until I try to spatialize the fitted models using grids predictors. I have 
used the predict function from RASTER package and the RSAGA functionalities, 
but always I have the same error: Error in object$xlevels : $ operator not 
defined for this S4 class.
 
I think the problem comes from the slot (@) used in lme4 for values derived 
from fitted models. In other mixed models (gausssian) from nlme package, the 
slots are $ and the predict function works fine. How do you think can I solve 
this problem?' Is there any other function or package to make grid maps from 
fitted glmer models?
 
These are the command lines and error message:
 
fitted_glmer_geo-predict(grid_stack, fitted_glmer, type=response)
Error in object$xlevels : $ operator not defined for this S4 class

Thanks in advance, and my best regards,
 
Olga
 
Olga Viedma Sillero
Profesora Ordenacion del Territorio
Departamento Ciencias Ambientales
Facultad Ciencias del Medio Ambiente
Avd/ Carlos III, s/n 45071 Toledo (Spain)
email: olga.vie...@uclm.es
Tel: 925-268800 (ext. 5469)
Tel movil: 675 880 297
Fax: 925 268844



De: MARIA OLGA VIEDMA SILLERO
Enviado el: mié 26/09/2012 13:09
Para: ba...@stat.wisc.edu; bbol...@gmail.com; maech...@r-project.org
Asunto: problems making grids from lmer models




[[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] create new column in a DF according to values from another column

2012-09-26 Thread jeff6868
Yes this is it!

Thank you for your help Berend!



--
View this message in context: 
http://r.789695.n4.nabble.com/create-new-column-in-a-DF-according-to-values-from-another-column-tp4644217p4644225.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] Jointly distributed random variables in R

2012-09-26 Thread Kizito Omala
Dear all,

is there a specific package and reference book for plotting Jointly
distributed random variables?

Kindly help.

Kizito.

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

2012-09-26 Thread Kizito Omala
Dear all,

I have just downloaded a package 'prob' and also loaded it using
library(prob). Whereas function 'tosscoin' works very well the other
functions like 'gbinom' for graphing density functions does not work.
I get the message:


 gbinom(20,0.3)
Error: could not find function gbinom

How do I go about it?

Thanks.

Kizito.

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


Re: [R] create new column in a DF according to values from another column

2012-09-26 Thread Rui Barradas

Hello,

'if' is not vectorized, it only uses the first value of the multiple 
condition. 'ifelse' is vectorized and in your case use nested ifelses.



DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10))
v1 - c(1,7,11,16)
v2 - c(4,14,20)
v3 - c(3,17,19)

DF$Station - ifelse(DF$number %in% v1, V1,
ifelse(DF$number %in% v2, V2, V3))


Hope this helps,

Rui Barradas

Em 26-09-2012 11:49, jeff6868 escreveu:

Hi everyone,

I have a small problem in my R-code.

Imagine this DF for example:

DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10))

I would like to add a new column Station in this DF. This new column must
be automatically filled with: V1 or V2 or V3.
The choice must be done on the numbers (1st column).

For example, I would like to have V1 in the column Station in the rows
where the numbers of the 1st column are: 1,7,11,16 ; then I would like to
have V2 in the rows where the numbers are: 4,14,20 and finally V3 in the
rows where the numbers are: 3,17,19.

I'm trying with if and something like this, but it's not working yet:
# For V1:
if(DF$number %in% c(1,7,11,16)) {test$Station==V1}
# For V2:
...

So my final DF should look like this:

FINALDF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10),
Station=c(V1,V2,V1,V3,V1,V1,V2,V3,V2,V3))

Could someone help me to finish this?

Thank you very much!!!





--
View this message in context: 
http://r.789695.n4.nabble.com/create-new-column-in-a-DF-according-to-values-from-another-column-tp4644217.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] average environmental data if AnimalID and Time is duplicated

2012-09-26 Thread arun


HI,

Just to add to Jim's solution with data.table()
myframe- data.frame (ID=c(Ernie, Ernie, Bert, Bert),
 Timestamp=c(24.09.2012 09:00, 24.09.2012 09:00, 24.09.2012 10:00,
 25.09.2012 10:00), Hunger=c(1,5,2,2), Temp=c(25,30,27,28)
 )
library(data.table)
myframe1-data.table(myframe)
 myframe2-within(myframe1,{Hunger-as.numeric(as.character(Hunger)); 
Temp-as.numeric(as.character(Temp))})
 myframe2[,list(meanHunger=mean(Hunger),meanTemp=mean(Temp)),list(ID,Timestamp)]
 #     ID    Timestamp meanHunger meanTemp
#1: Ernie 24.09.2012 09:00  3 27.5
#2:  Bert 24.09.2012 10:00  2 27.0
#3:  Bert 25.09.2012 10:00  2 28.0
A.K.


- Original Message -
From: Jim Lemon j...@bitwrit.com.au
To: Tagmarie ramga...@gmx.net
Cc: r-help@r-project.org
Sent: Wednesday, September 26, 2012 7:29 AM
Subject: Re: [R] average environmental data if AnimalID and Time is duplicated

On 09/26/2012 08:53 PM, Tagmarie wrote:
 Hello,
 I tried for about three hours now to solve this problem but I can't figure
 it out. I am sure someone knows how do it. At least I hope so.

 I have a data frame somewhat like this:

 myframe- data.frame (ID=c(Ernie, Ernie, Bert, Bert),
 Timestamp=c(24.09.2012 09:00, 24.09.2012 09:00, 24.09.2012 10:00,
 25.09.2012 10:00), Hunger=c(1,5,2,2), Temp=c(25,30,27,28)
 )
 myframe

 As you can see for Ernie I do have different data for 24.09.2012 9:00. Now I
 would like to average the Hunger and Temp value for this timestamp to get a
 data frame without duplicated Times and the respective average Temp and
 Hunger.

 I tried something like
 Meanframe-  by(myframe[, 3:4], duplicated(myframe$ID,
 Zusatzdaten3$Timestamp) == TRUE, mean)
 but it doesn't work and I guess that it is also totally crap ;-)

Hi Tagmarie,
Your problem is that both Hunger and Temp are read in as factors. If you 
try it like this:

by(as.numeric(as.character(myframe[,3])),myframe[,ID],mean)
by(as.numeric(as.character(myframe[,4])),myframe[,ID],mean)

You might get what you want. The as.character call is necessary, 
otherwise you will get the wrong mean values.

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] RCURL ftp upload - ASCII or Binary type?

2012-09-26 Thread Magnus Eriksson
I'm trying to upload a file using RCURL:s ftpUpload() to a ftp-server using the 
following command:

 ftpUpload('VERY.ODD.FILE.NAME(+1)',to=ftp://x.x.x.x/,;' 
 VERY.ODD.FILE.NAME(+1)',userpwd=USER:PASSWORD)
OK 
 0

The file I'm trying to upload is a very simple text-file but with a bit weird 
filename. Note the ' on each side of the filename.

So the upload itself is successful but the receiver of the file tells me that 
the file I uploaded was of Binary type and that his system only accepts 
ASCII. So the receiver can see the file but it contains only weird characters.

Surfing the web I found this:
http://www.webweaver.nu/html-tips/ascii-binary.shtml

and indeed, when I try filezilla (http://filezilla-project.org/) to do the same 
upload, there is a setting in filezilla: Default transfer type that can be 
set to ASCII or Binary. The transfer works fine when using ASCII and has 
same error as in R when using Binary.

My conclusion is that, for some reason, R uses Binary as Transfer type 
here, but it should be using ASCII.

I have been looking at curlSetOpt() but .encoding is not the problem here.


Is there a way to change R:s Transfer Type from Binary to ASCII in this 
case? How?


System: windows 7
R version: 2.15.0

Thanks for your help

Best regards
Magnus Eriksson

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


Re: [R] create new column in a DF according to values from another column

2012-09-26 Thread arun
HI,
Try this:
 DF$Station[DF$number%in%c(1,7,11,16)]-V1
 DF$Station[DF$number%in%c(4,14,20)]-V2
 DF$Station[DF$number%in%c(3,17,19)]-V3
 DF
#   number data Station
#1   1    1  V1
#2   4    2  V2
#3   7    3  V1
#4   3    4  V3
#5  11    5  V1
#6  16    6  V1
#7  14    7  V2
#8  17    8  V3
#9  20    9  V2
#10 19   10  V3

#or if you have more replacement values, then:
library(car)
DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10))
DF1-DF1
DF1$Station-recode(DF1$number,c(1,7,11,16)='V1';c(4,14,20)='V2';c(3,17,19)='V3')
 DF1
#   number data Station
#1   1    1  V1
#2   4    2  V2
#3   7    3  V1
#4   3    4  V3
#5  11    5  V1
#6  16    6  V1
#7  14    7  V2
#8  17    8  V3
#9  20    9  V2
#10 19   10  V3


A.K.





- Original Message -
From: jeff6868 geoffrey_kl...@etu.u-bourgogne.fr
To: r-help@r-project.org
Cc: 
Sent: Wednesday, September 26, 2012 6:49 AM
Subject: [R] create new column in a DF according to values from another column

Hi everyone,

I have a small problem in my R-code.

Imagine this DF for example:

DF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10))

I would like to add a new column Station in this DF. This new column must
be automatically filled with: V1 or V2 or V3.
The choice must be done on the numbers (1st column).

For example, I would like to have V1 in the column Station in the rows
where the numbers of the 1st column are: 1,7,11,16 ; then I would like to
have V2 in the rows where the numbers are: 4,14,20 and finally V3 in the
rows where the numbers are: 3,17,19.

I'm trying with if and something like this, but it's not working yet:
# For V1:
if(DF$number %in% c(1,7,11,16)) {test$Station==V1}
# For V2:
... 

So my final DF should look like this:

FINALDF - data.frame(number=c(1,4,7,3,11,16,14,17,20,19),data=c(1:10),
Station=c(V1,V2,V1,V3,V1,V1,V2,V3,V2,V3))

Could someone help me to finish this?

Thank you very much!!!





--
View this message in context: 
http://r.789695.n4.nabble.com/create-new-column-in-a-DF-according-to-values-from-another-column-tp4644217.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] average environmental data if AnimalID and Time is duplicated

2012-09-26 Thread Tagmarie
Thank you!

Am 26.09.2012 13:31, schrieb Jim Lemon [via R]:
 On 09/26/2012 08:53 PM, Tagmarie wrote:

  Hello,
  I tried for about three hours now to solve this problem but I can't 
 figure
  it out. I am sure someone knows how do it. At least I hope so.
 
  I have a data frame somewhat like this:
 
  myframe- data.frame (ID=c(Ernie, Ernie, Bert, Bert),
  Timestamp=c(24.09.2012 09:00, 24.09.2012 09:00, 24.09.2012 10:00,
  25.09.2012 10:00), Hunger=c(1,5,2,2), 
 Temp=c(25,30,27,28)
  )
  myframe
 
  As you can see for Ernie I do have different data for 24.09.2012 
 9:00. Now I
  would like to average the Hunger and Temp value for this timestamp 
 to get a
  data frame without duplicated Times and the respective average Temp and
  Hunger.
 
  I tried something like
  Meanframe-  by(myframe[, 3:4], duplicated(myframe$ID,
  Zusatzdaten3$Timestamp) == TRUE, mean)
  but it doesn't work and I guess that it is also totally crap ;-)
 
 Hi Tagmarie,
 Your problem is that both Hunger and Temp are read in as factors. If you
 try it like this:

 by(as.numeric(as.character(myframe[,3])),myframe[,ID],mean)
 by(as.numeric(as.character(myframe[,4])),myframe[,ID],mean)

 You might get what you want. The as.character call is necessary,
 otherwise you will get the wrong mean values.

 Jim

 __
 [hidden email] /user/SendEmail.jtp?type=nodenode=4644224i=0 
 mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


 
 If you reply to this email, your message will be added to the 
 discussion below:
 http://r.789695.n4.nabble.com/average-environmental-data-if-AnimalID-and-Time-is-duplicated-tp4644218p4644224.html
  

 To unsubscribe from average environmental data if AnimalID and Time is 
 duplicated, click here 
 http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=4644218code=UmFtZ2FkODJAZ214Lm5ldHw0NjQ0MjE4fDIwNzkwMzU2MDU=.
 NAML 
 http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewerid=instant_html%21nabble%3Aemail.namlbase=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespacebreadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
  






--
View this message in context: 
http://r.789695.n4.nabble.com/average-environmental-data-if-AnimalID-and-Time-is-duplicated-tp4644218p4644231.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] gbinom function

2012-09-26 Thread Berend Hasselman

On 26-09-2012, at 13:24, Kizito Omala kizrom...@gmail.com wrote:

 Dear all,
 
 I have just downloaded a package 'prob' and also loaded it using
 library(prob). Whereas function 'tosscoin' works very well the other
 functions like 'gbinom' for graphing density functions does not work.
 I get the message:
 
 
 gbinom(20,0.3)
 Error: could not find function gbinom
 

This error message is similar to what you got yesterday.
Function gbinom is simply not in package prob.
Did you look in the index of that package or in the table of contents?

 How do I go about it?

You could put some effort in searching. Try googling on gbinom.
You will see some hits.
There is apparently something available.

Berend

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


Re: [R] calculation of diversity confidence interval

2012-09-26 Thread Jean V Adams
Mike,

You could use bootstrapping.  See for example the function boot() in 
pacakge boot.

library(boot)
?boot

Jean



Michael Eisenring michael.eisenr...@gmx.ch wrote on 09/25/2012 04:54:29 
AM:
 
 Dear R-help members.
 Maybe this is not the right platform to ask this, but I'm looking 
 desperately for a test which is calculating confidence intervals 
 from diversity measurements (non-normaly distributed) (fishers alpha
 diversity). I was checking the package vegan but there seems to be
 nothing useful. Does anyone of you know with what package I easily 
 could calculate such a confindence interval?
 
 Best,
 Mike

[[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] Interaction scatterplots in ggplot with multiple regression lines

2012-09-26 Thread Isaac Petersen
I'm trying to treat a continuous variable as discrete for plotting
multiple regression lines in a scatterplot as a function of the level
on the moderating variable.  In the example below, there is only one
regression line plotted to the whole data.  I would like a separate
regression line for each discrete level of the moderator.  The
moderator is continuous, so I'd like to treat it as discrete for
plotting the regression lines.

Here's an example (I would like 7 regression lines corresponding to
the discrete levels of the moderator, as displayed in the legend,
instead of just 1 regression line):

###
library(ggplot2)
set.seed(1234)
predictor - rnorm(1000, 3)
outcome - rnorm(1000, 10)
moderator - rnorm(1000)
mydata - data.frame(predictor, outcome, moderator)

ggplot(mydata, aes(x=predictor, y=outcome, color=moderator)) +
geom_point() + scale_colour_gradient2(low=blue, high=red) +
stat_smooth(method=lm, se=TRUE, fullrange=T)
###

Also, how can I set how many discrete levels to plot (e.g., 3 instead of 7)?

Thanks in advance!

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


Re: [R] gbinom function

2012-09-26 Thread Berend Hasselman

I have forwarded your message to the R-help list.

You should also send your replies to the R-help list and not just to the 
person(s) who replied.

Berend

On 26-09-2012, at 15:44, Kizito Omala kizrom...@gmail.com wrote:

 Hello Berend,
 
 I got the code from google, pasted in the script editor run it and all is 
 well.
 
 Thanks for the guidance.
 
 
 
 On 26 September 2012 16:17, Berend Hasselman b...@xs4all.nl wrote:
 
 On 26-09-2012, at 13:24, Kizito Omala kizrom...@gmail.com wrote:
 
 Dear all,
 
 I have just downloaded a package 'prob' and also loaded it using
 library(prob). Whereas function 'tosscoin' works very well the other
 functions like 'gbinom' for graphing density functions does not work.
 I get the message:
 
 
 gbinom(20,0.3)
 Error: could not find function gbinom
 
 
 This error message is similar to what you got yesterday.
 Function gbinom is simply not in package prob.
 Did you look in the index of that package or in the table of contents?
 
 How do I go about it?
 
 You could put some effort in searching. Try googling on gbinom.
 You will see some hits.
 There is apparently something available.
 
 Berend
 

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


Re: [R] RCURL ftp upload - ASCII or Binary type?

2012-09-26 Thread Ben Tupper
Hi,

On Sep 26, 2012, at 8:07 AM, Magnus Eriksson wrote:

 I'm trying to upload a file using RCURL:s ftpUpload() to a ftp-server using 
 the following command:
 
 ftpUpload('VERY.ODD.FILE.NAME(+1)',to=ftp://x.x.x.x/,;' 
 VERY.ODD.FILE.NAME(+1)',userpwd=USER:PASSWORD)
 OK 
 0
 
 The file I'm trying to upload is a very simple text-file but with a bit weird 
 filename. Note the ' on each side of the filename.
 
 So the upload itself is successful but the receiver of the file tells me that 
 the file I uploaded was of Binary type and that his system only accepts 
 ASCII. So the receiver can see the file but it contains only weird 
 characters.
 
 Surfing the web I found this:
 http://www.webweaver.nu/html-tips/ascii-binary.shtml
 
 and indeed, when I try filezilla (http://filezilla-project.org/) to do the 
 same upload, there is a setting in filezilla: Default transfer type that 
 can be set to ASCII or Binary. The transfer works fine when using ASCII 
 and has same error as in R when using Binary.
 
 My conclusion is that, for some reason, R uses Binary as Transfer type 
 here, but it should be using ASCII.
 
 I have been looking at curlSetOpt() but .encoding is not the problem here.
 
 
 Is there a way to change R:s Transfer Type from Binary to ASCII in this 
 case? How?
 

What happens if you explicitly set the asText argument to ftpUpload() to TRUE?  
asText is defined by default based upon the 'what' argument.

 what = 'VERY.ODD.FILE.NAME(+1)'
 asText = inherits(what, AsIs) || is.raw(what)
 asText
[1] FALSE

So, maybe you need to set it to TRUE explicitly.  It's worth a try!

Cheers,
Ben




 
 System: windows 7
 R version: 2.15.0
 
 Thanks for your help
 
 Best regards
 Magnus Eriksson
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

Ben Tupper
Bigelow Laboratory for Ocean Sciences
180 McKown Point Rd. P.O. Box 475
West Boothbay Harbor, Maine   04575-0475 
http://www.bigelow.org

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


[R] Retrieve regression summary results after rq

2012-09-26 Thread Camila Mendes
Hi all,

I am using quantile regression with svy design. I want to retrieve
summary regression statistics (std error, p-value), since I don't have
any in my output:

Commands:

clus1_d- svydesign(id=~cd002_co, weights=~wtper, strata=~str, data=data)
bclus1-as.svrepdesign(clus1_d,type=bootstrap,replicates=100)
fit1- 
withReplicates(bclus1,quote(coef(rq(newm428b~sch_new_2+sch_new_3+sch_new_4,
tau=c(0.05,0.25,0.5,0.75,0.95),weights=wtper

Output:

coefficients(fit1)
tau= 0.05 tau= 0.25 tau= 0.50 tau= 0.75 tau= 0.95
(Intercept)  2340  2980  3.30e+03  3750 4360.
sch_new_2185   -30 -5.50e+01  -250 -360.
sch_new_315520  5.032317e-16  -200 -245.
sch_new_4 6520 -1.50e+01  -200 -309.9998

Any help will be appreciated.

Best,

C.

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


Re: [R] Interaction scatterplots in ggplot with multiple regression lines

2012-09-26 Thread John Kane
Some like this help?

mydata$modnew  -  cut(mydata$moderator, 7)
ggplot(mydata, aes(x=predictor, y=outcome, color=modnew)) +
geom_point() + stat_smooth(method=lm, se=TRUE, fullrange=T)


John Kane
Kingston ON Canada


 -Original Message-
 From: dadr...@gmail.com
 Sent: Wed, 26 Sep 2012 09:45:07 -0400
 To: r-help@r-project.org
 Subject: [R] Interaction scatterplots in ggplot with multiple regression
 lines
 
 I'm trying to treat a continuous variable as discrete for plotting
 multiple regression lines in a scatterplot as a function of the level
 on the moderating variable.  In the example below, there is only one
 regression line plotted to the whole data.  I would like a separate
 regression line for each discrete level of the moderator.  The
 moderator is continuous, so I'd like to treat it as discrete for
 plotting the regression lines.
 
 Here's an example (I would like 7 regression lines corresponding to
 the discrete levels of the moderator, as displayed in the legend,
 instead of just 1 regression line):
 
 ###
 library(ggplot2)
 set.seed(1234)
 predictor - rnorm(1000, 3)
 outcome - rnorm(1000, 10)
 moderator - rnorm(1000)
 mydata - data.frame(predictor, outcome, moderator)
 
 ggplot(mydata, aes(x=predictor, y=outcome, color=moderator)) +
 geom_point() + scale_colour_gradient2(low=blue, high=red) +
 stat_smooth(method=lm, se=TRUE, fullrange=T)
 ###
 
 Also, how can I set how many discrete levels to plot (e.g., 3 instead of
 7)?
 
 Thanks in advance!
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

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


Re: [R] Plotting of regsubsets adjr2 values not correct

2012-09-26 Thread Greg Snow
Does your dataset have any missing data? (without a reproducible
example we can only guess).

If it does then you may be fitting the same model to different subsets
of the data between the 2 methods.

On Tue, Sep 25, 2012 at 9:03 AM, Maximilian Lklweryc
maxlklwe...@gmail.com wrote:
 Hi,
 I want to make model selection with regsubsets. My code is:

 a-regsubsets(Gesamt ~ CommunistSocialist + CountrySize + GNI + Lifeexp +
 Schoolyears + ExpMilitary + Mortality +
   PopPoverty + PopTotal + ExpEdu + ExpHealth, data=olympiadaten, nbest=2)
 summary(a)
 plot(a,scale=adjr2)

 (output attached)

 The problem is now, that I want to fit the best model again manually and
 have a look at it, but the value of the adjusted R squared is not the same
 as in the regsubsets output? This is also the case for the other models,
 e.g. when I do the simplest model in the graphic:
 summary(lm(Gesamt~ExpHealth))
 I get an adj. R squared of 0.009202 but the plot says something abou 0.14,
 so it is not correct? I don't know how to solve this problem, any help
 would be nice, thanks.


 Also I do not understand, which models are shown there, e.g. the simple
 model just with an intercept and the variable GNI is not shown in the plot,
 why?

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

2012-09-26 Thread John Kane
summary(fit1) perhaps/

John Kane
Kingston ON Canada


 -Original Message-
 From: cacamende...@gmail.com
 Sent: Wed, 26 Sep 2012 11:39:30 -0300
 To: r-help@r-project.org
 Subject: [R] Retrieve regression summary results after rq
 
 Hi all,
 
 I am using quantile regression with svy design. I want to retrieve
 summary regression statistics (std error, p-value), since I don't have
 any in my output:
 
 Commands:
 
 clus1_d- svydesign(id=~cd002_co, weights=~wtper, strata=~str, data=data)
 bclus1-as.svrepdesign(clus1_d,type=bootstrap,replicates=100)
 fit1-
 withReplicates(bclus1,quote(coef(rq(newm428b~sch_new_2+sch_new_3+sch_new_4,
 tau=c(0.05,0.25,0.5,0.75,0.95),weights=wtper
 
 Output:
 
 coefficients(fit1)
 tau= 0.05 tau= 0.25 tau= 0.50 tau= 0.75 tau= 0.95
 (Intercept)  2340  2980  3.30e+03  3750 4360.
 sch_new_2185   -30 -5.50e+01  -250 -360.
 sch_new_315520  5.032317e-16  -200 -245.
 sch_new_4 6520 -1.50e+01  -200 -309.9998
 
 Any help will be appreciated.
 
 Best,
 
 C.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
desktop!

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


Re: [R] rows extraction

2012-09-26 Thread David L Carlson
 subtest - subset(test, Name. %in% c(PKB123, PKB22, PKB23, PKB32,
   CTV19, CTV20, PKB11, PKB11))
 subtest
Name. Score performance Environment.
10  CTV19 2  0.52740797   0.53639048
11  CTV20 3  0.05298615   0.04856818
12  PKB11 4  0.90037809   0.79427806
13  PKB11 5  0.41806588   0.40839968
14 PKB123 5  0.16914593   0.17565094
15  PKB22 4  0.13450181   0.14681555
16  PKB23 3  0.05703352   0.04438428
17  PKB32 2  0.07606024   0.07606045

--
David L Carlson
Associate Professor of Anthropology
Texas AM 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 Nico Met
 Sent: Wednesday, September 26, 2012 10:20 AM
 To: r-help
 Subject: [R] rows extraction
 
 Dear all,
 
 I want to extract rows from a data frame shown here as test. For
 example:
 rows with with sorting
  PKB123  PKB22  PKB23  PKB32  CTV19  CTV20  PKB11  PKB11
 
  dput(test)
 structure(list(Name. = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
 8L, 9L, 10L, 11L, 12L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
 19L), .Label = c(CTV10, CTV11, CTV12, CTV13, CTV14,
 CTV15, CTV16, CTV17, CTV18, CTV19, CTV20, PKB11,
 PKB123, PKB22, PKB23, PKB32, PKB54, PKB55, PKB65
 ), class = factor), Score = c(1, 3, 4, 5, 2, 3, 4, 5, 6, 2,
 3, 4, 5, 5, 4, 3, 2, 5, 6, 6, 2), performance = c(0.1885092462,
 0.0794777814, 0.2503300253, 0.0378809048, 0.7203585833, 0.0517920055,
 0.2064060066, 0.5514853303, 0.2605452552, 0.5274079653, 0.0529861537,
 0.9003780927, 0.4180658816, 0.1691459321, 0.1345018054, 0.0570335197,
 0.0760602378, 0.2203198271, 0.2233031679, 0.030859, 0.6791582042
 ), Environment. = c(0.1936732121, 0.1073581974, 0.2399158958,
 0.0370952629, 0.6749189555, 0.0545192018, 0.2067554284, 0.4832804062,
 0.2784950304, 0.5363904829, 0.0485681822, 0.7942780565, 0.4083996821,
 0.175650937, 0.1468155515, 0.0443842831, 0.0760604527, 0.2029511384,
 0.2486623715, 0.0362999435, 0.6409256796)), .Names = c(Name.,
 Score, performance, Environment.), class = data.frame,
 row.names =
 c(NA,
 21L))
 
 
 regards
 
 Nico
 
   [[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] geom_line: How to plot two data sets having different maximum X-axis values in a single plot?

2012-09-26 Thread John Kane
Clumsy but this should do it.  

aa$set  -  rep(a, length(aa$position))
bb$set  -  rep(b, length(bb$position))
 
(mydata  -  rbind(aa,bb))

p  -  ggplot( mydata , aes( position, count, colour = set  )) + geom_line()
p 

John Kane
Kingston ON Canada


 -Original Message-
 From: jimmikes...@gmail.com
 Sent: Tue, 25 Sep 2012 09:07:24 -0400
 To: r-help@r-project.org
 Subject: [R] geom_line: How to plot two data sets having different
 maximum X-axis values in a single plot?
 
 Hello, I just started  to learn R and ggplot2. Can someone help?
 
 How to plot two data sets having different maximum X-axis values in a
 single plot?
 
 For example, I have two data sets showed below. Using position as X, and
 count as Y, how can I plot them out in different color lines within a
 single plot using ggplot2 geom_line?
 
 
 
 dataset a:
 
 position count
 
 13
 
 29
 
 310
 
 415
 
 519
 
 628
 
 715
 
 813
 
 911
 
 105
 
 
 
 dataset b:
 
 position count
 
 14
 
 28
 
 316
 
 417
 
 519
 
 610
 
 
 
 Thanks a lot!
 
 
 
 
 Jim
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
desktop!

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


Re: [R] Retrieve regression summary results after rq

2012-09-26 Thread Camila Mendes
This does not work at all...

On Wed, Sep 26, 2012 at 12:04 PM, John Kane jrkrid...@inbox.com wrote:
 summary(fit1) perhaps/

 John Kane
 Kingston ON Canada


 -Original Message-
 From: cacamende...@gmail.com
 Sent: Wed, 26 Sep 2012 11:39:30 -0300
 To: r-help@r-project.org
 Subject: [R] Retrieve regression summary results after rq

 Hi all,

 I am using quantile regression with svy design. I want to retrieve
 summary regression statistics (std error, p-value), since I don't have
 any in my output:

 Commands:

 clus1_d- svydesign(id=~cd002_co, weights=~wtper, strata=~str, data=data)
 bclus1-as.svrepdesign(clus1_d,type=bootstrap,replicates=100)
 fit1-
 withReplicates(bclus1,quote(coef(rq(newm428b~sch_new_2+sch_new_3+sch_new_4,
 tau=c(0.05,0.25,0.5,0.75,0.95),weights=wtper

 Output:

 coefficients(fit1)
 tau= 0.05 tau= 0.25 tau= 0.50 tau= 0.75 tau= 0.95
 (Intercept)  2340  2980  3.30e+03  3750 4360.
 sch_new_2185   -30 -5.50e+01  -250 -360.
 sch_new_315520  5.032317e-16  -200 -245.
 sch_new_4 6520 -1.50e+01  -200 -309.9998

 Any help will be appreciated.

 Best,

 C.

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

 
 FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on your 
 desktop!
 Check it out at http://www.inbox.com/marineaquarium



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


Re: [R] Retrieve regression summary results after rq

2012-09-26 Thread John Kane
Strange, I have never used it but presumably you are using the package 
‘survey’? The manual suggests summary(xx) should work. 

What results or error messages do you get?


John Kane
Kingston ON Canada


 -Original Message-
 From: cacamende...@gmail.com
 Sent: Wed, 26 Sep 2012 12:39:46 -0300
 To: jrkrid...@inbox.com
 Subject: Re: [R] Retrieve regression summary results after rq
 
 This does not work at all...
 
 On Wed, Sep 26, 2012 at 12:04 PM, John Kane jrkrid...@inbox.com wrote:
 summary(fit1) perhaps/
 
 John Kane
 Kingston ON Canada
 
 
 -Original Message-
 From: cacamende...@gmail.com
 Sent: Wed, 26 Sep 2012 11:39:30 -0300
 To: r-help@r-project.org
 Subject: [R] Retrieve regression summary results after rq
 
 Hi all,
 
 I am using quantile regression with svy design. I want to retrieve
 summary regression statistics (std error, p-value), since I don't have
 any in my output:
 
 Commands:
 
 clus1_d- svydesign(id=~cd002_co, weights=~wtper, strata=~str,
 data=data)
 bclus1-as.svrepdesign(clus1_d,type=bootstrap,replicates=100)
 fit1-
 withReplicates(bclus1,quote(coef(rq(newm428b~sch_new_2+sch_new_3+sch_new_4,
 tau=c(0.05,0.25,0.5,0.75,0.95),weights=wtper
 
 Output:
 
 coefficients(fit1)
 tau= 0.05 tau= 0.25 tau= 0.50 tau= 0.75 tau= 0.95
 (Intercept)  2340  2980  3.30e+03  3750 4360.
 sch_new_2185   -30 -5.50e+01  -250 -360.
 sch_new_315520  5.032317e-16  -200 -245.
 sch_new_4 6520 -1.50e+01  -200 -309.9998
 
 Any help will be appreciated.
 
 Best,
 
 C.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on
 your desktop!
 Check it out at http://www.inbox.com/marineaquarium
 



GET FREE SMILEYS FOR YOUR IM  EMAIL - Learn more at 
http://www.inbox.com/smileys
Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most 
webmails

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


Re: [R] boxplot of different colors

2012-09-26 Thread John Kane
Shamelessly stealling Richard Heiberger's data set I'd suggest another way 
using ggplot2 which you would need to install

library(ggplot2)

dataN - data.frame(GE_distance=rnorm(260),
Diet_B=factor(rep(1:13, each=20)))

p  -  ggplot(dataN , aes(Diet_B, GE_distance, colour = Diet_B  )) + 
geom_boxplot() +
   xlab(Migration) + ylab(Distance)
p 


John Kane
Kingston ON Canada


 -Original Message-
 From: r...@temple.edu
 Sent: Mon, 24 Sep 2012 19:00:09 -0400
 To: elaine.kuo...@gmail.com
 Subject: Re: [R] boxplot of different colors
 
 ## I would do this in lattice using the panel.bwplot.intermediate.hh
 ## function from the HH package.
 
 ## install.packages(HH) ## if necessary
 library(HH)
 
 dataN - data.frame(GE_distance=rnorm(260),
 Diet_B=factor(rep(1:13, each=20)))
 Diet.colors - c(forestgreen, darkgreen,chocolate1,darkorange2,
  sienna2,red2,firebrick3,saddlebrown,coral4,
  chocolate4,darkblue,navy,grey38)
 bwplot(GE_distance ~ Diet_B, data=dataN,
xlab=list(Diet of Breeding Ground, cex = 1.4),
ylab = list(
  Distance between Centers of B and NB Range (1000 km),
  cex = 1.4),
panel=panel.bwplot.intermediate.hh,
col=Diet.colors,
pch=rep(|,13))
 
 
 On Mon, Sep 24, 2012 at 6:23 PM, Elaine Kuo elaine.kuo...@gmail.com
 wrote:
 
 Hello,
 
 I am making a boxplot of 13 boxes.
 I tried to color the box using 13 colors but failed.
 Only red and brown were displayed.
 Green, blue, and grey disappeared.
 
 Please kindly advise modification after checking the code below.
 Thank you in advance.
 
 Elaine
 
 R code
 # data input
 dataN
 
 -read.csv(H:/a_mig_distance_B_NB/R_data/Mig_bird_586_20120925.csv,header=T,
 row.names=1)
 dim(dataN)
 dataN[1,]
 str(dataN)
 
   # graph
 par(mai=c(1,1.03,0.4,0.4))
 
 obs.group-dataN$Diet_B
 
 par(new=T)
 
 boxplot(GE_distance~Diet_B, data=dataN,xlab=Diet  of  Breeding
  Ground,ylab=,
 yaxt=n,type=p,
 pch=1,lwd=0.95,
 cex.lab=1.4, cex.axis=1.2,
 font.axis=2,
 cex=1.5,
 las=1,
 bty=l,
 col=c(forestgreen,
 darkgreen,chocolate1,darkorange2,sienna2,
 red2,firebrick3,
 
 
 saddlebrown,coral4,chocolate4,darkblue,navy,grey38)[obs.group]))
 
 op = par(mar = c(5,5,4,2) + 0.1)
 title(ylab = Distance between Centers of B and NB Range (1000 km),
 cex.lab = 1.4,line = 3)
 
 axis(side=2,yaxp=c(0,2,4),cex.lab=1.4, cex.axis=1.2,font.axis=2,
 las=1)
 
 [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
   [[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.


Send any screenshot to your friends in seconds...
Works in all emails, instant messengers, blogs, forums and social networks.
TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE

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


Re: [R] Latitude Longitude to SPDF

2012-09-26 Thread John Kane
I think I know considerably less than you do but have a look as the sp package. 
 I think you are referring to and object type SpatialPolygonsDataFrame from 
the package
sp or which that package will produce.  

Good luck.  Now to install rgdal.


John Kane
Kingston ON Canada


 -Original Message-
 From: vickytha...@gmail.com
 Sent: Mon, 24 Sep 2012 10:02:39 -0500
 To: r-help@r-project.org
 Subject: [R] Latitude Longitude to SPDF
 
 Hi Team,
 
 Need your guidance in building SPDF objects from Latitude, Longitude
 Information available.
 I am using package plotGoogleMaps which is really awesome but it
 requires
 SPDF objects to build the maps.
 I have a data frame which have Latitude and Longitude information and
 wanted to convert it in SPDF for making maps.
 
 Please help me to find suitable package or function to convert it. Or if
 I
 am missing something. I am really sorry but have very less
 experience when dealing with Spatial Data.
 
 Best Regards,
 
 
 Bhupendrasinh Thakre
 
 *Disclaimer :*
 
 The information contained in this communication is =\ ...{{dropped:15}}

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


Re: [R] rows extraction

2012-09-26 Thread Jeff Newmiller
You need to use the match function if you want to specify result sort order or 
duplication.

test[ match(c( PKB123, PKB22, PKB23,PKB32, CTV19, CTV20, PKB11, 
PKB11 ),test$Name.), ]

---
Jeff NewmillerThe .   .  Go Live...
DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

David L Carlson dcarl...@tamu.edu wrote:

 subtest - subset(test, Name. %in% c(PKB123, PKB22, PKB23,
PKB32,
   CTV19, CTV20, PKB11, PKB11))
 subtest
Name. Score performance Environment.
10  CTV19 2  0.52740797   0.53639048
11  CTV20 3  0.05298615   0.04856818
12  PKB11 4  0.90037809   0.79427806
13  PKB11 5  0.41806588   0.40839968
14 PKB123 5  0.16914593   0.17565094
15  PKB22 4  0.13450181   0.14681555
16  PKB23 3  0.05703352   0.04438428
17  PKB32 2  0.07606024   0.07606045

--
David L Carlson
Associate Professor of Anthropology
Texas AM 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 Nico Met
 Sent: Wednesday, September 26, 2012 10:20 AM
 To: r-help
 Subject: [R] rows extraction
 
 Dear all,
 
 I want to extract rows from a data frame shown here as test. For
 example:
 rows with with sorting
  PKB123  PKB22  PKB23  PKB32  CTV19  CTV20  PKB11  PKB11
 
  dput(test)
 structure(list(Name. = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
 8L, 9L, 10L, 11L, 12L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
 19L), .Label = c(CTV10, CTV11, CTV12, CTV13, CTV14,
 CTV15, CTV16, CTV17, CTV18, CTV19, CTV20, PKB11,
 PKB123, PKB22, PKB23, PKB32, PKB54, PKB55, PKB65
 ), class = factor), Score = c(1, 3, 4, 5, 2, 3, 4, 5, 6, 2,
 3, 4, 5, 5, 4, 3, 2, 5, 6, 6, 2), performance = c(0.1885092462,
 0.0794777814, 0.2503300253, 0.0378809048, 0.7203585833, 0.0517920055,
 0.2064060066, 0.5514853303, 0.2605452552, 0.5274079653, 0.0529861537,
 0.9003780927, 0.4180658816, 0.1691459321, 0.1345018054, 0.0570335197,
 0.0760602378, 0.2203198271, 0.2233031679, 0.030859, 0.6791582042
 ), Environment. = c(0.1936732121, 0.1073581974, 0.2399158958,
 0.0370952629, 0.6749189555, 0.0545192018, 0.2067554284, 0.4832804062,
 0.2784950304, 0.5363904829, 0.0485681822, 0.7942780565, 0.4083996821,
 0.175650937, 0.1468155515, 0.0443842831, 0.0760604527, 0.2029511384,
 0.2486623715, 0.0362999435, 0.6409256796)), .Names = c(Name.,
 Score, performance, Environment.), class = data.frame,
 row.names =
 c(NA,
 21L))
 
 
 regards
 
 Nico
 
  [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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

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


[R] Removing duplicates without a for loop

2012-09-26 Thread wwreith
 I have several thousand rows of shipment data imported into R as a data
frame, with two columns of particular interest, col 1 is the entry date, and
col 2 is the tracking number (colname is REQ.NR). Tracking numbers should be
unique but on occassion aren't because they get entered more than once. This
creates two or more rows of with the same tracking number but different
dates. I wrote a for loop that will keep the row with the oldest date but it
is extremely slow. 

Any suggestions of how I should write this so that it is faster?

# Creates a vector of on the unique tracking numbers #
u-na.omit(unique(Para.5C$REQ.NR))

# Create Data Frame to rbind unique rows to #
Para.5C.final-data.frame()

# For each value in u subset Para.5C find the min date and rbind it to
Para.5C.final #
for(i in 1:length(u))
{
  x-subset(Para.5C,Para.5C$REQ.NR==u[i])
  Para.5C.final-rbind(Para.5C.final,x[which(x[,1]==min(x[,1])),])
}



--
View this message in context: 
http://r.789695.n4.nabble.com/Removing-duplicates-without-a-for-loop-tp4644255.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] specifying arguments in functions and calling functions, within functions

2012-09-26 Thread K. Brand
Esteemed R UseRs,

Regarding specifying arguments in functions and calling functions
within functions:

## beginning ##
## some data
ex - rnorm(10)
ex[5] - NA

## example function
Scale - function(x, method=c(mean, median)) {
   scl - method
   scl(x)
}

## both return NA
Scale(ex, method=median)
median(ex, na.rm=FALSE)

## both return the median
Scale(ex, method=median)
median(ex, na.rm=TRUE)

## 1. Why does the use of apostrophes have this effect when calling
## a fucntion within a function?

## 2. What's the canonical use of apostrophes in functions like the above:
## Scale - function(x, method=c(mean, median)) {
## or
## Scale - function(x, method=c(mean, median)) {

## 3. How does one specify the arguments of a function being called
## within a function? i.e. i thought the use of '...' might work in
## the following but i was wrong.

## '...' has no apparent effect
Scale - function(x, method=c(mean, median),...) {
   scl - method
   scl(x)
}

## both return NA
Scale(ex, method=median, na.rm=TRUE)
Scale(ex, method=median, na.rm=FALSE)
## end ##


I failed to comprehend anything google returned when trying to
understand this myself. Greatly appreciate any thoughts /or
examples on this.

Tia, Karl

-- 
Karl Brand
Dept of Cardiology and Dept of Bioinformatics
Erasmus MC
Dr Molewaterplein 50
3015 GE Rotterdam
T +31 (0)10 703 2460 |M +31 (0)642 777 268 |F +31 (0)10 704 4161
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] map two names into one

2012-09-26 Thread arun


HI,

Try this:
vec1-GALAXY ACE S 5830
vec2-S 5830 GALAXY ACE
vec3-R GALAXY 5812 ACE
 vec11-paste(sort(unlist(strsplit(vec2, ))),collapse=_)
 vec22-paste(sort(unlist(strsplit(vec2, ))),collapse=_)
 vec11
#[1] 5830_ACE_GALAXY_S
 vec22
#[1] 5830_ACE_GALAXY_S

 identical(vec11,vec22)
#[1] TRUE
 vec33-paste(sort(unlist(strsplit(vec3, ))),collapse=_)
 identical(vec11,vec33)
#[1] FALSE

A.K.

- Original Message -
From: Tammy Ma metal_lical...@live.com
To: r-help@r-project.org r-help@r-project.org
Cc: 
Sent: Wednesday, September 26, 2012 5:04 AM
Subject: [R] map two names into one


Dear R user:


I have got the following problem:

I have imported two data sets into R: one set includes price information, 
another one includes volume information. but I noticed the wrong data order 
problem in the product name,

for instance,

in one data set,

GALAXY ACE S 5830

in another one,

it is S 5830 GALAXY ACE  

both represent same product. how do i map two name into one in R?

there are so many product name having this problem. i hope there is some 
mechanism which can autimatically map those.  thanks for your help..


Kind regards,
Tammy
                          
    [[alternative HTML version deleted]]

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


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


[R] Reading multiple files

2012-09-26 Thread Silvano Cesar da Costa
Hi,

I have 35 data files for reading. I would like get a program for
performing reading of 35 files at once.
All are of the type: Dados1.raw, Dados2.raw and so on.

If the files have the same number of columns, I can read with the
following commands:

rm(list=ls())
filenames = list.files(path=~/Silvano/Arq, pattern=Dados+.*raw)
names = substr(filenames, 1, 7)

for(i in names){
  filepath = file.path(~/Silvano/Dados, paste(i, .raw, sep=))
  assign(i, read.delim(filepath,
   colClasses=c(rep(character, 5), rep(numeric, 5)),
   sep = ))
}

It happens that the files have different number of columns. And I can't
solve the problem.

Any suggestions?


-
Silvano Cesar da Costa

Universidade Estadual de Londrina
Centro de Ciências Exatas
Departamento de Estatística

Fone: (43) 3371-4346

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

2012-09-26 Thread Eko andryanto Prakasa
 haiii

i want to know, is there any script in R to measure looping averageif (like in 
the excel) ...
for example:
i have a vector
rowvalue
10
22
3-3
4-2
51
6-2

i want to measure the average of the vector for negative value with window 
estimation 5
so first mean is (-3+-2)/2
 second mean is (-3+-2+-2)/3  

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


[R] Help with R invoking

2012-09-26 Thread Li, Jianying (NIH/NIEHS) [C]
Hi,

I encountered a very strange error with R (2.14.1).

I tried to build an R package and eventually worked (passing all the checks 
etc.). Then, I tried this command R CMD INSTALL --binary pkg, which 
supposedly installs and produce a binary source archive (*.zip) for use on 
Windows only.

Nothing happened, but I could not run R CMD check pkg anymore. Further, when 
I tried to invoke R, I had \

Warning message:
In normalizePath(c(new, .Library.site, .Library), /) :
  path[1]=: No such file or directory

I looked through all the document but could not find an answer.

Could you please provide some hint?

Thanks!


Jianying Li
Bionformatics Scientist, Contractor
National Institute of Environmental Health Sciences
l...@niehs.nih.govmailto:l...@niehs.nih.gov
(919) 541 - 5736


[[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] Submit a new script after all parallel jobs have completed

2012-09-26 Thread francesca casalino
Dear R experts,

I have an R script that creates multiple scripts and submits these
simultaneously to a computer cluster, and after all of the multiple
scripts have completed and the output has been written in the
respective folders, I would like to automatically launch another R
script that works on these outputs.

I haven't been able to figure out whether there is a way to do this in
R: the function 'wait' is not what I want since the scripts are
submitted as different jobs and each of them completes and writes its
output file at different times, but I actually want to run the
subsequent script after all of the outputs appear. Can you please help
me find a solution?

Thank you very much
-fra

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


Re: [R] factor expansion

2012-09-26 Thread Jose Bustos Melo
Thank you PIKAL Petr,

This is used when you have a big data base of a national sample. So, this 
factor is a variable that uses the sample in order to obtain information about 
all the people of the country.  Similar of getting a real approach about what's 
going on in the total population. I don't know how it is called in english (my 
first tonge is spanish).  Perhaps, there's a function in R, but I have not 
idea. 
Hope it helps.
Thanks in advance.
José




 De: PIKAL Petr petr.pi...@precheza.cz

l...@r-project.org 
Enviado: Miércoles 19 de septiembre de 2012 9:19
Asunto: RE: [R] factor expansion

Hi

I did not see any answer yet but can you explain what you mean by factor 
expansion? Something like expand.grid?

Petr

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Jose Bustos Melo
 Sent: Wednesday, September 12, 2012 4:16 PM
 To: r-help@r-project.org
 Subject: [R] factor expansion
 
 I'm trying to use a data base from SPSS and get all data representing
 the true data. I would like to use a variable as expansion data. In our
 data base we have the variable with the factor expansion, but we have
 not idea how to set it in R.
 Any idea?
 
 Thanks in advance!
 José
     [[alternative HTML version deleted]]
[[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] Create an error logging text file

2012-09-26 Thread Sam Sturge
Hi,

I am looking to run a script which calls other functions from other scripts.
Such as in script 1 I may have function f1 which then calls functions f2,
f3, f4 which are found in script 3 and then f4 also calls function f6 which
can be found in script 3 etc.

What I am looking to do is to create a text file that reports any errors or
warnings that come about while running this script, and then also reporting
which function and script that error/warning occurs.

Any help would be greatly appreciated.

Regards,

Sam





--
View this message in context: 
http://r.789695.n4.nabble.com/Create-an-error-logging-text-file-tp4644268.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] Specifying a response variable in a Bayesian network

2012-09-26 Thread Abraham Mathew
I'm trying to teach myself about Bayesian Networks and am working with the
following data and the bnlearn package.
I understand the conceptual aspects of BNs, but I'm not sure how to specify
the response variables in R when constructing
a dag plot. I've cecked ?hc and done numerous google searches without luck.

Can anyone help?

library(bnlearn)
library(Rgraphviz)

dat=data.frame(won=c(1,0,0,1,0,0), sold=c(0,0,0,1,0,0),
insured=c(0,0,1,0,0,1),
   credit=c(POOR,FAIR,GOOD,FAIR,FAIR,GOOD))
dat$won = factor(dat$won)
dat$sold = factor(dat$sold)
dat$insured = factor(dat$insured)
dat$credit = factor(dat$credit)

highlight.opts - list(nodes = c(won,sold,insured,credit),
   col = red, fill = grey)
bn.hc - hc(dat, score = aic)
graphviz.plot(bn.hc, highlight=highlight.opts)



Thanks,
Abraham


-- 
*Abraham Mathew
Statistical Analyst
www.amathew.com
720-648-0108
@abmathewks*

[[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] lme(y ~ ns(x, df=splineDF)) error

2012-09-26 Thread Jacob Wegelin


I would like to fit regression models of the form

y ~ ns(x, df=splineDF)

where splineDF is passed as an argument to a wrapper function.

This works fine if the regression function is lm(). But with lme(),
I get two different errors, depending on how I handle splineDF
inside the wrapper function.

A workaround is to turn the lme() command, along with the appropriate
value of splineDF, into a text string and then use
eval(parse(text=mystring)).  Is there not a more elegant solution?

The function below demonstrates this. According to the value of
WhichApproach (1, 2, or 3), it attempts one of the approaches that
does not work or the workaround using the text string.


sessionInfo()

R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

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

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

other attached packages:
[1] nlme_3.1-104  ggplot2_0.9.1

loaded via a namespace (and not attached):
  [1] colorspace_1.1-1   dichromat_1.2-4digest_0.5.2
  grid_2.15.1labeling_0.1
   [6] lattice_0.20-6 MASS_7.3-18memoise_0.1
   munsell_0.3plyr_1.7.1
   [11] proto_0.3-9.2  RColorBrewer_1.0-5 reshape2_1.2.1
   scales_0.2.1   stringr_0.6
   [16] tools_2.15.1


wrapper -function(WhichApproach=1, splineDF=4 ){
#   Create toy dataset
nID-25
IDnames-LETTERS[1:nID]

longdat-data.frame( x=rep(-10:10, nID) / 3 , ID= rep( IDnames , each=21)
)
set.seed(5)
longdat$x-longdat$x + rnorm(nrow(longdat))/10
IDeffect-rnorm(nID) * 20
names(IDeffect) - IDnames
longdat$IDeffect-IDeffect[as.character(longdat$ID)]
longdat$y- (longdat$x
+ longdat$x^3
+ (longdat$x-1)^4  / 5
+ 1/(abs(longdat$x/50) + 0.02)
+ longdat$IDeffect
+ rnorm(1:nrow(longdat)) * 2
)
longdat-longdat[order(longdat$x),]

library(splines)
#   Calling ns within lm works fine:
mylm- lm( y ~ ns(x,df=splineDF), data=longdat)
longdat$lmfit-predict(mylm)
library(ggplot2)
print(
ggplot(longdat, aes(x, y))
+ geom_point(shape=1)
+ geom_line(aes(x=x, y=lmfit), color=red)
)


cat(Enter to attempt lme.)
readline()
library(nlme)

if(WhichApproach==1) {
# returns: Error in eval(expr, envir, enclos) : object 'splineDF' not found
#
# First make sure splineDF does not exist in .GlobalEnv, else we would be in 
WhichApproach==2.
if(exists(splineDF, where=.GlobalEnv)) remove(list=splineDF, 
pos=.GlobalEnv)
mylme-lme(fixed= y ~ ns(x, df=splineDF)
, random= ~ 1 | ID
, correlation = corAR1()
, data=longdat
)
} else if(WhichApproach==2) {
# returns: Error in model.frame.default(formula = ~ID + y + x + splineDF, data = list( : 
# variable lengths differ (found for 'splineDF')

assign(x=splineDF, value=splineDF, pos=.GlobalEnv)
mylme-lme(fixed= y ~ ns(x, df=splineDF)
, random= ~ 1 | ID
, correlation = corAR1()
, data=longdat
)
} else if (WhichApproach==3) {

thecommandstring- paste(mylme-lme(fixed= y ~ ns(x, df=, splineDF, ) , random= ~ 
1 | ID , correlation = corAR1() , data=longdat))
thecommandstring
eval(parse(text=thecommandstring))

} else {
stop(paste(WhichApproach=, WhichApproach,  not valid.))
}

mylme
longdat$fullfit-predict(mylme)

library(ggplot2)
print(
ggplot( longdat, aes(x,y))
+ geom_point(shape=1)
+ facet_wrap( ~ ID )
+ geom_line( aes(x, fullfit), color=red)
)

invisible(mylme)
}

Jacob A. Wegelin
Assistant Professor
Department of Biostatistics
Virginia Commonwealth University
830 E. Main St., Seventh Floor
P. O. Box 980032
Richmond VA 23298-0032
U.S.A.

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


Re: [R] specifying arguments in functions and calling functions, within functions

2012-09-26 Thread Sarah Goslee
Hi,

You have some basic confusion here, and a problem likely caused by an
object named scl that exists in your global environment.

On Wed, Sep 26, 2012 at 11:56 AM, K. Brand k.br...@erasmusmc.nl wrote:
 Esteemed R UseRs,

 Regarding specifying arguments in functions and calling functions
 within functions:

 ## beginning ##
 ## some data
 ex - rnorm(10)
 ex[5] - NA

 ## example function
 Scale - function(x, method=c(mean, median)) {
scl - method
scl(x)
 }

 ## both return NA
 Scale(ex, method=median)
 median(ex, na.rm=FALSE)

 ## both return the median
 Scale(ex, method=median)
 median(ex, na.rm=TRUE)

 ## 1. Why does the use of apostrophes have this effect when calling
 ## a fucntion within a function?

Those are double quotes, not apostrophes, and they don't have that effect:

 Scale(ex, method=median)
[1] NA
 Scale(ex, method=median)
Error in Scale(ex, method = median) : could not find function scl


You probably have something named scl in your global environment: you
can see that with ls().

Take a look at:

 class(median)
[1] function
 class(median)
[1] character

In your first example, you're passing a function to Scale(), which
gives it a new name then uses it. In the second you're passing a
character string that happens to be the name of a function, which
Scale() gives a new name and then tries but fails to use (because it
isn't a function).

See also:
 Scale(ex, Nothing)
Error in Scale(ex, Nothing) : could not find function scl

 ## 2. What's the canonical use of apostrophes in functions like the above:
 ## Scale - function(x, method=c(mean, median)) {
 ## or
 ## Scale - function(x, method=c(mean, median)) {

Depends on whether you want to pass a function or the name of a function.

 ## 3. How does one specify the arguments of a function being called
 ## within a function? i.e. i thought the use of '...' might work in
 ## the following but i was wrong.

 ## '...' has no apparent effect
 Scale - function(x, method=c(mean, median),...) {
scl - method
scl(x)
 }

You can pass them explicitly as named arguments, or with ... as you
try. In either case you have to hand those off to the function you
want to use them:

Scale - function(x, method=c(mean, median),...) {
   scl - method
scl(x, ...)
}

Scale - function(x, method=c(mean, median), na.rm=FALSE) {
   scl - method
scl(x, na.rm=na.rm)
}

 ## both return NA
 Scale(ex, method=median, na.rm=TRUE)
 Scale(ex, method=median, na.rm=FALSE)
 ## end ##


 I failed to comprehend anything google returned when trying to
 understand this myself. Greatly appreciate any thoughts /or
 examples on this.

Many functions that come with R are written purely in R and use these
capabilities so you can look at them for examples.

Sarah

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

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


Re: [R] Help with R invoking

2012-09-26 Thread Duncan Murdoch

On 26/09/2012 11:03 AM, Li, Jianying (NIH/NIEHS) [C] wrote:

Hi,

I encountered a very strange error with R (2.14.1).

I tried to build an R package and eventually worked (passing all the checks etc.). Then, I tried 
this command R CMD INSTALL --binary pkg, which supposedly installs and produce a 
binary source archive (*.zip) for use on Windows only.

Nothing happened, but I could not run R CMD check pkg anymore. Further, when 
I tried to invoke R, I had \

Warning message:
In normalizePath(c(new, .Library.site, .Library), /) :
   path[1]=: No such file or directory

I looked through all the document but could not find an answer.

Could you please provide some hint?



Please try to put together a reproducible example.  It looks sort of 
like symptoms of having a bad package name in your DESCRIPTION file, 
which was fixed quite recently (after 2.15.1):


 * A malformed package name could cause |R CMD INSTALL| to write 
outside the target library.


You can try a nightly build of R-patched if you can make the problem 
reproducible.  If it's not fixed yet, please send me instructions on how 
to reproduce.  (That probably means sending me a copy of your pkg source.)


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] how to know where you've been sourced from

2012-09-26 Thread Alexander Shenkin
Hello All,

I need a script to perform different actions depending on the file from
which it was source()'d.  Thus, my script needs a way to figure out from
whence it was sourced.

There seems to be some relevant information in sys.calls() (see below).
 However, I need to get at the name of the file that directly source the
file in question.  That is, just one level above.  For example, in the
example below, test.r needs to know that it was called by source_test.r.
 In this example, the information is in sys.calls()[[4]].  But, if there
are other calls in the stack, I don't imagine it will always be in
sys.calls()[[4]].  Is there a consistent place in sys.calls() or
elsewhere I can look for the sourcing file name?

thanks,
allie


 cat(print(sys.calls()),file=test.r)
 cat(source(\test.r\),file=source_test.r)
 cat(source(\source_test.r\),file=source_test_parent.r)
 source(source_test_parent.r)

[[1]]
source(source_test_parent.r)

[[2]]
eval.with.vis(ei, envir)

[[3]]
eval.with.vis(expr, envir, enclos)

[[4]]
source(source_test.r)

[[5]]
eval.with.vis(ei, envir)

[[6]]
eval.with.vis(expr, envir, enclos)

[[7]]
source(test.r)

[[8]]
eval.with.vis(ei, envir)

[[9]]
eval.with.vis(expr, envir, enclos)

[[10]]
print(sys.calls())

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


Re: [R] rows extraction

2012-09-26 Thread David Winsemius

On Sep 26, 2012, at 8:28 AM, David L Carlson wrote:

 subtest - subset(test, Name. %in% c(PKB123, PKB22, PKB23, PKB32,
   CTV19, CTV20, PKB11, PKB11))
 subtest
Name. Score performance Environment.
 10  CTV19 2  0.52740797   0.53639048
 11  CTV20 3  0.05298615   0.04856818
 12  PKB11 4  0.90037809   0.79427806
 13  PKB11 5  0.41806588   0.40839968
 14 PKB123 5  0.16914593   0.17565094
 15  PKB22 4  0.13450181   0.14681555
 16  PKB23 3  0.05703352   0.04438428
 17  PKB32 2  0.07606024   0.07606045
 
 --
 David L Carlson
 Associate Professor of Anthropology
 Texas AM University
 College Station, TX 77843-4352

I read the request as calling for a subsequent ordering:

subtest[match(subtest$Name., c(PKB123, PKB22, PKB23, PKB32,
CTV19, CTV20, PKB11, PKB11) ), ]
  Name. Score performance Environment.
14   PKB123 5  0.16914593   0.17565094
15PKB22 4  0.13450181   0.14681555
16PKB23 3  0.05703352   0.04438428
16.1  PKB23 3  0.05703352   0.04438428
10CTV19 2  0.52740797   0.53639048
11CTV20 3  0.05298615   0.04856818
12PKB11 4  0.90037809   0.79427806
13PKB11 5  0.41806588   0.40839968

 
 
 
 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Nico Met
 Sent: Wednesday, September 26, 2012 10:20 AM
 To: r-help
 Subject: [R] rows extraction
 
 Dear all,
 
 I want to extract rows from a data frame shown here as test. For
 example:
 rows with with sorting
 PKB123  PKB22  PKB23  PKB32  CTV19  CTV20  PKB11  PKB11
 
 dput(test)
 structure(list(Name. = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L,
 8L, 9L, 10L, 11L, 12L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
 19L), .Label = c(CTV10, CTV11, CTV12, CTV13, CTV14,
 CTV15, CTV16, CTV17, CTV18, CTV19, CTV20, PKB11,
 PKB123, PKB22, PKB23, PKB32, PKB54, PKB55, PKB65
 ), class = factor), Score = c(1, 3, 4, 5, 2, 3, 4, 5, 6, 2,
 3, 4, 5, 5, 4, 3, 2, 5, 6, 6, 2), performance = c(0.1885092462,
 0.0794777814, 0.2503300253, 0.0378809048, 0.7203585833, 0.0517920055,
 0.2064060066, 0.5514853303, 0.2605452552, 0.5274079653, 0.0529861537,
 0.9003780927, 0.4180658816, 0.1691459321, 0.1345018054, 0.0570335197,
 0.0760602378, 0.2203198271, 0.2233031679, 0.030859, 0.6791582042
 ), Environment. = c(0.1936732121, 0.1073581974, 0.2399158958,
 0.0370952629, 0.6749189555, 0.0545192018, 0.2067554284, 0.4832804062,
 0.2784950304, 0.5363904829, 0.0485681822, 0.7942780565, 0.4083996821,
 0.175650937, 0.1468155515, 0.0443842831, 0.0760604527, 0.2029511384,
 0.2486623715, 0.0362999435, 0.6409256796)), .Names = c(Name.,
 Score, performance, Environment.), class = data.frame,
 row.names =
 c(NA,
 21L))
 
 
 regards
 
 Nico


David Winsemius, MD
Alameda, CA, USA

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


Re: [R] how to know where you've been sourced from

2012-09-26 Thread Duncan Murdoch

On 26/09/2012 2:39 PM, Alexander Shenkin wrote:

Hello All,

I need a script to perform different actions depending on the file from
which it was source()'d.  Thus, my script needs a way to figure out from
whence it was sourced.

There seems to be some relevant information in sys.calls() (see below).
  However, I need to get at the name of the file that directly source the
file in question.  That is, just one level above.  For example, in the
example below, test.r needs to know that it was called by source_test.r.
  In this example, the information is in sys.calls()[[4]].  But, if there
are other calls in the stack, I don't imagine it will always be in
sys.calls()[[4]].  Is there a consistent place in sys.calls() or
elsewhere I can look for the sourcing file name?


Look in the global variable you created just before you sourced it, e.g.

MyNameIs - foo.R
source(bar.R)



thanks,
allie


 cat(print(sys.calls()),file=test.r)
 cat(source(\test.r\),file=source_test.r)
 cat(source(\source_test.r\),file=source_test_parent.r)
 source(source_test_parent.r)

[[1]]
source(source_test_parent.r)

[[2]]
eval.with.vis(ei, envir)

[[3]]
eval.with.vis(expr, envir, enclos)

[[4]]
source(source_test.r)

[[5]]
eval.with.vis(ei, envir)

[[6]]
eval.with.vis(expr, envir, enclos)

[[7]]
source(test.r)

[[8]]
eval.with.vis(ei, envir)

[[9]]
eval.with.vis(expr, envir, enclos)

[[10]]
print(sys.calls())

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] specifying arguments in functions and calling functions, within functions

2012-09-26 Thread Rui Barradas

Hello,

You define a 2nd version of Scale with the dots argument but do not use it.


Scale2 - function(x, method=c(mean, median),...) {
   scl - match.fun(method)
   scl(x, ...)   # Here!
}

Scale2(ex, method=median, na.rm=TRUE)  # both return
Scale2(ex, method=median, na.rm=TRUE)  # the median

You could also use 'na.rm = TRUE' instead of '...', since both mean and 
median use it. Anyway, if you define a function with certain arguments, 
do try to use them in the function body. :)


As for the method argument, when the default value is a vector, it's 
primary use is to check that one of those vector values and _only_ one 
of those is passed to the function. More or less like this.


Scale3 - function(x, method=c(mean, median),...) {
   method - match.arg(method)
   scl - match.fun(method)
   scl(x, ...)
}

Scale3(ex, method=median, na.rm=TRUE)  # Error
Scale3(ex, method=median, na.rm=TRUE)  # Right
Scale3(ex, method=var, na.rm=TRUE)  # Other type of error


Hope this helps,

Rui Barradas

Em 26-09-2012 16:56, K. Brand escreveu:

Esteemed R UseRs,

Regarding specifying arguments in functions and calling functions
within functions:

## beginning ##
## some data
ex - rnorm(10)
ex[5] - NA

## example function
Scale - function(x, method=c(mean, median)) {
scl - method
scl(x)
}

## both return NA
Scale(ex, method=median)
median(ex, na.rm=FALSE)

## both return the median
Scale(ex, method=median)
median(ex, na.rm=TRUE)

## 1. Why does the use of apostrophes have this effect when calling
## a fucntion within a function?

## 2. What's the canonical use of apostrophes in functions like the above:
## Scale - function(x, method=c(mean, median)) {
## or
## Scale - function(x, method=c(mean, median)) {

## 3. How does one specify the arguments of a function being called
## within a function? i.e. i thought the use of '...' might work in
## the following but i was wrong.

## '...' has no apparent effect
Scale - function(x, method=c(mean, median),...) {
scl - method
scl(x)
}

## both return NA
Scale(ex, method=median, na.rm=TRUE)
Scale(ex, method=median, na.rm=FALSE)
## end ##


I failed to comprehend anything google returned when trying to
understand this myself. Greatly appreciate any thoughts /or
examples on this.

Tia, Karl



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


Re: [R] Retrieve regression summary results after rq

2012-09-26 Thread David Winsemius

On Sep 26, 2012, at 8:50 AM, John Kane wrote:

 Strange, I have never used it but presumably you are using the package 
 ‘survey’? The manual suggests summary(xx) should work. 
 
 What results or error messages do you get?

She didn't return a model object as fit1. She return only the results of the 
coef() on the rq(model) object.

Perhaps:

summ1 - withReplicates(bclus1,
quote( summary( rq( 
newm428b~sch_new_2+sch_new_3+sch_new_4,
  
tau=c(0.05,0.25,0.5,0.75,0.95),weights=wtper

Untested, and I've never used 'survey' and 'rq' packages together so this is 
based entirely on analogous reasoning.)
-- 
David.

 
 
 John Kane
 Kingston ON Canada
 
 
 -Original Message-
 From: cacamende...@gmail.com
 Sent: Wed, 26 Sep 2012 12:39:46 -0300
 To: jrkrid...@inbox.com
 Subject: Re: [R] Retrieve regression summary results after rq
 
 This does not work at all...
 
 On Wed, Sep 26, 2012 at 12:04 PM, John Kane jrkrid...@inbox.com wrote:
 summary(fit1) perhaps/
 
 John Kane
 Kingston ON Canada
 
 
 -Original Message-
 From: cacamende...@gmail.com
 Sent: Wed, 26 Sep 2012 11:39:30 -0300
 To: r-help@r-project.org
 Subject: [R] Retrieve regression summary results after rq
 
 Hi all,
 
 I am using quantile regression with svy design. I want to retrieve
 summary regression statistics (std error, p-value), since I don't have
 any in my output:
 
 Commands:
 
 clus1_d- svydesign(id=~cd002_co, weights=~wtper, strata=~str,
 data=data)
 bclus1-as.svrepdesign(clus1_d,type=bootstrap,replicates=100)
 fit1-
 withReplicates(bclus1,quote(coef(rq(newm428b~sch_new_2+sch_new_3+sch_new_4,
 tau=c(0.05,0.25,0.5,0.75,0.95),weights=wtper
 
 Output:
 
 coefficients(fit1)
tau= 0.05 tau= 0.25 tau= 0.50 tau= 0.75 tau= 0.95
 (Intercept)  2340  2980  3.30e+03  3750 4360.
 sch_new_2185   -30 -5.50e+01  -250 -360.
 sch_new_315520  5.032317e-16  -200 -245.
 sch_new_4 6520 -1.50e+01  -200 -309.9998
 
 Any help will be appreciated.
 
 Best,
 
 C.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks  orcas on
 your desktop!
 Check it out at http://www.inbox.com/marineaquarium
 
 
 
 
 GET FREE SMILEYS FOR YOUR IM  EMAIL - Learn more at 
 http://www.inbox.com/smileys
 Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and 
 most webmails
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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
Alameda, CA, USA

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


Re: [R] specifying arguments in functions and calling functions, within functions

2012-09-26 Thread David L Carlson
Adding on to what Sarah has said, your function appears to limit the
functions that can be passed to it, but it does not. The character strings
mean and median will fail, but passing the function name directly will
work:

 Scale - function(x, method=mean,...) {
scl - method
scl(x, ...)
 }

The method=c(mean, median) is irrelevant to the function because you
never check to guarantee that only those strings are used in the function
call. This is fortunate since those strings will fail whereas passing any
function that requires a single vector as input will work just fine:

 set.seed(42)
 ex - runif(10)
 ex[5] - NA
 Scale(ex)
 [1] NA
 Scale(ex, na.rm=TRUE)
[1] 0.635653
 Scale(ex, median)
Error in Scale(ex, median) : could not find function scl
 Scale(ex, median)
[1] NA
 Scale(ex, median, na.rm=TRUE)
[1] 0.7050648
 Scale(ex, fivenum)
[1] 0.134 0.5190959 0.7050648 0.8304476 0.9370754
 Scale(ex, hist)

--
David L Carlson
Associate Professor of Anthropology
Texas AM 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 Sarah Goslee
 Sent: Wednesday, September 26, 2012 1:26 PM
 To: K. Brand
 Cc: r-help@r-project.org
 Subject: Re: [R] specifying arguments in functions and calling
 functions, within functions
 
 Hi,
 
 You have some basic confusion here, and a problem likely caused by an
 object named scl that exists in your global environment.
 
 On Wed, Sep 26, 2012 at 11:56 AM, K. Brand k.br...@erasmusmc.nl
 wrote:
  Esteemed R UseRs,
 
  Regarding specifying arguments in functions and calling functions
  within functions:
 
  ## beginning ##
  ## some data
  ex - rnorm(10)
  ex[5] - NA
 
  ## example function
  Scale - function(x, method=c(mean, median)) {
 scl - method
 scl(x)
  }
 
  ## both return NA
  Scale(ex, method=median)
  median(ex, na.rm=FALSE)
 
  ## both return the median
  Scale(ex, method=median)
  median(ex, na.rm=TRUE)
 
  ## 1. Why does the use of apostrophes have this effect when calling
  ## a fucntion within a function?
 
 Those are double quotes, not apostrophes, and they don't have that
 effect:
 
  Scale(ex, method=median)
 [1] NA
  Scale(ex, method=median)
 Error in Scale(ex, method = median) : could not find function scl
 
 
 You probably have something named scl in your global environment: you
 can see that with ls().
 
 Take a look at:
 
  class(median)
 [1] function
  class(median)
 [1] character
 
 In your first example, you're passing a function to Scale(), which
 gives it a new name then uses it. In the second you're passing a
 character string that happens to be the name of a function, which
 Scale() gives a new name and then tries but fails to use (because it
 isn't a function).
 
 See also:
  Scale(ex, Nothing)
 Error in Scale(ex, Nothing) : could not find function scl
 
  ## 2. What's the canonical use of apostrophes in functions like the
 above:
  ## Scale - function(x, method=c(mean, median)) {
  ## or
  ## Scale - function(x, method=c(mean, median)) {
 
 Depends on whether you want to pass a function or the name of a
 function.
 
  ## 3. How does one specify the arguments of a function being called
  ## within a function? i.e. i thought the use of '...' might work in
  ## the following but i was wrong.
 
  ## '...' has no apparent effect
  Scale - function(x, method=c(mean, median),...) {
 scl - method
 scl(x)
  }
 
 You can pass them explicitly as named arguments, or with ... as you
 try. In either case you have to hand those off to the function you
 want to use them:
 
 Scale - function(x, method=c(mean, median),...) {
scl - method
 scl(x, ...)
 }
 
 Scale - function(x, method=c(mean, median), na.rm=FALSE) {
scl - method
 scl(x, na.rm=na.rm)
 }
 
  ## both return NA
  Scale(ex, method=median, na.rm=TRUE)
  Scale(ex, method=median, na.rm=FALSE)
  ## end ##
 
 
  I failed to comprehend anything google returned when trying to
  understand this myself. Greatly appreciate any thoughts /or
  examples on this.
 
 Many functions that come with R are written purely in R and use these
 capabilities so you can look at them for examples.
 
 Sarah
 
 --
 Sarah Goslee
 http://www.functionaldiversity.org
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-
 guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Removing duplicates without a for loop

2012-09-26 Thread Jean V Adams
This might be quicker.

Para.5C.sorted - Para.5C[order(Para.5C[, 1]), ]
Para.5C.final - Para.5C.sorted[!duplicated(Para.5C.sorted$REQ.NR), ]

If your data are already sorted by date, then you can skip the first step 
and just run
Para.5C.final - Para.5C[!duplicated(Para.5C$REQ.NR), ]

Jean



wwreith reith_will...@bah.com wrote on 09/26/2012 10:19:21 AM:
 
  I have several thousand rows of shipment data imported into R as a data
 frame, with two columns of particular interest, col 1 is the entry date, 
and
 col 2 is the tracking number (colname is REQ.NR). Tracking numbers 
should be
 unique but on occassion aren't because they get entered more than once. 
This
 creates two or more rows of with the same tracking number but different
 dates. I wrote a for loop that will keep the row with the oldest date 
but it
 is extremely slow. 
 
 Any suggestions of how I should write this so that it is faster?
 
 # Creates a vector of on the unique tracking numbers #
 u-na.omit(unique(Para.5C$REQ.NR))
 
 # Create Data Frame to rbind unique rows to #
 Para.5C.final-data.frame()
 
 # For each value in u subset Para.5C find the min date and rbind it to
 Para.5C.final #
 for(i in 1:length(u))
 {
   x-subset(Para.5C,Para.5C$REQ.NR==u[i])
   Para.5C.final-rbind(Para.5C.final,x[which(x[,1]==min(x[,1])),])
 }

[[alternative HTML version deleted]]

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


Re: [R] Reading multiple files

2012-09-26 Thread Jean V Adams
Will your data be read in correctly if you do away with the colClasses 
argument to read.delim (or read.table)?

Jean



Silvano Cesar da Costa silv...@uel.br wrote on 09/26/2012 09:11:33 AM:
 
 Hi,
 
 I have 35 data files for reading. I would like get a program for
 performing reading of 35 files at once.
 All are of the type: Dados1.raw, Dados2.raw and so on.
 
 If the files have the same number of columns, I can read with the
 following commands:
 
 rm(list=ls())
 filenames = list.files(path=~/Silvano/Arq, pattern=Dados+.*raw)
 names = substr(filenames, 1, 7)
 
 for(i in names){
   filepath = file.path(~/Silvano/Dados, paste(i, .raw, sep=))
   assign(i, read.delim(filepath,
colClasses=c(rep(character, 5), rep(numeric, 
5)),
sep = ))
 }
 
 It happens that the files have different number of columns. And I can't
 solve the problem.
 
 Any suggestions?
 
 
 -
 Silvano Cesar da Costa
 
 Universidade Estadual de Londrina
 Centro de Ciências Exatas
 Departamento de Estatística
 
 Fone: (43) 3371-4346

[[alternative HTML version deleted]]

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


[R] R and sell buy stock

2012-09-26 Thread baycan global
Hi all,

I have seen that R can be switched on to a Broker called IB.

There is another one similar to IB that permits to make a code and send
orders to broker to buy or sell stocks?

Can be done trough R, writte in excel and trough API sell/buy to the broker?

Can someone send me an example (easy example?)

Many thanks.

[[alternative HTML version deleted]]

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


Re: [R] Removing duplicates without a for loop

2012-09-26 Thread Rui Barradas
Sorry, but in my previous post I've confused the columns. It's by 
REQ.NR, not by date


REQ.NR - 1:4
REQ.NR - c(REQ.NR, sample(REQ.NR, 2))
dat - data.frame(date = Sys.Date() + 1:6, REQ.NR = REQ.NR, value = 
rnorm(6))


aggregate(dat, by = list(dat$REQ.NR), FUN = tail, 1)

Rui Barradas
Em 26-09-2012 16:19, wwreith escreveu:

  I have several thousand rows of shipment data imported into R as a data
frame, with two columns of particular interest, col 1 is the entry date, and
col 2 is the tracking number (colname is REQ.NR). Tracking numbers should be
unique but on occassion aren't because they get entered more than once. This
creates two or more rows of with the same tracking number but different
dates. I wrote a for loop that will keep the row with the oldest date but it
is extremely slow.

Any suggestions of how I should write this so that it is faster?

# Creates a vector of on the unique tracking numbers #
u-na.omit(unique(Para.5C$REQ.NR))

# Create Data Frame to rbind unique rows to #
Para.5C.final-data.frame()

# For each value in u subset Para.5C find the min date and rbind it to
Para.5C.final #
for(i in 1:length(u))
{
   x-subset(Para.5C,Para.5C$REQ.NR==u[i])
   Para.5C.final-rbind(Para.5C.final,x[which(x[,1]==min(x[,1])),])
}



--
View this message in context: 
http://r.789695.n4.nabble.com/Removing-duplicates-without-a-for-loop-tp4644255.html
Sent from the R help mailing list archive at Nabble.com.

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


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


[R] Help with invoking R

2012-09-26 Thread Li, Jianying (NIH/NIEHS) [C]
Hi,

I encountered a very strange error with R (2.14.1).

I tried to build an R package and eventually worked (passing all the checks 
etc.). Then, I tried this command R CMD INSTALL --binary pkg, which 
supposedly installs and produce a binary source archive (*.zip) for use on 
Windows only.

Nothing happened, but I could not run R CMD check pkg anymore. Further, when 
I tried to invoke R, I had \

Warning message:
In normalizePath(c(new, .Library.site, .Library), /) :
  path[1]=: No such file or directory

I looked through all the document but could not find an answer.

Could you please provide some hint?

Thanks!


Jianying Li
Bionformatics Scientist, Contractor
National Institute of Environmental Health Sciences
l...@niehs.nih.govmailto:l...@niehs.nih.gov
(919) 541 - 5736


[[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] Removing duplicates without a for loop

2012-09-26 Thread Rui Barradas

Hello,

If I understand it correctly, something like this will get you what you 
want.



d - Sys.Date() + 1:4
d2 - sample(d, 2)
dat - data.frame(id = 1:6, date = c(d, d2), value = rnorm(6))

aggregate(dat, by = list(dat$date), FUN = tail, 1)

Hope this helps,

Rui Barradas
Em 26-09-2012 16:19, wwreith escreveu:

  I have several thousand rows of shipment data imported into R as a data
frame, with two columns of particular interest, col 1 is the entry date, and
col 2 is the tracking number (colname is REQ.NR). Tracking numbers should be
unique but on occassion aren't because they get entered more than once. This
creates two or more rows of with the same tracking number but different
dates. I wrote a for loop that will keep the row with the oldest date but it
is extremely slow.

Any suggestions of how I should write this so that it is faster?

# Creates a vector of on the unique tracking numbers #
u-na.omit(unique(Para.5C$REQ.NR))

# Create Data Frame to rbind unique rows to #
Para.5C.final-data.frame()

# For each value in u subset Para.5C find the min date and rbind it to
Para.5C.final #
for(i in 1:length(u))
{
   x-subset(Para.5C,Para.5C$REQ.NR==u[i])
   Para.5C.final-rbind(Para.5C.final,x[which(x[,1]==min(x[,1])),])
}



--
View this message in context: 
http://r.789695.n4.nabble.com/Removing-duplicates-without-a-for-loop-tp4644255.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] replace string values with numbers

2012-09-26 Thread JiangZhengyu




Hi everyone, I have a data frame Gene with SNPs eg.   P1 P2 P3 
 CG CG GG
-- --  AC 
 -- AC CC
AC  --  AC I tried to replace all the GG with a value 3.Gene[Gene==GG]-3 
It always give me:  Warning in `[-.factor`(`*tmp*`, thisvar, value = 3) :
  invalid factor level, NAs generated Does any know if there is anything wrong 
with my code? Thanks, Zhengyu  
[[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] Background color in a grid plot seems to interfere with plot()

2012-09-26 Thread Marius Hofert
Dear Paul,

Many thanks, that solved it.

Cheers,

Marius

Paul Murrell p.murr...@auckland.ac.nz writes:

 Hi

 On 25/09/2012 6:10 p.m., Marius Hofert wrote:
 Dear Paul,

 Thanks. Redrawing the points solves it for the minimal example, but
 what happens if you have plot(.., type=b) like below?

 You can use points(..., type=b)

 Paul

 Actually, originally I wanted to use just grid (without mixing it
 with base graphics), but I couldn't find an equivalent for plot(..,
 type=b). Also, later on, I would like to use eaxis() to draw nice
 y-axes in log-scale. I guess that's easier with gridBase then.

 Cheers,

 Marius



 require(grid) require(gridBase)

 pdf(file=Rplot.pdf, width=8, height=8, onefile=FALSE)

 ## set up the grid layout plot.new() # start (empty) new page with
 'graphics' gl- grid.layout(5, 5, widths=unit(c(1.8, 8, 0.8, 8, 0.8),
 cm), heights=unit(c(0.8, 8, 0.8, 8, 1.5), cm))
 pushViewport(viewport(layout=gl))

 ## plot data par.- par(no.readonly=TRUE) # save plot settings for(i
 in 1:2) { # rows i.- if(i  1) i+2 else i+1 # jumping over gaps
 for(j in 1:2) { # columns j.- if(j  1) j+2 else j+1 # jumping over
 gaps pushViewport(viewport(layout.pos.row=i., layout.pos.col=j.))
 grid.rect(gp=gpar(col=NA, fill=gray90)) # background
 par(plt=gridPLT()) ## plot par(new=TRUE) # always do this before each
 new 'graphics' plot plot(runif(5), runif(5), type=b, log=y,
 xlab=, ylab=, frame.plot=FALSE, xaxt=n, yaxt=n)
 grid(col=white, lty=solid, lwd=1.6, equilogs=FALSE) # background
 grid upViewport() } } par(par.) dev.off()


 Paul Murrellp...@stat.auckland.ac.nz  writes:

 Hi

 On 25/09/12 11:50, Marius Hofert wrote:
 Dear Paul,

 Thanks for helping. Is there a way to call grid() first? The
 problem seems to be that everything drawn before grid() is
 overplotted.

 No, but you can redraw the points ...

 require(grid) require(gridBase)

 pdf(file=Rplot.pdf, width=8, height=8, onefile=FALSE)

 ## set up the grid layout plot.new() # start (empty) new page with
 'graphics' gl- grid.layout(5, 5, widths=unit(c(1.8, 8, 0.8, 8,
 0.8), cm), heights=unit(c(0.8, 8, 0.8, 8, 1.5), cm))
 pushViewport(viewport(layout=gl))

 ## plot data par.- par(no.readonly=TRUE) # save plot settings
 for(i in 1:2) { # rows i.- if(i  1) i+2 else i+1 # jumping over
 gaps for(j in 1:2) { # columns j.- if(j  1) j+2 else j+1 #
 jumping over gaps pushViewport(viewport(layout.pos.row=i.,
 layout.pos.col=j.)) grid.rect(gp=gpar(col=NA, fill=gray90)) #
 background par(plt=gridPLT()) ## plot par(new=TRUE) # always do
 this before each new 'graphics' plot plot(1:5, if(i==1  j==2)
 c(1, 1, 2, 3, 1) else 1:5, log=y, xlab=, ylab=,
 frame.plot=FALSE, xaxt=n, yaxt=n) # background grid
 grid(col=white, lty=solid, lwd=1.6, equilogs=FALSE) points(1:5,
 if(i==1  j==2) c(1, 1, 2, 3, 1) else 1:5) upViewport() } }
 par(par.) dev.off()

 Paul

 Cheers,

 Marius



 require(grid) require(gridBase)

 pdf(file=Rplot.pdf, width=8, height=8, onefile=FALSE)

 ## set up the grid layout plot.new() # start (empty) new page
 with 'graphics' gl- grid.layout(5, 5, widths=unit(c(1.8, 8, 0.8,
 8, 0.8), cm), heights=unit(c(0.8, 8, 0.8, 8, 1.5), cm))
 pushViewport(viewport(layout=gl))

 ## plot data par.- par(no.readonly=TRUE) # save plot settings
 for(i in 1:2) { # rows i.- if(i  1) i+2 else i+1 # jumping over
 gaps for(j in 1:2) { # columns j.- if(j  1) j+2 else j+1 #
 jumping over gaps pushViewport(viewport(layout.pos.row=i.,
 layout.pos.col=j.)) grid.rect(gp=gpar(col=NA, fill=gray90)) #
 background par(plt=gridPLT()) ## plot par(new=TRUE) # always do
 this before each new 'graphics' plot plot(1:5, if(i==1  j==2)
 c(1, 1, 2, 3, 1) else 1:5, log=y, xlab=, ylab=,
 frame.plot=FALSE, xaxt=n, yaxt=n) grid(col=white,
 lty=solid, lwd=1.6, equilogs=FALSE) # background grid
 upViewport() } } par(par.) dev.off()


 Paul Murrellp...@stat.auckland.ac.nz  writes:

 Hi

 On 24/09/12 18:06, Marius Hofert wrote:
 Dear Paul,

 Thank you for helping. This works great.

 I then tried to put in a grid (via grid()). Why does that
 fail?

 Because grid() is used to add lines to an existing plot;  just
 put the grid() call AFTER the plot() call and it should work
 ok.

 Paul

 Cheers,

 Marius


 require(grid) require(gridBase)

 pdf(file=Rplot.pdf, width=8, height=8, onefile=FALSE)

 ## set up the grid layout plot.new() # start (empty) new page
 with 'graphics' gl- grid.layout(5, 5, widths=unit(c(1.8, 8,
 0.8, 8, 0.8), cm), heights=unit(c(0.8, 8, 0.8, 8, 1.5),
 cm)) pushViewport(viewport(layout=gl))

 ## plot data par.- par(no.readonly=TRUE) # save plot
 settings for(i in 1:2) { # rows i.- if(i  1) i+2 else i+1 #
 jumping over gaps for(j in 1:2) { # columns j.- if(j  1)
 j+2 else j+1 # jumping over gaps
 pushViewport(viewport(layout.pos.row=i., layout.pos.col=j.))
 grid.rect(gp=gpar(fill=gray90)) # background
 par(plt=gridPLT()) ## plot par(new=TRUE) # always do this
 before each new 'graphics' plot grid(col=1) plot(1:10, 1:10,
 log=y, xlab=, ylab=, xaxt=if(i==2) s else n,
 yaxt=if(j==1) s 

Re: [R] Removing duplicates without a for loop

2012-09-26 Thread Clint Bowman

?duplicated

Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600

USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274

On Wed, 26 Sep 2012, Rui Barradas wrote:

Sorry, but in my previous post I've confused the columns. It's by REQ.NR, not 
by date


REQ.NR - 1:4
REQ.NR - c(REQ.NR, sample(REQ.NR, 2))
dat - data.frame(date = Sys.Date() + 1:6, REQ.NR = REQ.NR, value = rnorm(6))

aggregate(dat, by = list(dat$REQ.NR), FUN = tail, 1)

Rui Barradas
Em 26-09-2012 16:19, wwreith escreveu:

  I have several thousand rows of shipment data imported into R as a data
frame, with two columns of particular interest, col 1 is the entry date, 
and
col 2 is the tracking number (colname is REQ.NR). Tracking numbers should 
be
unique but on occassion aren't because they get entered more than once. 
This

creates two or more rows of with the same tracking number but different
dates. I wrote a for loop that will keep the row with the oldest date but 
it

is extremely slow.

Any suggestions of how I should write this so that it is faster?

# Creates a vector of on the unique tracking numbers #
u-na.omit(unique(Para.5C$REQ.NR))

# Create Data Frame to rbind unique rows to #
Para.5C.final-data.frame()

# For each value in u subset Para.5C find the min date and rbind it to
Para.5C.final #
for(i in 1:length(u))
{
   x-subset(Para.5C,Para.5C$REQ.NR==u[i])
   Para.5C.final-rbind(Para.5C.final,x[which(x[,1]==min(x[,1])),])
}



--
View this message in context: 
http://r.789695.n4.nabble.com/Removing-duplicates-without-a-for-loop-tp4644255.html

Sent from the R help mailing list archive at Nabble.com.

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

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


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



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


[R] Simple Question About Exporting Back to Excel

2012-09-26 Thread RCar
All,
Relatively new R user so this is probably an easy question to answer.  
I am able to generate a cluster for my dataset using hclust() then ploting
the data with plot().
This results in an image with a dendrogram with my sample names along the
bottom.  Great!
However, I now need a way to get that sample order from the image into
excel.
i.e. sample 7 was on the far left, sample 19 was in position 2, sample 93
was in position 3, etc.
As of now the only way for me to do this is to manually type the samples
from the image into a worksheet.  
Very time consuming as I've got a couple hundred samples and several
different dendrograms!
Any thoughts?

Thanks so much!



--
View this message in context: 
http://r.789695.n4.nabble.com/Simple-Question-About-Exporting-Back-to-Excel-tp4644296.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] Removing duplicates without a for loop

2012-09-26 Thread David Winsemius

On Sep 26, 2012, at 11:23 AM, Rui Barradas wrote:

 Hello,
 
 If I understand it correctly, something like this will get you what you want.
 
 
 d - Sys.Date() + 1:4
 d2 - sample(d, 2)
 dat - data.frame(id = 1:6, date = c(d, d2), value = rnorm(6))
 
 aggregate(dat, by = list(dat$date), FUN = tail, 1)

If these are sorted by date, then the oldest date would come first any you 
would want:

 aggregate(dat, by = list(dat$date), FUN = head, 1)
-- 
David.
 
 Hope this helps,
 
 Rui Barradas
 Em 26-09-2012 16:19, wwreith escreveu:
  I have several thousand rows of shipment data imported into R as a data
 frame, with two columns of particular interest, col 1 is the entry date, and
 col 2 is the tracking number (colname is REQ.NR). Tracking numbers should be
 unique but on occassion aren't because they get entered more than once. This
 creates two or more rows of with the same tracking number but different
 dates. I wrote a for loop that will keep the row with the oldest date but it
 is extremely slow.
 
 Any suggestions of how I should write this so that it is faster?
 
 # Creates a vector of on the unique tracking numbers #
 u-na.omit(unique(Para.5C$REQ.NR))
 
 # Create Data Frame to rbind unique rows to #
 Para.5C.final-data.frame()
 
 # For each value in u subset Para.5C find the min date and rbind it to
 Para.5C.final #
 for(i in 1:length(u))
 {
   x-subset(Para.5C,Para.5C$REQ.NR==u[i])
   Para.5C.final-rbind(Para.5C.final,x[which(x[,1]==min(x[,1])),])
 }
 
-- 

David Winsemius, MD
Alameda, CA, USA

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


Re: [R] replace string values with numbers

2012-09-26 Thread David Winsemius

On Sep 26, 2012, at 12:52 PM, JiangZhengyu wrote:

 
 
 
 
 Hi everyone, I have a data frame Gene with SNPs eg.   P1 P2 P3 
 CG CG GG
 -- --  AC 
 -- AC CC
 AC  --  AC I tried to replace all the GG with a value 3.
 Gene[Gene==GG]-3 It always give me:  Warning in `[-.factor`(`*tmp*`, 
 thisvar, value = 3) :
  invalid factor level, NAs generated Does any know if there is anything wrong 
 with my code?

You are trying to replace a factor value with a level that it doesn't have. 
Hence that particular very informative error message.

-- 

David Winsemius, MD
Alameda, CA, USA

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


Re: [R] replace string values with numbers

2012-09-26 Thread David Winsemius

On Sep 26, 2012, at 2:27 PM, David Winsemius wrote:

 
 On Sep 26, 2012, at 12:52 PM, JiangZhengyu wrote:
 
 Hi everyone, I have a data frame Gene with SNPs eg.   P1 P2 P3 
 CG CG GG
 -- --  AC 
 -- AC CC
 AC  --  AC I tried to replace all the GG with a value 3.
 Gene[Gene==GG]-3 It always give me:  Warning in `[-.factor`(`*tmp*`, 
 thisvar, value = 3) :
 invalid factor level, NAs generated Does any know if there is anything wrong 
 with my code?
 
 You are trying to replace a factor value with a level that it doesn't have. 
 Hence that particular very informative error message.

You probably could do this:

Gene[] - lapply(Gene, as.character)
 Gene
  P1 P2 P3
1 CG CG GG
2 -- -- AC
3 -- AC CC
4 AC -- AC

The use of the form `object[] -` preserves the original dimensions. You would 
otherwise have needed to use data.frame() around the result.


 Gene[Gene==GG] - 3
 Gene
  P1 P2 P3
1 CG CG  3
2 -- -- AC
3 -- AC CC
4 AC -- AC


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

Your code was not really self-contained and reproducible, but what I did was 
this:

Gene - read.table(text=P1 P2 P3 
 CG CG GG
 -- --  AC 
 -- AC CC
 AC  --  AC, header=TRUE)

read.table will by default create factors when the input column contains 
character values unless you use stringsAsFactors=FALSE.

-- 

David Winsemius, MD
Alameda, CA, USA

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


Re: [R] Reading multiple files

2012-09-26 Thread Bretschneider SIG-R

On 26 Sep 2012, at 16:11 , Silvano Cesar da Costa wrote:

 Hi,
 
 I have 35 data files for reading. I would like get a program for
 performing reading of 35 files at once.
 All are of the type: Dados1.raw, Dados2.raw and so on.
 
 If the files have the same number of columns, I can read with the
 following commands:
 
 rm(list=ls())
 filenames = list.files(path=~/Silvano/Arq, pattern=Dados+.*raw)
 names = substr(filenames, 1, 7)
 
 for(i in names){
  filepath = file.path(~/Silvano/Dados, paste(i, .raw, sep=))
  assign(i, read.delim(filepath,
   colClasses=c(rep(character, 5), rep(numeric, 5)),
   sep = ))
 }
 
 It happens that the files have different number of columns. And I can't
 solve the problem.
 
 Any suggestions?
 



Dear Silvano Cesar da Costa,


You can read an entire folder by analysing the path.
I wrote this program to convert wave files, but it can be applied to any file 
type.
Just change the few lines (if ywave... etc) into your own operations:


#  select FOLDER with WAV-files
fnam = dirname(file.choose())
print(); print(FILES)
print(list.files(fnam))
print(); print(DIRS)
print(list.dirs(fnam, full.names=FALSE))
print(); print(RECURSIVE FILE LIST)
filist = list.files(fnam, recursive=TRUE, pattern=wav)
print(filist)
filist1 = paste(fnam,/,filist, sep=)
nfiles = length(filist1)
#  
#  filenames loop ===
for(i in 1:nfiles) {
inname=filist1[i]
ywave=readWave(inname)
ster=ywave@stereo
if (ster==stereo) {} #  wat dan??
srate=yw...@samp.rate
ywave2=ywave
if (ywave2@bit==8) {
ywave2@left=(ywave2@left-128)*255
ywave2@bit - 16
}
if (ywa...@samp.rate10) {
ywa...@samp.rate - ywa...@samp.rate * 10
}
if (ywa...@samp.rate != 312500) {
ywave2 - resamp(ywave2,f=ywa...@samp.rate,g=312500, 
output=Wave)
}

outname=paste(dirname(inname), /*,basename(inname), sep=)
writeWave(ywave2,outname)
}


Best wishes,

Franklin Bretschneider

Dept of Biology
Kruytgebouw W711
Padualaan 8
3584 CH Utrecht
The Netherlands
f.bretschnei...@uu.nl

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


Re: [R] Reading multiple files

2012-09-26 Thread Jean V Adams
If your previously posted code worked with files all having the same 
number of columns, and if your data is read in correctly without the 
colClasses argument, then I think the following code should work.

for(i in names){
filepath = file.path(~/Silvano/Dados, paste(i, .raw, sep=))
assign(i, read.table(filepath))
}

If not, then my guess is the error (what is the error message???) is due 
to the file referencing or naming.  For example, it's not clear to me why 
you take the substring of the file name, only to paste on the file type 
suffix later.

Jean



Silvano Cesar da Costa silv...@uel.br wrote on 09/26/2012 04:31:48 PM:
 
 Hi,
 
 I didn't notice problems with this.
 
 
  Will your data be read in correctly if you do away with the colClasses
  argument to read.delim (or read.table)?
 
  Jean
 
 
 
  Silvano Cesar da Costa silv...@uel.br wrote on 09/26/2012 09:11:33 
AM:
 
  Hi,
 
  I have 35 data files for reading. I would like get a program for
  performing reading of 35 files at once.
  All are of the type: Dados1.raw, Dados2.raw and so on.
 
  If the files have the same number of columns, I can read with the
  following commands:
 
  rm(list=ls())
  filenames = list.files(path=~/Silvano/Arq, pattern=Dados+.*raw)
  names = substr(filenames, 1, 7)
 
  for(i in names){
filepath = file.path(~/Silvano/Dados, paste(i, .raw, sep=))
assign(i, read.delim(filepath,
 colClasses=c(rep(character, 5), 
rep(numeric,
  5)),
 sep = ))
  }
 
  It happens that the files have different number of columns. And I 
can't
  solve the problem.
 
  Any suggestions?
 
 
  -
  Silvano Cesar da Costa
 
  Universidade Estadual de Londrina
  Centro de Ciências Exatas
  Departamento de Estatística
 
  Fone: (43) 3371-4346

[[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] averageif and looping

2012-09-26 Thread Rui Barradas

Hello,

Try the following.


sapply(seq_len(nrow(dat) - 4), function(i){
w - window(dat$value, start = i, end = i + 4)
mean(w[w  0])})

Hope this helps,

Rui Barradas
Em 26-09-2012 16:38, Eko andryanto Prakasa escreveu:

  haiii

i want to know, is there any script in R to measure looping averageif (like in 
the excel) ...
for example:
i have a vector
rowvalue
10
22
3-3
4-2
51
6-2

i want to measure the average of the vector for negative value with window 
estimation 5
so first mean is (-3+-2)/2
  second mean is (-3+-2+-2)/3

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

2012-09-26 Thread William Dunlap
You could use filter(..., filter=rep(1,5)) to get running sums of length 5
to get your answer.  The following calls filter once to get the sum of
the negative values in each window and once to get the number of negative
values in each window, then divides to get the means.

f - function(x, n=5) {
sumNeg - filter(pmin(x, 0), filter=rep(1,n)) # running sums of negative 
values
numNeg - filter( x  0, filter=rep(1,n))  # running numbers of negative 
values
as.vector(sumNeg/numNeg) # running means of negative values
}

E.g.,
 s - c(0, 2, -3, -2, 1, -2)
 cbind(s, meanNeg = f(s, n=5))
  s   meanNeg
[1,]  0NA
[2,]  2NA
[3,] -3 -2.50
[4,] -2 -2.33
[5,]  1NA
[6,] -2NA

It is quick for long vectors
 ss - floor(sin(1:1e6)*5) # one million numbers
 system.time(f(ss, 5))
   user  system elapsed
  1.036   0.040   1.079

If you want results at the ends, append (n-1)/2 0's to each end of the series
and remove the NA's that appear at those positions in the output.

The 'as.vector' is there because filter always returns a 'ts' (a class of time 
series
objects), even if the input is a simple vector.

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 Eko andryanto Prakasa
 Sent: Wednesday, September 26, 2012 8:39 AM
 To: r-help@R-project.org
 Subject: [R] averageif and looping
 
  haiii
 
 i want to know, is there any script in R to measure looping averageif (like 
 in the excel)
 ...
 for example:
 i have a vector
 rowvalue
 10
 22
 3-3
 4-2
 51
 6-2
 
 i want to measure the average of the vector for negative value with window 
 estimation 5
 so first mean is (-3+-2)/2
  second mean is (-3+-2+-2)/3
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Is there a way to source from a specific Git repository without hardcoding the location everywhere?

2012-09-26 Thread Curt Seeliger
Folks,

A small group of us are working together to develop a set of R functions 
to support data management and analysis using Eclipse/StatET in a Windows 
environment.  We are using Git/EGit for version control. We work within 
our own repository and occasionally push to a common remote location.

I'd like to have the code source files from the 'local' git repository 
without modification, where 'local' could mean c:\yada\ for one person, 
m:\my documents\wetlands\ for another, and l:\foo\bar\sharedRemote\wet\ to 
another user.

The chdir argument to source() has been suggested for similar questions, 
but I have not been able to figure out how this helps without hardcoding 
the location in some manner.

One option is for each repository to have an untracked file which sets the 
local working directory before sourcing another file that actually sources 
the function definitions.  This file (projectStart.r below) would be read 
into the R session prior to use, at least during development.

projectStart.r  # untracked
setwd(c:\yada\)   # or setwd(L:\foo\bar\sharedRemote\wet\) 
-- this is the only difference among repository locations.
source(projectStart2.r)

projectStart2.r # tracked
source(func1.r)
source(func2.r)
source(func3.r)
...

func1.r # tracked

func2.r # tracked

func3.r # tracked

...

Is there an easier or better accepted method?

Thank you for your time,
cur

-- 
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.c...@epa.gov
541/754-4638

[[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] Is there a way to source from a specific Git repository without hardcoding the location everywhere?

2012-09-26 Thread Duncan Murdoch

On 12-09-26 8:25 PM, Curt Seeliger wrote:

Folks,

A small group of us are working together to develop a set of R functions
to support data management and analysis using Eclipse/StatET in a Windows
environment.  We are using Git/EGit for version control. We work within
our own repository and occasionally push to a common remote location.

I'd like to have the code source files from the 'local' git repository
without modification, where 'local' could mean c:\yada\ for one person,
m:\my documents\wetlands\ for another, and l:\foo\bar\sharedRemote\wet\ to
another user.

The chdir argument to source() has been suggested for similar questions,
but I have not been able to figure out how this helps without hardcoding
the location in some manner.

One option is for each repository to have an untracked file which sets the
local working directory before sourcing another file that actually sources
the function definitions.  This file (projectStart.r below) would be read
into the R session prior to use, at least during development.

projectStart.r  # untracked
 setwd(c:\yada\)   # or setwd(L:\foo\bar\sharedRemote\wet\)
-- this is the only difference among repository locations.
 source(projectStart2.r)

projectStart2.r # tracked
 source(func1.r)
 source(func2.r)
 source(func3.r)
 ...

func1.r # tracked

func2.r # tracked

func3.r # tracked

...

Is there an easier or better accepted method?


Yes.  Use

library(myProject)

where myProject is a package containing all the scripts, written as 
functions.


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] Mac Text editors

2012-09-26 Thread Steven Wolf
Hi everyone,

I've recently moved from using a windows machine to a Mac (some might call it 
an upgrade, others not…I'll let you be the judge).  Once I started using 
Notepad ++ on my windows machine, I really began to like it.  Unfortunately, 
I'm not sure what the free text editor options are for the Mac (Notepad ++ is 
windows only).  I've dabbled with Linux before and used Emacs/ESS there.  
However, I seem to remember fighting pretty hard to make that work and the OSX 
file structure isn't that intuitive to me yet.  (For example, where is my 
.emacs file?)  

What text editors are best for the Mac, keeping in mind that I'm probably going 
to use them via the command line interface (e.g. X11 or Terminal).

Thanks!
-Steve

___
Steven Wolf
Research Associate
CREATE for STEM Institute
115 H Erickson Hall
Michigan State University

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


Re: [R] Is there a way to source from a specific Git repository without hardcoding the location everywhere?

2012-09-26 Thread Curt Seeliger
Duncan Murdoch murdoch.dun...@gmail.com wrote on 09/26/2012 05:35:00 PM:
  ...
  I'd like to have the code source files from the 'local' git repository
  without modification, where 'local' could mean c:\yada\ for one 
person,
  m:\my documents\wetlands\ for another, and 
l:\foo\bar\sharedRemote\wet\ to
  another user.
  ...
 
 Yes.  Use
 
 library(myProject)
 
 where myProject is a package containing all the scripts, written as 
 functions.

Yes, the eventual fate of these functions is expected to be a package. I'd 
like the pushed/pulled code to be runable as is without an intermediate 
step of package creation or gsub()ing hardcoded paths.

Thanks for the quick reply,
cur

-- 
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.c...@epa.gov
541/754-4638

[[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] Comparing density plots using same axes or same axes scale

2012-09-26 Thread Meredith Ballard LaBeau
Good Evening-
  I have a set of nine scenarios I want to plot to see how the distribution
is changing, if one tail is getting larger in certain scenario, currently I
am using this code


colnames-dimnames(sag_pdfs)[[2]]

par(mfrow=c(3,3))

for(i in 1:9) {

d-density(sag[,i])

plot(d,type=n, main=colnames[i])

polygon(d,col=red,border=grey)}

where sag is a 7305x9 double matrix and 9 different scenarios. I want to be
able to compare the distribution using the same axes scale.
Can anyone help?

Thanks
Meredith LaBeau

-- 
Doctoral Candidate
Department of Civil and Environmental Engineering
Michigan Technological 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] Mac Text editors

2012-09-26 Thread Albyn Jones

Have you looked at aquamacs? (emacs for the mac).
its at aquamacs.org.

albyn

On 2012-09-26 17:48, Steven Wolf wrote:

Hi everyone,

I've recently moved from using a windows machine to a Mac (some might
call it an upgrade, others not…I'll let you be the judge).  Once I
started using Notepad ++ on my windows machine, I really began to 
like
it.  Unfortunately, I'm not sure what the free text editor options 
are

for the Mac (Notepad ++ is windows only).  I've dabbled with Linux
before and used Emacs/ESS there.  However, I seem to remember 
fighting

pretty hard to make that work and the OSX file structure isn't that
intuitive to me yet.  (For example, where is my .emacs file?)

What text editors are best for the Mac, keeping in mind that I'm
probably going to use them via the command line interface (e.g. X11 
or

Terminal).

Thanks!
-Steve

___
Steven Wolf
Research Associate
CREATE for STEM Institute
115 H Erickson Hall
Michigan State University

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

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


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


Re: [R] Mac Text editors

2012-09-26 Thread David Winsemius

On Sep 26, 2012, at 5:48 PM, Steven Wolf wrote:

 Hi everyone,
 
 I've recently moved from using a windows machine to a Mac (some might call it 
 an upgrade, others not…I'll let you be the judge).  Once I started using 
 Notepad ++ on my windows machine, I really began to like it.  Unfortunately, 
 I'm not sure what the free text editor options are for the Mac (Notepad ++ is 
 windows only).  I've dabbled with Linux before and used Emacs/ESS there.  
 However, I seem to remember fighting pretty hard to make that work and the 
 OSX file structure isn't that intuitive to me yet.  (For example, where is my 
 .emacs file?)  
 
 What text editors are best for the Mac, keeping in mind that I'm probably 
 going to use them via the command line interface (e.g. X11 or Terminal).

Probably best in the future to post to R-SIG-Mac.

The editor in the Mac-GUI works well. Has parenthesis, bracket and ellipsis 
matching which is very helpful. Also tab-completion thanks to the continuing 
effors to Simon Urbanek and Hans-Joerg Bibiko and probably others whose 
contributions are too subtle for for my aging brane. You can also get 
R-specific macro behaviors with TextWrangler. The default editor defined by 
options() is vi which has many powerful features as well. (I do not think I 
am interacting with 'vi' inside the editing panels that pop up from the GUI, 
although I would be happy to be corrected on this point.) Emacs is a UNIX 
standard and the Mac is yet-another-Unix-boxen.

Many Mac users are also happy with R-Studio.

-- 

David Winsemius, MD
Alameda, CA, USA

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


[R] Random Forest - Extract

2012-09-26 Thread Lopez, Dan
Hello,

I have two Random Forest (RF) related questions.


1.   How do I view the classifications for the detail data of my training 
data (aka trainset) that I used to build the model? I know there is an object 
called predicted which I believe is a vector. To view the detail for my testset 
I use the below-bind the columns together. I was trying to do something similar 
for my trainset  but without putting it through the predict function. Instead 
taking directly from the randomForest which I stored in FOREST_model. I really 
need to get to this information to do some comparison of certain cases.

RF_DTL-cbind(testset,predict(FOREST_model, testset, type=response))



2.   In the RF model in R the predict function has three possible 
arguments: response, vote or prob. I noticed vote and prob are 
identical for all records in my data set. Is this typical? If so then what is 
the point of having these two arguments? Ease of use?

Dan


[[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] Mac Text editors

2012-09-26 Thread David Winsemius

On Sep 26, 2012, at 5:48 PM, Steven Wolf wrote:

 Hi everyone,
 
 I've recently moved from using a windows machine to a Mac (some might call it 
 an upgrade, others not…I'll let you be the judge).  Once I started using 
 Notepad ++ on my windows machine, I really began to like it.  Unfortunately, 
 I'm not sure what the free text editor options are for the Mac (Notepad ++ is 
 windows only).  I've dabbled with Linux before and used Emacs/ESS there.  
 However, I seem to remember fighting pretty hard to make that work and the 
 OSX file structure isn't that intuitive to me yet.  (For example, where is my 
 .emacs file?)  

Further point. Just as with Windoze, your dot-files are hidden by Finder.app. 
You can see them with terminal or do as I do and unhide them (and never trash 
any).

Run this in a terminal session:

defaults write com.apple.Finder AppleShowAllFiles YES


# and pt-click-hold on Dock-Finder-icon, choose relaunch


 
 What text editors are best for the Mac, keeping in mind that I'm probably 
 going to use them via the command line interface (e.g. X11 or Terminal).
 
 Thanks!
 -Steve
 
 ___
 Steven Wolf
 Research Associate
 CREATE for STEM Institute
 115 H Erickson Hall
 Michigan State University
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Alameda, CA, USA

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


Re: [R] Comparing density plots using same axes or same axes scale

2012-09-26 Thread Rui Barradas

Hello,

Something like this?

sag - matrix(rnorm(1e3 * 9), ncol = 9)

d.list - apply(sag, 2, density)
xrange - range(sapply(d.list, function(d) range(d$x)))
ymax - max(sapply(d.list, function(d) max(d$y)))

op - par(mfrow=c(3,3))
for(i in 1:9)
plot(d.list[[i]], xlim = xrange, ylim = c(0, ymax))
par(op)


Hope this helps,

Rui Barradas
Em 27-09-2012 01:53, Meredith Ballard LaBeau escreveu:

Good Evening-
   I have a set of nine scenarios I want to plot to see how the distribution
is changing, if one tail is getting larger in certain scenario, currently I
am using this code


colnames-dimnames(sag_pdfs)[[2]]

par(mfrow=c(3,3))

for(i in 1:9) {

d-density(sag[,i])

plot(d,type=n, main=colnames[i])

polygon(d,col=red,border=grey)}

where sag is a 7305x9 double matrix and 9 different scenarios. I want to be
able to compare the distribution using the same axes scale.
Can anyone help?

Thanks
Meredith LaBeau



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


Re: [R] Mac Text editors

2012-09-26 Thread David Winsemius

On Sep 26, 2012, at 6:06 PM, David Winsemius wrote:

 
 On Sep 26, 2012, at 5:48 PM, Steven Wolf wrote:
 
 Hi everyone,
 
 I've recently moved from using a windows machine to a Mac (some might call 
 it an upgrade, others not…I'll let you be the judge).  Once I started using 
 Notepad ++ on my windows machine, I really began to like it.  Unfortunately, 
 I'm not sure what the free text editor options are for the Mac (Notepad ++ 
 is windows only).  I've dabbled with Linux before and used Emacs/ESS there.  
 However, I seem to remember fighting pretty hard to make that work and the 
 OSX file structure isn't that intuitive to me yet.  (For example, where is 
 my .emacs file?)  
 
 Further point. Just as with Windoze, your dot-files are hidden by Finder.app. 
 You can see them with terminal or do as I do and unhide them (and never trash 
 any).
 
 Run this in a terminal session:
 
 defaults write com.apple.Finder AppleShowAllFiles YES

Sorry. I do not know how to relaunch in Snow Leopard. Those direction for 
relaunching Finder.app worked in Leopard but when I just checked, no longer 
seem to.
 
 
 # and pt-click-hold on Dock-Finder-icon, choose relaunch
 
 
 
 What text editors are best for the Mac, keeping in mind that I'm probably 
 going to use them via the command line interface (e.g. X11 or Terminal).
 
 Thanks!
 -Steve
 
 ___
 Steven Wolf
 Research Associate
 CREATE for STEM Institute
 115 H Erickson Hall
 Michigan State University
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 David Winsemius, MD
 Alameda, CA, USA
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Alameda, CA, USA

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


Re: [R] Comparing density plots using same axes or same axes scale

2012-09-26 Thread Rui Barradas

Hello, again.

I forgot, but the subject line also says same axes, not just same axes 
scale.

If you want all densities on the same graph, use ?matplot (matrix plot).

Rui Barradas
Em 27-09-2012 02:08, Rui Barradas escreveu:

Hello,

Something like this?

sag - matrix(rnorm(1e3 * 9), ncol = 9)

d.list - apply(sag, 2, density)
xrange - range(sapply(d.list, function(d) range(d$x)))
ymax - max(sapply(d.list, function(d) max(d$y)))

op - par(mfrow=c(3,3))
for(i in 1:9)
plot(d.list[[i]], xlim = xrange, ylim = c(0, ymax))
par(op)


Hope this helps,

Rui Barradas
Em 27-09-2012 01:53, Meredith Ballard LaBeau escreveu:

Good Evening-
   I have a set of nine scenarios I want to plot to see how the 
distribution
is changing, if one tail is getting larger in certain scenario, 
currently I

am using this code


colnames-dimnames(sag_pdfs)[[2]]

par(mfrow=c(3,3))

for(i in 1:9) {

d-density(sag[,i])

plot(d,type=n, main=colnames[i])

polygon(d,col=red,border=grey)}

where sag is a 7305x9 double matrix and 9 different scenarios. I want 
to be

able to compare the distribution using the same axes scale.
Can anyone help?

Thanks
Meredith LaBeau



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

2012-09-26 Thread Bhupendrasinh Thakre
My vote for R-Studio. Very elegant design and great functionality. However if 
coming from languages like Java and others then eclipse is better. R-Studio 
have dedicated section for Mac user which you will find useful.



Best Regards,

Bhupendrasinh Thakre
Sent from my iPhone

On Sep 26, 2012, at 7:48 PM, Steven Wolf wolfs...@msu.edu wrote:

 Hi everyone,
 
 I've recently moved from using a windows machine to a Mac (some might call it 
 an upgrade, others not…I'll let you be the judge).  Once I started using 
 Notepad ++ on my windows machine, I really began to like it.  Unfortunately, 
 I'm not sure what the free text editor options are for the Mac (Notepad ++ is 
 windows only).  I've dabbled with Linux before and used Emacs/ESS there.  
 However, I seem to remember fighting pretty hard to make that work and the 
 OSX file structure isn't that intuitive to me yet.  (For example, where is my 
 .emacs file?)  
 
 What text editors are best for the Mac, keeping in mind that I'm probably 
 going to use them via the command line interface (e.g. X11 or Terminal).
 
 Thanks!
 -Steve
 
 ___
 Steven Wolf
 Research Associate
 CREATE for STEM Institute
 115 H Erickson Hall
 Michigan State University
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


  1   2   >