[R] read htm table error

2012-08-09 Thread Lay, Kiung

Hi I am using Version R 2.15 and I haven't been able read html table. Following 
is my code and error message.
Error in htmlParse(doc) :
  error in creating parser for 
http://en.wikipedia.org/wiki/Brazil_national_football_team

theurl <- "http://en.wikipedia.org/wiki/Brazil_national_football_team";
 tables <- readHTMLTable(theurl)

Regards,
Kiung

[[alternative HTML version deleted]]

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


[R] Using unicode symbol has unexpected results in levels of factor object

2012-08-09 Thread Wyatt, Kristin M
Dear all,

When I use a unicode symbol in the labels for a factor object, the 
corresponding level does not display as expected. However, using levels() on 
the factor returns the desired output. I noticed the discrepancy when the 
legend labels from a call to ggplot() did not display the desired symbol, but 
an explicitly built legend using the same labels did. 

Example (I am trying to get the less than or equal to symbol): 

> .df <- data.frame(afp = c(0,0,1,1), time=c(0,2,0,1), surv=c(1, 0.5, 1, 0.4))
> afpLabels <- c("AFP \u2264 16", "AFP > 16")
> afpStrata <- factor(.df$afp, labels=afpLabels)
> afpStrata
[1] AFP ? 16 AFP ? 16 AFP > 16 AFP > 16
Levels: AFP = 16 AFP > 16

The first level is reported as "AFP = 16".

> levels(afpStrata)
[1] "AFP ? 16" "AFP > 16"
> 

The desired result is produced with levels().


The code below shows this issue in context through calls to ggplot() if you 
don't mind loading all the libraries.

> library(ggplot2)
> library(gridExtra)
> library(plyr)
> 
> ggplot(.df, aes(time, surv)) + geom_step(aes(color = afpStrata), size = 1.0)  
> 
> ggplot(.df, aes(time, surv)) + geom_step(aes(color = afpStrata), size = 1.0)  
> +  
+ scale_colour_hue(breaks=afpLabels, labels=afpLabels)
> 

I am running a pre-compiled version of R on Windows 7 (64-bit).
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C  
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] plyr_1.7.1gridExtra_0.9 ggplot2_0.9.1

loaded via a namespace (and not attached):
 [1] colorspace_1.1-1   dichromat_1.2-4digest_0.5.2   labeling_0.1  
 [5] MASS_7.3-18memoise_0.1munsell_0.3proto_0.3-9.2 
 [9] RColorBrewer_1.0-5 reshape2_1.2.1 scales_0.2.1   stringr_0.6.1 
[13] tools_2.15.1  
> 

Sincerely,
Kristin Berry

[[alternative HTML version deleted]]

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


[R] How to draw clock in R ?

2012-08-09 Thread Manish Gupta
0 down vote favorite


I am working on R and trying to draw a clock using a pie chart.

code:

pie(c(25,20,15,10,10,30),labels = c(1,2,3,4,5,6,7,8,9,10,11,12),
col=rainbow(length(lbls)), clockwise = TRUE, init.angle = 90)

but i need all 12 labels to be there independent of no of segments in input. 

http://r.789695.n4.nabble.com/file/n4639721/Screenshot-7.png 

How can i implement it?



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

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


[R] How to overlap pie chart with same radius?

2012-08-09 Thread Manish Gupta
Hi,

i am overlapping 2pie chart with same radius.

1. with labels 
2. without labels.

Output 
pie chart 2 with label of first. 


http://r.789695.n4.nabble.com/file/n4639723/Ist_Pie.png 

http://r.789695.n4.nabble.com/file/n4639723/IInd_Oie.png 


output:

http://r.789695.n4.nabble.com/file/n4639723/Screenshot-7.png 


How can i implement it?

Regards



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-overlap-pie-chart-with-same-radius-tp4639723.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] help to program my function

2012-08-09 Thread Petr PIKAL
I am not allowed to connect to Nabble from work, sorry.

Petr

> 
> hi peter the pdf folder is in
>  http://r.789695.n4.nabble.com/file/n4639434/aj.pdf
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/help-to-
> program-my-function-tp4639434p4639629.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] NADA Package: Referencing Data Frame Columns

2012-08-09 Thread Petr PIKAL
Hi

> 
> > Specifically, since it has only a single detection indicator column
> > (ceneq1), it implies that within any single sample either all the 
analytes
> > were detected, or all were not. Not what I would expect.
> 
> Don,
> 
>I have been thinking about this and wondered whether the cast format 
was
> appropriate just for the reason there's only a single censored 
indicator.
> I'm glad you confirmed this as the/one problem.
> 
> > As to your larger question of which layout is appropriate for use with
> > NADA functions, the answer is that either can be used. The "trick" is 
to
> > use the appropriate syntax to extract the values needed to pass the 
data
> > to a NADA function.
> 
>And I've not discovered this in the time I spent trying different 
syntax.
> 
> > For the long format you subset the rows, then pass the appropriate
> > columns. Here's one way:
> >
> >   with(subset(chem, param=='AgDis') , ros(quant,ceneq1))
> 
>This makes a lot of sense. I was thinking that I needed to create 
separate
> data frames for each parameter but subsetting on the fly is much more
> efficient and elegant.
> 
> > Hope this helps.
> 
>It certainly does! Thanks.
> 
> > (p.s., I still think you'll be better off in the long run if you store
> > site, param, and maybe era, as character objects, not factors.)
> 
>I need to research this because I thought that factors were character
> objects used to partition quantities into groups.

It is partly a matter of opinion. I personally prefer factors as they 
seems to me handier.

> a<-sample(letters[1:5], 20, replace=T)
> a
 [1] "c" "e" "c" "d" "c" "d" "b" "d" "d" "d" "b" "a" "d" "b" "c" "e" "e" 
"c" "c"
[20] "c"

Suppose I want to change all "c" and "b" to "f"

> a.f<-as.factor(a)
> a.f
 [1] c e c d c d b d d d b a d b c e e c c c
Levels: a b c d e
> levels(a.f)
[1] "a" "b" "c" "d" "e"

 In factors I can only change appropriate levels.

> levels(a.f)[2:3]<-"f"
> a.f
 [1] f e f d f d f d d d f a d f f e e f f f
Levels: a f d e

Regards
Petr




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

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


Re: [R] help, please! matrix operations inside 3 nested loops

2012-08-09 Thread Fridolin
thank you for your help.

my input data looks like this (tab separated):

Ind.nr. Pop.nr. scm266  rms1280 scm247  rms1107
1   101 305 318 222 135
1   101 305 318 231 135
2   101 305 313 999 96
2   101 305 321 999 130
3   101 305 324 231 135
3   101 305 324 231 135
4   101 305 313 230 126
4   101 305 313 230 135
6   101 305 313 231 135
6   101 305 321 231 135

it is a dataset with genetic marker alleles for single individuals. 
the first row is the header, all following rows are individuals. 2 rows
count for 1 individual.
first colum is the individual's number, second colum is the number for the
population the individual comes from, and all following colums are different
genetic markers.

what i want to do with this data in R, is to compare one individual with
each of the other individuals, allele-wise. there are five possibilities:
the two compared individuals share 4,3,2,1,0 alleles of the currently
examined marker (=colum). for each shared allele this pair of individuals
shall get 1 scoring point. for each pair of individuals, all scoring points
shall be summarized over all markers.


my code again, modified according to your suggestions:

#1) read in data:
daten<-read.table('K:/Analysen/STRUCTURE/test.txt', header=TRUE, sep="\t")
daten<-as.data.frame(daten)

#2) create empty matrix:
indxind<-matrix(0,nrow=617, ncol=617) 
indxind[1:20,1:19]

#3) compare cells to each other, score:
#for the whole dataset: s in 3:34, z1 in 1:617, z2 in 1:617
for (s in 3:6) {   #walks though the matrix colum by colum, starting at
colum 3
  for (z1 in 1:6) {  #for each current colum, take one row (z1)...
for (z2 in 1:6) {  #...and compare it to another row (z2) of the current
colum
  if (z1!=z2) {topf<-indxind[z1,z2]
   if (daten[2*z1-1,s]==daten[2*z2-1,s]) topf<-topf+1  
#actually, 2 rows make up 1 individual,
   if (daten[2*z1-1,s]==daten[2*z2,s]) topf<-topf+1 
#therefore i compare 2 rows
   if (daten[2*z1,s]==daten[2*z2-1,s]) topf<-topf+1 
#with another 2 rows
   if (daten[2*z1,s]==daten[2*z2,s]) topf<-topf+1
   indxind[z1,z2]<-topf
   indxind[z2,z1]<-topf
  }
  #print(c(s,z1,z2,indxind[1,2])) ##counts s, z1 and z2 properly, but
gives always 8 for indxind[1,2]
}
#indxind[1:5,1:5] #empty matrix
  }
  #indxind[1:5,1:5] #empty matrix
}

#4) check:
indxind[1:5,1:5]



@ Michael Weylandt: i've done my best with regard to the "big picture" of my
algorithm and the small reproducible example. i hope both is sufficient.
@ Petr Pikal-3: in this case, there are only numerical values, but it's a
useful hint for my other codes.
@ Petr Pikal-3 and Berend Hasselman: initializing indxind with 0's instead
of NAs helps, it fills something in indxind now. but it does the calculation
only for the first marker (colum 3), afterwards i get an error: 
Fehler in if (daten[2 * z1 - 1, s] == daten[2 * z2 - 1, s]) topf <- topf + 
: 
  Fehlender Wert, wo TRUE/FALSE nötig ist
Error in if (daten[2 * z1 - 1, s] == daten[2 * z2 - 1, s]) topf <- topf +  :
  Missing value, where TRUE/FAlse is required
Has this something to do with the changing to daten<-as.data.frame(daten) in
line 3 (instead of as.matrix before)?



--
View this message in context: 
http://r.789695.n4.nabble.com/help-please-matrix-operations-inside-3-nested-loops-tp4639592p4639730.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to draw clock in R ?

2012-08-09 Thread Jim Lemon

On 08/09/2012 03:43 PM, Manish Gupta wrote:

0 down vote favorite


I am working on R and trying to draw a clock using a pie chart.

code:

pie(c(25,20,15,10,10,30),labels = c(1,2,3,4,5,6,7,8,9,10,11,12),
col=rainbow(length(lbls)), clockwise = TRUE, init.angle = 90)

but i need all 12 labels to be there independent of no of segments in input.

http://r.789695.n4.nabble.com/file/n4639721/Screenshot-7.png

How can i implement it?


Hi Manish,

library(plotrix)
pie(c(25,20,15,10,10,30))
floating.pie(0,0,c(25,20,15,10,10,30))
pie.labels(0,0,seq(0,23*pi/12,by=pi/6),c(3:1,12:4),
 radius=1.1,border=NA)

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] Using unicode symbol has unexpected results in levels of factor object

2012-08-09 Thread peter dalgaard

On Aug 9, 2012, at 06:53 , Wyatt, Kristin M wrote:

> Dear all,
> 
> When I use a unicode symbol in the labels for a factor object, the 
> corresponding level does not display as expected. However, using levels() on 
> the factor returns the desired output. I noticed the discrepancy when the 
> legend labels from a call to ggplot() did not display the desired symbol, but 
> an explicitly built legend using the same labels did. 
> 
> Example (I am trying to get the less than or equal to symbol): 
> 
>> .df <- data.frame(afp = c(0,0,1,1), time=c(0,2,0,1), surv=c(1, 0.5, 1, 0.4))
>> afpLabels <- c("AFP \u2264 16", "AFP > 16")
>> afpStrata <- factor(.df$afp, labels=afpLabels)
>> afpStrata
> [1] AFP ? 16 AFP ? 16 AFP > 16 AFP > 16
> Levels: AFP = 16 AFP > 16
> 
> The first level is reported as "AFP = 16".
> 
>> levels(afpStrata)
> [1] "AFP ? 16" "AFP > 16"
>> 
> 
> The desired result is produced with levels().
> 
> 
> The code below shows this issue in context through calls to ggplot() if you 
> don't mind loading all the libraries.
> 
>> library(ggplot2)
>> library(gridExtra)
>> library(plyr)
>> 
>> ggplot(.df, aes(time, surv)) + geom_step(aes(color = afpStrata), size = 1.0) 
>>  
>> 
>> ggplot(.df, aes(time, surv)) + geom_step(aes(color = afpStrata), size = 1.0) 
>>  +  
> + scale_colour_hue(breaks=afpLabels, labels=afpLabels)
>> 
> 
> I am running a pre-compiled version of R on Windows 7 (64-bit).
>> sessionInfo()
> R version 2.15.1 (2012-06-22)
> Platform: x86_64-pc-mingw32/x64 (64-bit)

For whatever it is worth, this works fine (both examples) under OSX Snow 
Leopard.

Looking at the code for print.factor, I would strongly suspect that the culprit 
is the line 

n <- length(lev <- encodeString(levels(x), quote = ifelse(quote, 
"\"", "")))

which figures since you are in a .1252 locale, not .utf8 (or UTF-8 or ...). 

Over to the Windows/locale/charset experts...

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

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


[R] Zoo object problem: problem when I attempt to create a zoo object of only one column

2012-08-09 Thread jpm miao
Hi,

   Part of my program is to calculate the number of time series in a zoo
object. It works well if it has more than one time series, but it fails if
it has only one. How can I access the number of column (i.e. the number of
time series) when I have only one column? Why is the number of an object of
only one object "NULL"? It should be one, shouldn't it? (The following
example does not involve the creation of a zoo object; in reality, similar
problems are encountered when I create a zoo object)

> temp5<-read.csv("A_Consumption.csv", header=TRUE)> temp5[1:3,]TIME C  
> C_D  C_ND
1 196101 70345 1051 69294
2 196102 61738  905 60833
3 196103 63838  860 62978> temp6<-temp5[,2:ncol(temp5)]> temp6[1:3,]
   C  C_D  C_ND
1 70345 1051 69294
2 61738  905 60833
3 63838  860 62978> colnames(temp6)[1] "C""C_D"  "C_ND">
temp7<-read.csv("A_FX_EUR_Q.csv", header=TRUE)> temp7[1:3,]TIME
 EUR
1 198001 1.41112
2 198002 1.39108
3 198003 1.42323> temp8<-temp7[,2:ncol(temp7)]> temp8[1:3,]Error in
temp8[1:3, ] : incorrect number of dimensions

> ncol(temp6)[1] 3> ncol(temp8)   # Why isn't it 1?NULL

> temp8  [1] 1.411120 1.391080 1.423230 1.342050 1.232870
  [6] 1.115090 1.032930 1.089250 1.036320 1.001850
 [11] 0.950641 0.933593 0.947940 0.911204 0.860682
 [16] 0.843864 0.831666 0.824776 0.768626 0.732064
 [21] 0.684473 0.726018 0.784729 0.852911 0.922885
 [26] 0.958778 1.012740 1.038160 1.124550 1.149780
 [31] 1.128450 1.214120 1.233530 1.216270 1.113620
 [36] 1.170250 1.126230 1.074330 1.078480 1.127870
 [41] 1.205540 1.222740 1.296500 1.366550 1.341280
 [46] 1.187600 1.176790 1.254490 1.262610 1.271820
 [51] 1.385930 1.268130 1.190480 1.206840 1.150270
 [56] 1.140010 1.125200 1.163450 1.226830 1.240210
 [61] 1.273300 1.331010 1.312420 1.317350 1.287330
 [66] 1.254500 1.274210 1.261930 1.178970 1.143500
 [71] 1.093320 1.123400 1.086770 1.100380 1.117670
 [76] 1.176960 1.121600 1.056900 1.048600 1.038000
 [81] 0.986500 0.933200 0.905200 0.868300 0.923200
 [86] 0.872500 0.890300 0.895900 0.876600 0.918800
 [91] 0.983800 0.999400 1.073100 1.137200 1.124800
 [96] 1.189000 1.249700 1.204600 1.222000 1.297700
[101] 1.311300 1.259400 1.219900 1.188400 1.202300
[106] 1.258200 1.274300 1.288700 1.310600 1.348100
[111] 1.373800 1.448600 1.497600 1.562200 1.505000
[116] 1.318000 1.302900 1.363200 1.430300 1.477900
[121] 1.382900 1.270800 1.291000 1.358300 1.368000
[126] 1.439100 1.412700 1.348200 1.310800 1.281400

[[alternative HTML version deleted]]

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


Re: [R] How to overlap pie chart with same radius?

2012-08-09 Thread Jim Lemon

On 08/09/2012 04:28 PM, Manish Gupta wrote:

Hi,

i am overlapping 2pie chart with same radius.

1. with labels
2. without labels.

Output
pie chart 2 with label of first.


http://r.789695.n4.nabble.com/file/n4639723/Ist_Pie.png

http://r.789695.n4.nabble.com/file/n4639723/IInd_Oie.png


output:

http://r.789695.n4.nabble.com/file/n4639723/Screenshot-7.png


How can i implement it?


Hi Manish,
Use floating.pie for the second pie chart.

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] R versus SAS

2012-08-09 Thread Rolf Turner

On 09/08/12 14:35, Yihui Xie wrote:

The Department of Redundancy Department can "recompensate"...


Ye :-)

cheers,

Rolf

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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, please! matrix operations inside 3 nested loops

2012-08-09 Thread Fridolin
SORRY it should be:


Fridolin wrote
> 
> for (s in 3:6) {   #walks though the matrix colum by colum, starting at
> colum 3
>   for (z1 in 1:5) {  #for each current colum, take one row (z1)...
> for (z2 in 1:5) {  #...and compare it to another row (z2) of the
> current colum
> 

error is gone now SORRY!!!



--
View this message in context: 
http://r.789695.n4.nabble.com/help-please-matrix-operations-inside-3-nested-loops-tp4639592p4639735.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] decimal points midline

2012-08-09 Thread Jim Lemon

On 08/09/2012 04:52 AM, array chip wrote:

Hi, does anyone know how to make decimal points midline when plotting? The 
journal to which we are going to submit a manuscript require this particular 
formatting, and it gives direction how to do this on PC: hold down ALT key and 
type 0183 on the number pad


Hi John,
The decimal.align function in the prettyR package might do what you want.

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] Zoo object problem: problem when I attempt to create a zoo object of only one column

2012-08-09 Thread Achim Zeileis

On Thu, 9 Aug 2012, jpm miao wrote:


Hi,

  Part of my program is to calculate the number of time series in a zoo
object. It works well if it has more than one time series, but it fails if
it has only one. How can I access the number of column (i.e. the number of
time series) when I have only one column? Why is the number of an object of
only one object "NULL"? It should be one, shouldn't it? (The following
example does not involve the creation of a zoo object; in reality, similar
problems are encountered when I create a zoo object)


Univariate zoo series are by default vectors, i.e., have no "dim" 
attribute. You can either choose to store a matrix instead of a vector in 
the zoo series - or you can use NCOL() instead of ncol() to extract the 
number of columns. See the corresponding manual pages for more details. An 
illustration is included below:


## univariate series

R> x <- sin(1:4)
R> z <- zoo(x)
R> z
 1  2  3  4
 0.8414710  0.9092974  0.1411200 -0.7568025
R> dim(z)
NULL
R> ncol(z)
NULL
R> NCOL(z)
[1] 1

## alternatives to create a 1-column matrix instead of a vector

R> z1 <- zoo(matrix(x, ncol = 1))
R> z1

1  0.8414710
2  0.9092974
3  0.1411200
4 -0.7568025
R> dim(z1)
[1] 4 1

R> dim(z) <- c(NROW(z), NCOL(z))
R> z

1  0.8414710
2  0.9092974
3  0.1411200
4 -0.7568025
R> dim(z)
[1] 4 1



temp5<-read.csv("A_Consumption.csv", header=TRUE)> temp5[1:3,]TIME C  
C_D  C_ND

1 196101 70345 1051 69294
2 196102 61738  905 60833
3 196103 63838  860 62978> temp6<-temp5[,2:ncol(temp5)]> temp6[1:3,]
  C  C_D  C_ND
1 70345 1051 69294
2 61738  905 60833
3 63838  860 62978> colnames(temp6)[1] "C""C_D"  "C_ND">
temp7<-read.csv("A_FX_EUR_Q.csv", header=TRUE)> temp7[1:3,]TIME
EUR
1 198001 1.41112
2 198002 1.39108
3 198003 1.42323> temp8<-temp7[,2:ncol(temp7)]> temp8[1:3,]Error in
temp8[1:3, ] : incorrect number of dimensions


ncol(temp6)[1] 3> ncol(temp8)   # Why isn't it 1?NULL



temp8  [1] 1.411120 1.391080 1.423230 1.342050 1.232870

 [6] 1.115090 1.032930 1.089250 1.036320 1.001850
[11] 0.950641 0.933593 0.947940 0.911204 0.860682
[16] 0.843864 0.831666 0.824776 0.768626 0.732064
[21] 0.684473 0.726018 0.784729 0.852911 0.922885
[26] 0.958778 1.012740 1.038160 1.124550 1.149780
[31] 1.128450 1.214120 1.233530 1.216270 1.113620
[36] 1.170250 1.126230 1.074330 1.078480 1.127870
[41] 1.205540 1.222740 1.296500 1.366550 1.341280
[46] 1.187600 1.176790 1.254490 1.262610 1.271820
[51] 1.385930 1.268130 1.190480 1.206840 1.150270
[56] 1.140010 1.125200 1.163450 1.226830 1.240210
[61] 1.273300 1.331010 1.312420 1.317350 1.287330
[66] 1.254500 1.274210 1.261930 1.178970 1.143500
[71] 1.093320 1.123400 1.086770 1.100380 1.117670
[76] 1.176960 1.121600 1.056900 1.048600 1.038000
[81] 0.986500 0.933200 0.905200 0.868300 0.923200
[86] 0.872500 0.890300 0.895900 0.876600 0.918800
[91] 0.983800 0.999400 1.073100 1.137200 1.124800
[96] 1.189000 1.249700 1.204600 1.222000 1.297700
[101] 1.311300 1.259400 1.219900 1.188400 1.202300
[106] 1.258200 1.274300 1.288700 1.310600 1.348100
[111] 1.373800 1.448600 1.497600 1.562200 1.505000
[116] 1.318000 1.302900 1.363200 1.430300 1.477900
[121] 1.382900 1.270800 1.291000 1.358300 1.368000
[126] 1.439100 1.412700 1.348200 1.310800 1.281400

[[alternative HTML version deleted]]

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



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


Re: [R] R versus SAS

2012-08-09 Thread Jim Lemon

On 08/09/2012 07:17 AM, Rolf Turner wrote:

...
P. S. There is no such word as "recompensate".

Thanks to R, the internet and pretentious, semi-literate public servants 
around the world, there probably is now.


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] Calculating percentages across multiple columns

2012-08-09 Thread Rui Barradas

Hello,

If I understand it well, the following should do it.


dd <- subset(f, sold == 1)
at <- with(dd, bid == purchase)
mean(at)  # wanted value

Hope this helps,

Rui Barradas

Em 09-08-2012 01:52, Daisy Englert Duursma escreveu:

Your question is very unclear.Can you provide a better question or at
least a column of outputs you expect and an example with the dataframe
you provided?

On Thu, Aug 9, 2012 at 8:29 AM, Abraham Mathew  wrote:

I have the following data and am trying to find the percentage of bid
values purchased for that price.

So let's say I have a bid of 5 and it's sold 2 times for $3 and $5. Since
the original bid was $5, the
percentage of times that that bid value results in a sold purchase AT that
specific bid level was
1/3 because of the three time where the bid was three, it ended up being
sold for $5 one time.

So I'm wonder how to generate that info in R. The percentage of a bid being
sold at the same purchase
price. Can anyone point me in the right direction.

f = data.frame(bid=c(3,5,5,8,3,5,4,2,3,5), purchase=c(6,3,4,5,5,5,6,2,3,7),
sold=c(0,1,0,0,0,1,1,0,0,1))
f


Thanks.


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


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


Re: [R] help, please! matrix operations inside 3 nested loops

2012-08-09 Thread Fridolin
all problems solved. thank you for your help!
for the sake of completeness, here my solution:
#1) read in data:
daten<-read.table('K:/Analysen/STRUCTURE/test.txt', header=TRUE, sep="\t")
daten<-as.data.frame(daten)

#2) create empty matrix:
indxind<-matrix(0,nrow=617, ncol=617) 
#indxind[1:20,1:19]

#3) compare cells to each other, score:
#for the whole dataset: s in 3:34, z1 in 1:617, z2 in 1:617
z1<-1 #running variable for rows in daten
z2<-1 #running variable for rows in daten
l1<-1 #running variable for rows in indxind
l2<-1 #running variable for rows in indxind
for (s in 3:6) {   #walks though the matrix colum by colum, starting at
colum 3
while (z1<11) {  #for each current colum, take one row
(z1)...
while (z2<11) {  #...and compare it to
another row (z2) of the current colum
  if (z1!=z2) {
  l1
 
topf<-indxind[l1,l2]
  if
(daten[z1,s]==daten[z2,s]) topf<-topf+1   #actually, 2 rows make up 1
individual,
  if
(daten[z1,s]==daten[z2+1,s]) topf<-topf+1  #therefore i compare 2 rows
  if
(daten[z1+1,s]==daten[z2,s]) topf<-topf+1  #with another 2 rows
  if
(daten[z1+1,s]==daten[z2+1,s]) topf<-topf+1
 
indxind[l1,l2]<-topf
  }
  z2<-z2+2
  l2<-l2+1
  }
z2<-1
l2<-1
z1<-z1+2
l1<-l1+1
  }
z1<-1
l1<-1
   }

#4) check:
indxind[1:5,1:5]



--
View this message in context: 
http://r.789695.n4.nabble.com/help-please-matrix-operations-inside-3-nested-loops-tp4639592p4639744.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] Count not NA cells in RasterStack

2012-08-09 Thread Alexey Ch
Good Day!
I have RasterLayers list with same resolution. (31 items: 720 x 1440) .  I
need to get RasterLayer with  average values without NA value.  How I can
do that?

For example:

We have 3 RasterLayers

1 2  34
2 3 NA  3
NA  1  3NA



1 2 34
2NA  NA  3
NA  1  3NA


1 2  34
NA  3  NA  3
NA  1  3   5


Result Layer is
1   2  3 4
2   3  NA  3
NA 1  3   5

Thnx.

[[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] Installing HDF5 package

2012-08-09 Thread sihemsaad
As Uwe Ligges-3 guessed, i am working on a Windows Station.

I also tried the link Uwe Ligges-3 posted and I think it worked

Thank you all for your answers!



--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-HDF5-package-tp4639633p4639728.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] How does the cm function under package "actuar" works?

2012-08-09 Thread chris123
Dear all, 

I have a question about how the function "cm" works? It can be found under
the package actuar. 
In particular, I want to use it to apply the Buhlmann-Straub model into some
data.

I am using the example that R has in the help page for cm.
I use the dataset hachemeister and then the code:

fit<-cm(~state, hachemeister,
   ratios = ratio.1:ratio.12, weights = weight.1:weight.12)
predict(fit)
summary(fit)

However before knowing the existence of this build-in function I have wrote
my own function, based on an example from a book (I get the same results as
the book) but I dont get the same results as when using the cm function!

Does anybody know how this function works? For example, how does it produce
the weights for the next period? is it random data? 

Thank you in advance!!
Chris





--
View this message in context: 
http://r.789695.n4.nabble.com/How-does-the-cm-function-under-package-actuar-works-tp4639742.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] Accents and special character using hwriter (on Windows)

2012-08-09 Thread ramonovelar
Thanks David, but this is not easy to me as these string are already in my
data (labels, variable strings). Well, I still can make some script to do
it, but it's messy, maybe I want make a Word file (not a html through Word)
after this. When a HTML page has a UTF-8 charset it works ok with characters
such as í or ñ.  It seems that it's a Windows (maybe just Win7) issue. I
will try to find out a bit when I come back to work.




--
View this message in context: 
http://r.789695.n4.nabble.com/Accents-and-special-character-using-hwriter-on-Windows-tp4638474p4639739.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] Treemap lost data

2012-08-09 Thread KingKazma
First: Im sorry for my bad english ;-)

I use "portfolio" to create treemaps with "R". 
I've got a .csv dataset of all the schools in my city, containing 6
variables each with 1469 lines of data. 
When I create a treemap, 3 of these schools were not taken into account by
"R". I dont know why. It doesn't matter where I put them in my dataset, they
won't appear in my treemap. 
When I reduce my dataset to 1000 lines, one of the three schools magically
appear. 
When I reduce my dataset to  500 lines, two of them appear, but not the one
of the "1000-lines-attemp". 
I hope you understand what my problem is.

Patrick



--
View this message in context: 
http://r.789695.n4.nabble.com/Treemap-lost-data-tp4639743.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] Factor moderators in metafor

2012-08-09 Thread John Hodgson
I'm puzzled by the behaviour of factors in rma models, see example and
comments below. I'm sure there's a simple explanation but can't see it... 

Thanks for any input

John Hodgson


- code/selected output -


library(metafor)

##Set up data (from Lenters et al  A Meta-analysis of Asbestos and Lung
Cancer...
##Environmental Health Perspectives • volume 119 | number 11 | November
2011)
 
KL = c(0.02905, 0.06929, -0.1523, 1.6441, 0.1215, 0.3975, 1.0566, 0.1257,
0.2277, 0.06791, 0.08164, 0.2526, 0.07577, 0.03266, 0.1141, 0.1836, 1.8276,
0.4149, 15.4974)
SE = c(0.006633, 0.09335, 0.08909, 0.4297, 0.07858, 0.1753, 0.3679, 0.1837,
0.2172, 0.2775, 0.4201, 0.1976, 0.7688, 0.06507, 0.06239, 0.09061, 0.9509,
0.2181, 7.331)

VL = SE*SE

amph =   c(0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
mix =c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
ftype =  c(0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2) 


factor(amph)
factor(ftype)
factor(mix)

##  Fit ftype...
 
> rma(KL,VL,mods=ftype)


Mixed-Effects Model (k = 19; tau^2 estimator: REML)

tau^2 (estimate of residual amount of heterogeneity): 0.0111 (SE = 0.0095)
tau (sqrt of the estimate of residual heterogeneity): 0.1054

Test for Residual Heterogeneity: 
QE(df = 17) = 43.0937, p-val = 0.0005

Test of Moderators (coefficient(s) 2): 
QM(df = 1) = 1.1069, p-val = 0.2928

Model Results:

 estimate  sezvalpvalci.lb   ci.ub   
intrcpt0.0811  0.0606  1.3380  0.1809  -0.0377  0.2000   
mods   0.0473  0.0449  1.0521  0.2928  -0.0408  0.1353   


Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 


##   why only one df for the 2-level factor?
##   in other words, why isn't the above model the same as the following...


> 
> 
> 
> rma(KL,VL,mods=cbind(amph,mix))

Mixed-Effects Model (k = 19; tau^2 estimator: REML)

tau^2 (estimate of residual amount of heterogeneity): 0.0030 (SE = 0.0046)
tau (sqrt of the estimate of residual heterogeneity): 0.0549

Test for Residual Heterogeneity: 
QE(df = 16) = 37.5762, p-val = 0.0017

Test of Moderators (coefficient(s) 2,3): 
QM(df = 2) = 6.9220, p-val = 0.0314

Model Results:

 estimate  sezvalpvalci.lb   ci.ub   
intrcpt0.0380  0.0402  0.9448  0.3447  -0.0408  0.1169   
amph   0.2879  0.1163  2.4754  0.0133   0.0599  0.5158  *
mix0.0888  0.0625  1.4199  0.1556  -0.0338  0.2114   

---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

> 




--
View this message in context: 
http://r.789695.n4.nabble.com/Factor-moderators-in-metafor-tp4639745.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to draw clock in R ?

2012-08-09 Thread Manish Gupta
Great! It works fine for me. But i have one query. In my clock i have only 10
points so i am using as follows. 

pie(c(25,20,15,10,10,30))
floating.pie(0,0,c(25,20,15,10,10,30))
pie.labels(0,0,seq(0,19*pi/10,by=pi/5),c(3,2,1,0,9,8,7,6,5,4)*10,radius=1.1,border=NA)


But format is not correct. I tried  a lot but 0 always comes in beyond
center.  


http://r.789695.n4.nabble.com/file/n4639746/Untitled.png 



--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-draw-clock-in-R-tp4639721p4639746.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] Ctree plot

2012-08-09 Thread rodrock
HI everybody!

Has anybody figure out how would be possible to plot several ctree plots
beside each other?
I would really appreciate it
 My idea would be like this, but the par() function seem to be lower in
hierarchy
Thanks in advance
#
library(party)

mtree <- ctree(Species ~ ., data=iris)
sep.tree<-ctree(Sepal.Length ~ ., data=iris)

par(mfrow=c(1,2)) # Does not work
plot(mtree) 
plot(sep.tree) 




-
Rodrigo Vargas G.
-
Silviculture Institute
Freiburg University

--
View this message in context: 
http://r.789695.n4.nabble.com/Ctree-plot-tp4639750.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] Kolmogorov distribution

2012-08-09 Thread densur
Please help me to get a function for Kolmogorov distribution.
I've looked through the ks.test code and found that Kolmogorov distribution
is calculating in the following way:

pkstwo <- function(x, tol = 1e-06) {
  if (is.numeric(x))
  x <- as.double(x)
  else stop("argument 'x' must be numeric")
  p <- rep(0, length(x))
  p[is.na(x)] <- NA
  IND <- which(!is.na(x) & (x > 0))
  if (length(IND))
  p[IND] <- .C(C_pkstwo, length(x[IND]), p = x[IND],
as.double(tol), PACKAGE = "stats")$p
  p
  }

but when I am trying  to call, for example, pkstwo(0.8),
R tells me that it could not find 'C_pkstwo' object.

Thank you in advance.



--
View this message in context: 
http://r.789695.n4.nabble.com/Kolmogorov-distribution-tp4639751.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 interpunct (dot) symbol to axis label?

2012-08-09 Thread Duncan Murdoch

On 12-08-08 9:21 PM, Hillary Ward wrote:

I'm having problems creating an axis label for a plot.

y_label = expression(paste(plain('CPUE
'),plain('(fish'),plain('x'),plain('h'^{-1}),plain(')')))

I'd like to replace the "x" with an interpunct symbol (dot). Any
suggestions how to do this?


The interpunct symbol is \u00b7 in Unicode.  You could try that, i.e.

y_label = expression(paste(plain('CPUE
'),plain('(fish'),plain('\u00b7'),plain('h'^{-1}),plain(')')))

It might not work if your graphics device doesn't support Unicode.

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.


Re: [R] How to draw clock in R ?

2012-08-09 Thread Jim Lemon

On 08/09/2012 08:58 PM, Manish Gupta wrote:

Great! It works fine for me. But i have one query. In my clock i have only 10
points so i am using as follows.

pie(c(25,20,15,10,10,30))
floating.pie(0,0,c(25,20,15,10,10,30))
pie.labels(0,0,seq(0,19*pi/10,by=pi/5),c(3,2,1,0,9,8,7,6,5,4)*10,radius=1.1,border=NA)


But format is not correct. I tried  a lot but 0 always comes in beyond
center.


Hi Manish,
As the circumferential positions start at the right side, you will have 
to arrange your angles something like this:


# untested
pie.labels(0,0,seq(pi/10,19*pi/10,by=pi/5),
 c(2,1,0,9,8,7,6,5,4,3)*10,radius=1.1,border=NA)

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] help, please! matrix operations inside 3 nested loops

2012-08-09 Thread Petr PIKAL
Hi

> thank you for your help.
> 
> my input data looks like this (tab separated):
> 
> Ind.nr.   Pop.nr.   scm266   rms1280   scm247   rms1107
> 1   101   305   318   222   135
> 1   101   305   318   231   135
> 2   101   305   313   999   96
> 2   101   305   321   999   130
> 3   101   305   324   231   135
> 3   101   305   324   231   135
> 4   101   305   313   230   126
> 4   101   305   313   230   135
> 6   101   305   313   231   135
> 6   101   305   321   231   135

Better to use dput(your.data) for sharing data. Anyway I am still confused 
but you probably are able to clarify things further.

> 
> it is a dataset with genetic marker alleles for single individuals. 
> the first row is the header, all following rows are individuals. 2 rows
> count for 1 individual.
> first colum is the individual's number, second colum is the number for 
the
> population the individual comes from, and all following colums are 
different
> genetic markers.
> 
> what i want to do with this data in R, is to compare one individual with

In those 2 rows for one individual sometimes the genetic marker differs

> test[1:2, "scm247"]
[1] 222 231

What do you want to do with them?

> each of the other individuals, allele-wise. there are five 
possibilities:
> the two compared individuals share 4,3,2,1,0 alleles of the currently
> examined marker (=colum). for each shared allele this pair of 
individuals
> shall get 1 scoring point. for each pair of individuals, all scoring 
points
> shall be summarized over all markers.

Based on your example, 

> dput(test)
structure(list(Ind.nr. = c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 6L, 
6L), Pop.nr. = c(101L, 101L, 101L, 101L, 101L, 101L, 101L, 101L, 
101L, 101L), scm266 = c(305L, 305L, 305L, 305L, 305L, 305L, 305L, 
305L, 305L, 305L), rms1280 = c(318L, 318L, 313L, 321L, 324L, 
324L, 313L, 313L, 313L, 321L), scm247 = c(222L, 231L, 999L, 999L, 
231L, 231L, 230L, 230L, 231L, 231L), rms1107 = c(135L, 135L, 
96L, 130L, 135L, 135L, 126L, 135L, 135L, 135L)), .Names = c("Ind.nr.", 
"Pop.nr.", "scm266", "rms1280", "scm247", "rms1107"), class = 
"data.frame", row.names = c(NA, 
-10L))

what is your desired result?

Regards
Petr


> 
> 
> my code again, modified according to your suggestions:
> 
> #1) read in data:
> daten<-read.table('K:/Analysen/STRUCTURE/test.txt', header=TRUE, 
sep="\t")
> daten<-as.data.frame(daten)
> 
> #2) create empty matrix:
> indxind<-matrix(0,nrow=617, ncol=617) 
> indxind[1:20,1:19]
> 
> #3) compare cells to each other, score:
> #for the whole dataset: s in 3:34, z1 in 1:617, z2 in 1:617
> for (s in 3:6) {   #walks though the matrix colum by colum, starting at
> colum 3
>   for (z1 in 1:6) {  #for each current colum, take one row (z1)...
> for (z2 in 1:6) {  #...and compare it to another row (z2) of the 
current
> colum
>   if (z1!=z2) {topf<-indxind[z1,z2]
>if (daten[2*z1-1,s]==daten[2*z2-1,s]) topf<-topf+1 
> #actually, 2 rows make up 1 individual,
>if (daten[2*z1-1,s]==daten[2*z2,s]) topf<-topf+1 
> #therefore i compare 2 rows
>if (daten[2*z1,s]==daten[2*z2-1,s]) topf<-topf+1 
> #with another 2 rows
>if (daten[2*z1,s]==daten[2*z2,s]) topf<-topf+1
>indxind[z1,z2]<-topf
>indxind[z2,z1]<-topf
>   }
>   #print(c(s,z1,z2,indxind[1,2])) ##counts s, z1 and z2 properly, 
but
> gives always 8 for indxind[1,2]
> }
> #indxind[1:5,1:5] #empty matrix
>   }
>   #indxind[1:5,1:5] #empty matrix
> }
> 
> #4) check:
> indxind[1:5,1:5]
> 
> 
> 
> @ Michael Weylandt: i've done my best with regard to the "big picture" 
of my
> algorithm and the small reproducible example. i hope both is sufficient.
> @ Petr Pikal-3: in this case, there are only numerical values, but it's 
a
> useful hint for my other codes.
> @ Petr Pikal-3 and Berend Hasselman: initializing indxind with 0's 
instead
> of NAs helps, it fills something in indxind now. but it does the 
calculation
> only for the first marker (colum 3), afterwards i get an error: 
> Fehler in if (daten[2 * z1 - 1, s] == daten[2 * z2 - 1, s]) topf <- topf 
+ 
> : 
>   Fehlender Wert, wo TRUE/FALSE nötig ist
> Error in if (daten[2 * z1 - 1, s] == daten[2 * z2 - 1, s]) topf <- topf 
+  :
>   Missing value, where TRUE/FAlse is required
> Has this something to do with the changing to 
daten<-as.data.frame(daten) in
> line 3 (instead of as.matrix before)?
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/help-please-
> matrix-operations-inside-3-nested-loops-tp4639592p4639730.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-pro

Re: [R] How to find data in a map according to coordinates?

2012-08-09 Thread Rui Barradas

Hello,

You have three coordinates but the problem description only envolves two 
of them, x and y. The code below is valid for any number of dimensions.



min.dist <- function(p, coord){
which.min( colSums((t(coord) - p)^2) )
}

# Use set.seed to have reproducible simulations
set.seed(1)
test <- data.frame(x=c(1:10),y=c(41:50),temperature=rnorm(1:10))

imin <- min.dist(c(4, 46), test[, 1:2])
test[imin, "temperature"]

Hope this helps

Rui Barradas

Em 09-08-2012 07:56, jeff6868 escreveu:

Hello,

I have created a spatial map of temperature over an area thanks to
interpolation. So I have temperature data everywhere on my map.
My question is: how can I find temperature data on my map for a specific
location according to coordinates?

For this, I have a data frame containing 4 columns: "x" for longitude, "y"
for latitude, "z" for altitude" and "temperature" for my data, for each
pixel of my map. My real data has more than 9 million of rows (because I
have a temperature data for each 0.0008° of longitude or latitude).

Let's take a smallest example with 10 rows and so just 1° of LAT and LON for
each pixel (just with "x", "y" and my data):

test <- data.frame(x=c(1:10),y=c(41:50),temperature=rnorm(1:10))

In this example, I would like to ask the user of the algorithm to type on R
the coordinates (x and y) for which the user wants the temperature.

For example:
cat("choose your coordinates:\n")
x: "HERE THE USER SHOULD TYPE A NUMERIC VALUE"
y: "HERE THE USER SHOULD TYPE A NUMERIC VALUE"

and then R gives the value for temperature (in my third column).

In this example, if the user type 6 for "x" and  "46" for y, R should give
as a result:   "0.9713693"

And if the coordinates typed by the user are between the coordinates in my
data.frame, it should response the temperature value of the nearest pixel.

For example, if the user type 3.89 for "x" and 43.62 for "y", R should give
as a result:   "0.6871172" (value of the nearest pixel: 4 for "x" and 44 for
"y").

I absolutely don't know how to do this, and if it's easy to do or not. I
didn't find anything about it on the web for R.
Have you any idea or suggestions about a package, function or a way to do
this?
Hope you've understood!

thanks everybody!










--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-find-data-in-a-map-according-to-coordinates-tp4639724.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] help, please! matrix operations inside 3 nested loops

2012-08-09 Thread Petr PIKAL
Hi

> all problems solved. thank you for your help!
> for the sake of completeness, here my solution:
> #1) read in data:
> daten<-read.table('K:/Analysen/STRUCTURE/test.txt', header=TRUE, 
sep="\t")
> daten<-as.data.frame(daten)

not needed, daten is already data frame

> 
> #2) create empty matrix:
> indxind<-matrix(0,nrow=617, ncol=617) 
> #indxind[1:20,1:19]
> 
> #3) compare cells to each other, score:
> #for the whole dataset: s in 3:34, z1 in 1:617, z2 in 1:617
> z1<-1 #running variable for rows in daten
> z2<-1 #running variable for rows in daten
> l1<-1 #running variable for rows in indxind
> l2<-1 #running variable for rows in indxind
> for (s in 3:6) {   #walks though the matrix colum by colum, starting at
> colum 3
> while (z1<11) {  #for each current colum, take one row
> (z1)...
> while (z2<11) {  #...and compare it to
> another row (z2) of the current colum
>   if (z1!=z2) {
>   l1
> 
> topf<-indxind[l1,l2]
>   if
> (daten[z1,s]==daten[z2,s]) topf<-topf+1   #actually, 2 rows make up 1
> individual,
>   if
> (daten[z1,s]==daten[z2+1,s]) topf<-topf+1  #therefore i compare 2 
rows
>   if
> (daten[z1+1,s]==daten[z2,s]) topf<-topf+1  #with another 2 rows
>   if
> (daten[z1+1,s]==daten[z2+1,s]) topf<-topf+1
> 
> indxind[l1,l2]<-topf
>   }
>   z2<-z2+2
>   l2<-l2+1
>   }
> z2<-1
> l2<-1
> z1<-z1+2
> l1<-l1+1
>   }
> z1<-1
> l1<-1
>}
> 
> #4) check:
> indxind[1:5,1:5]

I believe that above cycles can be simplified, maybe by changing your 
daten to three dimensional array or some clever **ply construction but if 
your loops works it is not probably worth en effort.

Regards
Petr

> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/help-please-
> matrix-operations-inside-3-nested-loops-tp4639592p4639744.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] basehaz() in package survival and warnings with coxph

2012-08-09 Thread Terry Therneau

I've never seen this, and have no idea how to reproduce it.
For resloution you are going to have to give me a working example of the 
failure.


Also, per the posting guide, what is your sessionInfo()?

Terry Therneau

On 08/09/2012 04:11 AM, r-help-requ...@r-project.org wrote:

I have a couple of questions with regards to fitting a coxph model to a data
set in R:

I have a very large dataset and wanted to get the baseline hazard using the
basehaz() function in the package : 'survival'.
If I use all the covariates then the output from basehaz(fit), where fit is
a model fit using coxph(), gives 507 unique values for the time and the
corresponding cumulative hazard function. However if I use a subset of the
varaibles, basehaz() gives 611 values for the time and cumulative hazard.


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


Re: [R] Ctree plot

2012-08-09 Thread Weidong Gu
Hi,

You may want to check grid.arrange in gridExtra package.

Weidong

On Thu, Aug 9, 2012 at 7:36 AM, rodrock  wrote:
> HI everybody!
>
> Has anybody figure out how would be possible to plot several ctree plots
> beside each other?
> I would really appreciate it
>  My idea would be like this, but the par() function seem to be lower in
> hierarchy
> Thanks in advance
> #
> library(party)
>
> mtree <- ctree(Species ~ ., data=iris)
> sep.tree<-ctree(Sepal.Length ~ ., data=iris)
>
> par(mfrow=c(1,2)) # Does not work
> plot(mtree)
> plot(sep.tree)
>
>
>
>
> -
> Rodrigo Vargas G.
> -
> Silviculture Institute
> Freiburg University
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/Ctree-plot-tp4639750.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] How to interpret Poisson curve

2012-08-09 Thread Aziz, Muhammad Fayez

Hi All,

My question is more academic than technical.

The question is about interpretation of Poisson curve. I am using it to assess 
scale-free nature of degree distribution. Can you please briefly describe what 
is meant by the Poisson curve when you give it your range of k-neighbour data 
which apparently follows power-law (or does otherwise). The code I am using 
within the xyplot.panel to plot the Poisson curve follows. y is the degrees 
vector.

kfreq <- table(y); # compute frequency hash table of y, the degrees
k <- 1:max(y)
for (i in k) {
ichar <- as.character(i) # convert to match the names(freq), the 
character-based hash key of freq, which is degree-value
if (!(ichar %in% names(kfreq)))
kfreq[ichar] <- 0
}
sortedkeys <- as.character(k)
kfreq <-  kfreq[sortedkeys]
pk <- kfreq / length(y)
panel.xyplot(col="blue", k, pk)

#overlaying the poisson distribution
poissonk <- ppois(k, lambda = mean(y), lower.tail = FALSE) # 
lower.tail: if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]
panel.xyplot(col="red", k, poissonk)

Regrads,
Fayez
GCA lab - UIUC

[[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] Factor moderators in metafor

2012-08-09 Thread Viechtbauer Wolfgang (STAT)
There is a simple explanation:

1) The command:

factor(ftype)

does not actually turn 'ftype' permanently into a factor, since you are not 
re-assigning it back to the object 'ftype'. You have to use:

ftype <- factor(ftype)

2) If you want to use the formula interface for specifying moderators, you have 
to use mods = ~ , so in other words:

rma(KL, VL, mods = ~ ftype)

after you have made 'ftype' a factor (see 1).

Or you can simply use:

rma(KL, VL, mods = ~ factor(ftype))

which does the conversion of 'ftype' into a factor within the model formula.

Best,

Wolfgang

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

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of John Hodgson
> Sent: Thursday, August 09, 2012 12:56
> To: r-help@r-project.org
> Subject: [R] Factor moderators in metafor
> 
> I'm puzzled by the behaviour of factors in rma models, see example and
> comments below. I'm sure there's a simple explanation but can't see it...
> 
> Thanks for any input
> 
> John Hodgson
> 
> 
> - code/selected output ---
> --
> 
> 
> library(metafor)
> 
> ##Set up data (from Lenters et al  A Meta-analysis of Asbestos and
> Lung
> Cancer...
> ##Environmental Health Perspectives • volume 119 | number 11 |
> November
> 2011)
> 
> KL = c(0.02905, 0.06929, -0.1523, 1.6441, 0.1215, 0.3975, 1.0566, 0.1257,
> 0.2277, 0.06791, 0.08164, 0.2526, 0.07577, 0.03266, 0.1141, 0.1836,
> 1.8276,
> 0.4149, 15.4974)
> SE = c(0.006633, 0.09335, 0.08909, 0.4297, 0.07858, 0.1753, 0.3679,
> 0.1837,
> 0.2172, 0.2775, 0.4201, 0.1976, 0.7688, 0.06507, 0.06239, 0.09061, 0.9509,
> 0.2181, 7.331)
> 
> VL = SE*SE
> 
> amph =   c(0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
> mix =c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
> ftype =  c(0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
> 
> 
> factor(amph)
> factor(ftype)
> factor(mix)
> 
> ##  Fit ftype...
> 
> > rma(KL,VL,mods=ftype)
> 
> 
> Mixed-Effects Model (k = 19; tau^2 estimator: REML)
> 
> tau^2 (estimate of residual amount of heterogeneity): 0.0111 (SE = 0.0095)
> tau (sqrt of the estimate of residual heterogeneity): 0.1054
> 
> Test for Residual Heterogeneity:
> QE(df = 17) = 43.0937, p-val = 0.0005
> 
> Test of Moderators (coefficient(s) 2):
> QM(df = 1) = 1.1069, p-val = 0.2928
> 
> Model Results:
> 
>  estimate  sezvalpvalci.lb   ci.ub
> intrcpt0.0811  0.0606  1.3380  0.1809  -0.0377  0.2000
> mods   0.0473  0.0449  1.0521  0.2928  -0.0408  0.1353
> 
> 
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> 
> 
> ##   why only one df for the 2-level factor?
> ##   in other words, why isn't the above model the same as the
> following...
> 
> 
> >
> >
> >
> > rma(KL,VL,mods=cbind(amph,mix))
> 
> Mixed-Effects Model (k = 19; tau^2 estimator: REML)
> 
> tau^2 (estimate of residual amount of heterogeneity): 0.0030 (SE = 0.0046)
> tau (sqrt of the estimate of residual heterogeneity): 0.0549
> 
> Test for Residual Heterogeneity:
> QE(df = 16) = 37.5762, p-val = 0.0017
> 
> Test of Moderators (coefficient(s) 2,3):
> QM(df = 2) = 6.9220, p-val = 0.0314
> 
> Model Results:
> 
>  estimate  sezvalpvalci.lb   ci.ub
> intrcpt0.0380  0.0402  0.9448  0.3447  -0.0408  0.1169
> amph   0.2879  0.1163  2.4754  0.0133   0.0599  0.5158  *
> mix0.0888  0.0625  1.4199  0.1556  -0.0338  0.2114
> 
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R versus SAS

2012-08-09 Thread John Kane

> -Original Message-
> From: j...@bitwrit.com.au
> Sent: Thu, 09 Aug 2012 19:55:29 +1000
> To: rolf.tur...@xtra.co.nz
> Subject: Re: [R] R versus SAS
> 
> On 08/09/2012 07:17 AM, Rolf Turner wrote:
>> ...
>> P. S. There is no such word as "recompensate".
>> 
> Thanks to R, the internet and pretentious, semi-literate public servants
> around the world, there probably is now.
> 
> Jim

Wait a minute now.  Perhaps it's some recursive compensation scheme/

  Ugh, I think I am getting a head ache.


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] Density

2012-08-09 Thread li li
Hi David,
   Thanks a lot for the reply.
   I might not have stated the problem clearly. Let me try again.

   Given a set of observations X, I want to find out the estimated density
values for the observations X?

  I believe that the values "x" returned from "density" function is not the
observations
that are fed into the function and the returned "y" values are estimated
density values for "x".
   Below are in the R manual

  x

the n coordinates of the points where the density is estimated.
 y

the estimated density values. These will be non-negative, but can be zero.

We can also check this using the code below.

X <- rnorm(100)
density(X)-> den0
den0
X[1:10]
(den0$x)[1:10]
(den0$y)[1:10]
round(dnorm((den0$x)[1:10]), 6)
round(dnorm(X[1:10]), 6)

Thank you.
 Hannah


2012/8/8 David L Carlson 

> The numbers are there, they just aren't listed by the default print method
> for density.  When you type the object name, den0, R runs
> print.density(den0) which provides summary statistics. You need to look at
> the manual page (?density) and pay close attention to the section labeled
> "Value" which provides information about what values are returned by the
> function.
>
> str(den0)
> den0$x
> den0$y
> plot(den0$x, den0$y, typ="l")
>
> --
> David L Carlson
> Associate Professor of Anthropology
> Texas A&M University
> College Station, TX 77843-4352
>
>
> > -Original Message-
> > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> > project.org] On Behalf Of li li
> > Sent: Wednesday, August 08, 2012 9:03 PM
> > To: r-help
> > Subject: [R] Density
> >
> > Dear all,
> >Given a set of observations X, I want to evaluate the kernel density
> > estimator
> > at these observed values. If I do the following, I do not get the those
> > estimated values directly.
> > Can anyone familiar with this give an idea on how to find out the
> > estimated
> > density values for X?
> >
> > > X <- rnorm(100)
> >
> > > density(X)-> den0
> >
> > > den0
> >
> >
> > Call:
> >
> > density.default(x = X)
> >
> >
> > Data: X (100 obs.); Bandwidth 'bw' = 0.354
> >
> >
> >x y
> >
> >  Min.   :-3.2254   Min.   :0.0002658
> >
> >  1st Qu.:-1.6988   1st Qu.:0.0359114
> >
> >  Median :-0.1721   Median :0.1438772
> >
> >  Mean   :-0.1721   Mean   :0.1635887
> >
> >  3rd Qu.: 1.3545   3rd Qu.:0.2866889
> >
> >  Max.   : 2.8812   Max.   :0.3776935
> >
> >
> > I did write the code for the kernel density
> >
> > estimator myself. So once I find a proper bandwidth,
> >
> > I can use the following function. However, it would be nicer
> >
> > if there is a more direct way.
> >
> >
> > > fhat <- function(x, X){
> >
> > +  h <- density(X, bw="SJ")$bw
> >
> > +  n <- length(X)
> >
> > +  1/(n*h)*sum(dnorm((x-X)/h))}
> >
> > >
> >
> > > est <- numeric(length(X))
> >
> > > for (i in 1:length(X)){est[i] <- fhat(x=X[i], X=X)}
> >
> > >
> >
> > > est
> >
> >
> >
> >
> > Thanks in advance.
> >
> >   Hannah
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide 
> > http://www.R-project.org/posting-
> > guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

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


[R] R Commander - Time Series

2012-08-09 Thread Billpete002
Hello all,

I'm just starting to learn R and I heard a good way of doing that was R
Commander. For my work I use a lot of time series, so I installed (and
loaded) R Commander with epack.

When I go to Ts-Models, after loading my data, I click on ARIMA Models tab.

I load my variable D1 Ln Demand (1st differenced ln demand). I set my
regular and seasonal p d q settings hit run and I get:

[1] "Error in list(order = c(0, 1, 0), period = ) : argument 2 is empty\n"
attr(,"class")
[1] "try-error"
attr(,"condition")


I assume it means the period is empty? But there was no option to set that.

It says in the messages sections:

[4] ERROR:  argument 2 is empty

[5] ERROR: the model ArimaModel.1 is no longer available
[6] ERROR: There are no models from which to choose.
[7] ERROR:  argument 2 is empty
[8] ERROR: the model ArimaModel.2 is no longer available
[9] ERROR:  argument 2 is empty
[10] ERROR: the model ArimaModel.4 is no longer available

Thoughts?



--
View this message in context: 
http://r.789695.n4.nabble.com/R-Commander-Time-Series-tp4639765.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] read htm table error

2012-08-09 Thread arun
HI,

I am using R 2.15 in Ubuntu 12.04.  It works fine for me.

library(XML)
theurl <- "http://en.wikipedia.org/wiki/Brazil_national_football_team";
tables <- readHTMLTable(theurl)

A.K.

- Original Message -
From: "Lay, Kiung" 
To: "r-help@R-project.org" 
Cc: 
Sent: Thursday, August 9, 2012 2:55 AM
Subject: [R] read htm table error


Hi I am using Version R 2.15 and I haven't been able read html table. Following 
is my code and error message.
Error in htmlParse(doc) :
  error in creating parser for 
http://en.wikipedia.org/wiki/Brazil_national_football_team

theurl <- "http://en.wikipedia.org/wiki/Brazil_national_football_team";
tables <- readHTMLTable(theurl)

Regards,
Kiung

    [[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] Pseudo R2 in Quantile Regression

2012-08-09 Thread Vito Ricci


 Dear All,

I'm starting to use the quantile regression, I would like to know if there is a 
way to calculate the fit of the model such as a pseudo R2.

Many thanks.
Best regards.
Vito Ricci
[[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] reshape2's dcast() Adds NAs to Data Frame

2012-08-09 Thread Rich Shepard

On Wed, 8 Aug 2012, Jeff Newmiller wrote:

I took a closer look, and unused factor levels is not the problem... the 
problem is defining id variables appropriately.


Jeff,

  OK.

1) "sample" is the name of a builtin function, so it is not advisable to use 
it as the name of data. I have used "samp" instead of "sample"


  Ah, I did not realize that 'sample' was a reserved word.

2) Your input data is essentially in long form already, so you don't need to 
melt it.


  Despite my multiple readings of the reshape2 docs I did not pick up on
this. All data to be analyzed with R are written out from database tables
which is the long format. I have worked on the idea that all reshaping
requires the data be melted to a common intermediate form before being cast
to another form, in my case wide.

3) It is almost never a good idea to use a floating point column as an id 
variable. Perhaps you were imagining something like:


> samp.cast <- dcast(samp[,1:5], site+sampdate+era~param, value.var="quant" > )


Clearly, this still includes NA values, but if we look at the input data 
corresponding to

the first row:


  


There are only 26 chemicals corresponding to that row, but there are a
total of 54 different possible chemicals to quantify in the first row.
Thus, there must be NA values inserted to fill out the data frame. (The
problem gets worse when you try to keep those other data columns as id
columns... they represent additional distinct combinations so you end up
with more rows and fewer values in each row.)


  I see this now. This is a common situation with permit compliance
monitoring data. There are not always concentrations for each chemical at
every site and sampling date.


I am not familiar with the NADA library, so I cannot suggest what you
SHOULD be doing, but it does seem that you should perhaps study some more
examples of its use to figure out what form you should have your data in.


  Agreed. This is what I've been trying to do, but without success so far.
Perhaps I need to subset the long form for each parameter so the data frame
hos no missing values. I'll delve more deeply into learning how to apply the
NADA methods to my data.

Thanks very much,

Rich

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


Re: [R] read htm table error

2012-08-09 Thread John Kane
Works fine for me.  

 sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: i686-pc-linux-gnu (32-bit)

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

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

other attached packages:
[1] XML_3.9-4  directlabels_2.6   stringr_0.6.1  RColorBrewer_1.0-5
[5] reshape2_1.2.1 scales_0.2.1   plyr_1.7.1 gridExtra_0.9 
[9] ggplot2_0.9.1 

loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4  digest_0.5.2 labeling_0.1
[5] MASS_7.3-20  memoise_0.1  munsell_0.3  proto_0.3-9.2   
[9] tools_2.15.1
1> 


John Kane
Kingston ON Canada


> -Original Message-
> From: kiung@sensis.com.au
> Sent: Thu, 9 Aug 2012 06:55:17 +
> To: r-help@r-project.org
> Subject: [R] read htm table error
> 
> 
> Hi I am using Version R 2.15 and I haven't been able read html table.
> Following is my code and error message.
> Error in htmlParse(doc) :
>   error in creating parser for
> http://en.wikipedia.org/wiki/Brazil_national_football_team
> 
> theurl <- "http://en.wikipedia.org/wiki/Brazil_national_football_team";
>  tables <- readHTMLTable(theurl)
> 
> Regards,
> Kiung
> 
>   [[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 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.


[R] All combinations possible in a mutliple regression

2012-08-09 Thread zel7223
Hi,

I want to use four independent variables to predict the output of one
dependent variable using a linear model lm. I want to compare all possible
combinations of the 4 independent variables, including singles, pairs and
triples.

I was thinking of using the AIC test to compare all models and pick the best
one.

The model looks like this : 

lm(Y ~ X1 + X2 + X3 + X4)

Thanks for your help

Cheers

Jean-Michel Fortin
UOttawa



--
View this message in context: 
http://r.789695.n4.nabble.com/All-combinations-possible-in-a-mutliple-regression-tp4639762.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] Density

2012-08-09 Thread William Dunlap
You can use approx(d, xout=) (or spline()) on the output of density()
to get density estimates at the points in xout.  E.g.,
   > X <- c(rnorm(20, -1, 1), rgamma(50,1/2))
   > d <- density(X)
   > plot(d)
   > points(approx(d, xout=-2:2))

Or you could use the functions in package:logspline to fit the density
function and evaluate it where you wish
  > z <- logspline(X)
  > points(-2:2, dlogspline(-2:2, fit=z), col="red")

(The vector '-2:2' about could be any set of numbers, including your
original data points.)

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 li li
> Sent: Thursday, August 09, 2012 6:55 AM
> To: dcarl...@tamu.edu
> Cc: r-help
> Subject: Re: [R] Density
> 
> Hi David,
>Thanks a lot for the reply.
>I might not have stated the problem clearly. Let me try again.
> 
>Given a set of observations X, I want to find out the estimated density
> values for the observations X?
> 
>   I believe that the values "x" returned from "density" function is not the
> observations
> that are fed into the function and the returned "y" values are estimated
> density values for "x".
>Below are in the R manual
> 
>   x
> 
> the n coordinates of the points where the density is estimated.
>  y
> 
> the estimated density values. These will be non-negative, but can be zero.
> 
> We can also check this using the code below.
> 
> X <- rnorm(100)
> density(X)-> den0
> den0
> X[1:10]
> (den0$x)[1:10]
> (den0$y)[1:10]
> round(dnorm((den0$x)[1:10]), 6)
> round(dnorm(X[1:10]), 6)
> 
> Thank you.
>  Hannah
> 
> 
> 2012/8/8 David L Carlson 
> 
> > The numbers are there, they just aren't listed by the default print method
> > for density.  When you type the object name, den0, R runs
> > print.density(den0) which provides summary statistics. You need to look at
> > the manual page (?density) and pay close attention to the section labeled
> > "Value" which provides information about what values are returned by the
> > function.
> >
> > str(den0)
> > den0$x
> > den0$y
> > plot(den0$x, den0$y, typ="l")
> >
> > --
> > David L Carlson
> > Associate Professor of Anthropology
> > Texas A&M University
> > College Station, TX 77843-4352
> >
> >
> > > -Original Message-
> > > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> > > project.org] On Behalf Of li li
> > > Sent: Wednesday, August 08, 2012 9:03 PM
> > > To: r-help
> > > Subject: [R] Density
> > >
> > > Dear all,
> > >Given a set of observations X, I want to evaluate the kernel density
> > > estimator
> > > at these observed values. If I do the following, I do not get the those
> > > estimated values directly.
> > > Can anyone familiar with this give an idea on how to find out the
> > > estimated
> > > density values for X?
> > >
> > > > X <- rnorm(100)
> > >
> > > > density(X)-> den0
> > >
> > > > den0
> > >
> > >
> > > Call:
> > >
> > > density.default(x = X)
> > >
> > >
> > > Data: X (100 obs.); Bandwidth 'bw' = 0.354
> > >
> > >
> > >x y
> > >
> > >  Min.   :-3.2254   Min.   :0.0002658
> > >
> > >  1st Qu.:-1.6988   1st Qu.:0.0359114
> > >
> > >  Median :-0.1721   Median :0.1438772
> > >
> > >  Mean   :-0.1721   Mean   :0.1635887
> > >
> > >  3rd Qu.: 1.3545   3rd Qu.:0.2866889
> > >
> > >  Max.   : 2.8812   Max.   :0.3776935
> > >
> > >
> > > I did write the code for the kernel density
> > >
> > > estimator myself. So once I find a proper bandwidth,
> > >
> > > I can use the following function. However, it would be nicer
> > >
> > > if there is a more direct way.
> > >
> > >
> > > > fhat <- function(x, X){
> > >
> > > +  h <- density(X, bw="SJ")$bw
> > >
> > > +  n <- length(X)
> > >
> > > +  1/(n*h)*sum(dnorm((x-X)/h))}
> > >
> > > >
> > >
> > > > est <- numeric(length(X))
> > >
> > > > for (i in 1:length(X)){est[i] <- fhat(x=X[i], X=X)}
> > >
> > > >
> > >
> > > > est
> > >
> > >
> > >
> > >
> > > Thanks in advance.
> > >
> > >   Hannah
> > >
> > >   [[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- project.org/posting->
> > > guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE 

Re: [R] R Commander - Time Series

2012-08-09 Thread John Kane
I don't think a lot of people here use R Commander so diagnosing something from 
there may be difficult.   

Probably the first thing to do is to supply us with some sample data.  The best 
way do do this is usually to use the dput() command and just copy and paste the 
output into your email .  If it is a lot of data try something like 
head(dput(mydata, 50)) which should supply 50 rows of data..  I think you can 
do this by typing it in the Script window.

Also we should see the output window commands and error messages.

BTW, nice as Rcmdr is, in the longer run, I think you are better off with a 
terminal and good R editor. Tinn-R for Windows or gedit for linux are not bad 
and some fanatics love EMACS with ESS :)

Wecome to R.  


John Kane
Kingston ON Canada


> -Original Message-
> From: billpete...@hotmail.com
> Sent: Thu, 9 Aug 2012 06:54:50 -0700 (PDT)
> To: r-help@r-project.org
> Subject: [R] R Commander - Time Series
> 
> Hello all,
> 
> I'm just starting to learn R and I heard a good way of doing that was R
> Commander. For my work I use a lot of time series, so I installed (and
> loaded) R Commander with epack.
> 
> When I go to Ts-Models, after loading my data, I click on ARIMA Models
> tab.
> 
> I load my variable D1 Ln Demand (1st differenced ln demand). I set my
> regular and seasonal p d q settings hit run and I get:
> 
> [1] "Error in list(order = c(0, 1, 0), period = ) : argument 2 is
> empty\n"
> attr(,"class")
> [1] "try-error"
> attr(,"condition")
> 
> 
> I assume it means the period is empty? But there was no option to set
> that.
> 
> It says in the messages sections:
> 
> [4] ERROR:  argument 2 is empty
> 
> [5] ERROR: the model ArimaModel.1 is no longer available
> [6] ERROR: There are no models from which to choose.
> [7] ERROR:  argument 2 is empty
> [8] ERROR: the model ArimaModel.2 is no longer available
> [9] ERROR:  argument 2 is empty
> [10] ERROR: the model ArimaModel.4 is no longer available
> 
> Thoughts?
> 
> 
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/R-Commander-Time-Series-tp4639765.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.


FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

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


Re: [R] Factor moderators in metafor

2012-08-09 Thread John Hodgson
Thanks, I suspected it would be something simple.   Best wishes John

On 09/08/2012 14:42, Viechtbauer Wolfgang (STAT)-2 [via R] wrote:
> There is a simple explanation:
>
> 1) The command:
>
> factor(ftype)
>
> does not actually turn 'ftype' permanently into a factor, since you 
> are not re-assigning it back to the object 'ftype'. You have to use:
>
> ftype <- factor(ftype)
>
> 2) If you want to use the formula interface for specifying moderators, 
> you have to use mods = ~ , so in other words:
>
> rma(KL, VL, mods = ~ ftype)
>
> after you have made 'ftype' a factor (see 1).
>
> Or you can simply use:
>
> rma(KL, VL, mods = ~ factor(ftype))
>
> which does the conversion of 'ftype' into a factor within the model 
> formula.
>
> Best,
>
> Wolfgang
>
> -- 
> Wolfgang Viechtbauer, Ph.D., Statistician
> Department of Psychiatry and Psychology
> School for Mental Health and Neuroscience
> Faculty of Health, Medicine, and Life Sciences
> Maastricht University, P.O. Box 616 (VIJV1)
> 6200 MD Maastricht, The Netherlands
> +31 (43) 388-4170 | http://www.wvbauer.com
>
> > -Original Message-
> > From: [hidden email] 
>  [mailto:[hidden 
> email] ]
> > On Behalf Of John Hodgson
> > Sent: Thursday, August 09, 2012 12:56
> > To: [hidden email] 
> > Subject: [R] Factor moderators in metafor
> >
> > I'm puzzled by the behaviour of factors in rma models, see example and
> > comments below. I'm sure there's a simple explanation but can't see 
> it...
> >
> > Thanks for any input
> >
> > John Hodgson
> >
> >
> > - code/selected output 
> ---
> > --
> >
> >
> > library(metafor)
> >
> > ##Set up data (from Lenters et al  A Meta-analysis of Asbestos and
> > Lung
> > Cancer...
> > ##Environmental Health Perspectives • volume 119 | number 11 |
> > November
> > 2011)
> >
> > KL = c(0.02905, 0.06929, -0.1523, 1.6441, 0.1215, 0.3975, 1.0566, 
> 0.1257,
> > 0.2277, 0.06791, 0.08164, 0.2526, 0.07577, 0.03266, 0.1141, 0.1836,
> > 1.8276,
> > 0.4149, 15.4974)
> > SE = c(0.006633, 0.09335, 0.08909, 0.4297, 0.07858, 0.1753, 0.3679,
> > 0.1837,
> > 0.2172, 0.2775, 0.4201, 0.1976, 0.7688, 0.06507, 0.06239, 0.09061, 
> 0.9509,
> > 0.2181, 7.331)
> >
> > VL = SE*SE
> >
> > amph =   c(0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
> > mix =c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
> > ftype =  c(0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)
> >
> >
> > factor(amph)
> > factor(ftype)
> > factor(mix)
> >
> > ##  Fit ftype...
> >
> > > rma(KL,VL,mods=ftype)
> >
> >
> > Mixed-Effects Model (k = 19; tau^2 estimator: REML)
> >
> > tau^2 (estimate of residual amount of heterogeneity): 0.0111 (SE = 
> 0.0095)
> > tau (sqrt of the estimate of residual heterogeneity): 0.1054
> >
> > Test for Residual Heterogeneity:
> > QE(df = 17) = 43.0937, p-val = 0.0005
> >
> > Test of Moderators (coefficient(s) 2):
> > QM(df = 1) = 1.1069, p-val = 0.2928
> >
> > Model Results:
> >
> >  estimate  sezvalpvalci.lb   ci.ub
> > intrcpt0.0811  0.0606  1.3380  0.1809  -0.0377  0.2000
> > mods   0.0473  0.0449  1.0521  0.2928  -0.0408  0.1353
> >
> >
> > Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 
> > ‘ ’ 1
> >
> >
> > ##   why only one df for the 2-level factor?
> > ##   in other words, why isn't the above model the same as the
> > following...
> >
> >
> > >
> > >
> > >
> > > rma(KL,VL,mods=cbind(amph,mix))
> >
> > Mixed-Effects Model (k = 19; tau^2 estimator: REML)
> >
> > tau^2 (estimate of residual amount of heterogeneity): 0.0030 (SE = 
> 0.0046)
> > tau (sqrt of the estimate of residual heterogeneity): 0.0549
> >
> > Test for Residual Heterogeneity:
> > QE(df = 16) = 37.5762, p-val = 0.0017
> >
> > Test of Moderators (coefficient(s) 2,3):
> > QM(df = 2) = 6.9220, p-val = 0.0314
> >
> > Model Results:
> >
> >  estimate  sezvalpvalci.lb   ci.ub
> > intrcpt0.0380  0.0402  0.9448  0.3447  -0.0408  0.1169
> > amph   0.2879  0.1163  2.4754  0.0133   0.0599  0.5158  *
> > mix0.0888  0.0625  1.4199  0.1556  -0.0338  0.2114
> >
> > ---
> > Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 
> > ‘ ’ 1
> __
> [hidden email]  
> mailing list
> https://stat.ethz.ch/mailman/listinfo/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/Factor-moderators-in-metafor-tp4639745p4639763.html
>  
>
> To unsubscribe from Factor moderators in metafor, click here 
> 

Re: [R] Fill pattern for Boxplots?

2012-08-09 Thread John Kane
Probably not. See 
http://r.789695.n4.nabble.com/Boxplot-Fill-Pattern-td4457209.html on this topic.

What exactly are you doing?  There may be a workaround or alternative.

John Kane
Kingston ON Canada


> -Original Message-
> From: meyfa...@uni-potsdam.de
> Sent: Wed, 8 Aug 2012 16:56:05 -0700 (PDT)
> To: r-help@r-project.org
> Subject: [R] Fill pattern for Boxplots?
> 
> Is it possible to fill the boxes of  a boxplot with filling
> patterns/texture
> instead of colours? Or both mixed? (for example white, grey, left
> diagonal
> striped, right diagonal striped) How can I do that? I searched here, but
> didn't find an answer.
> Thank you!
> 
> 
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Fill-pattern-for-Boxplots-tp4639698.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.


FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
family!
Visit http://www.inbox.com/photosharing to find out more!

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


Re: [R] R Commander - Time Series

2012-08-09 Thread Michael Weylandt


On Aug 9, 2012, at 9:21 AM, John Kane  wrote:

> I don't think a lot of people here use R Commander so diagnosing something 
> from there may be difficult.   
> 
> Probably the first thing to do is to supply us with some sample data.  The 
> best way do do this is usually to use the dput() command and just copy and 
> paste the output into your email .  If it is a lot of data try something like 
> head(dput(mydata, 50)) which should supply 50 rows of data..  I think you can 
> do this by typing it in the Script window.


Rather dput(head(my data, 50))

> 
> Also we should see the output window commands and error messages.
> 
> BTW, nice as Rcmdr is, in the longer run, I think you are better off with a 
> terminal and good R editor. Tinn-R for Windows or gedit for linux are not bad 
> and some fanatics love EMACS with ESS :)
> 
> Wecome to R.  
> 
> 
> John Kane
> Kingston ON Canada
> 
> 
>> -Original Message-
>> From: billpete...@hotmail.com
>> Sent: Thu, 9 Aug 2012 06:54:50 -0700 (PDT)
>> To: r-help@r-project.org
>> Subject: [R] R Commander - Time Series
>> 
>> Hello all,
>> 
>> I'm just starting to learn R and I heard a good way of doing that was R
>> Commander. For my work I use a lot of time series, so I installed (and
>> loaded) R Commander with epack.
>> 
>> When I go to Ts-Models, after loading my data, I click on ARIMA Models
>> tab.
>> 
>> I load my variable D1 Ln Demand (1st differenced ln demand). I set my
>> regular and seasonal p d q settings hit run and I get:
>> 
>> [1] "Error in list(order = c(0, 1, 0), period = ) : argument 2 is
>> empty\n"
>> attr(,"class")
>> [1] "try-error"
>> attr(,"condition")
>> 
>> 
>> I assume it means the period is empty? But there was no option to set
>> that.
>> 
>> It says in the messages sections:
>> 
>> [4] ERROR:  argument 2 is empty
>> 
>> [5] ERROR: the model ArimaModel.1 is no longer available
>> [6] ERROR: There are no models from which to choose.
>> [7] ERROR:  argument 2 is empty
>> [8] ERROR: the model ArimaModel.2 is no longer available
>> [9] ERROR:  argument 2 is empty
>> [10] ERROR: the model ArimaModel.4 is no longer available
>> 
>> Thoughts?
>> 
>> 
>> 
>> --
>> View this message in context:
>> http://r.789695.n4.nabble.com/R-Commander-Time-Series-tp4639765.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.
> 
> 
> FREE ONLINE PHOTOSHARING - Share your photos online with your friends and 
> family!
> Visit http://www.inbox.com/photosharing to find out more!
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Parallel runs of an external executable with snow in local

2012-08-09 Thread Xavier Portell/UPC
Hi Uwe,
I’ve tried changing the working directory and made a few tests and it 
seems it works perfectly fine. Thank you so much for your suggestion.

I’ve found a minor issue running my code.  Although I’m using: 

unlink(temporary.folder, recursive=TRUE)

, it seems that many folders are not unlinked and remain in the working 
directory. Any suggestion to avoid this? 

I was afraid (due to my poor knowledge of parallel code) that changing the 
directory would cause all instances use the same folder, so messing up files 
again. However, it seems that changing work directory just affects the calling 
instance. Please, someone correct me if I’m wrong.

All the best, 

Xavi 

-Uwe Ligges  ha escrit: -

Per a: Xavier Portell/UPC 
De: Uwe Ligges 
Data: 07/08/2012 03:41PM
a/c: r-help@r-project.org
Assumpte: Re: [R] Parallel runs of an external executable with snow in local



On 06.08.2012 17:07, Xavier Portell/UPC wrote:
> Thanks Uwe but, actually, I did so.
>
> Since “filetorun.exe” looks in the current folder for 
> “input.txt”, I tried moving all needed files to a newly created 
> temporary folder “tmp.id” (say, tmp.1) and running the 
> executable. This works fine by doing it directly from the windows command 
> line but not by doing it from R, since using:
>
> #
> System(“C:/Users/…/currentworkdirectory/temp.1/filetorun.exe”)
> #
>
> Causes “filetorun.exe” to look for “input.txt” in 
> “C:/Users/…/currentworkdirectory”. So there’s no 
> point on moving files to a folder, it seems that input file must be situated 
> in the current R work directory. Does anybody know how to avoid this 
> behaviour?

Errr, you mean you cannot specify an input for "filetorun.exe"?

If so, you can ask R to switch to use another working directory for each 
instance.

Best,
Uwe Ligges







>
> I hope I’ve explained that clearly,
>
> Xavier Portell Canal, PhD candidate.
> Department of Agri-food Engineering,
> Universitat Politècnica de Catalunya
>
> -Uwe Ligges  ha escrit: -
>
> Per a: Xavier Portell/UPC 
> De: Uwe Ligges 
> Data: 05/08/2012 07:46PM
> a/c: r-help@r-project.org
> Assumpte: Re: [R] Parallel runs of an external executable with snow in local
>
>
>
> On 03.08.2012 19:21, Xavier Portell/UPC wrote:
>> Hi everyone,
>>
>> I'm aiming to run an external executable (say filetorun.EXE) in parallel. 
>> The external executable collect needed data from a file, say "input.txt" 
>> and, in turn,generates several output files, say "output.txt". I need to 
>> generate "input.txt", run the executable and keep "input.txt" and 
>> "output.txt". I'm using Windows 7, R version 2.15.1 (2012-06-22) on RStudio 
>> and platform: i386.pc.mingw32/i386 (32-bit).
>>
>> My first attempt was a R code which, by using
>> System("filetorun.EXE", intern = F, ignore.stdout = F,
>> ignore.stderr = F, wait = T, input = NULL,
>> show.output.on.console = T, minimized = F, invisible = T))
>> , ran the executable and kept required files to a conveniently named folder. 
>> After that I changed my previous R script so I could use the function 
>> lapply().This script apparently worked fine.
>>
>> Finally, I tried to parallelize the problem by using snow and parLapply(). 
>> The resulting script looks like this:
>>
>> ## Not run
>> #
>> library(snow)cl <- makeCluster(3, type = "SOCK")
>> clusterExport(cl,list('param.esp','copy.files','for12.template','program.executor'))
>> parLapply(cl,a.list,a.function))stopCluster(cl)
>> #
>> ##End not run
>>
>> Although it runs, the parallelized version is messing up the input 
>> parameters to pass to the executable (see table below, where parameters P1 
>> and P2 are considered. ".s" comes from the serial code and ".p" from the 
>> parallelized one):
>> s r P1.s P2.s P1.p P2.p
>> 1 1 1  1.0 3.00  2.0 3.00
>> 2 2 1  1.5 3.00  2.0 3.75
>> 3 3 1  2.0 3.00  2.0 3.00
>> 4 4 1  1.0 3.75  1.5 3.00
>> 5 5 1  1.5 3.75  1.5 3.00
>> 6 6 1  2.0 3.75  2.0 3.75
>>
>> My first thought to avoid the described behaviour was creating a temporary 
>> file, say "tmp.id" with id being an identification run number, and copying 
>> "filetorun.EXE" and "Input.txt" to "tmp.id". However, while doing so, I 
>> realised that although running the correct "filetorun.EXE" copy (i.e., the 
>> one in "tmp.id") R looks for "input.txt" in the work directory.
>
>
> Not sure about the real setup, but you can actually specify the path,
> not only filenames.
>
> Uwe Ligges
>
>
>>
>>
>> I've been looking thoroughly for a solution but I got nothing.
>>
>> Thanks for any help in advance,
>>
>>
>> Xavier Portell Canal
>>
>> PhD candidate
>> Department of Agri-food engineering,
>> Universitat Politècnica de Catalunya
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>


Re: [R] Density

2012-08-09 Thread David L Carlson
Sorry, between x and X I got confused about what you were trying to do. The
quickest route is approx() or approxfun():

set.seed(42)
X <- rnorm(100)
den0 <- density(X, bw="SJ")
XY <- approx(den0$x, den0$y, X)

XY$y will differ slightly from your values (you could double the number of
points in the density() computation to m=1024, to get closer if you need to
– it depends on what you are using the results for):

Y <- sapply(1:100, function(i) fhat(X[i], X)
mean(Y-XY$y)
[1] -0.0002195961

sd(Y-XY$y)
[1] 5.682146e-05

plot(Y, XY$y, pch=4)
abline(0, 1)

I used your fhat function with sapply to save some steps, but it is possible
to speed things up by vectorizing the whole function:

Y1 <- 1/(length(X)*den0$bw)*colSums(dnorm((outer(X, X, "-")/den0$bw)))
identical(Y, Y1)
[1] TRUE

---
David


From: li li [mailto:hannah@gmail.com] 
Sent: Thursday, August 09, 2012 8:55 AM
To: dcarl...@tamu.edu
Cc: r-help
Subject: Re: [R] Density

Hi David,
   Thanks a lot for the reply.
   I might not have stated the problem clearly. Let me try again.
  
   Given a set of observations X, I want to find out the estimated density 
values for the observations X?  
 
  I believe that the values "x" returned from "density" function is not the
observations
that are fed into the function and the returned "y" values are estimated
density values for "x".
   Below are in the R manual
 
x
the n coordinates of the points where the density is estimated.
y
the estimated density values. These will be non-negative, but can be zero.
 
We can also check this using the code below.
 
X <- rnorm(100)
density(X)-> den0
den0
X[1:10]
(den0$x)[1:10]
(den0$y)[1:10]
round(dnorm((den0$x)[1:10]), 6)
round(dnorm(X[1:10]), 6)
 
Thank you.
 Hannah 
 
 
2012/8/8 David L Carlson 
The numbers are there, they just aren't listed by the default print method
for density.  When you type the object name, den0, R runs
print.density(den0) which provides summary statistics. You need to look at
the manual page (?density) and pay close attention to the section labeled
"Value" which provides information about what values are returned by the
function.

str(den0)
den0$x
den0$y
plot(den0$x, den0$y, typ="l")

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


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of li li
> Sent: Wednesday, August 08, 2012 9:03 PM
> To: r-help
> Subject: [R] Density
>
> Dear all,
>    Given a set of observations X, I want to evaluate the kernel density
> estimator
> at these observed values. If I do the following, I do not get the those
> estimated values directly.
> Can anyone familiar with this give an idea on how to find out the
> estimated
> density values for X?
>
> > X <- rnorm(100)
>
> > density(X)-> den0
>
> > den0
>
>
> Call:
>
> density.default(x = X)
>
>
> Data: X (100 obs.); Bandwidth 'bw' = 0.354
>
>
>        x                 y
>
>  Min.   :-3.2254   Min.   :0.0002658
>
>  1st Qu.:-1.6988   1st Qu.:0.0359114
>
>  Median :-0.1721   Median :0.1438772
>
>  Mean   :-0.1721   Mean   :0.1635887
>
>  3rd Qu.: 1.3545   3rd Qu.:0.2866889
>
>  Max.   : 2.8812   Max.   :0.3776935
>
>
> I did write the code for the kernel density
>
> estimator myself. So once I find a proper bandwidth,
>
> I can use the following function. However, it would be nicer
>
> if there is a more direct way.
>
>
> > fhat <- function(x, X){
>
> +          h <- density(X, bw="SJ")$bw
>
> +          n <- length(X)
>
> +          1/(n*h)*sum(dnorm((x-X)/h))}
>
> >
>
> > est <- numeric(length(X)).
>
> > for (i in 1:length(X)){est[i] <- fhat(x=X[i], X=X)}
>
> >
>
> > est
>
>
>
>
> Thanks in advance.
>
>       Hannah
>
>       [[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] Add interpunct (dot) symbol to axis label?

2012-08-09 Thread Uwe Ligges



On 09.08.2012 13:56, Duncan Murdoch wrote:

On 12-08-08 9:21 PM, Hillary Ward wrote:

I'm having problems creating an axis label for a plot.

y_label = expression(paste(plain('CPUE
'),plain('(fish'),plain('x'),plain('h'^{-1}),plain(')')))

I'd like to replace the "x" with an interpunct symbol (dot). Any
suggestions how to do this?


The interpunct symbol is \u00b7 in Unicode.  You could try that, i.e.

y_label = expression(paste(plain('CPUE
'),plain('(fish'),plain('\u00b7'),plain('h'^{-1}),plain(')')))

It might not work if your graphics device doesn't support Unicode.


As I explained yesterday in another mail with that question (so 
apparently it is a homework problem we should not answer at all), one 
could use the UTF-8 encoded version by


 options("OutDec"="\xB7")

and just start the plotting ...

Uwe Ligges






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

2012-08-09 Thread John Fox
Dear Billpete002,

This looks to me like it's possibly a bug in RcmdrPlugin.epack -- that is,
you may have done something wrong, but I'd expect in this case that the
timeseries plug=in would intercept the error and return an informative error
message. You might want to correspond directly with the author of the
plug-in package, Erin Hodgess. I'm copying my response to Erin in case she
didn't notice your posting.

Best,
 John

---
John Fox
Senator William McMaster Professor of Social Statistics
Department of Sociology
McMaster Univeristy
Hamilton, Ontario, Canada



> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Billpete002
> Sent: August-09-12 6:55 AM
> To: r-help@r-project.org
> Subject: [R] R Commander - Time Series
> 
> Hello all,
> 
> I'm just starting to learn R and I heard a good way of doing that was R
> Commander. For my work I use a lot of time series, so I installed (and
> loaded) R Commander with epack.
> 
> When I go to Ts-Models, after loading my data, I click on ARIMA Models
tab.
> 
> I load my variable D1 Ln Demand (1st differenced ln demand). I set my
> regular and seasonal p d q settings hit run and I get:
> 
> [1] "Error in list(order = c(0, 1, 0), period = ) : argument 2 is empty\n"
> attr(,"class")
> [1] "try-error"
> attr(,"condition")
> 
> 
> I assume it means the period is empty? But there was no option to set
that.
> 
> It says in the messages sections:
> 
> [4] ERROR:  argument 2 is empty
> 
> [5] ERROR: the model ArimaModel.1 is no longer available [6] ERROR: There
> are no models from which to choose.
> [7] ERROR:  argument 2 is empty
> [8] ERROR: the model ArimaModel.2 is no longer available [9] ERROR:
> argument 2 is empty [10] ERROR: the model ArimaModel.4 is no longer
> available
> 
> Thoughts?
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/R-
> Commander-Time-Series-tp4639765.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] R Commander - Time Series

2012-08-09 Thread John Kane

> Rather dput(head(my data, 50))

Argh!!!  I think that in the third time in three weeks .
John Kane
Kingston ON Canada


> -Original Message-
> From: michael.weyla...@gmail.com
> Sent: Thu, 9 Aug 2012 10:29:07 -0500
> To: jrkrid...@inbox.com
> Subject: Re: [R] R Commander - Time Series
> 
> 
> 
> On Aug 9, 2012, at 9:21 AM, John Kane  wrote:
> 
>> I don't think a lot of people here use R Commander so diagnosing
>> something from there may be difficult.
>> 
>> Probably the first thing to do is to supply us with some sample data.
>> The best way do do this is usually to use the dput() command and just
>> copy and paste the output into your email .  If it is a lot of data try
>> something like head(dput(mydata, 50)) which should supply 50 rows of
>> data..  I think you can do this by typing it in the Script window.
> 
> 
> Rather dput(head(my data, 50))
> 
>> 
>> Also we should see the output window commands and error messages.
>> 
>> BTW, nice as Rcmdr is, in the longer run, I think you are better off
>> with a terminal and good R editor. Tinn-R for Windows or gedit for linux
>> are not bad and some fanatics love EMACS with ESS :)
>> 
>> Wecome to R.
>> 
>> 
>> John Kane
>> Kingston ON Canada
>> 
>> 
>>> -Original Message-
>>> From: billpete...@hotmail.com
>>> Sent: Thu, 9 Aug 2012 06:54:50 -0700 (PDT)
>>> To: r-help@r-project.org
>>> Subject: [R] R Commander - Time Series
>>> 
>>> Hello all,
>>> 
>>> I'm just starting to learn R and I heard a good way of doing that was R
>>> Commander. For my work I use a lot of time series, so I installed (and
>>> loaded) R Commander with epack.
>>> 
>>> When I go to Ts-Models, after loading my data, I click on ARIMA Models
>>> tab.
>>> 
>>> I load my variable D1 Ln Demand (1st differenced ln demand). I set my
>>> regular and seasonal p d q settings hit run and I get:
>>> 
>>> [1] "Error in list(order = c(0, 1, 0), period = ) : argument 2 is
>>> empty\n"
>>> attr(,"class")
>>> [1] "try-error"
>>> attr(,"condition")
>>> >> empty>
>>> 
>>> I assume it means the period is empty? But there was no option to set
>>> that.
>>> 
>>> It says in the messages sections:
>>> 
>>> [4] ERROR:  argument 2 is empty
>>> 
>>> [5] ERROR: the model ArimaModel.1 is no longer available
>>> [6] ERROR: There are no models from which to choose.
>>> [7] ERROR:  argument 2 is empty
>>> [8] ERROR: the model ArimaModel.2 is no longer available
>>> [9] ERROR:  argument 2 is empty
>>> [10] ERROR: the model ArimaModel.4 is no longer available
>>> 
>>> Thoughts?
>>> 
>>> 
>>> 
>>> --
>>> View this message in context:
>>> http://r.789695.n4.nabble.com/R-Commander-Time-Series-tp4639765.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.
>> 
>> 
>> FREE ONLINE PHOTOSHARING - Share your photos online with your friends
>> and family!
>> Visit http://www.inbox.com/photosharing to find out more!
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.


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.


[R] correlating rows of two differently-sized data frames in R

2012-08-09 Thread JenniferH
Hello everyone,

I have two sets of data, with the following structure:

DataSet1
Location   PartSample 1   Sample 2
A 1   value value
A 2   value value
A 3   value value
B 1   value value

DataSet2
Location   Sample 1Sample 2
A  value  value
B  value  value
C  value  value

I would like to look at the correlations between DataSet1 and DataSet2, such
that each row in Location A from DataSet1 is paired with the Location A row
from DataSet2, and so forth.  So far, my only ideas  involve trying to
copy-paste each of the rows in DataSet2 the number of times each occurs in
DataSet1 on a spreadsheet before loading the sets into R; however, as I have
approaching 8000 rows in DataSet2, this is clearly not a workable solution!

I'm sure there's a simple solution to this, so I'm sorry if this seems like
a really silly question.

Thanks for your help!

Jen



--
View this message in context: 
http://r.789695.n4.nabble.com/correlating-rows-of-two-differently-sized-data-frames-in-R-tp4639774.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] Changing labels positions in two graphics

2012-08-09 Thread gaiarrido
Sorry for the late answer.
You both put me iin the correct way.
Problem is solved



-
Mario Garrido Escudero
PhD student
Dpto. de Biología Animal, Ecología, Parasitología, Edafología y Qca. Agrícola
Universidad de Salamanca
--
View this message in context: 
http://r.789695.n4.nabble.com/Changing-labels-positions-in-two-graphics-tp4638722p4639776.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] mgcv and gamm4: REML, GCV, and AIC

2012-08-09 Thread Ben Bolker
john benson  hotmail.com> writes:


> I've been using gamm4 to build GAMMs for exploring environmental
> influences on genetic ancestry.  Things have gone well and I have 2
> very straightforward questions: 1. I've used method=REML.  Am I
> correct that this is an alternative method for estimating the smooth
> functions in GAMMs rather than GCV that is often used for GAMs?
> I've read up on REML and it makes sense, but I'm confused about
> whether GCV is used for any part of the model formation of a GAMM
> with method=REML.  I think it is not.  Is this why no GCV score is
> returned for GAMMs through mgcv and gamm4?  For Gams I've always
> used the GCV scores to help with model selection, but I assume these
> aren't available for GAMMs estimated with REML.

   To the best of my knowledge, REML and GCV are not doing
similar things.  REML is an approach for estimating variance
components in a less-biased way (as you will have seen in your
reading).  However, one major caveat with REML is that it is
inappropriate to compare models with different fixed effects
that have been estimated via REML, so (if that's what you're
doing) **you might not want to use REML** ...  In contrast, GCV is
used to estimate the degree of smoothing/penalization factor
for the smooth functions.

> 2. Instead I've been using AIC values with GAMMs.  Is it correct to
> use the AIC value from the underlying linear mixed model,
> i.e. extracted using summary(gamm1$mer)?  Or is there another AIC
> calculated specifically for the gam object?  Many thanks for help
> with these (admittedly simple and boring) questions, I really like
> the mgcv and gamm4 packages which I've found very user friendly in
> conjunction with Wood (2006).  John

  I seem to recall that this is a bit delicate, and that there
may be a discussion somewhere in the mgcv help files -- but I 
don't remember where and can't find it at the moment.  The thing to be
careful about is that the effective degrees of freedom are 
appropriately represented in the 'mer' part of the fit ...

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


Re: [R] Installing HDF5 package

2012-08-09 Thread Uwe Ligges



On 09.08.2012 10:18, sihemsaad wrote:

As Uwe Ligges-3 guessed, i am working on a Windows Station.

I also tried the link Uwe Ligges-3 posted and I think it worked



Actually, my surname is "Ligges" rather than "Ligges-3". And you failed 
to cite the contents of the former part of the thread. Please read this 
mailing list's posting guide and be aware R-help is not Nabble!


Best,
Uwe Ligges




Thank you all for your answers!



--
View this message in context: 
http://r.789695.n4.nabble.com/Installing-HDF5-package-tp4639633p4639728.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] Remove axes in boplot

2012-08-09 Thread Filoche
Hi everyone.

I'm trying to customize a biplot (RDA). I would like to remove all axes
ticks. Therefore, I was using *ann=FALSE* (see following example). However,
it only clear the axis 1 and 2 leaving ticks on axis 3 and 4.  Any
suggestions to get rdi of the remaining ticks?

data(varespec)
data(varechem)
## Common but bad way: use all variables you happen to have in your
## environmental data matrix
vare.cca <- cca(varespec ~ Al + P*(K + Baresoil), data=varechem)
vare.cca
plot(vare.cca, xaxt = 'n', yaxt = 'n', ann=FALSE)

With regards,
Phil




--
View this message in context: 
http://r.789695.n4.nabble.com/Remove-axes-in-boplot-tp4639779.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] All combinations possible in a mutliple regression

2012-08-09 Thread Filoche
Try a look at this:

http://stat.ethz.ch/R-manual/R-patched/library/MASS/html/stepAIC.html

Regards,
Phil



--
View this message in context: 
http://r.789695.n4.nabble.com/All-combinations-possible-in-a-mutliple-regression-tp4639762p4639782.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 interpunct (dot) symbol to axis label?

2012-08-09 Thread Duncan Murdoch

On 09/08/2012 11:52 AM, Uwe Ligges wrote:


On 09.08.2012 13:56, Duncan Murdoch wrote:
> On 12-08-08 9:21 PM, Hillary Ward wrote:
>> I'm having problems creating an axis label for a plot.
>>
>> y_label = expression(paste(plain('CPUE
>> '),plain('(fish'),plain('x'),plain('h'^{-1}),plain(')')))
>>
>> I'd like to replace the "x" with an interpunct symbol (dot). Any
>> suggestions how to do this?
>
> The interpunct symbol is \u00b7 in Unicode.  You could try that, i.e.
>
> y_label = expression(paste(plain('CPUE
> '),plain('(fish'),plain('\u00b7'),plain('h'^{-1}),plain(')')))
>
> It might not work if your graphics device doesn't support Unicode.

As I explained yesterday in another mail with that question (so
apparently it is a homework problem we should not answer at all), one
could use the UTF-8 encoded version by

   options("OutDec"="\xB7")

and just start the plotting ...


Yes, I saw your message, which is how I knew the symbol exists.  But I 
think the question is different:  this one isn't being used as a decimal 
point, just a dot in a formula.


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] any recommendation for software about prediction analysis of gene expression data

2012-08-09 Thread Dai, Hongying,
Dear R users,

I have a microRNA (similar to microarray) data set with gene expressions and 
group variables. I'd like to perform (class) prediction analysis to see which 
genes or gene sets predict the group variable well.

I'm at the beginner level. Is there any free software in R or in point/click 
format that is commonly used and highly recommended?

I googled this topic and found "SAM" and "PAM" packages for prediction 
analysis. Am I on the right track?

Thanks!

Dai

Electronic mail from Children's Mercy Hospitals and Clinics. This communication 
is intended only for the use of the addressee. It may contain information that 
is privileged or confidential under applicable law. If you are not the intended 
recipient or the agent of the recipient, you are hereby notified that any 
dissemination, copy or disclosure of this communication is strictly prohibited. 
If you have received this communication in error, please immediately forward 
the message to Children's Mercy Hospital’s Information Security Officer via 
return electronic mail at informationsecurityoffi...@cmh.edu and expunge this 
communication without making any copies. Thank you for your cooperation.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 interpunct (dot) symbol to axis label?

2012-08-09 Thread Uwe Ligges



On 09.08.2012 18:05, Duncan Murdoch wrote:

On 09/08/2012 11:52 AM, Uwe Ligges wrote:


On 09.08.2012 13:56, Duncan Murdoch wrote:
> On 12-08-08 9:21 PM, Hillary Ward wrote:
>> I'm having problems creating an axis label for a plot.
>>
>> y_label = expression(paste(plain('CPUE
>> '),plain('(fish'),plain('x'),plain('h'^{-1}),plain(')')))
>>
>> I'd like to replace the "x" with an interpunct symbol (dot). Any
>> suggestions how to do this?
>
> The interpunct symbol is \u00b7 in Unicode.  You could try that, i.e.
>
> y_label = expression(paste(plain('CPUE
> '),plain('(fish'),plain('\u00b7'),plain('h'^{-1}),plain(')')))
>
> It might not work if your graphics device doesn't support Unicode.

As I explained yesterday in another mail with that question (so
apparently it is a homework problem we should not answer at all), one
could use the UTF-8 encoded version by

   options("OutDec"="\xB7")

and just start the plotting ...


Yes, I saw your message, which is how I knew the symbol exists.  But I
think the question is different:  this one isn't being used as a decimal
point, just a dot in a formula.



Oh, sorry, should read more carefully:

Several years ago I added %.% to the plotmath syntax symbols for that 
reason, see ?plotmath, hence:


plot(1, main = expression(CPUE(fish %.% h^{-1})))

seems to do the right thing.

Best,
Uwe











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.


Re: [R] any recommendation for software about prediction analysis of gene expression data

2012-08-09 Thread R. Michael Weylandt
I might suggest you move this question to the Bioconductor help list.
(And look into bioconductor more generally)

Best,
Michael

On Thu, Aug 9, 2012 at 10:26 AM, Dai, Hongying,  wrote:
> Dear R users,
>
> I have a microRNA (similar to microarray) data set with gene expressions and 
> group variables. I'd like to perform (class) prediction analysis to see which 
> genes or gene sets predict the group variable well.
>
> I'm at the beginner level. Is there any free software in R or in point/click 
> format that is commonly used and highly recommended?
>
> I googled this topic and found "SAM" and "PAM" packages for prediction 
> analysis. Am I on the right track?
>
> Thanks!
>
> Dai
>
> Electronic mail from Children's Mercy Hospitals and Clinics. This 
> communication is intended only for the use of the addressee. It may contain 
> information that is privileged or confidential under applicable law. If you 
> are not the intended recipient or the agent of the recipient, you are hereby 
> notified that any dissemination, copy or disclosure of this communication is 
> strictly prohibited. If you have received this communication in error, please 
> immediately forward the message to Children's Mercy Hospital’s Information 
> Security Officer via return electronic mail at 
> informationsecurityoffi...@cmh.edu and expunge this communication without 
> making any copies. Thank you for your cooperation.
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] correlating rows of two differently-sized data frames in R

2012-08-09 Thread R. Michael Weylandt
Perhaps load them both and ?merge can show you the way.

Michael

On Thu, Aug 9, 2012 at 9:54 AM, JenniferH  wrote:
> Hello everyone,
>
> I have two sets of data, with the following structure:
>
> DataSet1
> Location   PartSample 1   Sample 2
> A 1   value value
> A 2   value value
> A 3   value value
> B 1   value value
>
> DataSet2
> Location   Sample 1Sample 2
> A  value  value
> B  value  value
> C  value  value
>
> I would like to look at the correlations between DataSet1 and DataSet2, such
> that each row in Location A from DataSet1 is paired with the Location A row
> from DataSet2, and so forth.  So far, my only ideas  involve trying to
> copy-paste each of the rows in DataSet2 the number of times each occurs in
> DataSet1 on a spreadsheet before loading the sets into R; however, as I have
> approaching 8000 rows in DataSet2, this is clearly not a workable solution!
>
> I'm sure there's a simple solution to this, so I'm sorry if this seems like
> a really silly question.
>
> Thanks for your help!
>
> Jen
>
>
>
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/correlating-rows-of-two-differently-sized-data-frames-in-R-tp4639774.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] RMySQL dbConnect issues

2012-08-09 Thread Anthony Dick

Hello,

I have access to my database via command line and through workbench, and 
have access on the grant tables:


mysql> SELECT host,user,password,select_priv,insert_priv FROM user;
+--+---+---+-+-+
| host | user  | password  | select_priv 
| insert_priv |

+--+---+---+-+-+
| %| adick | *D2D62126137364E6FDFD43E4887123C99C4C6B57 | Y   
| Y   |
| %| root  | *D2D62126137364E6FDFD43E4887123C99C4C6B57 | Y   
| Y   |

+--+---+---+-+-+
2 rows in set (0.00 sec)


But when I run the following:

> library(RMySQL)
Loading required package: DBI
> drv = dbDriver("MySQL")
> con = dbConnect(drv, user="adick", password = "***", dbname="***", 
host="***")

Error in mysqlNewConnection(drv, ...) :
  RS-DBI driver: (Failed to connect to database: Error: Access denied 
for user 'adick'@'host' (using password: YES)

)

Further, this error is sporadic. For example, it ran successfully 
yesterday afternoon. I have installed two MySQL databases on two 
separate computers and am having the same problems. Tried restarting 
computers/databases etc. Also, there are no limits to these users on 
number of connections etc. I am completely stumped at this point.


R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

Anthony

--
Anthony Steven Dick, Ph.D.
Assistant Professor
Director, Developmental Science Program
Department of Psychology
Florida International University
Modesto A. Maidique Campus DM 296B
11200 S.W. 8th Street
Miami, FL 33199
Phone: 305-348-4202 (try this first)
Lab Phone: 305-348-9057 or 305-348-9055
Fax: 305-348-3879
Email: ad...@fiu.edu
Webpage: http://www.fiu.edu/~adick
Lab Webpage: http://dcn.fiu.edu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
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 interpunct (dot) symbol to axis label?

2012-08-09 Thread Hillary Ward
Thanks for the help - both solutions work fine.

On Thu, Aug 9, 2012 at 9:20 AM, Uwe Ligges
wrote:

>
>
> On 09.08.2012 18:05, Duncan Murdoch wrote:
>
>> On 09/08/2012 11:52 AM, Uwe Ligges wrote:
>>
>>>
>>> On 09.08.2012 13:56, Duncan Murdoch wrote:
>>> > On 12-08-08 9:21 PM, Hillary Ward wrote:
>>> >> I'm having problems creating an axis label for a plot.
>>> >>
>>> >> y_label = expression(paste(plain('CPUE
>>> >> '),plain('(fish'),plain('x'),**plain('h'^{-1}),plain(')')))
>>> >>
>>> >> I'd like to replace the "x" with an interpunct symbol (dot). Any
>>> >> suggestions how to do this?
>>> >
>>> > The interpunct symbol is \u00b7 in Unicode.  You could try that, i.e.
>>> >
>>> > y_label = expression(paste(plain('CPUE
>>> > '),plain('(fish'),plain('\**u00b7'),plain('h'^{-1}),plain(**')')))
>>> >
>>> > It might not work if your graphics device doesn't support Unicode.
>>>
>>> As I explained yesterday in another mail with that question (so
>>> apparently it is a homework problem we should not answer at all), one
>>> could use the UTF-8 encoded version by
>>>
>>>options("OutDec"="\xB7")
>>>
>>> and just start the plotting ...
>>>
>>
>> Yes, I saw your message, which is how I knew the symbol exists.  But I
>> think the question is different:  this one isn't being used as a decimal
>> point, just a dot in a formula.
>>
>
>
> Oh, sorry, should read more carefully:
>
> Several years ago I added %.% to the plotmath syntax symbols for that
> reason, see ?plotmath, hence:
>
> plot(1, main = expression(CPUE(fish %.% h^{-1})))
>
> seems to do the right thing.
>
> Best,
> Uwe
>
>
>
>
>
>
>
>
>
>
>> Duncan Murdoch
>>
>>
>

[[alternative HTML version deleted]]

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


Re: [R] Fill pattern for Boxplots?

2012-08-09 Thread Susanne Meyfarth
Thank you. I saw these postings, but I don't want to learn lattice for 
this reason (was afraid to have to change then everything else in my 
graph). Anyway, I now tried with different shades of greyscale (4 
shades). I'm not fully satisfied with it, but it's ok. It's for a 
publication and depending on whether I have to change the graph, I 
decide to either put texture in some boxes manually or still look for a 
solution in R.



Original Message--
From: John Kane 
To: suse , r-help@r-project.org
Date: 09.08.2012 16:52
Subject: Re: [R] Fill pattern for Boxplots?

Probably not. See 
http://r.789695.n4.nabble.com/Boxplot-Fill-Pattern-td4457209.html on this topic.

What exactly are you doing?  There may be a workaround or alternative.

John Kane
Kingston ON Canada




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


Re: [R] read htm table error

2012-08-09 Thread Rui Barradas

Hello,

Ditto, Windows 7.

> library(XML)
> theurl <- "http://en.wikipedia.org/wiki/Brazil_national_football_team";
> tables <- readHTMLTable(theurl)
>
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252
[3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Portugal.1252

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

other attached packages:
[1] XML_3.9-4.1

loaded via a namespace (and not attached):
[1] fortunes_1.4-2

Hope this helps,

Rui Barradas
Em 09-08-2012 15:02, John Kane escreveu:

Works fine for me.

  sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: i686-pc-linux-gnu (32-bit)

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

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

other attached packages:
[1] XML_3.9-4  directlabels_2.6   stringr_0.6.1  RColorBrewer_1.0-5
[5] reshape2_1.2.1 scales_0.2.1   plyr_1.7.1 gridExtra_0.9
[9] ggplot2_0.9.1

loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4  digest_0.5.2 labeling_0.1
[5] MASS_7.3-20  memoise_0.1  munsell_0.3  proto_0.3-9.2
[9] tools_2.15.1
1>


John Kane
Kingston ON Canada



-Original Message-
From: kiung@sensis.com.au
Sent: Thu, 9 Aug 2012 06:55:17 +
To: r-help@r-project.org
Subject: [R] read htm table error


Hi I am using Version R 2.15 and I haven't been able read html table.
Following is my code and error message.
Error in htmlParse(doc) :
   error in creating parser for
http://en.wikipedia.org/wiki/Brazil_national_football_team

theurl <- "http://en.wikipedia.org/wiki/Brazil_national_football_team";
  tables <- readHTMLTable(theurl)

Regards,
Kiung

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


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


Re: [R] Fill pattern for Boxplots?

2012-08-09 Thread John Kane

You might want to have a look at  RColorBrewer.  If I remember correctly some 
of their palettes should work better than a standard R greyscale but I must 
admit I have not tried them.
 http://www.decisionstats.com/color-palettes-in-r-using-rcolorbrewer-rstats/  
for a start.
John Kane
Kingston ON Canada


> -Original Message-
> From: meyfa...@uni-potsdam.de
> Sent: Thu, 09 Aug 2012 19:07:43 +0200
> To: jrkrid...@inbox.com
> Subject: Re: [R] Fill pattern for Boxplots?
> 
> Thank you. I saw these postings, but I don't want to learn lattice for
> this reason (was afraid to have to change then everything else in my
> graph). Anyway, I now tried with different shades of greyscale (4
> shades). I'm not fully satisfied with it, but it's ok. It's for a
> publication and depending on whether I have to change the graph, I
> decide to either put texture in some boxes manually or still look for a
> solution in R.
> 
> 
> Original Message--
> From: John Kane 
> To: suse , r-help@r-project.org
> Date: 09.08.2012 16:52
> Subject: Re: [R] Fill pattern for Boxplots?
>> Probably not. See
>> http://r.789695.n4.nabble.com/Boxplot-Fill-Pattern-td4457209.html on
>> this topic.
>> 
>> What exactly are you doing?  There may be a workaround or alternative.
>> 
>> John Kane
>> Kingston ON Canada
>> 
>>


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] correlating rows of two differently-sized data frames in R

2012-08-09 Thread R. Michael Weylandt
Hi Jen,

It's generally best to keep cc'ing R-help so others can lend a hind
when I step away from my computer:

On Thu, Aug 9, 2012 at 11:49 AM, Jennifer Hobbs  wrote:
> Hi Michael -
>
> thanks for the advice - I did find merge() just after posting but I'm having
> difficulty with using it.  I've loaded both datasets; then I tried
>
>> CombinedData<-merge(MethyData1,ExprData1)
>
> but when I looked at CombinedData, I found there was no actual data in it:
>
>> str(CombinedData)
> 'data.frame': 0 obs. of  20 variables

Take a look at

?merge.data.frame

in particular since there are many different forms of merges. Your
original post suggests you may want to set

all = TRUE
by = "Location"

Hope that helps,
Michael



>
> I thought this might be due to the fact that my column names, as well as the
> row names, in both data sets were the same, so I renamed the column names in
> ExprData1 and tried again:
>
>> colnames(ExprData1)<-NewExprNames
>> merge(ExprData1,MethyData1)
> Error: cannot allocate vector of size 4.2 Gb
> In addition: Warning messages:
> 1: In expand.grid(seq_len(nx), seq_len(ny)) :
>   Reached total allocation of 8055Mb: see help(memory.size)
> 2: In expand.grid(seq_len(nx), seq_len(ny)) :
>   Reached total allocation of 8055Mb: see help(memory.size)
> 3: In expand.grid(seq_len(nx), seq_len(ny)) :
>   Reached total allocation of 8055Mb: see help(memory.size)
> 4: In expand.grid(seq_len(nx), seq_len(ny)) :
>   Reached total allocation of 8055Mb: see help(memory.size)
>
> I was surprised about this, as I'm using a 64-bit computer and it's managed

You'll also need to be using a 64 bit build of R. Merging is pretty
memory expensive so if you're right on the edge of what R can handle
you might have to look into a more specialized solution (such as an
SQL backend)

> to deal with much larger data sets before now (I know that's not the only
> criterion, but my understanding of computers isn't extensive).  I had
> previously run up against a memory problem because I hadn't transformed my
> data (I thought I was looking at columns, the computer was looking at rows)
> so I tried transforming both data sets and merging again, but I end up with
> another empty data frame:
>
>> tED1<-t(ExprData1)
>> tMD1<-t(MethyData1)
>> CombineData<-merge(tED1,tMD1)
>> str(CombineData)
> 'data.frame': 0 obs. of  152247 variables:
>
> This is where I'm stuck.  Any advice would be hugely appreciated!
>
> Jen
>
> On Thu, Aug 9, 2012 at 5:28 PM, R. Michael Weylandt
>  wrote:
>>
>> Perhaps load them both and ?merge can show you the way.
>>
>> Michael
>>
>> On Thu, Aug 9, 2012 at 9:54 AM, JenniferH  wrote:
>> > Hello everyone,
>> >
>> > I have two sets of data, with the following structure:
>> >
>> > DataSet1
>> > Location   PartSample 1   Sample 2
>> > A 1   value value
>> > A 2   value value
>> > A 3   value value
>> > B 1   value value
>> >
>> > DataSet2
>> > Location   Sample 1Sample 2
>> > A  value  value
>> > B  value  value
>> > C  value  value
>> >
>> > I would like to look at the correlations between DataSet1 and DataSet2,
>> > such
>> > that each row in Location A from DataSet1 is paired with the Location A
>> > row
>> > from DataSet2, and so forth.  So far, my only ideas  involve trying to
>> > copy-paste each of the rows in DataSet2 the number of times each occurs
>> > in
>> > DataSet1 on a spreadsheet before loading the sets into R; however, as I
>> > have
>> > approaching 8000 rows in DataSet2, this is clearly not a workable
>> > solution!
>> >
>> > I'm sure there's a simple solution to this, so I'm sorry if this seems
>> > like
>> > a really silly question.
>> >
>> > Thanks for your help!
>> >
>> > Jen
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> > http://r.789695.n4.nabble.com/correlating-rows-of-two-differently-sized-data-frames-in-R-tp4639774.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] Pass Conditional & loop argument into a function

2012-08-09 Thread David Winsemius


On Aug 8, 2012, at 2:16 PM, greatest.possible.newbie wrote:

Ok I see that point with the quotes. But what I want to do still  
doesn't

work:

a <- matrix(1:15,ncol=3)
b <- paste(  paste("a[," ,paste(1:3), "]",sep="")
,"^",1:3,sep="",collapse="+")
b
#[1] "a[,1]^1+a[,2]^2+a[,3]^3"
#instead of (which I want)
a[,1]^1+a[,2]^2+a[,3]^3
#[1] 1368 1779 2264 2829 3480


I had another idea that would not go the route of parsing an expression:

> rowSums(a^col(a))
[1] 1368 1779 2264 2829 3480

Does not need to re-specify the number of rows. And if you wanted to  
multiply each polynomial term with by a column-level constant vector,  
it would just be:


   rowSums( rep( const, each=nrow(a) )*a^col(a) )

E.G:

> a^col(a)
 [,1] [,2] [,3]
[1,]1   36 1331
[2,]2   49 1728
[3,]3   64 2197
[4,]4   81 2744
[5,]5  100 3375
> const <- c(10, 1, 0.1)
> rowSums( rep( const, each=nrow(a) )*a^col(a) )
[1] 179.1 241.8 313.7 395.4 487.5





or I want to change some function input (dramatically) just by  
changing two

conditional arguments (in my case constant and c).
a <- matrix(1:15,ncol=3)
b <- matrix(NA,nrow=nrow(a),ncol=ncol(a))
constant <- 1
c <- 5

for (j in 1:ncol(a))
 b[,j] <- mapply(function(x){
 if(is.null(constant))  {paste(paste("x^", paste(1:c) , sep="",  
collapse="

+ ") , ", a[,",j,"]" ,sep=" ")
 } else if(!is.null(constant)) {paste(paste(constant, paste("x^",
paste(1:c) , sep="",collapse="+"),collapse="+") , ",  
a[,",j,"]" ,sep=" ") }

 })

By the way.. Can anyone tell my why collapse doesn't work in outer  
paste

function?


Doesn't work means  what?

First you should tell us what is supposed to be accomplished. Is the  
"constant" just being added to a vector? Seems like you are going  
through incredibly complex efforts to do just this:


> 1:5 + 5
[1]  6  7  8  9 10

--
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] Question about R and multiple CPU's

2012-08-09 Thread R. Michael Weylandt
On Wed, Aug 8, 2012 at 6:18 PM, Eberle, Anthony  wrote:
> I have a question about multiple cores and CPU's for running R.  I've
> been running various tests on different types of hardware and operating
> systems (64 bit, 32 bit, Solaris, Linux, Windows, RV.10, .12, .15,
> .15.1.)  Generally speaking, it seems that for a single user and process
> that R prefers to have as much resources as possible; especially memory.
>
> I've looked at some of the r-sig groups and it seems most threads about
> multicore or CPU's have to deal with using packages like parallel or
> snow or something such as this and leaving it up to the user what can be
> parallelized and how which makes perfect sense to me.
>
> The question I have is about what the advantage of machines with
> multiple cores or CPU's.  To me, it seems that until R is parallelized
> (or if I am writing my own code that can run in a parallel fashion) that
> a single user and single (non-parallel) process would work just as fine
> on a single core, single CPU box as it would on (for example) a quad
> core with 24 threads?  Is my observation off or am I missing something?
> Of course, I know there are other "things" going on with most modern
> systems such as operating system and other processes that in practice
> affect this observation a bit.  In addition if I had a R environment
> where multiple people were logging in and running R queries that would
> likely gain from multiple CPU's and a multitasking OS I'm assuming.

To a first approximation, I believe that is correct if you are doing
nothing else on the computer. If you are, it's nice to have that
second core around :-)

Note however, that it's very easy to write parallelizable code with R
since every *apply() statement is trivially parallelizable. The more
difficult question is asking yourself whether the overhead of
parallelizing is worth it (and that's a much harder question)

Best,
Michael

>
> I'm just trying to get a feeling and validate what I think I am seeing.
> Thoughts and comments are appreciated.
>
>
> Thanks,
>
> Anthony
>
> [[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] Fill pattern for Boxplots?

2012-08-09 Thread David L Carlson
It's not too hard to use rect() to add shading to the boxplots. The boxes
are centered on consecutive integers and the width is +/- .4. The boxplot()
function returns the quartiles of each box. 

set.seed(42)
DF <- data.frame(val=rnorm(150), grp=rep(letters[1:6], 25))
outstat <- boxplot(val~grp, DF)   # save the boxplot stats
ngroups <- length(levels(DF$grp)) # get number of groups
dval <- c(6, 6, 6, 12, 12, 12)# density vals for each group
aval <- c(0, 30, 60, 90, 120, 150)# angle vals for each group
rect((1:ngroups)-.4, outstat$stats[2,], (1:ngroups)+.4, outstat$stats[4,], 
 density=dval, angle=aval)# draw the rectangles

You can also play with lty= and lwd= but that will affect the box border as
well.

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

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Susanne Meyfarth
> Sent: Thursday, August 09, 2012 12:08 PM
> To: John Kane
> Cc: r-help@r-project.org
> Subject: Re: [R] Fill pattern for Boxplots?
> 
> Thank you. I saw these postings, but I don't want to learn lattice for
> this reason (was afraid to have to change then everything else in my
> graph). Anyway, I now tried with different shades of greyscale (4
> shades). I'm not fully satisfied with it, but it's ok. It's for a
> publication and depending on whether I have to change the graph, I
> decide to either put texture in some boxes manually or still look for a
> solution in R.
> 
> 
> Original Message--
> From: John Kane 
> To: suse , r-help@r-project.org
> Date: 09.08.2012 16:52
> Subject: Re: [R] Fill pattern for Boxplots?
> > Probably not. See http://r.789695.n4.nabble.com/Boxplot-Fill-Pattern-
> td4457209.html on this topic.
> >
> > What exactly are you doing?  There may be a workaround or
> alternative.
> >
> > John Kane
> > Kingston ON Canada
> >
> >
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] R Commander - Time Series

2012-08-09 Thread David Winsemius


On Aug 9, 2012, at 8:55 AM, John Kane wrote:




Rather dput(head(my data, 50))


There's an Internet name for the misspelling a correction of a  
spelling error. Something like  Corollary. This is what I  
found, but it's not the name I (don't) remember:


http://rationalwiki.org/wiki/Skitt%27s_Law



Argh!!!  I think that in the third time in three weeks .


Michael probably made his error just to make you feel better.

--
Best;
David.


John Kane
Kingston ON Canada



-Original Message-
From: michael.weyla...@gmail.com
Sent: Thu, 9 Aug 2012 10:29:07 -0500
To: jrkrid...@inbox.com
Subject: Re: [R] R Commander - Time Series



On Aug 9, 2012, at 9:21 AM, John Kane  wrote:


I don't think a lot of people here use R Commander so diagnosing
something from there may be difficult.

Probably the first thing to do is to supply us with some sample  
data.
The best way do do this is usually to use the dput() command and  
just
copy and paste the output into your email .  If it is a lot of  
data try

something like head(dput(mydata, 50)) which should supply 50 rows of
data..  I think you can do this by typing it in the Script window.



Rather dput(head(my data, 50))



Also we should see the output window commands and error messages.

BTW, nice as Rcmdr is, in the longer run, I think you are better off
with a terminal and good R editor. Tinn-R for Windows or gedit for  
linux

are not bad and some fanatics love EMACS with ESS :)

Wecome to R.


John Kane
Kingston ON Canada



-Original Message-
From: billpete...@hotmail.com
Sent: Thu, 9 Aug 2012 06:54:50 -0700 (PDT)
To: r-help@r-project.org
Subject: [R] R Commander - Time Series

Hello all,

I'm just starting to learn R and I heard a good way of doing that  
was R
Commander. For my work I use a lot of time series, so I installed  
(and

loaded) R Commander with epack.

When I go to Ts-Models, after loading my data, I click on ARIMA  
Models

tab.

I load my variable D1 Ln Demand (1st differenced ln demand). I  
set my

regular and seasonal p d q settings hit run and I get:

[1] "Error in list(order = c(0, 1, 0), period = ) : argument 2 is
empty\n"
attr(,"class")
[1] "try-error"
attr(,"condition")


I assume it means the period is empty? But there was no option to  
set

that.

It says in the messages sections:

[4] ERROR:  argument 2 is empty

[5] ERROR: the model ArimaModel.1 is no longer available
[6] ERROR: There are no models from which to choose.
[7] ERROR:  argument 2 is empty
[8] ERROR: the model ArimaModel.2 is no longer available
[9] ERROR:  argument 2 is empty
[10] ERROR: the model ArimaModel.4 is no longer available

Thoughts?



--
View this message in context:
http://r.789695.n4.nabble.com/R-Commander-Time-Series- 
tp4639765.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.



FREE ONLINE PHOTOSHARING - Share your photos online with your  
friends

and family!
Visit http://www.inbox.com/photosharing to find out more!

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



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] sapply and matrix command

2012-08-09 Thread R. Michael Weylandt
On Wed, Aug 8, 2012 at 10:37 AM, alijk1989 [via R]
 wrote:
>
>
> Hi Michael,
>
> Thanks for your response. Here is a simple example of what I am trying to
> do:
>
> w=rep(0.02,10)
> Q=rep(0.02,10)
> rho=matrix(0.5,nrow=10,ncol=10)
> m=10
> LGD=0.45
>
> M1=sum(sapply(1:m,
> function(k){sum(sapply(1:m,function(j){w[k]*w[j]*LGD^2*(pmnorm(c(qnorm(Q[k]),qnorm(Q[j])),c(0,0),equicorr(2,rho[k,j]))-Q[k]*Q[j])}))}))
>
> It uses the mnormt and QRM packages.
>
> I am trying to reproduce the following sum:
>
> \sum\limits_{j=1}^M \sum\limits_{k=1}^M w_j w_k
> LGD^2[N_2(N^{-1}[Q(j)],N^{-1}[Q(k)],\rho_{jk})-Q(j)Q(k)]

Hi Alijk,

The problem ultimately comes from the fact that equicorr() is not
nicely vectorized so you'll need to home-brew something to replace it,
but that's not hard. However, I don't think that pmnorm is vectorized
in the varcov argument: we can probably work out the double sapply()
loop if you can assume rho is constant, otherwise I think you're
stuck.

Michael

>
>
>
> ___
> If you reply to this email, your message will be added to the discussion 
> below:
> http://r.789695.n4.nabble.com/sapply-and-matrix-command-tp4637769p4639622.html
>
> To unsubscribe from sapply and matrix command, visit 
> http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4637769&code=ci1oZWxwQHItcHJvamVjdC5vcmd8NDYzNzc2OXwtNzg0MjM1NTA4
> [[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] All combinations possible in a mutliple regression

2012-08-09 Thread arun
HI,

I hope this helps you,

set.seed(1)
 dat1<-data.frame(X1=rnorm(25,15),X2=rnorm(25,5),X3=runif(25,0.4),X4=rnorm(25,12),Y=rnorm(25,35))
 ColNam<-names(dat1)
 ColNam
#[1] "X1" "X2" "X3" "X4" "Y" 

 ColNam<-ColNam[!ColNam %in% "Y"]
 n<-length(ColNam)
 ColNam
#[1] "X1" "X2" "X3" "X4"

 id1<-unlist(lapply(1:n,function(x)combn(1:n,x,simplify=F)),recursive=F)
f1<-lapply(id1,function(x)
 paste("Y~",paste(ColNam[x],collapse="+")))
res1<- lapply(f1,function(x) lm(as.formula(x),data=dat1))
 summary(res1[[1]])

Call:
lm(formula = as.formula(x), data = dat1)

Residuals:
 Min   1Q   Median   3Q  Max 
-1.46344 -0.78252 -0.08563  0.68324  1.49788 

Coefficients:
    Estimate Std. Error t value Pr(>|t|)    
(Intercept) 34.26057    3.03804  11.277 7.56e-11 ***
X1   0.05828    0.19991   0.292    0.773    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 0.9305 on 23 degrees of freedom
Multiple R-squared: 0.003682,    Adjusted R-squared: -0.03964 
F-statistic: 0.085 on 1 and 23 DF,  p-value: 0.7732 

A.K.



- Original Message -
From: zel7223 
To: r-help@r-project.org
Cc: 
Sent: Thursday, August 9, 2012 9:28 AM
Subject: [R] All combinations possible in a mutliple regression

Hi,

I want to use four independent variables to predict the output of one
dependent variable using a linear model lm. I want to compare all possible
combinations of the 4 independent variables, including singles, pairs and
triples.

I was thinking of using the AIC test to compare all models and pick the best
one.

The model looks like this : 

lm(Y ~ X1 + X2 + X3 + X4)

Thanks for your help

Cheers

Jean-Michel Fortin
UOttawa



--
View this message in context: 
http://r.789695.n4.nabble.com/All-combinations-possible-in-a-mutliple-regression-tp4639762.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] All combinations possible in a mutliple regression

2012-08-09 Thread arun


HI,

I forgot about the AIC.
 resAIC<-list()
for(i in 1:length(res1)){
 resAIC[[i]]<-list()
 resAIC[[i]]<-AIC(res1[[i]])
 }
 unlist(resAIC)
# [1] 71.25981 65.22991 71.32024 71.29489 67.20616 73.15101 73.13823 66.17742
 #[9] 66.96219 73.27309 67.78183 68.85621 75.03196 68.00660 69.39852

A.K.





- Original Message -
From: zel7223 
To: r-help@r-project.org
Cc: 
Sent: Thursday, August 9, 2012 9:28 AM
Subject: [R] All combinations possible in a mutliple regression

Hi,

I want to use four independent variables to predict the output of one
dependent variable using a linear model lm. I want to compare all possible
combinations of the 4 independent variables, including singles, pairs and
triples.

I was thinking of using the AIC test to compare all models and pick the best
one.

The model looks like this : 

lm(Y ~ X1 + X2 + X3 + X4)

Thanks for your help

Cheers

Jean-Michel Fortin
UOttawa



--
View this message in context: 
http://r.789695.n4.nabble.com/All-combinations-possible-in-a-mutliple-regression-tp4639762.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] Saving Data

2012-08-09 Thread Eric Kaufmann
I have a researcher who is running a large R job The job is currently on
3725 iterations. The total number of iterations is 27500. Is there a way to
kill this and recover the data that has been generated thus far?

Thanks,

Eric

-- 
Eric Kaufmann |  Application Support Analyst -  Advanced Technology Group |
Saint Louis University | 314-977-2257 | kaufm...@slu.edu

[[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 hist some 'x' not counted; maybe 'breaks' do not span range of 'x'

2012-08-09 Thread aprendiz programa


Hello Guys,

I would like help in script R  when I try to plot the histogram appears the 
error:
Erro em hist.default   some 'x' not counted; maybe 'breaks' do not span range 
of 'x'
I using a file  with more 1000 datas (vector)
hist(dados[[1]], seq(0, 20, 0.5), prob=TRUE, xlab="chuva 
(mm/dia)",ylab="frequência", main="", cex.lab=1.6, 
cex.sub=3,cex.axis=3,cex.main=6)
Please, someone could help me?
Thanks
Best Regards  
[[alternative HTML version deleted]]

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


[R] Survey package: using subset option with svyrepdesign

2012-08-09 Thread BrentMast
Hi. I'm using American Housing Survey (AHS) data with replicate weights. I
want subpopulation estimates. When I try to subset the survey design, I get
an error message. I don't get the error message when not using the replicate
weights (using  the regular svydesign function). 

Any help would be appreciated. My code and error message are below.

> dsn <-
> svrepdesign(weights=~wgt90geo,repweights=~repwgt,type="Fay",data=temp2,combined.weights=TRUE,rho=.5)
> dsub <- subset(dsn,subpop==TRUE)
Error in x$variables[i, , drop = FALSE] : incorrect number of dimensions

Thanks,
Brent Mast
HUD



--
View this message in context: 
http://r.789695.n4.nabble.com/Survey-package-using-subset-option-with-svyrepdesign-tp4639802.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 Commander - Time Series

2012-08-09 Thread Prof Brian Ripley

On 09/08/2012 21:13, David Winsemius wrote:


On Aug 9, 2012, at 8:55 AM, John Kane wrote:




Rather dput(head(my data, 50))


There's an Internet name for the misspelling a correction of a spelling
error. Something like  Corollary. This is what I found, but
it's not the name I (don't) remember:

http://rationalwiki.org/wiki/Skitt%27s_Law


Remember the (statistician, so not completely OT) Stigler's law.


Argh!!!  I think that in the third time in three weeks .


Michael probably made his error just to make you feel better.




--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] help hist some 'x' not counted; maybe 'breaks' do not span range of 'x'

2012-08-09 Thread David L Carlson
Use summary(dados[[1]]). The error message is telling you that the data
include values outside the 0 to 20 range you have specified.


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

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of aprendiz programa
> Sent: Thursday, August 09, 2012 3:13 PM
> To: r-help@r-project.org
> Subject: [R] help hist some 'x' not counted; maybe 'breaks' do not span
> range of 'x'
> 
> 
> 
> Hello Guys,
> 
> I would like help in script R  when I try to plot the histogram appears
> the error:
> Erro em hist.default   some 'x' not counted; maybe 'breaks' do not span
> range of 'x'
> I using a file  with more 1000 datas (vector)
> hist(dados[[1]], seq(0, 20, 0.5), prob=TRUE, xlab="chuva
> (mm/dia)",ylab="frequjncia", main="", cex.lab=1.6,
> cex.sub=3,cex.axis=3,cex.main=6)
> Please, someone could help me?
> Thanks
> Best Regards
>   [[alternative HTML version deleted]]

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


Re: [R] Add interpunct (dot) symbol to axis label?

2012-08-09 Thread David Winsemius


On Aug 8, 2012, at 6:21 PM, Hillary Ward wrote:


I'm having problems creating an axis label for a plot.

y_label = expression(paste(plain('CPUE
'),plain('(fish'),plain('x'),plain('h'^{-1}),plain(')')))

I'd like to replace the "x" with an interpunct symbol (dot). Any
suggestions how to do this?


I see you have seen other efforts in this direction, but thought I  
would throw in something different. I think the 'interpunct' symbol is  
already include in plotmath as '%.%'


 and I cannot resist attempting to greatly simplify that complex  
expression. Most uses of the plotmath 'paste' function I see in other  
postings are both redundant and obfuscatory (at least I think that  
should be a word). And parentheses behave as expected  And you do  
not need to use quotes around anything that is not a plotmath  
function.  I think this does the same construction and is MUCH easier  
to read:


  ylab = expression( CPUE(fish %.% h^{-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] Saving Data

2012-08-09 Thread Duncan Murdoch

On 12-08-09 3:41 PM, Eric Kaufmann wrote:

I have a researcher who is running a large R job The job is currently on
3725 iterations. The total number of iterations is 27500. Is there a way to
kill this and recover the data that has been generated thus far?


Not likely, unless the process is writing it out to file.

It's conceivable that you could cause a debugger to interrupt the 
process (or cause the OS to abort it and dump memory to a file for post 
mortem debugging), but it's not at all easy to find anything useful in 
such a situation.


Duncan Murdoch



Thanks,

Eric



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

2012-08-09 Thread jimi adams
I'm still not fully understanding exactly how R is handling data frames, but am 
getting closer. Any help with this one will likely go a long way in getting me 
there. Let's say I have a data frame, let's call it "a". Within that data frame 
i have two variables, let's call them "b" and "c", where "b" is a single 
numeric value per observation, while "c" is a LIST of numeric values. What I 
want to be able to do is perform an operation on each element in "c" by the 
single element in "b". 

So, for example, if I wanted to subtract each element in "c" from the scalar in 
"b". For example, if i had

> a$b
[1] 1988
[2] 1989
…
& 
> a$c
[[1]]
[1] 1985 1982 1984
[[2]]
[1] 1988 1980
…

I'm looking for a result of:
a$new
[[1]]
[1] 3 6 4
[[2]]
[1] 1 9
…

I've tried a few different things, none of which have the desired result. Any 
help appreciated.
thanks!

jimi adams
Assistant Professor
Department of Sociology
American University
e: jad...@american.edu
w: jimiadams.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] POSIXct to ts

2012-08-09 Thread Mary Ann Middleton

Hi, 

I have a dataframe (try.1) with  date/time and temperature columns, and the 
date/time is in POSIXct fomat. Sample included below. 

I would like to to try decompose () or stl() to look at the trends and 
seasonality in my data, eventually so that  I can  look at autocorrelation.  
The series is 3 years of water temperature with clearly visible seasonal 
periods. 

Right now, if I try decompose, I get the following error, w hich I beleive is 
because I haven't correctly defined a time series. 
"Error in decompose(try.1) : time series has no or less than 2 periods" 
  
I am stuck trying to go from POSIXct to as.ts 
Any suggestions on how to tackle this would be greatly appreciated.   

Sincerely, 
Mary Ann 

A sample of the data looks like this: 
'data.frame':   26925 obs. of  2 variables:
 $ date  : POSIXct, format: "2008-07-11 21:00:00" "2008-07-11 22:00:00" ...
 $ DL_1297699: num  15.3 15.1 14.9 14.6 14.1 ...   date DL_1297699 1   
2008-07-11 21:00:00 15.318 
2   2008-07-11 22:00:00 15.127 
3   2008-07-11 23:00:00 14.888 
4   2008-07-12 00:00:00 14.553 
5   2008-07-12 01:00:00 14.146 
6   2008-07-12 02:00:00 13.738 
7   2008-07-12 03:00:00 13.401 
8   2008-07-12 04:00:00 13.088 
9   2008-07-12 05:00:00 12.823 
10  2008-07-12 06:00:00 12.630 and the dput(head(x,50) gives this 
output: structure(list(date = structure(c(121581, 1215813600, 1215817200, 
1215820800, 1215824400, 1215828000, 1215831600, 1215835200, 1215838800, 
1215842400, 1215846000, 1215849600, 1215853200, 1215856800, 1215860400, 
1215864000, 1215867600, 1215871200, 1215874800, 1215878400, 1215882000, 
1215885600, 1215889200, 1215892800, 1215896400, 121590, 1215903600, 
1215907200, 1215910800, 1215914400, 1215918000, 1215921600, 1215925200, 
1215928800, 1215932400, 1215936000, 1215939600, 1215943200, 1215946800, 
1215950400, 1215954000, 1215957600, 1215961200, 1215964800, 1215968400, 
1215972000, 1215975600, 1215979200, 1215982800, 1215986400), class = 
c("POSIXt", 
"POSIXct"), tzone = "UTC"), DL_1297699 = c(15.318, 15.127, 14.888, 
14.553, 14.146, 13.738, 13.401, 13.088, 12.823, 12.63, 12.461, 
12.413, 12.461, 12.703, 13.04, 13.497, 14.026, 14.553, 15.031, 
15.366, 15.7, 15.819, 15.819, 15.7, 15.605, 15.461, 15.247, 14.984, 
14.673, 14.337, 14.002, 13.666, 13.377, 13.137, 12.944, 12.823, 
12.847, 13.016, 13.329, 13.762, 14.242, 14.697, 15.175, 15.581, 
15.891, 16.034, 16.034, 15.939, 15.772, 15.581)), .Names = c("date", 
"DL_1297699"), row.names = c(NA, 50L), class = "data.frame") 



[[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] Setting Number of Displayed Digits

2012-08-09 Thread Steve Taylor
Have you tried:  options(digits=9)

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Rich Shepard
Sent: Wednesday, 8 August 2012 5:51a
To: r-help@r-project.org
Subject: [R] Setting Number of Displayed Digits

   Some chemicals have concentrations at or below the method detection limit
(MDL; 'less-thans') of 0.005 mg/L. When I look at the data frame that is how
the concentration is displayed. But, when I ask for a summary() of that data
frame column only 0 is displayed.

   How can I adjust the number of digits displayed by functions such as
summary()?

Rich

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] summary() after changing contrasts

2012-08-09 Thread Daniel Weitzenfeld
Hi,
After running a regression on a factor variable, summary() reports the
coefficients 'nicely,' ie, labelled with a string that is a concatenation
of the variable name and the factor label.
However, changing the base case a la

contrasts(variable)<-contr.treatment(N, base=x)

results in the coefficients being reported as a less-helpful concatenation
of variable name plus a digit.

Of course, it's possible to map the digit to the appropriate factor label,
but I'm wondering if there's an easy fix...
-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] indexing in data frames

2012-08-09 Thread David L Carlson
You have not defined a data frame since data frames cannot contain lists,
but lists can contain data frames so you are asking about how to process a
list. I'm changing your object names to a, b, and d because c() is the
concatenation function and it can cause all kinds of problems to use it as
an object name.

> a <- list(b=c(1988, 1989), d=list(c(1985, 1982, 1984), c(1988, 1980)))
> a
$b
[1] 1988 1989

$d
$d[[1]]
[1] 1985 1982 1984

$d[[2]]
[1] 1988 1980

> a$b; a[[1]] # Two ways to refer to the first element of the list
[1] 1988 1989
[1] 1988 1989

> a$d; a[[2]] # Two ways to refer to the second element of the list
[[1]]
[1] 1985 1982 1984

[[2]]
[1] 1988 1980

[[1]]
[1] 1985 1982 1984

[[2]]
[1] 1988 1980

> a[[2]][[1]]; a$d[[1]] # Two ways to refer to the 1st element of the 2nd
element
[1] 1985 1982 1984
[1] 1985 1982 1984

> a[[2]][[2]]; a$d[[2]] # Two ways to refer to the 2nd element of the 2nd
element
[1] 1988 1980
[1] 1988 1980

> a$new <- sapply(1:2, function(i) a$b[i] - a$d[[i]])
> a$new
[[1]]
[1] 3 6 4

[[2]]
[1] 1 9

You can do all this with a data.frame if you think about it differently:

> a <- data.frame(year = c(1988, 1989), group = c("G1988", "G1989"))
> b <- data.frame(group = c(rep("G1988", 3), rep("G1989", 2)), 
d = c(1985, 1982, 1984, 1988, 1980))
> ab <- merge(a, b)
> ab <- data.frame(ab, diff=ab$year-ab$d)
> new <- split(ab$diff, ab$group)
> new
$G1988
[1] 3 6 4

$G1989
[1] 1 9

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

> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of jimi adams
> Sent: Thursday, August 09, 2012 3:43 PM
> To: r-help@r-project.org
> Subject: [R] indexing in data frames
> 
> I'm still not fully understanding exactly how R is handling data
> frames, but am getting closer. Any help with this one will likely go a
> long way in getting me there. Let's say I have a data frame, let's call
> it "a". Within that data frame i have two variables, let's call them
> "b" and "c", where "b" is a single numeric value per observation, while
> "c" is a LIST of numeric values. What I want to be able to do is
> perform an operation on each element in "c" by the single element in
> "b".
> 
> So, for example, if I wanted to subtract each element in "c" from the
> scalar in "b". For example, if i had
> 
> > a$b
> [1] 1988
> [2] 1989
> .
> &
> > a$c
> [[1]]
> [1] 1985 1982 1984
> [[2]]
> [1] 1988 1980
> .
> 
> I'm looking for a result of:
> a$new
> [[1]]
> [1] 3 6 4
> [[2]]
> [1] 1 9
> .
> 
> I've tried a few different things, none of which have the desired
> result. Any help appreciated.
> thanks!
> 
> jimi adams
> Assistant Professor
> Department of Sociology
> American University
> e: jad...@american.edu
> w: jimiadams.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] POSIXct to ts

2012-08-09 Thread R. Michael Weylandt
On Thu, Aug 9, 2012 at 3:30 PM, Mary Ann Middleton  wrote:
>
> Hi,
>
> I have a dataframe (try.1) with  date/time and temperature columns, and the 
> date/time is in POSIXct fomat. Sample included below.
>
> I would like to to try decompose () or stl() to look at the trends and 
> seasonality in my data, eventually so that  I can  look at autocorrelation.  
> The series is 3 years of water temperature with clearly visible seasonal 
> periods.
>
> Right now, if I try decompose, I get the following error, w hich I beleive is 
> because I haven't correctly defined a time series.
> "Error in decompose(try.1) : time series has no or less than 2 periods"
>
> I am stuck trying to go from POSIXct to as.ts
> Any suggestions on how to tackle this would be greatly appreciated.
>
> Sincerely,
> Mary Ann
>
> A sample of the data looks like this:
> 'data.frame':   26925 obs. of  2 variables:
>  $ date  : POSIXct, format: "2008-07-11 21:00:00" "2008-07-11 22:00:00" 
> ...
>  $ DL_1297699: num  15.3 15.1 14.9 14.6 14.1 ...   date DL_1297699 1
> 2008-07-11 21:00:00 15.318
> 2   2008-07-11 22:00:00 15.127
> 3   2008-07-11 23:00:00 14.888
> 4   2008-07-12 00:00:00 14.553
> 5   2008-07-12 01:00:00 14.146
> 6   2008-07-12 02:00:00 13.738
> 7   2008-07-12 03:00:00 13.401
> 8   2008-07-12 04:00:00 13.088
> 9   2008-07-12 05:00:00 12.823
> 10  2008-07-12 06:00:00 12.630 and the dput(head(x,50) gives this 
> output: structure(list(date = structure(c(121581, 1215813600, 1215817200,
> 1215820800, 1215824400, 1215828000, 1215831600, 1215835200, 1215838800,
> 1215842400, 1215846000, 1215849600, 1215853200, 1215856800, 1215860400,
> 1215864000, 1215867600, 1215871200, 1215874800, 1215878400, 1215882000,
> 1215885600, 1215889200, 1215892800, 1215896400, 121590, 1215903600,
> 1215907200, 1215910800, 1215914400, 1215918000, 1215921600, 1215925200,
> 1215928800, 1215932400, 1215936000, 1215939600, 1215943200, 1215946800,
> 1215950400, 1215954000, 1215957600, 1215961200, 1215964800, 1215968400,
> 1215972000, 1215975600, 1215979200, 1215982800, 1215986400), class = 
> c("POSIXt",
> "POSIXct"), tzone = "UTC"), DL_1297699 = c(15.318, 15.127, 14.888,
> 14.553, 14.146, 13.738, 13.401, 13.088, 12.823, 12.63, 12.461,
> 12.413, 12.461, 12.703, 13.04, 13.497, 14.026, 14.553, 15.031,
> 15.366, 15.7, 15.819, 15.819, 15.7, 15.605, 15.461, 15.247, 14.984,
> 14.673, 14.337, 14.002, 13.666, 13.377, 13.137, 12.944, 12.823,
> 12.847, 13.016, 13.329, 13.762, 14.242, 14.697, 15.175, 15.581,
> 15.891, 16.034, 16.034, 15.939, 15.772, 15.581)), .Names = c("date",
> "DL_1297699"), row.names = c(NA, 50L), class = "data.frame")
>

Thank you for the dput()-ed data!

The "time series" object that stl() and decompose() expect doesn't
have time stamps -- rather it has a "start" and "end" marker as well
as a frequency. [For more details, see ?tsp]

With your described data, I'd imagine you'd have start = 2008 and
frequency = 365*24 (if you have hourly data and an underlying yearly
periodicity) but to work with the data you gave, lets suppose 12 hours
is a cycle. Note you don't have to give end because that's figured out
automatically from frequency and start.

x.ts <- ts(x[,2], start = 1, frequency = 12)

then I can

stl(x, "per")
decompose(x)

as desired.

Hope that helps,
Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 overlay a global map on a filled contour?

2012-08-09 Thread Cable, Sam B Civ USAF AFMC AFRL/RVBXI
I would like to plot some lat-lon data in a filled contour, and then
overlay a map of the globe on top. I am trying something like this:

 

filled.contour(lons, lats, glb.data, 
plot.axes={axis(1);axis(2);map(projection='rectangular',parameters=0,add
=T)} 
) 

 

The filled contour plots fine, and the map shows up, but only as a very
tiny little black rectangle in a small area of the contour plot. Of
course, I want the map to stretch over the entire area of the filled
contour plot. 

 

I've also tried something like:

filled.contour(lons, lats, glb.data, 
plot.axes={axis(1);axis(2);map(projection='rectangular',x=lons,y=lats,pa
rameters=0,add=T)} 
) 

 

In this case, the map does not plot at all and I get an error message
"nothing to draw: all regions out of bounds"

 

People apparently do this successfully all the time, but I haven't been
able to get it to work. Can anyone tell me what I am doing wrong? BTW, I
don't want to use the lattice package. It will not work with the other
stuff my group is doing. 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] indexing in data frames

2012-08-09 Thread David Winsemius


On Aug 9, 2012, at 2:43 PM, David L Carlson wrote:

You have not defined a data frame since data frames cannot contain  
lists,


Not true:

> dput(a)
structure(list(b = c(1988, 1989),
   c = list(c(1985, 1982, 1984),
c(1988, 1980))), .Names = c("b", "c"))

> ab <- data.frame(a$b)
> ab
   a.b
1 1988
2 1989
> ab$cb <- a$c
> ab
   a.b   cb
1 1988 1985, 1982, 1984
2 1989   1988, 1980
> str(ab)
'data.frame':   2 obs. of  2 variables:
 $ a.b: num  1988 1989
 $ cb :List of 2
  ..$ : num  1985 1982 1984
  ..$ : num  1988 1980

But it seems unlikely that the OP's "a" object is a dataframe since  
the console eval-print loop would not display a dataframe in that  
manner.


At any rate with the ab dataframe:

> for( i in 1:NROW(ab) ) print(  ab$a.b[i] - ab$cb[[i]] )
[1] 3 6 4
[1] 1 9

The OP should note the need to use '[[' on a list-object to get  
commensurate classes to pass to the '-' operator.


--
david.


but lists can contain data frames so you are asking about how to  
process a

list. I'm changing your object names to a, b, and d because c() is the
concatenation function and it can cause all kinds of problems to use  
it as

an object name.

a <- list(b=c(1988, 1989), d=list(c(1985, 1982, 1984), c(1988,  
1980)))

a

$b
[1] 1988 1989

$d
$d[[1]]
[1] 1985 1982 1984

$d[[2]]
[1] 1988 1980


a$b; a[[1]] # Two ways to refer to the first element of the list

[1] 1988 1989
[1] 1988 1989


a$d; a[[2]] # Two ways to refer to the second element of the list

[[1]]
[1] 1985 1982 1984

[[2]]
[1] 1988 1980

[[1]]
[1] 1985 1982 1984

[[2]]
[1] 1988 1980

a[[2]][[1]]; a$d[[1]] # Two ways to refer to the 1st element of the  
2nd

element
[1] 1985 1982 1984
[1] 1985 1982 1984

a[[2]][[2]]; a$d[[2]] # Two ways to refer to the 2nd element of the  
2nd

element
[1] 1988 1980
[1] 1988 1980


a$new <- sapply(1:2, function(i) a$b[i] - a$d[[i]])
a$new

[[1]]
[1] 3 6 4

[[2]]
[1] 1 9

You can do all this with a data.frame if you think about it  
differently:



a <- data.frame(year = c(1988, 1989), group = c("G1988", "G1989"))
b <- data.frame(group = c(rep("G1988", 3), rep("G1989", 2)),

   d = c(1985, 1982, 1984, 1988, 1980))

ab <- merge(a, b)
ab <- data.frame(ab, diff=ab$year-ab$d)
new <- split(ab$diff, ab$group)
new

$G1988
[1] 3 6 4

$G1989
[1] 1 9

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


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of jimi adams
Sent: Thursday, August 09, 2012 3:43 PM
To: r-help@r-project.org
Subject: [R] indexing in data frames

I'm still not fully understanding exactly how R is handling data
frames, but am getting closer. Any help with this one will likely  
go a
long way in getting me there. Let's say I have a data frame, let's  
call

it "a". Within that data frame i have two variables, let's call them
"b" and "c", where "b" is a single numeric value per observation,  
while

"c" is a LIST of numeric values. What I want to be able to do is
perform an operation on each element in "c" by the single element in
"b".

So, for example, if I wanted to subtract each element in "c" from the
scalar in "b". For example, if i had


a$b

[1] 1988
[2] 1989
.
&

a$c

[[1]]
[1] 1985 1982 1984
[[2]]
[1] 1988 1980
.

I'm looking for a result of:
a$new
[[1]]
[1] 3 6 4
[[2]]
[1] 1 9
.

I've tried a few different things, none of which have the desired
result. Any help appreciated.
thanks!

jimi adams
Assistant Professor
Department of Sociology
American University
e: jad...@american.edu
w: jimiadams.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.


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 overlay a global map on a filled contour?

2012-08-09 Thread Duncan Murdoch

On 12-08-09 6:14 PM, Cable, Sam B Civ USAF AFMC AFRL/RVBXI wrote:

I would like to plot some lat-lon data in a filled contour, and then
overlay a map of the globe on top. I am trying something like this:



filled.contour(lons, lats, glb.data,
plot.axes={axis(1);axis(2);map(projection='rectangular',parameters=0,add
=T)}
)



The filled contour plots fine, and the map shows up, but only as a very
tiny little black rectangle in a small area of the contour plot. Of
course, I want the map to stretch over the entire area of the filled
contour plot.



I've also tried something like:

filled.contour(lons, lats, glb.data,
plot.axes={axis(1);axis(2);map(projection='rectangular',x=lons,y=lats,pa
rameters=0,add=T)}
)



In this case, the map does not plot at all and I get an error message
"nothing to draw: all regions out of bounds"



People apparently do this successfully all the time, but I haven't been
able to get it to work. Can anyone tell me what I am doing wrong? BTW, I
don't want to use the lattice package. It will not work with the other
stuff my group is doing. Thanks.



Your code doesn't quite make sense.  The map function doesn't want to 
know the x and y values; it just wants to know the region to plot, which 
should have been set by the data.  So, assuming that 
filled.contour(lons, lats, glb.data) produces something sensible, you'd 
get what you want with


filled.contour(lons, lats, glb.data, plot.axes={axis(1); axis(2); 
map(add=TRUE)})


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.


Re: [R] indexing in data frames

2012-08-09 Thread David L Carlson
Amazing. You have to create the data frame and then add a variable
containing the list to keep R from checking the number of rows and
objecting:

This does not work
data.frame(b = c(1988, 1989),c = list(c(1985, 1982, 1984),c(1988, 1980)))

Nor this
data.frame(a$b, a$c)

---
David

> -Original Message-
> From: David Winsemius [mailto:dwinsem...@comcast.net]
> Sent: Thursday, August 09, 2012 5:17 PM
> To: dcarl...@tamu.edu
> Cc: 'jimi adams'; r-help@r-project.org
> Subject: Re: [R] indexing in data frames
> 
> 
> On Aug 9, 2012, at 2:43 PM, David L Carlson wrote:
> 
> > You have not defined a data frame since data frames cannot contain
> > lists,
> 
> Not true:
> 
>  > dput(a)
> structure(list(b = c(1988, 1989),
> c = list(c(1985, 1982, 1984),
>  c(1988, 1980))), .Names = c("b", "c"))
> 
>  > ab <- data.frame(a$b)
>  > ab
> a.b
> 1 1988
> 2 1989
>  > ab$cb <- a$c
>  > ab
> a.b   cb
> 1 1988 1985, 1982, 1984
> 2 1989   1988, 1980
>  > str(ab)
> 'data.frame': 2 obs. of  2 variables:
>   $ a.b: num  1988 1989
>   $ cb :List of 2
>..$ : num  1985 1982 1984
>..$ : num  1988 1980
> 
> But it seems unlikely that the OP's "a" object is a dataframe since
> the console eval-print loop would not display a dataframe in that
> manner.
> 
> At any rate with the ab dataframe:
> 
>  > for( i in 1:NROW(ab) ) print(  ab$a.b[i] - ab$cb[[i]] )
> [1] 3 6 4
> [1] 1 9
> 
> The OP should note the need to use '[[' on a list-object to get
> commensurate classes to pass to the '-' operator.
> 
> --
> david.
> 
> 
> > but lists can contain data frames so you are asking about how to
> > process a
> > list. I'm changing your object names to a, b, and d because c() is
> the
> > concatenation function and it can cause all kinds of problems to use
> > it as
> > an object name.
> >
> >> a <- list(b=c(1988, 1989), d=list(c(1985, 1982, 1984), c(1988,
> >> 1980)))
> >> a
> > $b
> > [1] 1988 1989
> >
> > $d
> > $d[[1]]
> > [1] 1985 1982 1984
> >
> > $d[[2]]
> > [1] 1988 1980
> >
> >> a$b; a[[1]] # Two ways to refer to the first element of the list
> > [1] 1988 1989
> > [1] 1988 1989
> >
> >> a$d; a[[2]] # Two ways to refer to the second element of the list
> > [[1]]
> > [1] 1985 1982 1984
> >
> > [[2]]
> > [1] 1988 1980
> >
> > [[1]]
> > [1] 1985 1982 1984
> >
> > [[2]]
> > [1] 1988 1980
> >
> >> a[[2]][[1]]; a$d[[1]] # Two ways to refer to the 1st element of the
> >> 2nd
> > element
> > [1] 1985 1982 1984
> > [1] 1985 1982 1984
> >
> >> a[[2]][[2]]; a$d[[2]] # Two ways to refer to the 2nd element of the
> >> 2nd
> > element
> > [1] 1988 1980
> > [1] 1988 1980
> >
> >> a$new <- sapply(1:2, function(i) a$b[i] - a$d[[i]])
> >> a$new
> > [[1]]
> > [1] 3 6 4
> >
> > [[2]]
> > [1] 1 9
> >
> > You can do all this with a data.frame if you think about it
> > differently:
> >
> >> a <- data.frame(year = c(1988, 1989), group = c("G1988", "G1989"))
> >> b <- data.frame(group = c(rep("G1988", 3), rep("G1989", 2)),
> >d = c(1985, 1982, 1984, 1988, 1980))
> >> ab <- merge(a, b)
> >> ab <- data.frame(ab, diff=ab$year-ab$d)
> >> new <- split(ab$diff, ab$group)
> >> new
> > $G1988
> > [1] 3 6 4
> >
> > $G1989
> > [1] 1 9
> >
> > --
> > David L Carlson
> > Associate Professor of Anthropology
> > Texas A&M University
> > College Station, TX 77843-4352
> >
> >> -Original Message-
> >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> >> project.org] On Behalf Of jimi adams
> >> Sent: Thursday, August 09, 2012 3:43 PM
> >> To: r-help@r-project.org
> >> Subject: [R] indexing in data frames
> >>
> >> I'm still not fully understanding exactly how R is handling data
> >> frames, but am getting closer. Any help with this one will likely
> >> go a
> >> long way in getting me there. Let's say I have a data frame, let's
> >> call
> >> it "a". Within that data frame i have two variables, let's call them
> >> "b" and "c", where "b" is a single numeric value per observation,
> >> while
> >> "c" is a LIST of numeric values. What I want to be able to do is
> >> perform an operation on each element in "c" by the single element in
> >> "b".
> >>
> >> So, for example, if I wanted to subtract each element in "c" from
> the
> >> scalar in "b". For example, if i had
> >>
> >>> a$b
> >> [1] 1988
> >> [2] 1989
> >> .
> >> &
> >>> a$c
> >> [[1]]
> >> [1] 1985 1982 1984
> >> [[2]]
> >> [1] 1988 1980
> >> .
> >>
> >> I'm looking for a result of:
> >> a$new
> >> [[1]]
> >> [1] 3 6 4
> >> [[2]]
> >> [1] 1 9
> >> .
> >>
> >> I've tried a few different things, none of which have the desired
> >> result. Any help appreciated.
> >> thanks!
> >>
> >> jimi adams
> >> Assistant Professor
> >> Department of Sociology
> >> American University
> >> e: jad...@american.edu
> >> w: jimiadams.com
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do 

[R] predict.drc for specific point

2012-08-09 Thread Joch
Does any one know how to calculate/predict the value at some time point (say
90%) based on dose response curve using "drc' in R? I know how to fit the
curve with drc. But need to calculate 90% value at some time point. Many
thanks. 



--
View this message in context: 
http://r.789695.n4.nabble.com/predict-drc-for-specific-point-tp4639820.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] indexing in data frames

2012-08-09 Thread arun
HI,

If  "b" is also an "element of list, then it would be much easier.
b<-c(1988,1989,1990,1991,1992)
c<-list(c(1985,1982,1984),c(1988,1980),c(1983,1984),c(1988,1998,1993),c(1993,1994,1998))
 a<-list(b,c)
 names(a)<-c("b","c")

 lapply(1:length(a$c),function(x) a$b[x]-a$c[[x]])
[[1]]
[1] 3 6 4

[[2]]
[1] 1 9

[[3]]
[1] 7 6

[[4]]
[1]  3 -7 -2

[[5]]
[1] -1 -2 -6
#2nd case

d<-data.frame(a1=c(1998,1924,1938),b1=c(1942,1938,1944))
a2<-list(d,c)

lapply(1:length(c),function(x) a2$d[,1:2]-a2$c[[x]])



A.K.






- Original Message -
From: jimi adams 
To: arun 
Cc: R help 
Sent: Thursday, August 9, 2012 5:42 PM
Subject: Re: [R] indexing in data frames

Thanks. Yes, I got it to work with loops for small data. I was just hoping, 
given the size of the data.frame (hundreds of thousands) and the length of the 
lists (varying up to a few hundred) to avoid that if at all possible. Perhaps 
I'm expecting some behavior that's not feasible?

cheers,
jimi

On 09Aug, 2012, at 17:39 , arun wrote:

> HI,
> 
> In the reply I sent, I forgot to add,
> 
> anew<-list()#before,
> for(i in 1:length(b1)){
>  anew[[i]]<-list()
>  anew[[i]]<-b1[[i]]-c[[i]]
>  }
> 
> A.K.
> 
> - Original Message -
> From: jimi adams 
> To: r-help@r-project.org
> Cc: 
> Sent: Thursday, August 9, 2012 4:42 PM
> Subject: [R] indexing in data frames
> 
> I'm still not fully understanding exactly how R is handling data frames, but 
> am getting closer. Any help with this one will likely go a long way in 
> getting me there. Let's say I have a data frame, let's call it "a". Within 
> that data frame i have two variables, let's call them "b" and "c", where "b" 
> is a single numeric value per observation, while "c" is a LIST of numeric 
> values. What I want to be able to do is perform an operation on each element 
> in "c" by the single element in "b". 
> 
> So, for example, if I wanted to subtract each element in "c" from the scalar 
> in "b". For example, if i had
> 
>> a$b
> [1] 1988
> [2] 1989
> …
> & 
>> a$c
> [[1]]
> [1] 1985 1982 1984
> [[2]]
> [1] 1988 1980
> …
> 
> I'm looking for a result of:
> a$new
> [[1]]
> [1] 3 6 4
> [[2]]
> [1] 1 9
> …
> 
> I've tried a few different things, none of which have the desired result. Any 
> help appreciated.
> thanks!
> 
> jimi adams
> Assistant Professor
> Department of Sociology
> American University
> e: jad...@american.edu
> w: jimiadams.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] indexing in data frames

2012-08-09 Thread arun
HI,

You can get the results you wanted by:
c=list(c(1985,1982,1984),c(1988,1980),c(1983,1984),c(1988,1998,1993),c(1993,1994,1998))
b1<-list(1988,1989,1990,1991,1992)
for(i in 1:length(b1)){
 anew[[i]]<-list()
 anew[[i]]<-b1[[i]]-c[[i]]
 }
 anew
[[1]]
[1] 3 6 4

[[2]]
[1] 1 9
---
---
But, if you wanted both both a list and a vector in a dataframe "a"
It is possible:
b<-c(1988,1989,1990,1991,1992)
c=list(c(1985,1982,1984),c(1988,1980),c(1983,1984),c(1988,1998,1993),c(1993,1994,1998))

 a<-data.frame(b,c1=cbind(c))

 a
# b    c
#1 1988 1985, 1982, 1984
#2 1989   1988, 1980
#3 1990   1983, 1984
#4 1991 1988, 1998, 1993
#5 1992 1993, 1994, 1998
anew1<-list()
for(i in 1:nrow(a)){
 anew1[[i]]<-list()
 anew1[[i]]<-a$b[i]-a$c[[i]]
 }
> anew1
[[1]]
[1] 3 6 4

[[2]]
[1] 1 9

[[3]]
[1] 7 6

[[4]]
[1]  3 -7 -2

[[5]]
[1] -1 -2 -6
A.K.




- Original Message -
From: jimi adams 
To: r-help@r-project.org
Cc: 
Sent: Thursday, August 9, 2012 4:42 PM
Subject: [R] indexing in data frames

I'm still not fully understanding exactly how R is handling data frames, but am 
getting closer. Any help with this one will likely go a long way in getting me 
there. Let's say I have a data frame, let's call it "a". Within that data frame 
i have two variables, let's call them "b" and "c", where "b" is a single 
numeric value per observation, while "c" is a LIST of numeric values. What I 
want to be able to do is perform an operation on each element in "c" by the 
single element in "b". 

So, for example, if I wanted to subtract each element in "c" from the scalar in 
"b". For example, if i had

> a$b
[1] 1988
[2] 1989
…
& 
> a$c
[[1]]
[1] 1985 1982 1984
[[2]]
[1] 1988 1980
…

I'm looking for a result of:
a$new
[[1]]
[1] 3 6 4
[[2]]
[1] 1 9
…

I've tried a few different things, none of which have the desired result. Any 
help appreciated.
thanks!

jimi adams
Assistant Professor
Department of Sociology
American University
e: jad...@american.edu
w: jimiadams.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] How to overlay a global map on a filled contour?

2012-08-09 Thread Cable, Sam B Civ USAF AFMC AFRL/RVBXI
Duncan,

I agree that my second code doesn't make sense.  Sorry for the red herring.
I was grasping at straws.

My first code, however, differs from your suggestion only in that I am
asking for a rectangular projection, AFAICT.  As it turns out, I do get
quite different results when asking for the rectangular projection and when
I just accept the default, as in your code.  But neither one actually fits
the map to the region of the filled contour.

I have found a kluge that works, involving re-setting par(usr)  before the
call to map(), but it is really ugly and "empirical".  I am hoping there is
a better way.

Thanks.



-Original Message-
From: Duncan Murdoch [mailto:murdoch.dun...@gmail.com] 
Sent: Thursday, August 09, 2012 4:39 PM
To: Cable, Sam B Civ USAF AFMC AFRL/RVBXI
Cc: r-help@r-project.org
Subject: Re: [R] How to overlay a global map on a filled contour?

...

>Your code doesn't quite make sense.  The map function doesn't want to know
the x and y values; it just wants to know the region to plot, which >should
have been set by the data.  So, assuming that filled.contour(lons, lats,
glb.data) produces something sensible, you'd get what you want >with

>filled.contour(lons, lats, glb.data, plot.axes={axis(1); axis(2);
>map(add=TRUE)})

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


Re: [R] indexing in data frames

2012-08-09 Thread arun
HI,

In the reply I sent, I forgot to add,

anew<-list()#before,
for(i in 1:length(b1)){
 anew[[i]]<-list()
 anew[[i]]<-b1[[i]]-c[[i]]
 }

A.K.

- Original Message -
From: jimi adams 
To: r-help@r-project.org
Cc: 
Sent: Thursday, August 9, 2012 4:42 PM
Subject: [R] indexing in data frames

I'm still not fully understanding exactly how R is handling data frames, but am 
getting closer. Any help with this one will likely go a long way in getting me 
there. Let's say I have a data frame, let's call it "a". Within that data frame 
i have two variables, let's call them "b" and "c", where "b" is a single 
numeric value per observation, while "c" is a LIST of numeric values. What I 
want to be able to do is perform an operation on each element in "c" by the 
single element in "b". 

So, for example, if I wanted to subtract each element in "c" from the scalar in 
"b". For example, if i had

> a$b
[1] 1988
[2] 1989
…
& 
> a$c
[[1]]
[1] 1985 1982 1984
[[2]]
[1] 1988 1980
…

I'm looking for a result of:
a$new
[[1]]
[1] 3 6 4
[[2]]
[1] 1 9
…

I've tried a few different things, none of which have the desired result. Any 
help appreciated.
thanks!

jimi adams
Assistant Professor
Department of Sociology
American University
e: jad...@american.edu
w: jimiadams.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.


  1   2   >