Re: [R] FW: Group by and duplicate a value/dplyr

2021-05-11 Thread Elahe chalabi via R-help
Hi Petr,

Thanks for your help! it works perfectly fine. 






On Tuesday, May 11, 2021, 01:36:50 PM GMT+2, PIKAL Petr 
 wrote: 





I forgot to cc to rhelp.

Petr


Hi
Dunno how to do it by dplyr
I would use ave

df$MinValue <- ave(df$Value, paste(df$Class, df$Department), FUN =
function(x)
min(x[x>0]))

Cheers
Petr



> > -Original Message-
> > From: R-help  On Behalf Of Elahe chalabi
> via
> > R-help
> > Sent: Tuesday, May 11, 2021 1:12 PM
> > To: R-help Mailing List 
> > Subject: [R] Group by and duplicate a value/dplyr
> >
> > Hi all,
> >
> > I have the following data frame
> >
> >
> > dput(df)
> >    structure(list(Department = c("A", "A", "A", "A", "A", "A", "A", "A",
> > "B", "B",
> > "B", "B", "B", "B", "B", "B"), Class = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
> > 1L,
> > 1L, 1L, 1L,
> > 2L, 2L, 2L, 2L), Value = c(0L, 100L, 800L, 800L, 0L, 300L, 1200L, 1200L, 
> > 0L,
> > 0L,
> > 400L, 400L, 200L, 800L, 1200L, 1200L)), class = "data.frame", row.names =
> > c(NA,
> > -16L))
> >
> >
> > I would like to group by "Department" and "Class" and repeat the minimum
> > value of "Valule" excluding zeros or get the second minimum value. The
> > desired output is:
> >
> >
> >    dput(df)
> >    structure(list(Department = c("A", "A", "A", "A", "A", "A", "A", "A",
> > "B", "B",
> > "B", "B", "B", "B", "B", "B"), Class = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
> > 1L,
> > 1L, 1L, 1L,
> > 2L, 2L, 2L, 2L), Value = c(0L, 100L, 800L, 800L, 0L, 300L, 1200L, 1200L, 
> > 0L,
> > 0L,
> > 400L, 400L, 200L, 800L, 1200L, 1200L), MinValue = c(100L, 100L, 100L, 
> > 100L,
> > 300L, 300L, 300L, 300L, 400L, 400L, 400L, 400L, 200L, 200L, 200L, 200L)),
> > class =
> > "data.frame", row.names = c(NA, -16L))
> >
> >
> > how should I change the following dplyr to give me the desired output?
> >
> >
> >    df <-
> >  df %>%
> >  group_by(Department,Class) %>%
> >  mutate(MinValue=min(Value) )
> >
> >
> > Thanks for any help.
> > Elahe
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-
> > guide.html
> > and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] FW: problem with markov random field smooths in mgcv

2020-04-30 Thread Wilcox, Chris (O&A, Hobart)
Thanks very much Simon, that is super helpful.

Best,

Chris

On 25/3/20, 9:47 am, "Simon Wood"  wrote:

Hi Chris,

It's kind of a documentation glitch, a node is not supposed to be listed 
as its own neighbour (it causes the diagonal entries in the penalty 
matrix to be over-written by the wrong value). i.e. the neighbour list 
should be.

  NB <- list()
 NB$'East Timor' <- c(2,15)
 NB$Australia <- c(1,15)
 NB$'Sri Lanka' <-c(12,16)
 NB$Bangladesh <-c(12,13,16)
 NB$Philippines <- c(6,11,14,15,17)
 NB$Taiwan <- c(5,11)
 NB$Thailand <- c(8,10,12,13,14,15)
 NB$Vietnam <- c(7,10,11,14,15)
 NB$`South Korea` <- c(11)
 NB$Cambodia <- c(7,8)
 NB$China <- c(5,6,8,9,14)
 NB$India <- c(3,4,7,13,15,16)
 NB$Myanmar <- c(4,7,12,16)
 NB$Malaysia <- c(5,7,8,11,15)
 NB$Indonesia <- c(1,2,5,7,8,12,14)
 NB$HighSeas2 <- c(3,4,12,13)
 NB$HighSeas1 <- c(5)

I've fixed the help page and had the smooth constructor ignore 
auto-neighbours for the next release.

best,
Simon

   On 18/03/2020 07:44, Wilcox, Chris (O&A, Hobart) wrote:
> Hi all,
>  
>  I am trying to fit a model with a markov random field smooth in 
mgcv.  I am having some trouble with getting it to run, and in particular I am 
getting the message
>  
>  Error in initial.sp(w * x, S, off) : S[[1]] matrix is not +ve 
definite.
>  
>  After reading everything I could find on mrf, it sounds like there 
was a bug that was brought up with Simon Wood in 2012, due to differences 
between windows and linux, with the linus machine stopping due to this error, 
while windows was not.  I have not been able to find much else on it.  Any 
suggestions would be much appreciated.
>  
>  There is reproducible code below.
>  
>  Thanks
>  
>  Chris
>  
>  
>  library(mgcv)
>  
>  #create data
>  Country <- 
as.factor(c("Australia","Australia","Australia","Australia","Australia","Australia","Bangladesh","Bangladesh","Bangladesh",
>  
"Bangladesh","Bangladesh","Bangladesh","Cambodia","Cambodia","Cambodia","Cambodia","Cambodia","Cambodia",
>  "China","China","China","China","China","China","East Timor","East 
Timor","East Timor",
>  "East Timor","East Timor","East 
Timor","HighSeas1","HighSeas1","HighSeas1","HighSeas1","HighSeas1","HighSeas1",
>  
"HighSeas2","HighSeas2","HighSeas2","HighSeas2","HighSeas2","HighSeas2","China","China","China","China","China","China",
>  
"India","India","India","India","India","India","Indonesia","Indonesia","Indonesia","Indonesia","Indonesia","Indonesia",
>  
"Malaysia","Malaysia","Malaysia","Malaysia","Malaysia","Malaysia","Myanmar","Myanmar","Myanmar","Myanmar","Myanmar",
>  
"Myanmar","Philippines","Philippines","Philippines","Philippines","Philippines","Philippines","South
 Korea","South Korea",
>  "South Korea","South Korea","South Korea","South 
Korea","China","China","China","China","China","China",
>  "Sri Lanka","Sri Lanka","Sri Lanka","Sri Lanka","Sri Lanka","Sri 
Lanka","Taiwan","Taiwan","Taiwan","Taiwan",
>  
"Taiwan","Taiwan","Thailand","Thailand","Thailand","Thailand","Thailand","Thailand","Vietnam","Vietnam","Vietnam","Vietnam",
>  "Vietnam","Vietnam"))
>  
>  Count <- 
c(0,0,3,5,1,5,0,0,0,0,0,1,0,0,0,0,0,3,0,0,2,1,0,6,0,0,0,1,0,0,0,1,0,0,0,0
>  
,0,0,20,0,1,0,0,0,0,0,0,2,0,0,6,3,3,10,1,1,18,11,8,11,0,1,2,2,1,14,0,0,0,1,0,0
>  
,0,0,4,3,9,16,0,0,3,0,0,1,0,0,1,0,0,0,0,0,33,18,8,16,0,0,0,0,0,2,0,1,14,6,8,2
>  ,0,0,0,0,1,1)
>  
>  Data <- data.frame(Count,Country)
>  
>  #create neighbour matrix
>  NB <- list()
>  NB$'East Timor' <- c(1,2,15)
>  NB$Australia <- c(1,2,15)
>  NB$'Sri Lanka' <-c(3,12,16)
>  NB$Bangladesh <-c(4,12,13,16)
>  NB$Philippines <- c(5,6,11,14,15,17)
>  NB$Taiwan <- c(5,6,11)
>  NB$Thailand <- c(7,8,10,12,13,14,15)
>  NB$Vietnam <- c(7,8,10,11,14,15)
>  NB$`South Korea` <- c(9,11)
>  NB$Cambodia <- c(7,8,10)
>  NB$China <- c(5,6,8,9,11,14)
>  NB$India <- c(3,4,7,12,13,15,16)
>  NB$Myanmar <- c(4,7,12,13,16)
>  NB$Malaysia <- c(5,7,8,11,14,15)
>  NB$Indonesia <- c(1,2,5,7,8,12,14,15)
>  NB$HighSeas2 <- c(3,4,12,13,16)
>  NB$HighSeas1 <- c(5,17)
>  
>  #check levels and names match
>  all.equal(sort(names(NB)), sort(levels(Data$Country)))
>  
>  #try fitting GAM
>  m1 <- gam(Data$Count ~ s(Data$Country, bs = 'mrf', xt = list(nb = 
NB)))
>  
>  
>
> __
> R-help@r-pr

Re: [R] FW: problem with markov random field smooths in mgcv

2020-03-24 Thread Simon Wood

Hi Chris,

It's kind of a documentation glitch, a node is not supposed to be listed 
as its own neighbour (it causes the diagonal entries in the penalty 
matrix to be over-written by the wrong value). i.e. the neighbour list 
should be.


 NB <- list()
    NB$'East Timor' <- c(2,15)
    NB$Australia <- c(1,15)
    NB$'Sri Lanka' <-c(12,16)
    NB$Bangladesh <-c(12,13,16)
    NB$Philippines <- c(6,11,14,15,17)
    NB$Taiwan <- c(5,11)
    NB$Thailand <- c(8,10,12,13,14,15)
    NB$Vietnam <- c(7,10,11,14,15)
    NB$`South Korea` <- c(11)
    NB$Cambodia <- c(7,8)
    NB$China <- c(5,6,8,9,14)
    NB$India <- c(3,4,7,13,15,16)
    NB$Myanmar <- c(4,7,12,16)
    NB$Malaysia <- c(5,7,8,11,15)
    NB$Indonesia <- c(1,2,5,7,8,12,14)
    NB$HighSeas2 <- c(3,4,12,13)
    NB$HighSeas1 <- c(5)

I've fixed the help page and had the smooth constructor ignore 
auto-neighbours for the next release.


best,
Simon

  On 18/03/2020 07:44, Wilcox, Chris (O&A, Hobart) wrote:

Hi all,
 
 I am trying to fit a model with a markov random field smooth in mgcv.  I am having some trouble with getting it to run, and in particular I am getting the message
 
 Error in initial.sp(w * x, S, off) : S[[1]] matrix is not +ve definite.
 
 After reading everything I could find on mrf, it sounds like there was a bug that was brought up with Simon Wood in 2012, due to differences between windows and linux, with the linus machine stopping due to this error, while windows was not.  I have not been able to find much else on it.  Any suggestions would be much appreciated.
 
 There is reproducible code below.
 
 Thanks
 
 Chris
 
 
 library(mgcv)
 
 #create data

 Country <- 
as.factor(c("Australia","Australia","Australia","Australia","Australia","Australia","Bangladesh","Bangladesh","Bangladesh",
 
"Bangladesh","Bangladesh","Bangladesh","Cambodia","Cambodia","Cambodia","Cambodia","Cambodia","Cambodia",
 "China","China","China","China","China","China","East Timor","East Timor","East 
Timor",
 "East Timor","East Timor","East 
Timor","HighSeas1","HighSeas1","HighSeas1","HighSeas1","HighSeas1","HighSeas1",
 
"HighSeas2","HighSeas2","HighSeas2","HighSeas2","HighSeas2","HighSeas2","China","China","China","China","China","China",
 
"India","India","India","India","India","India","Indonesia","Indonesia","Indonesia","Indonesia","Indonesia","Indonesia",
 
"Malaysia","Malaysia","Malaysia","Malaysia","Malaysia","Malaysia","Myanmar","Myanmar","Myanmar","Myanmar","Myanmar",
 
"Myanmar","Philippines","Philippines","Philippines","Philippines","Philippines","Philippines","South
 Korea","South Korea",
 "South Korea","South Korea","South Korea","South 
Korea","China","China","China","China","China","China",
 "Sri Lanka","Sri Lanka","Sri Lanka","Sri Lanka","Sri Lanka","Sri 
Lanka","Taiwan","Taiwan","Taiwan","Taiwan",
 
"Taiwan","Taiwan","Thailand","Thailand","Thailand","Thailand","Thailand","Thailand","Vietnam","Vietnam","Vietnam","Vietnam",
 "Vietnam","Vietnam"))
 
 Count <- c(0,0,3,5,1,5,0,0,0,0,0,1,0,0,0,0,0,3,0,0,2,1,0,6,0,0,0,1,0,0,0,1,0,0,0,0

 
,0,0,20,0,1,0,0,0,0,0,0,2,0,0,6,3,3,10,1,1,18,11,8,11,0,1,2,2,1,14,0,0,0,1,0,0
 
,0,0,4,3,9,16,0,0,3,0,0,1,0,0,1,0,0,0,0,0,33,18,8,16,0,0,0,0,0,2,0,1,14,6,8,2
 ,0,0,0,0,1,1)
 
 Data <- data.frame(Count,Country)
 
 #create neighbour matrix

 NB <- list()
 NB$'East Timor' <- c(1,2,15)
 NB$Australia <- c(1,2,15)
 NB$'Sri Lanka' <-c(3,12,16)
 NB$Bangladesh <-c(4,12,13,16)
 NB$Philippines <- c(5,6,11,14,15,17)
 NB$Taiwan <- c(5,6,11)
 NB$Thailand <- c(7,8,10,12,13,14,15)
 NB$Vietnam <- c(7,8,10,11,14,15)
 NB$`South Korea` <- c(9,11)
 NB$Cambodia <- c(7,8,10)
 NB$China <- c(5,6,8,9,11,14)
 NB$India <- c(3,4,7,12,13,15,16)
 NB$Myanmar <- c(4,7,12,13,16)
 NB$Malaysia <- c(5,7,8,11,14,15)
 NB$Indonesia <- c(1,2,5,7,8,12,14,15)
 NB$HighSeas2 <- c(3,4,12,13,16)
 NB$HighSeas1 <- c(5,17)
 
 #check levels and names match

 all.equal(sort(names(NB)), sort(levels(Data$Country)))
 
 #try fitting GAM

 m1 <- gam(Data$Count ~ s(Data$Country, bs = 'mrf', xt = list(nb = NB)))
 
 


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


--
Simon Wood, School of Mathematics, University of Bristol, BS8 1TW UK
https://people.maths.bris.ac.uk/~sw15190/

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

Re: [R] FW: problem with markov random field smooths in mgcv

2020-03-18 Thread Wilcox, Chris (O&A, Hobart)
Hi David,

Thanks for the comments.  I am running the analysis on a mac OS 10.12.6, using 
R R 3.5.3 GUI 1.70 El Capitan build (7632), and mgcv 1.8-31.  

I am aware of the procedure of using data = "xx" in a call to gam.  I am having 
a strange issue locally, in that gam does not see to be able to find the 
response variable (Count) if I use the standard way of handing gam the data.  
That is the reason I wrote the gam function as I did.  I wanted to ignore that 
issue for the moment.  I have not had it happen with mgcv before, despite 
having used it for 10 years or so.

In reference to your question about spatial data, see the section of the code 
that starts with #create neighbourhood matrix.  This should say list, not 
matrix.  But it is the indices of the levels in the Country variable that are 
neighbours.  This list defines the parameter nb in the call to the function 
that constructs the mrf.

Thanks for spending the time to look at the problem.  I did not use the columb 
structure, but if you read down in the help for the smooth constructor function 
you can see that Simon has an example using nb that is like the one I submitted.

Cheers,

Chris

On 19/3/20, 3:41 am, "David Winsemius"  wrote:


On 3/18/20 12:44 AM, Wilcox, Chris (O&A, Hobart) wrote:
> Hi all,
>  
>  I am trying to fit a model with a markov random field smooth in 
mgcv.  I am having some trouble with getting it to run, and in particular I am 
getting the message
>  
>  Error in initial.sp(w * x, S, off) : S[[1]] matrix is not +ve 
definite.
>  
>  After reading everything I could find on mrf, it sounds like there 
was a bug that was brought up with Simon Wood in 2012, due to differences 
between windows and linux, with the linus machine stopping due to this error, 
while windows was not.  I have not been able to find much else on it.  Any 
suggestions would be much appreciated.
>  
>  There is reproducible code below.
>  
>  Thanks
>  
>  Chris
>  
>  
>  library(mgcv)
>  
>  #create data
>  Country <- 
as.factor(c("Australia","Australia","Australia","Australia","Australia","Australia","Bangladesh","Bangladesh","Bangladesh",
>  
"Bangladesh","Bangladesh","Bangladesh","Cambodia","Cambodia","Cambodia","Cambodia","Cambodia","Cambodia",
>  "China","China","China","China","China","China","East Timor","East 
Timor","East Timor",
>  "East Timor","East Timor","East 
Timor","HighSeas1","HighSeas1","HighSeas1","HighSeas1","HighSeas1","HighSeas1",
>  
"HighSeas2","HighSeas2","HighSeas2","HighSeas2","HighSeas2","HighSeas2","China","China","China","China","China","China",
>  
"India","India","India","India","India","India","Indonesia","Indonesia","Indonesia","Indonesia","Indonesia","Indonesia",
>  
"Malaysia","Malaysia","Malaysia","Malaysia","Malaysia","Malaysia","Myanmar","Myanmar","Myanmar","Myanmar","Myanmar",
>  
"Myanmar","Philippines","Philippines","Philippines","Philippines","Philippines","Philippines","South
 Korea","South Korea",
>  "South Korea","South Korea","South Korea","South 
Korea","China","China","China","China","China","China",
>  "Sri Lanka","Sri Lanka","Sri Lanka","Sri Lanka","Sri Lanka","Sri 
Lanka","Taiwan","Taiwan","Taiwan","Taiwan",
>  
"Taiwan","Taiwan","Thailand","Thailand","Thailand","Thailand","Thailand","Thailand","Vietnam","Vietnam","Vietnam","Vietnam",
>  "Vietnam","Vietnam"))
>  
>  Count <- 
c(0,0,3,5,1,5,0,0,0,0,0,1,0,0,0,0,0,3,0,0,2,1,0,6,0,0,0,1,0,0,0,1,0,0,0,0
>  
,0,0,20,0,1,0,0,0,0,0,0,2,0,0,6,3,3,10,1,1,18,11,8,11,0,1,2,2,1,14,0,0,0,1,0,0
>  
,0,0,4,3,9,16,0,0,3,0,0,1,0,0,1,0,0,0,0,0,33,18,8,16,0,0,0,0,0,2,0,1,14,6,8,2
>  ,0,0,0,0,1,1)
>  
>  Data <- data.frame(Count,Country)


I'm not seeing any spatial data being defined, so I'm puzzled by the 
expectation that this is yet a markov random field problem. You appear 
to be following the last part of the example code in 
?smooth.construct.mrf.smooth.spec {mgcv} without constructing your data 
set to match the structure of the `columb` example dataset.

str(columb)

#--

'data.frame': 49 obs. of  8 variables:
  $ area  : num  0.3094 0.2593 0.1925 0.0838 0.4889 ...
  $ home.value: num  80.5 44.6 26.4 33.2 23.2 ...
  $ income: num  19.53 21.23 15.96 4.48 11.25 ...
  $ crime : num  15.7 18.8 30.6 32.4 50.7 ...
  $ open.space: num  2.851 5.297 4.535 0.394 0.406 ...
  $ district  : Factor w/ 49 levels "0","1","2","3",..: 1 2 3 4 5 6 7 8 
9 10 ...
  $ x : num  8.83 8.33 9.01 8.46 9.01 ...
  $ y : num  14.4 14 13.8 13.7 13.3 ...


You are also committing a common R-beginner error in accessing columns 
of a data object dire

Re: [R] FW: problem with markov random field smooths in mgcv

2020-03-18 Thread David Winsemius



On 3/18/20 12:44 AM, Wilcox, Chris (O&A, Hobart) wrote:

Hi all,
 
 I am trying to fit a model with a markov random field smooth in mgcv.  I am having some trouble with getting it to run, and in particular I am getting the message
 
 Error in initial.sp(w * x, S, off) : S[[1]] matrix is not +ve definite.
 
 After reading everything I could find on mrf, it sounds like there was a bug that was brought up with Simon Wood in 2012, due to differences between windows and linux, with the linus machine stopping due to this error, while windows was not.  I have not been able to find much else on it.  Any suggestions would be much appreciated.
 
 There is reproducible code below.
 
 Thanks
 
 Chris
 
 
 library(mgcv)
 
 #create data

 Country <- 
as.factor(c("Australia","Australia","Australia","Australia","Australia","Australia","Bangladesh","Bangladesh","Bangladesh",
 
"Bangladesh","Bangladesh","Bangladesh","Cambodia","Cambodia","Cambodia","Cambodia","Cambodia","Cambodia",
 "China","China","China","China","China","China","East Timor","East Timor","East 
Timor",
 "East Timor","East Timor","East 
Timor","HighSeas1","HighSeas1","HighSeas1","HighSeas1","HighSeas1","HighSeas1",
 
"HighSeas2","HighSeas2","HighSeas2","HighSeas2","HighSeas2","HighSeas2","China","China","China","China","China","China",
 
"India","India","India","India","India","India","Indonesia","Indonesia","Indonesia","Indonesia","Indonesia","Indonesia",
 
"Malaysia","Malaysia","Malaysia","Malaysia","Malaysia","Malaysia","Myanmar","Myanmar","Myanmar","Myanmar","Myanmar",
 
"Myanmar","Philippines","Philippines","Philippines","Philippines","Philippines","Philippines","South
 Korea","South Korea",
 "South Korea","South Korea","South Korea","South 
Korea","China","China","China","China","China","China",
 "Sri Lanka","Sri Lanka","Sri Lanka","Sri Lanka","Sri Lanka","Sri 
Lanka","Taiwan","Taiwan","Taiwan","Taiwan",
 
"Taiwan","Taiwan","Thailand","Thailand","Thailand","Thailand","Thailand","Thailand","Vietnam","Vietnam","Vietnam","Vietnam",
 "Vietnam","Vietnam"))
 
 Count <- c(0,0,3,5,1,5,0,0,0,0,0,1,0,0,0,0,0,3,0,0,2,1,0,6,0,0,0,1,0,0,0,1,0,0,0,0

 
,0,0,20,0,1,0,0,0,0,0,0,2,0,0,6,3,3,10,1,1,18,11,8,11,0,1,2,2,1,14,0,0,0,1,0,0
 
,0,0,4,3,9,16,0,0,3,0,0,1,0,0,1,0,0,0,0,0,33,18,8,16,0,0,0,0,0,2,0,1,14,6,8,2
 ,0,0,0,0,1,1)
 
 Data <- data.frame(Count,Country)



I'm not seeing any spatial data being defined, so I'm puzzled by the 
expectation that this is yet a markov random field problem. You appear 
to be following the last part of the example code in 
?smooth.construct.mrf.smooth.spec {mgcv} without constructing your data 
set to match the structure of the `columb` example dataset.


str(columb)

#--

'data.frame': 49 obs. of  8 variables:
 $ area  : num  0.3094 0.2593 0.1925 0.0838 0.4889 ...
 $ home.value: num  80.5 44.6 26.4 33.2 23.2 ...
 $ income    : num  19.53 21.23 15.96 4.48 11.25 ...
 $ crime : num  15.7 18.8 30.6 32.4 50.7 ...
 $ open.space: num  2.851 5.297 4.535 0.394 0.406 ...
 $ district  : Factor w/ 49 levels "0","1","2","3",..: 1 2 3 4 5 6 7 8 
9 10 ...

 $ x : num  8.83 8.33 9.01 8.46 9.01 ...
 $ y : num  14.4 14 13.8 13.7 13.3 ...


You are also committing a common R-beginner error in accessing columns 
of a data object directly in a formula while failing to use a data 
argument for a regression call.


--

David.

 
 #create neighbour matrix

 NB <- list()
 NB$'East Timor' <- c(1,2,15)
 NB$Australia <- c(1,2,15)
 NB$'Sri Lanka' <-c(3,12,16)
 NB$Bangladesh <-c(4,12,13,16)
 NB$Philippines <- c(5,6,11,14,15,17)
 NB$Taiwan <- c(5,6,11)
 NB$Thailand <- c(7,8,10,12,13,14,15)
 NB$Vietnam <- c(7,8,10,11,14,15)
 NB$`South Korea` <- c(9,11)
 NB$Cambodia <- c(7,8,10)
 NB$China <- c(5,6,8,9,11,14)
 NB$India <- c(3,4,7,12,13,15,16)
 NB$Myanmar <- c(4,7,12,13,16)
 NB$Malaysia <- c(5,7,8,11,14,15)
 NB$Indonesia <- c(1,2,5,7,8,12,14,15)
 NB$HighSeas2 <- c(3,4,12,13,16)
 NB$HighSeas1 <- c(5,17)
 
 #check levels and names match

 all.equal(sort(names(NB)), sort(levels(Data$Country)))
 
 #try fitting GAM

 m1 <- gam(Data$Count ~ s(Data$Country, bs = 'mrf', xt = list(nb = NB)))
 
 


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


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

Re: [R] Fw: How to read a file saved in Rstudio

2019-09-12 Thread Jeff Newmiller
Please keep the mailing list included with reply-all.

I misread your error. I suspect you need to use a newer version of R on your 
"pc".

On September 12, 2019 12:29:39 AM PDT, Faheem Jan  wrote:
>Jeff Newmiller i dies not understand your answer,i run the simulation
>it give result in pc and i save the result in rda file but when i open
>it in my laptop the file loaded to Rstudio but does show the output
>that i save in the file
>
>On Thursday, September 12, 2019, 12:05:36 PM GMT+5, Jeff Newmiller
> wrote:  
> 
> Use the correct function.. readRDS.
>
>On September 11, 2019 11:28:41 PM PDT, Faheem Jan via R-help
> wrote:
>>
>>
>>Subject: How to read a result  saved in Rstudio
>>HI, i run the simulation result in other computer with high speed
>>computer ,i save the result in the rda file. know i want to open this
>>file rda file  in my laptop, the file loaded in my laptop , i got the
>>error like this load("C:/Users/Khan/Downloads/Poly.Slow.100.kappa08
>>(1).rda")> Poly.Slow.100.kappa08 (1).rdaError: unexpected symbol in
>>"Poly.Slow.100.kappa08 (1).rda" can any one help me to resolve my
>>issue. thanks alot in advance    
>>  
>>    [[alternative HTML version deleted]]
>>
>>__
>>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide
>>http://www.R-project.org/posting-guide.html
>>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

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


Re: [R] Fw: How to read a file saved in Rstudio

2019-09-12 Thread Jeff Newmiller
Use the correct function.. readRDS.

On September 11, 2019 11:28:41 PM PDT, Faheem Jan via R-help 
 wrote:
>
>
>Subject: How to read a result  saved in Rstudio
>HI, i run the simulation result in other computer with high speed
>computer ,i save the result in the rda file. know i want to open this
>file rda file  in my laptop, the file loaded in my laptop , i got the
>error like this load("C:/Users/Khan/Downloads/Poly.Slow.100.kappa08
>(1).rda")> Poly.Slow.100.kappa08 (1).rdaError: unexpected symbol in
>"Poly.Slow.100.kappa08 (1).rda" can any one help me to resolve my
>issue. thanks alot in advance    
>  
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

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


Re: [R] Fw: problem with nlsLM.....

2019-03-20 Thread J C Nash
Of course, you might just try a more powerful approach. Duncan responded to the 
obvious issue earlier,
but the second problem seems to need the analytic derivatives of the nlsr 
package. Note that
nlsLM uses the SAME very simple forward difference derivative approximation for 
the Jacobian.
Optimization folk will generally say "singular Jacobian" and the singular 
values reported by
nlsr show how bad the case is here. Note that the nlsr output summary seems to 
imply that
the singular values are associated with specific parameters. My bad -- I wanted 
to keep
the summary tidy. The sv's apply to the problem in general, but there are as 
many of them as
parameters, so they fit on the page nicely where I've put them. The singularity 
leads to no
standard errors, of course.

JN

>> library(nlsr)
>> nonlin_modDH5 <- nlxb(formulaDH5, start = list(a = 0.43143, b = 0.68173,A = 
>> 0.09,w = 0.8,c = 0.01,C = 0.94))
> vn:[1] "HM1" "a"   "b"   "HM2" "A"   "w"   "HM3" "c"   "C"  
> no weights
>> nonlin_modDH5
> nlsr object: x 
> residual sumsquares =  0.66987  on  680 observations
> after  15Jacobian and  20 function evaluations
>   namecoeff  SE   tstat  pval  gradient
> JSingval   
> a  0.0929101NA NA NA  -5.817e-07  
>  42.97  
> b   0.541246NA NA NA  -3.359e-07  
>  7.043  
> A 0.00921275NA NA NA9.42e-08  
>  0.984  
> w   0.545654NA NA NA  -8.693e-09  
>  0.195  
> c  -0.770181NA NA NA-5.2e-09 
> 0.07464  
> C0.60148NA NA NA  -5.817e-07   
> 7.567e-14  
>> 



On 2019-03-20 4:20 a.m., akshay kulkarni wrote:
> dear members,
>  I think Duncan's  solution is not working...I've 
> checked the function again:
> 
>> formulaDH5 <- as.formula(HM1 ~ (a + (b * ((HM2 + 0.3)^(1/2 + 
>> (A*sin(w*HM3 + c) + C))
>> nonlin_modDH5 <- nls(formulaDH5, start = list(a = 0.43143, b = 0.68173,A = 
>> 0.09,w = 0.8,c = 0.01,C = 0.94))
> Error in nlsModel(formula, mf, start, wts) :
>   singular gradient matrix at initial parameter estimates
>> nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 0.43143, b = 0.68173,A = 
>> 0.09,w = 0.8,c = 0.01,C = 0.94))
> Error in nlsModel(formula, mf, start, wts) :
>   singular gradient matrix at initial parameter estimates
> 
> 
> I've checked the Internet  for a method of getting the starting values, but 
> they are not comprehensiveany resources for how to find the starting 
> values?
> 
>> dput(HM1)
> c(1.01484280343579, 0.977004104656811, 1.02448653468064, 1.01562102015533,
> 0.968359321714289, 0.99105072887847, 0.99384582083167, 1.00579414727333,
> 0.967593120445675, 1.04694148058855, 1.03832347454026, 0.971040156128456,
> 0.976967848281943, 0.990386686964446, 1.02257020722784, 0.994529161072552,
> 1.05361176882747, 0.988021514764882, 0.998909692369571, 1.04933819895509,
> 0.988354009297047, 0.878584020586706, 1.01438895222572, 1.01522203155842,
> 0.79601913003, 0.975862934766315, 1.03948445565434, 1.02493339899053,
> 0.972267168470219, 0.971001051421653, 1.03066167719129, 0.967898970631469,
> 0.976606662010519, 0.990061873979734, 1.0339889317, 1.05491455733517,
> 0.995997711923663, 0.991213393857838, 0.9903216916016, 1.06850794640807,
> 1.01345738121581, 0.877847194198055, 0.992124544661245, 1.00927272338804,
> 0.988196514422814, 0.987504905313256, 0.990274516132497, 1.01484624802751,
> 0.9800176904083, 0.969321725342799, 1.07407427451262, 1.02023130729371,
> 0.975827723120998, 0.988260886231393, 1.05116598585815, 0.977996171738906,
> 0.985118207891832, 0.98243346941999, 0.991380612684958, 1.00960741365585,
> 1.03062446605116, 1.04176358759364, 1.02494798972349, 1.04645592406625,
> 0.98705820515, 0.972161829098397, 0.991313521356105, 1.0211561076261,
> 0.971257832217016, 1.00935026461508, 0.997140402835885, 1.00719609467891,
> 0.97483865743955, 0.987491380127905, 1.0643888147255, 1.00804564512905,
> 0.989366232219398, 0.942042386899482, 1.0140328534339, 0.98812919092058,
> 1.04584882138055, 0.970586857498767, 1.0098232311784, 1.02237732533005,
> 0.99306513943649, 0.963808401790738, 1.03577231048959, 1.00540101137939,
> 0.970458918298484, 0.973460294926879, 0.992676651187501, 1.04079931972326,
> 0.988928168736541, 0.986376934855979, 1.04117941173535, 1.01252015337269,
> 0.920578394310677, 0.98933093765412, 0.98116698970429, 0.995498900493761,
> 0.96463760451942, 1.1059686605887, 1.03366353582116, 0.981256131441973,
> 1.0152599452654, 0.995362080418312, 0.997276311537458, 0.943438355295013,
> 1.04025117202718, 1.03102737097366, 1.02096902615856, 1.02506560388494,
> 0.959364103040633, 0.987217067188943, 1.00454456275356, 1.03517749036747,
> 1.0148342900634, 0.974518005568706, 1.02515903830848, 1.00435361604303,
> 0.973400954462685, 0.9817029

Re: [R] Fw: problem with nlsLM function

2019-03-19 Thread akshay kulkarni
Dear duncan,
Sorry to bother you with such a silly mistake I 
didn,t notice it!
Sent: Tuesday, March 19, 2019 6:01 PM
To: akshay kulkarni; R help Mailing list
Subject: Re: [R] Fw: problem with nlsLM function

On 19/03/2019 8:26 a.m., akshay kulkarni wrote:
>
> dear members,
>  also,I can provide HM1,HM2 and HM3 if needed
>
> 
> From: R-help  on behalf of akshay kulkarni 
> 
> Sent: Tuesday, March 19, 2019 5:43 PM
> To: R help Mailing  list
> Subject: [R] problem with nlsLM function
>
> dear members,
>  I am getting the "singular gradient error" when I use 
> nls for a function of two variables:
>> formulaDH5
> HM1 ~ (a + (b * ((HM2 + 0.3)^(1/2 + (A * sin(w * HM3 + a) +
>  C)
>
> HM1 is the response variable, and HM2 and HM3 are predictors.
>
> The problem is I get the same error even when I use nlsLM(in the minpack.lm 
> package):
>
>> nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 0.43143, b = 2,A = 
>> 0.09,w = 0.8,a = 0.01,C = 0.94))

You have "a" twice in your start list.  That's bound to cause trouble...

Duncan Murdoch


> Error in nlsModel(formula, mf, start, wts) :
>singular gradient matrix at initial parameter estimates
>> nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 1, b = 2,A = 0.09,w = 
>> 0.8,a = 0.01,C = 0.94))
> Error in nlsModel(formula, mf, start, wts) :
>singular gradient matrix at initial parameter estimates
>> nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 1, b = 2,A = 0.09,w = 
>> 0.8,a = 0.01,C = 2))
> Error in nlsModel(formula, mf, start, wts) :
>singular gradient matrix at initial parameter estimates
>
> I came to know that nlsLM converges when nls throws a singular gradient 
> error. What is happening above? Can the problem get  solved if I use nls.lm 
> function(in the minpack.lm package) instead?
>
> very many thanks for your time and effort
> yours sincerely,
> AKSHAY M KULKARNI
>
>  [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


[[alternative HTML version deleted]]

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


Re: [R] Fw: problem with nlsLM function

2019-03-19 Thread Duncan Murdoch

On 19/03/2019 8:26 a.m., akshay kulkarni wrote:


dear members,
 also,I can provide HM1,HM2 and HM3 if needed


From: R-help  on behalf of akshay kulkarni 

Sent: Tuesday, March 19, 2019 5:43 PM
To: R help Mailing  list
Subject: [R] problem with nlsLM function

dear members,
 I am getting the "singular gradient error" when I use nls 
for a function of two variables:

formulaDH5

HM1 ~ (a + (b * ((HM2 + 0.3)^(1/2 + (A * sin(w * HM3 + a) +
 C)

HM1 is the response variable, and HM2 and HM3 are predictors.

The problem is I get the same error even when I use nlsLM(in the minpack.lm 
package):


nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 0.43143, b = 2,A = 0.09,w = 
0.8,a = 0.01,C = 0.94))


You have "a" twice in your start list.  That's bound to cause trouble...

Duncan Murdoch



Error in nlsModel(formula, mf, start, wts) :
   singular gradient matrix at initial parameter estimates

nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 1, b = 2,A = 0.09,w = 0.8,a 
= 0.01,C = 0.94))

Error in nlsModel(formula, mf, start, wts) :
   singular gradient matrix at initial parameter estimates

nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 1, b = 2,A = 0.09,w = 0.8,a 
= 0.01,C = 2))

Error in nlsModel(formula, mf, start, wts) :
   singular gradient matrix at initial parameter estimates

I came to know that nlsLM converges when nls throws a singular gradient error. 
What is happening above? Can the problem get  solved if I use nls.lm 
function(in the minpack.lm package) instead?

very many thanks for your time and effort
yours sincerely,
AKSHAY M KULKARNI

 [[alternative HTML version deleted]]

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

[[alternative HTML version deleted]]

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



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


Re: [R] Fw: inconsistency in nls output....

2019-03-06 Thread akshay kulkarni
dear JN,
Thanks for the reply. I will consider using the nlsr package. 
But for now I make did with reducing the exponent. It is working for me.

very many thanks for your time and effort
yours sincerely,
AKSHAY M KULKARNI


From: J C Nash 
Sent: Wednesday, March 6, 2019 10:40 PM
To: akshay kulkarni; R help Mailing list
Subject: Re: [R] Fw: inconsistency in nls output

nls() is a Model T Ford trying to drive on the Interstate. The code
is quite old and uses approximations that work well when the user
provides a reasonable problem, but in cases where there are mixed large
and small numbers like yours could get into trouble.

Duncan Murdoch and I prepared the nlsr package to address some
of the weaknesses (in particular we try to use analytic derivatives).

The output of nlsr also gives the singular values of the Jacobian, though
I suspect many R users will have to do some work to interpret those.

You haven't provided a reproducible example. That's almost always the
way to get definitive answers. Otherwise we're guessing as to the issue.

JN

On 2019-03-06 7:48 a.m., akshay kulkarni wrote:
> dear members,
> with reference to the attached message:
>
> I think I have found out the problem:
> YLf13 has the structure:
> YLf13 <- a*exp(-1000*LM1); LM1 is another vector.
>
> most of the YLf13 vector is getting populated with zeros, I think, because of 
> the very low value of exp(-1000*LM1). Is there any method in R wherein I can 
> work with these very low values?
>
> Or is the problem not related to the structure of YLf13?
>
> very many thanks for your time and effort...
> yours sincerely,
> AKSHAY M KULKARNI
>
>
> 
> From: R-help  on behalf of akshay kulkarni 
> 
> Sent: Wednesday, March 6, 2019 6:02 PM
> To: R help Mailing  list
> Subject: [R] inconsistency in nls output
>
> dear members,
>  I have the following nls output:
>
>  Formula: YLf13 ~ (d + e * ((XL)^(1/3)) + f * log(LM3 + 18.81))
>
> Parameters:
> Estimate Std. Error t value Pr(>|t|)
> d  5.892e-09  8.644e-10   6.817 2.06e-11 ***
> e -6.585e-09  5.518e-10 -11.934  < 2e-16 ***
> f  1.850e-10  2.295e-10   0.806 0.42
> ---
> Signif. codes:  0 �***� 0.001 �**� 0.01 �*� 0.05 �.� 0.1 � � 1
>
> Residual standard error: 9.57e-10 on 677 degrees of freedom
>
> Number of iterations to convergence: 2
> Achieved convergence tolerance: 3.973e-08
>
> --
> Residual sum of squares: 6.2e-16
>
> --
> t-based confidence interval:
>2.5% 97.5%
> d  4.195378e-09  7.589714e-09
> e -7.668142e-09 -5.501342e-09
> f -2.655647e-10  6.354852e-10
>
> --
> Correlation matrix:
>d e f
> d  1.000 -6.202339e-01 -7.832539e-01
> e -0.6202339  1.00e+00 -2.127301e-05
> f -0.7832539 -2.127301e-05  1.00e+00
>
>
> if I let XL = 1.1070513 and LM3 = 0.3919 , and consider the coeffs as given 
> above, the right hand side of the above equation is negative.
> But YLf13 is always positive! How is this possible? Am I interpreting the 
> result of the nls output properly?  Should I interpret the coeffs 
> differently? I have done hours of thinking over the above problem but 
> couldn't find any results...
>
> I cannot provide the full values of YLf13, XL and LM3 due to IPR 
> issuesplease cooperate..however, if the only way to solve the problem 
> is to give these values, I would indeed give them.
>
> Also forgive me if there is a minor mistake in my calculations... or a 
> typo
>
> very many thanks for your time and effort
> yours sincerely,
> AKSHAY M KULKARNI
>
> [[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Fw: inconsistency in nls output....

2019-03-06 Thread J C Nash
nls() is a Model T Ford trying to drive on the Interstate. The code
is quite old and uses approximations that work well when the user
provides a reasonable problem, but in cases where there are mixed large
and small numbers like yours could get into trouble.

Duncan Murdoch and I prepared the nlsr package to address some
of the weaknesses (in particular we try to use analytic derivatives).

The output of nlsr also gives the singular values of the Jacobian, though
I suspect many R users will have to do some work to interpret those.

You haven't provided a reproducible example. That's almost always the
way to get definitive answers. Otherwise we're guessing as to the issue.

JN

On 2019-03-06 7:48 a.m., akshay kulkarni wrote:
> dear members,
> with reference to the attached message:
> 
> I think I have found out the problem:
> YLf13 has the structure:
> YLf13 <- a*exp(-1000*LM1); LM1 is another vector.
> 
> most of the YLf13 vector is getting populated with zeros, I think, because of 
> the very low value of exp(-1000*LM1). Is there any method in R wherein I can 
> work with these very low values?
> 
> Or is the problem not related to the structure of YLf13?
> 
> very many thanks for your time and effort...
> yours sincerely,
> AKSHAY M KULKARNI
> 
> 
> 
> From: R-help  on behalf of akshay kulkarni 
> 
> Sent: Wednesday, March 6, 2019 6:02 PM
> To: R help Mailing  list
> Subject: [R] inconsistency in nls output
> 
> dear members,
>  I have the following nls output:
> 
>  Formula: YLf13 ~ (d + e * ((XL)^(1/3)) + f * log(LM3 + 18.81))
> 
> Parameters:
> Estimate Std. Error t value Pr(>|t|)
> d  5.892e-09  8.644e-10   6.817 2.06e-11 ***
> e -6.585e-09  5.518e-10 -11.934  < 2e-16 ***
> f  1.850e-10  2.295e-10   0.806 0.42
> ---
> Signif. codes:  0 �***� 0.001 �**� 0.01 �*� 0.05 �.� 0.1 � � 1
> 
> Residual standard error: 9.57e-10 on 677 degrees of freedom
> 
> Number of iterations to convergence: 2
> Achieved convergence tolerance: 3.973e-08
> 
> --
> Residual sum of squares: 6.2e-16
> 
> --
> t-based confidence interval:
>2.5% 97.5%
> d  4.195378e-09  7.589714e-09
> e -7.668142e-09 -5.501342e-09
> f -2.655647e-10  6.354852e-10
> 
> --
> Correlation matrix:
>d e f
> d  1.000 -6.202339e-01 -7.832539e-01
> e -0.6202339  1.00e+00 -2.127301e-05
> f -0.7832539 -2.127301e-05  1.00e+00
> 
> 
> if I let XL = 1.1070513 and LM3 = 0.3919 , and consider the coeffs as given 
> above, the right hand side of the above equation is negative.
> But YLf13 is always positive! How is this possible? Am I interpreting the 
> result of the nls output properly?  Should I interpret the coeffs 
> differently? I have done hours of thinking over the above problem but 
> couldn't find any results...
> 
> I cannot provide the full values of YLf13, XL and LM3 due to IPR 
> issuesplease cooperate..however, if the only way to solve the problem 
> is to give these values, I would indeed give them.
> 
> Also forgive me if there is a minor mistake in my calculations... or a 
> typo
> 
> very many thanks for your time and effort
> yours sincerely,
> AKSHAY M KULKARNI
> 
> [[alternative HTML version deleted]]
> 
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Fw: inconsistency in pbmclapply...

2018-10-16 Thread Bert Gunter
As I think you hve been told before, most attachments don't make it through
the mail server. Use ?dput instead to include data.

Also, post in plain text, not html.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Oct 16, 2018 at 8:03 AM akshay kulkarni 
wrote:

> dear members,
>  I am attaching the object LYGH as used in my
> expression with pbmclapply so that you can recreate the expression:
>
> LYG1 <- pbmclapply(LYGH, FUN = auto.arima, mc.cores = detectCores()
>
> very many thanks for your help and time.
> yours sincerely,
> AKSHAY M KULKARNI
> 
> From: akshay kulkarni 
> Sent: Tuesday, October 16, 2018 2:21 PM
> To: R help Mailing list
> Subject: Fw: inconsistency in pbmclapply...
>
>
> dear members,
>  however, "ts must have more than one observation"
> error is only found for the first entry of LYG1 ( LYG1[[20]], LYG1[[200]],
> [[elided Hotmail spam]]
> 
> From: R-help  on behalf of akshay kulkarni <
> akshay...@hotmail.com>
> Sent: Tuesday, October 16, 2018 1:57 PM
> To: R help Mailing  list
> Subject: [R] inconsistency in pbmclapply...
>
> dear members,
>  I am using parallel processing with
> pbmclapply. below is the code. LYG1[[1]] got from pbmclapply is not the
> same as LYG1[[1]] got from direct application of auto.arima. what may be
> wrong?
>
>   debug at #20: LYG1 <- pbmclapply(LYGH, FUN =
> auto.arima, mc.cores = detectCores())
> Browse[2]>
>   |=   |  68%, ETA
> 00:21
> debug at #21: LYG2 <- pbmclapply(LYGH, FUN = ets, mc.cores =
> detectCores())
> Browse[2]> LYG1[[1]]
> [1] "Error in ts(x) : 'ts' object must have one or more observations\n"
> attr(,"class")
> [1] "try-error"
> attr(,"condition")
> 
> Warning message:
> In pbmclapply(LYGH, FUN = auto.arima, mc.cores = detectCores()) :
>   scheduled cores encountered errors in user code
> Browse[2]> LYGH[[1]]
>  [1] 0.7 0.4 0.3 0.15000 0.25000
> 0.95000
>  [7] 1.0 0.3 0.65000 0.2 0.6
> 0.1
> [13] 0.001412873 1.55000 0.15000 0.3 0.45000
> 0.35000
> [19] 0.15000 2.35000 0.25000 0.1 3.7
> 3.95000
> [25] 3.05000 0.9 0.4 1.05000 1.1
> 1.95000
> [31] 2.0 0.65000 0.7 0.25000 5.25000
> 0.8
> [37] 0.001412873
> Browse[2]> auto.arima(LYGH[[1]])
> Series: LYGH[[1]]
> ARIMA(0,1,0)
>
> sigma^2 estimated as 2.303:  log likelihood=-66.1
> AIC=134.2   AICc=134.31   BIC=135.78
>
> very many thanks for your time and effort.
> yours sincerely,
> AKSHAY M KULKARNI
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Fw: inconsistency in display of character vector....

2018-07-08 Thread Jeff Newmiller
Using dput and sending your questions with the plain text option as described 
in [1] will allow you to share your data with less ambiguity. To be sure you 
have supplied all the code needed for us to reproduce your problem, use [3].

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette) 

On July 8, 2018 5:37:33 AM PDT, akshay kulkarni  wrote:
>dear members,
>The mail is not showing the spaces between [192] "NSE/YESBANK" and 
>[193] "NSE/ZEEL" ...Actually there is a lot of empty spaces between the
>two.!!
>
>
>From: R-help  on behalf of akshay
>kulkarni 
>Sent: Sunday, July 8, 2018 5:58 PM
>To: R help Mailing  list
>Subject: [R] inconsistency in display of character vector
>
>dear members,
>I have the following code to update the list of stocks:
>
>function (snlcqn)
>{
>  lneq <- c()
>  URL <- "https://canmoney.in/Intraday%20scrip.xls";
>  file.string <- tempfile()
>
>  download.file(URL,file.string)
>
>  IDT <- read_excel(file.string)
>
>  leq <- IDT[,1]
>
>  for(i in 1:length(leq)){
>  lneq[i] <- substr(leq[i],1,(nchar(leq[i])-2))}
>
>  for(j in 1:length(lneq)){
>  snlcqna[j] <- paste("NSE/",lneq[j])}
>
>  if(identical(snlcqn,snlcqna) == "FALSE"){
>  return(snlcqna) }
>
>  else{
>  return(snlcqn)  }
>
>}
>snlcqn is the list of present stocks and snlcqna is the list of updated
>stocks.
>The problem is the return object, instead of getting displayed in
>contiguous list, is getting displayed with lots of spaces...( I am
>using R on a LINUX RHEL AWS instance):
>
>[192] "NSE/YESBANK"
>[193] "NSE/ZEEL"
>
>Why is this happening? How can I get the return object as a contiguous
>list?
>Very many thanks for your time and effort...
>yours sincerely,
>AKSHAY M KULKARNI
>
>[[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

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


Re: [R] Fw: subsetting lists....

2018-06-18 Thread Eric Berger
My response does not have an explicit for loop.

On Mon, Jun 18, 2018 at 2:15 PM, akshay kulkarni 
wrote:

> correctionI want the method without a for loop
> 
> From: akshay kulkarni 
> Sent: Monday, June 18, 2018 4:25 PM
> To: R help Mailing list
> Subject: subsetting lists
>
> dear members,
> I have list YH and index vector iuhV. I want
> to select iuhV[1] from YH[[1]], iuhv[2] from YH[[2]], iuhv[3] from
> YH[[3]]..iuhv[n] from YH[[n]]...
>
> How to do this?
> I searched SO and the internet but was bootless
>
> Very many thanks for your time and effort.
> Yours sincerely,
> AKSHAY M KULKARNI
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Fw: modified mankendal

2017-11-24 Thread Jim Lemon
Hi Elham,
The error message:

Error in if (S == 0) { : missing value where TRUE/FALSE needed

means that for at least one S, the value is missing. The best advice I
can give you is to load the data frame X1 as in your code above, and
try something like:

which.na<-function(x) return(which(is.na(x)))
sapply(X1,which.na)

You will then get a list of the positions of any NA values in X1.

Jim

On Fri, Nov 24, 2017 at 7:45 PM, Elham Fakharizade  wrote:
> Hello Dear Jim
> Thanks for your answering
> I have more than 65000 data in my file I search for NA or NAN but nothing
> find. how can I search for missing value?
> Sincerely yours
> Elham
>
> Elham Fakharizadeshirazi.
>
> Doctoral guest researcher in Institute of Meteorology,
>
> Department of Earth Sciences,
>
> Free university of Berlin,
>
> Berlin, Germany.
>
>
>
> On Friday, November 24, 2017, 4:33:12 AM GMT+1, Jim Lemon
>  wrote:
>
>
> Hi Elham,
> The error message is pretty explicit. Check your dataset for missing values.
>
> Jim
>
> On Thu, Nov 23, 2017 at 6:14 AM, Elham Fakharizade via R-help
>  wrote:
>>
>>  Hello DearI used modifiedmk package for trend analyses.this is my script
>>  require(modifiedmk)X1<-read.table("c:/elham/first
>> article/r/Spring_NDVI-1.txt",skip=2,header=FALSE)d=dim(X1)
>> outMK<-matrix(-999,nrow=4,ncol=d[2])for (c in
>> 1:d[2]){MK<-tfpwmk(X1[,c])outMK[1,c]<-getElement(MK,"S")outMK[2,c]<-getElement(MK,"Var(S)")outMK[3,c]<-getElement(MK,"Sen's
>> Slope")outMK[4,c]<-getElement(MK,"P-value")} unfortunetally I got this
>> error:
>> Error in if (S == 0) { : missing value where TRUE/FALSE needed
>> would you please help me to solve itSincerely yoursElham
>
>>
>>
>>
>>[[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Fw: modified mankendal

2017-11-23 Thread Jim Lemon
Hi Elham,
The error message is pretty explicit. Check your dataset for missing values.

Jim

On Thu, Nov 23, 2017 at 6:14 AM, Elham Fakharizade via R-help
 wrote:
>
>  Hello DearI used modifiedmk package for trend analyses.this is my script
>  require(modifiedmk)X1<-read.table("c:/elham/first 
> article/r/Spring_NDVI-1.txt",skip=2,header=FALSE)d=dim(X1)
> outMK<-matrix(-999,nrow=4,ncol=d[2])for (c in 
> 1:d[2]){MK<-tfpwmk(X1[,c])outMK[1,c]<-getElement(MK,"S")outMK[2,c]<-getElement(MK,"Var(S)")outMK[3,c]<-getElement(MK,"Sen's
>  Slope")outMK[4,c]<-getElement(MK,"P-value")} unfortunetally I got this error:
> Error in if (S == 0) { : missing value where TRUE/FALSE needed
> would you please help me to solve itSincerely yoursElham
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Fw: modified mankendal

2017-11-23 Thread John Kane via R-help
 Would you resubmit your question in plain text mode?  
This is a plain text list and the HTML gets stripped away. What is left is this
Hello DearI used modifiedmk package for trend analyses.this is my script
 require(modifiedmk)X1<-read.table("c:/elham/first 
article/r/Spring_NDVI-1.txt",skip=2,header=FALSE)d=dim(X1)
outMK<-matrix(-999,nrow=4,ncol=d[2])for (c in 
1:d[2]){MK<-tfpwmk(X1[,c])outMK[1,c]<-getElement(MK,"S")outMK[2,c]<-getElement(MK,"Var(S)")outMK[3,c]<-getElement(MK,"Sen's
 Slope")outMK[4,c]<-getElement(MK,"P-value")} unfortunetally I got this error:
Error in if (S == 0) { : missing value where TRUE/FALSE needed
would you please help me to solve itSincerely yoursElham
It is very close to unreadable. You should read the posting guide at the bottom 
of each email. 
You might also find these links useful:
How to make a great R reproducible example? aka MCVE (Minimal, Complete, and 
Verifiable Example)


| 
| 
| 
|  |  |

 |

 |
| 
|  | 
How to make a great R reproducible example? aka MCVE (Minimal, Complete,...

When discussing performance with colleagues, teaching, sending a bug report or 
searching for guidance on mailing...
 |

 |

 |




On Wednesday, November 22, 2017, 3:24:05 PM EST, Elham Fakharizade via 
R-help  wrote:  
 
 
 Hello DearI used modifiedmk package for trend analyses.this is my script
 require(modifiedmk)X1<-read.table("c:/elham/first 
article/r/Spring_NDVI-1.txt",skip=2,header=FALSE)d=dim(X1)
outMK<-matrix(-999,nrow=4,ncol=d[2])for (c in 
1:d[2]){MK<-tfpwmk(X1[,c])outMK[1,c]<-getElement(MK,"S")outMK[2,c]<-getElement(MK,"Var(S)")outMK[3,c]<-getElement(MK,"Sen's
 Slope")outMK[4,c]<-getElement(MK,"P-value")} unfortunetally I got this error:
Error in if (S == 0) { : missing value where TRUE/FALSE needed
would you please help me to solve itSincerely yoursElham


  
    [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.  
[[alternative HTML version deleted]]

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

Re: [R] FW: Time Series

2017-11-07 Thread Eric Berger
Following Erin's pointer:

library(zoo)
times <- seq(from=as.POSIXct("2015-12-18 00:00:00"),
to=as.POSIXct("2017-10-24 23:00:00"), by="hour")
mydata <- rnorm(length(times))
tseri  <- zoo( x=mydata, order.by=times )

HTH,
Eric


On Tue, Nov 7, 2017 at 9:59 AM, Erin Hodgess 
wrote:

> Hello!
>
> What is the error message, please?
>
> At first glance, you are using the "ts" function.  That doesn't work for
> hourly frequency.
>
> You may want to create a zoo object.
>
> This is Round One.
>
> Sincerely,
> Erin
>
>
> On Tue, Nov 7, 2017 at 1:46 AM, Emre Karagülle 
> wrote:
>
> >
> > Hi,
> > I would like to ask a question about time series.
> > I am trying to convert my data into time series data.
> > I have hourly data from “2015-12-18 00:00” to “2017-10-24 23:00”
> > I am trying the following codes but they are not working.
> > Could you help me out?
> >
> > tseri <- ts(data ,seq(from=as.POSIXct("2015-12-18 00:00:00"),
> > to=as.POSIXct("2017-10-24 23:00:00"), by="hour"))
> >
> > tseri <- ts(data ,seq(from=as.Date("2015-12-18 00:00:00"),
> > to=as.Date("2017-10-24 23:00:00"), by="hour"))
> >
> >
> > Thank you
> >
> > --
> > Emre
> >
> >
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> > posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Mathematical and Statistics
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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

Re: [R] FW: Time Series

2017-11-07 Thread Erin Hodgess
Hello!

What is the error message, please?

At first glance, you are using the "ts" function.  That doesn't work for
hourly frequency.

You may want to create a zoo object.

This is Round One.

Sincerely,
Erin


On Tue, Nov 7, 2017 at 1:46 AM, Emre Karagülle 
wrote:

>
> Hi,
> I would like to ask a question about time series.
> I am trying to convert my data into time series data.
> I have hourly data from “2015-12-18 00:00” to “2017-10-24 23:00”
> I am trying the following codes but they are not working.
> Could you help me out?
>
> tseri <- ts(data ,seq(from=as.POSIXct("2015-12-18 00:00:00"),
> to=as.POSIXct("2017-10-24 23:00:00"), by="hour"))
>
> tseri <- ts(data ,seq(from=as.Date("2015-12-18 00:00:00"),
> to=as.Date("2017-10-24 23:00:00"), by="hour"))
>
>
> Thank you
>
> --
> Emre
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




-- 
Erin Hodgess
Associate Professor
Department of Mathematical and Statistics
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

[[alternative HTML version deleted]]

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

Re: [R] Fw: passing different sample sizes

2017-09-25 Thread Bert Gunter
Your code is full of syntactic errors. What do you think 1.71(se) means?

After you clean up your code, something like this might be what you want:

out <- lapply(seq(40,500,by = 25), f)

To get plots, just stick in a plot statement after you define m and d.

Have you gone through any R tutorials? You seem to be confused about basics
that tutorials could help you with.  This list is not meant to replace such
homework on your own.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Sep 25, 2017 at 3:28 PM, Farnoosh Sheikhi 
wrote:

> Hi Bert,
>
> Here is the code:
> f<-function(n){
> m=runif(n, 50, 100)
> d=rnorm(n, 0, 1)
> se=sd(d)/sqrt (n)
>
> ci.u<-mean(d)+1.96*sd(d)
> ci.l<-mean(d)-1.96*sd(d)
> ci.w<-ci.u-ci.l
>
> w.ci.uu<-ci.u+(qt (0.975, df=n-1)*1.71(se)
> w.ci.ul<-ci.u-(qt (0.975, df=n-1)*1.71(se)
> w.ci.upper<-w.ci.uu-w.ci.ul
>
> w.ci.lu<-ci.l+(qt (0.975, df=n-1)*1.71(se)
> w.ci.ll<-ci.l-(qt (0.975, df=n-1)*1.71(se)
> w.ci.lower<-w.ci.lu-w.ci.ll
>
>   res<-as.data.frame(cbind(n, ci.u, ci.l, ci.w, w.ci.upper, w.ci.lower))
>   return(res)
> }
>
>
> I would like to pass different sample sizes n<-seq(40, 500, by=25) and add
> a scatter plot for each n.
> plot(m~d)
>
> Thanks.
>
>
>
> On Monday, September 25, 2017 3:00 PM, Bert Gunter 
> wrote:
>
>
> 1. 2o is gibberish; 20 is the number of fingers and toes most of us have.
>
> 2. This is a plain text list. Your code became gibberish with your HTML
> post.
>
> Cheers,
> Bert
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Mon, Sep 25, 2017 at 2:16 PM, Farnoosh Sheikhi via R-help <
> r-help@r-project.org> wrote:
>
>
>
>
>
> Hi,
> I have the below function which returns confidence intervals. I wanted to
> pass different sample sizes through the function, but for some reason it's
> not working. n   <- seq(from=40, to=300, by=2o)
>
> I was also wondering how I can return a plot for different sample
> sizes. plot(m~d, main="n(i)")
> Any help or suggestion is appreciated.
>
>
> f< -function(n){  m = runif(n,50,200)  d =
>  rnorm(n,0,1)   ci.u<-mean(d)+1.96*sd(d)  ci.l<-mean(d)-1.96*sd(d)
> ci.w<-ci.u-ci.lse=sd(d)/sqrt(n)  w.ci.uu<-ci.u+(qt(.975,
> df=n-1))*1.71*se  w.ci.ul<-ci.u-(qt(.975, df=n-1))*1.71*se
> w.ci.upper<-w.ci.uu- w.ci.ulw.ci.lu<-ci.l+(qt(. 975,
> df=n-1))*1.71*se  w.ci.ll<-ci.l-(qt(.975, df=n-1))*1.71*se
> w.ci.lower<-w.ci.lu- w.ci.llres<-as.data.frame(cbind(n, ci.u, ci.l,
> ci.w, w.ci.upper, w.ci.lower))  return(res)} Best,Nooshi
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> __ 
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/ listinfo/r-help
> 
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html 
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
>

[[alternative HTML version deleted]]

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


Re: [R] Fw: passing different sample sizes

2017-09-25 Thread Bert Gunter
1. 2o is gibberish; 20 is the number of fingers and toes most of us have.

2. This is a plain text list. Your code became gibberish with your HTML
post.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Sep 25, 2017 at 2:16 PM, Farnoosh Sheikhi via R-help <
r-help@r-project.org> wrote:

>
>
>
>
> Hi,
> I have the below function which returns confidence intervals. I wanted to
> pass different sample sizes through the function, but for some reason it's
> not working. n   <- seq(from=40, to=300, by=2o)
>
> I was also wondering how I can return a plot for different sample
> sizes. plot(m~d, main="n(i)")
> Any help or suggestion is appreciated.
>
>
> f<-function(n){  m = runif(n,50,200)  d =
>  rnorm(n,0,1)   ci.u<-mean(d)+1.96*sd(d)  ci.l<-mean(d)-1.96*sd(d)
> ci.w<-ci.u-ci.lse=sd(d)/sqrt(n)  w.ci.uu<-ci.u+(qt(.975,
> df=n-1))*1.71*se  w.ci.ul<-ci.u-(qt(.975, df=n-1))*1.71*se
> w.ci.upper<-w.ci.uu- w.ci.ulw.ci.lu<-ci.l+(qt(.975, df=n-1))*1.71*se
> w.ci.ll<-ci.l-(qt(.975, df=n-1))*1.71*se  w.ci.lower<-w.ci.lu- w.ci.ll
> res<-as.data.frame(cbind(n, ci.u, ci.l, ci.w, w.ci.upper, w.ci.lower))
> return(res)} Best,Nooshi
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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


Re: [R] Fw: Need Help - R Programming - Using iteration value to change field names for processing for every iteraion

2017-05-30 Thread Bert Gunter
Your fields are adjacent, right?

If so, you do not need to refer to them by name to accomplish this.
Please spend some (more) time with an R tutorial or two as Rolf
suggested, especially with "indexing".

-- Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, May 30, 2017 at 3:07 AM, Vijaya Kumar Regati
 wrote:
> Hi All,
>
>
> I have tried in different ways.
>
> Finally I got the solution this way :
>
>
> for(i in 2:4) {
>test[,paste0("Day",i,".Prod.balc")] <- test[,paste0("Day",i,".Prod.balc")] 
> + test[,paste0("Day",i-1,".Prod.balc")]
> }
>
>
> Please save it for references, if needed in future.
> Thanks all for your references.
>
>
> List Moderator,
>
> You can mark the question as closed now.
>
>
>
> With Regards,
> Vijaya Kumar Regati
> Technical Lead, M3bi India Private Ltd
> Work: 040-67064732
>
>
> 
> From: Vijaya Kumar Regati
> Sent: Tuesday, May 30, 2017 3:35 PM
> To: Jim Lemon
> Subject: Re: [R] Need Help - R Programming - Using iteration value to change 
> field names for processing for every iteraion
>
>
> Thank you for the response.
>
> That did not give me desired output when ran.
>
>
> But I was able to find 1 solution :
>
>
> for(i in 2:4) {
>test[,paste0("Day",i,".Prod.balc")] <- test[,paste0("Day",i,".Prod.balc")] 
> + test[,paste0("Day",i-1,".Prod.balc")]
> }
>
> Its working now.
>
>
> With Regards,
> Vijaya Kumar Regati
> Technical Lead, M3bi India Private Ltd
> Work: 040-67064732
>
> 
> From: Jim Lemon 
> Sent: Tuesday, May 30, 2017 3:00:39 PM
> To: Vijaya Kumar Regati
> Subject: Re: [R] Need Help - R Programming - Using iteration value to change 
> field names for processing for every iteraion
>
> Hi Vijaya,
> How about:
>
> test_dataframe<-read.table(
>  text="Day1.balc Day2.balc Day3.balc Day4.balc
>  100203040
>  100101010",
>  header=TRUE)
> t(apply(test_dataframe,1,cumsum))
>
> Jim
>
> On Tue, May 30, 2017 at 5:02 PM, Vijaya Kumar Regati
>  wrote:
>> Hi,
>>
>> I am new to R programming, I am trying to work on below requirement. But 
>> could not achieve desired result.
>> Appreciate if someone can help me on this :
>>
>> test dataframe :
>>   Day1.balc Day2.balc Day3.balc Day4.balc
>> x   100203040
>> y   100101010
>>> class(test)
>> [1] "data.frame"
>>
>> My Goal is to accomplish :
>> Day2.balc <- Day2.balc + Day1.balc
>> Day3.balc <- Day3.balc + Day2.balc
>> .
>> .
>> .
>> Day30.balc <- Day30.balc + Day29.balc
>>
>> # Testing for first 4 days
>> for (i in 1:4 ) {
>> test$Day[i].balc <- test$Day[i].balc + test$Day[i-1].balc
>> }
>>
>> I identified the line I have written inside the loop is not the correct one, 
>> can someone help me how I can use iteration value(i), for every iteration, 
>> as a basis for changing field names since field consists of 1,2,3... for 
>> each different day( Day1.balc Day2.balc Day3.balc Day4.balc etc.,).
>>
>>
>> Thanks,
>>
>> Vijay
>>
>>
>>
>> Disclaimer: IMPORTANT NOTICE: This e-mail (including any attachments) are 
>> confidential, may contain proprietary or privileged information and is 
>> intended for the named recipient(s) only. If you are not the intended 
>> recipient, any disclosures, use, review, distribution, printing or copying 
>> of the information contained in this e-mail message and/or attachments to it 
>> are strictly prohibited. If you have received this email in error, please 
>> notify the sender by return e-mail or telephone immediately and permanently 
>> delete the message and any attachments.
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
> R-help Info Page - Homepage - SfS – Seminar for 
> Statistics
> stat.ethz.ch
> The main R mailing list, for announcements about the development of R and the 
> availability of new code, questions and answers about problems and solutions 
> using R ...
>
>
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> Disclaimer: IMPORTANT NOTICE: This e-mail (including any attachments) are 
> confidential, may contain proprietary or privileged information and is 
> intended for the named recipient(s) only. If you are not the intended 
> recipient, any disclosures, use, review, distribution, printing or copying of 
> the information contained in this e-mail message and/or attachments to it are 
> strictly prohibited. If you have received this email in error, please notify 
> the sender by return e-mail or telephone immediately and permanently delete 
> 

Re: [R] Fw: Averaging without NAs

2017-03-02 Thread Ng Bo Lin
Hi Elahe,

You can do so using the mean function, mean(), by specifying an additional 
argument, na.rm = TRUE. In this case, you specify that you wish to remove (rm) 
all NA values in the columns.

—> mean($X2016.Q1, na.rm = T).

By default, na.rm is set to FALSE, so mean() will return a NA value.

Hope this helps!

Regards,
Bo Lin
> On 2 Mar 2017, at 6:57 PM, ch.elahe via R-help  wrote:
> 
> 
> 
> The question seems easy but I could not find an answer for it. I have the 
> following column in my data frame and I want to take average of the column 
> excluding the number of NAs. 
> 
> $X2016.Q1 : int 47 53 75 97 NA NA 23 NA 43 NA 
> 
> Does anyone know how to do that?
> Thanks for any help 
> Elahe
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

Re: [R] Fw: Regex problem

2017-01-05 Thread Carl Sutton via R-help
Thank you gentlemen, thank you!   All worked as you said it would and my 
headers are now error free.
And David, thanks for the reference material cite.  I will looking at that this 
weekend.
 Carl Sutton 

On Thursday, January 5, 2017 12:12 PM, David Winsemius 
 wrote:
 
 

 
> On Jan 5, 2017, at 10:09 AM, Carl Sutton via R-help  
> wrote:
> 
> Re-sending help request, went to wrong addy first time.  
> r-help-requ...@r-project.org
> 
> Belated Happy new year to the Guru's:
> 
> I have a data frame with 570+ columns and in those column headers yours truly 
> has a few blunders.  Namely somehow I managed to end some of them with both 
> an apostrophe ' and an ending quote.

Doubtful. You probably only have a single apostrophe and no "ending quote". In 
fact when I run your `problemdf`, the `make.names` function (called by 
data.frame) changed the apostrophe into a period. To actually get a trailing 
apostrophe with `data.frame` you would need to set check.names=FALSE:

df1 <- data.frame("WhatAmI\'" = 1:5, "WhoAreYou" = 11:15, check.names=FALSE)
colnames(df1)
#[1] "WhatAmI'"  "WhoAreYou"
There is no double quote in that name. Now to remove the offending apostrophe 
(or even multiple instances of them) just do this:

names(df) <- gsub( "\\'", "", names(df)


>  I think the attached code finds the occurrences (not 100% sure) and feedback 
>is appreciated.  This is my first attempt at regex and I have been googling 
>and reading the last few days (including an R -Exercise).
> 
> Confused as to why the column names shows a "." instead of a " ' ".

See above.



> 
> Ignorant of why gregexpr and regexpr show attr(,"useBytes") as TRUE when the 
> default is FALSE.  Is it possible I somehow messed them up last week?  Simply 
> typing the function name in the console shows the defaults as FALSE.
> 
> I have not been able to build a construct to simply delete the apostrophe.  I 
> have made several attempts to do this, and left one for your perusal.  The 
> others were just to "off the wall" and embarrassing.
> 
> Lastly, is there a way for me to check that all of my column names end with a 
> letter followed by a quote?  I am thinking something along the lines of 
> "[[:alpha:]\\"" but I expect that will throw an error.  I stumbled upon the ' 
> " problem when dplyr complained about it last week, and it is unsettling to 
> think I may have more goofs.
> 
> Any suggestions of a good reference book is much appreciated.  I can see 
> extended use of regex coming toward me and I am so ignorant it is frightening 
> (all volunteer work, no $'s involved, but I dislike being incompetent).

I learned regex by reading the ?regex page, and by looking up and working 
through questions on R-help by Gabor Grothendeick:

http://markmail.org/search/?q=list%3Aorg.r-project.r-help+regex#query:list%3Aorg.r-project.r-help%20regex%20from%3A%22Gabor%20Grothendieck%22+page:1+state:facets


There are also several online sites where you can get an expression by 
expression readout of what your regexes are doing. They do need the 
understanding that hte escape character for R and regex are the same and the 
means they need to be doubled in hte pattern arguments (but _not_ the 
replacement arguments).

-- 
David.


> 
> 
> #  regex problemdf1 <- data.frame("WhatAmI'" = 1:5, "WhoAreYou" = 11:15)
> colnames(df1)
> df1
> ma_pattern <- "[[:punct:]][[:punct:]]" # Need single ][ in the middle??
> grep(ma_pattern,colnames(df1))
> ma_pattern <- "[[:punct:][:punct:]]"  #  single ][ worked
> grep(ma_pattern,colnames(df1),value = TRUE)  #  found it
> grepl(ma_pattern,colnames(df1)) 
> gregexpr(ma_pattern,colnames(df1))  # at position 8
> regexpr(ma_pattern,colnames(df1))
> 
> #sub(pattern, replacement, x, ignore.case = FALSE, perl = FALSE,
> #    fixed = FALSE, useBytes = FALSE)
> 
> #sub(ma_pattern,replacement = "'\\"",df1)
> colnames(df1)
> 
> Carl Sutton
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA


 
   
[[alternative HTML version deleted]]

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

Re: [R] Fw: Regex problem

2017-01-05 Thread David Winsemius

> On Jan 5, 2017, at 10:09 AM, Carl Sutton via R-help  
> wrote:
> 
> Re-sending help request, went to wrong addy first time.  
> r-help-requ...@r-project.org
> 
> Belated Happy new year to the Guru's:
> 
> I have a data frame with 570+ columns and in those column headers yours truly 
> has a few blunders.  Namely somehow I managed to end some of them with both 
> an apostrophe ' and an ending quote.

Doubtful. You probably only have a single apostrophe and no "ending quote". In 
fact when I run your `problemdf`, the `make.names` function (called by 
data.frame) changed the apostrophe into a period. To actually get a trailing 
apostrophe with `data.frame` you would need to set check.names=FALSE:

df1 <- data.frame("WhatAmI\'" = 1:5, "WhoAreYou" = 11:15, check.names=FALSE)
colnames(df1)
#[1] "WhatAmI'"  "WhoAreYou"
There is no double quote in that name. Now to remove the offending apostrophe 
(or even multiple instances of them) just do this:

names(df) <- gsub( "\\'", "", names(df)


>   I think the attached code finds the occurrences (not 100% sure) and 
> feedback is appreciated.  This is my first attempt at regex and I have been 
> googling and reading the last few days (including an R -Exercise).
> 
> Confused as to why the column names shows a "." instead of a " ' ".

See above.



> 
> Ignorant of why gregexpr and regexpr show attr(,"useBytes") as TRUE when the 
> default is FALSE.  Is it possible I somehow messed them up last week?   
> Simply typing the function name in the console shows the defaults as FALSE.
> 
> I have not been able to build a construct to simply delete the apostrophe.  I 
> have made several attempts to do this, and left one for your perusal.  The 
> others were just to "off the wall" and embarrassing.
> 
> Lastly, is there a way for me to check that all of my column names end with a 
> letter followed by a quote?  I am thinking something along the lines of 
> "[[:alpha:]\\"" but I expect that will throw an error.  I stumbled upon the ' 
> " problem when dplyr complained about it last week, and it is unsettling to 
> think I may have more goofs.
> 
> Any suggestions of a good reference book is much appreciated.  I can see 
> extended use of regex coming toward me and I am so ignorant it is frightening 
> (all volunteer work, no $'s involved, but I dislike being incompetent).

I learned regex by reading the ?regex page, and by looking up and working 
through questions on R-help by Gabor Grothendeick:

http://markmail.org/search/?q=list%3Aorg.r-project.r-help+regex#query:list%3Aorg.r-project.r-help%20regex%20from%3A%22Gabor%20Grothendieck%22+page:1+state:facets


There are also several online sites where you can get an expression by 
expression readout of what your regexes are doing. They do need the 
understanding that hte escape character for R and regex are the same and the 
means they need to be doubled in hte pattern arguments (but _not_ the 
replacement arguments).

-- 
David.


> 
> 
> #  regex problemdf1 <- data.frame("WhatAmI'" = 1:5, "WhoAreYou" = 11:15)
> colnames(df1)
> df1
> ma_pattern <- "[[:punct:]][[:punct:]]" # Need single ][ in the middle??
> grep(ma_pattern,colnames(df1))
> ma_pattern <- "[[:punct:][:punct:]]"  #  single ][ worked
> grep(ma_pattern,colnames(df1),value = TRUE)  #  found it
> grepl(ma_pattern,colnames(df1)) 
> gregexpr(ma_pattern,colnames(df1))   # at position 8
> regexpr(ma_pattern,colnames(df1))
> 
> #sub(pattern, replacement, x, ignore.case = FALSE, perl = FALSE,
> #fixed = FALSE, useBytes = FALSE)
> 
> #sub(ma_pattern,replacement = "'\\"",df1)
> colnames(df1)
> 
> Carl Sutton
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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


Re: [R] Fw: Urgent help

2016-12-27 Thread David Winsemius

> On Dec 26, 2016, at 9:09 PM, amit rathee  
> wrote:
> 
> 

The text file you attached has no commas. Perhaps the separators are tabs and 
you really need to use `read.delim` instead of `read.csv`.

David Winsemius
Alameda, CA, USA

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


Re: [R] Fw: R problem

2016-09-27 Thread John Kane
We have a "Do not help with homework" policy on R-help. We think that a student 
should speak with his or her instructor or tutor if help is needed.  So you are 
unlikely to get much help here though it is possible.

For future reference, 1. your script did not arrive. The data did. R-help is 
very fussy about what files it will accept.

It is better include your code (script) and data in the body of the email.  
Have a look at 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
  or 
http://adv-r.had.co.nz/Reproducibility.html 
for some suggestions on how to ask a question here.

Then send a new email with the code and data included in the body of the email. 
Someone might help.

John Kane
Kingston ON Canada


> -Original Message-
> From: r-help@r-project.org
> Sent: Tue, 27 Sep 2016 16:11:06 + (UTC)
> To: r-help@r-project.org
> Subject: [R] Fw: R problem
> 
> 
> 
> 
> HelloI want to calculate sen slope with out using package. I wrote one
> but,  it is wrong. I attache my data and my script. would you please
> check it.Many thanksSincerely yoursElham
> 
> 
> 
> 
> 
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


Share photos & screenshots in seconds...
TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if1
Works in all emails, instant messengers, blogs, forums and social networks.

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

Re: [R] Fw: R problem

2016-09-27 Thread Bert Gunter
This list has a *no homework* policy.

Cheers,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Sep 27, 2016 at 7:18 AM, Elham Fakharizade via R-help
 wrote:
>
>
>
>
> HelloI am university student.I should do a R home work. That is writing sen 
> slope code in R and calculate it with out using package. I wrote one but,  it 
> is wrong. I attache my data and my script. would you please check it.Many 
> thanksSincerely yoursElham
>
>
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Fw: How I can calculate the value of response variable

2016-06-26 Thread rezvan hatami via R-help
For the sake ofsimplicity, I use my example to explain what I have written:


nutrient<-lm(nitrate~0.9*fertilizer-0.02*flowrate+0.5*rain)

datafram=data1


Change the value offertelizer--à datafram=data2


predict(lm(nitrate~0.9*fertilizer2-0.02*flowrate+0.5*rain), datafram=data2
Is that better now?

  From: Bert Gunter 
 To: rezvan hatami  
Cc: "r-help@r-project.org" 
 Sent: Monday, 27 June 2016, 10:34
 Subject: Re: [R] Fw: How I can calculate the value of response variable
   
Is this homework? This list tries to enforce  a no homework policy...

If not, it looks to me as if you have made no effort to learn R nor
have you read and followed the posting guide. We generally expect
posters to have made reasonable efforts to do both and demonstrate
what they have tried and how it has failed.

Cheers,
Bert Gunter





Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Jun 26, 2016 at 5:22 PM, rezvan hatami via R-help
 wrote:
>
>
>
> - Forwarded Message -
>  From: rezvan hatami 
>  To: David Winsemius 
>  Sent: Monday, 27 June 2016, 9:44
>  Subject: Re: [R] How I can calculate the value of response variable
>
> Dear DavidThank you for your answer. My equation is:
> nitrate=0.9*fertilizer-0.02*flowrate+0.5*rain
> my matrix:
> | season | site | nitrate | fertilizer1 | flow rate |
> | spring | site1 | 0.2 | 2 | 1 |
> | spring | site2 | 1.2 | 3 | 1 |
> | spring | site3 | 2.2 | 5 | 2 |
> | summer | site1 | 3.2 | 1 | 2 |
> | summer | site2 | 4.2 | 2 | 2 |
> | summer | site3 | 5.2 | 3 | 2 |
> | fall | site1 | 6.2 | 4 | 3 |
> | fall | site2 | 7.2 | 5 | 3 |
> | fall | site3 | 8.2 | 6 | 3 |
> | winter | site1 | 9.2 | 4 | 4 |
> | winter | site2 | 10.2 | 8 | 4 |
> | winter | site3 | 11.2 | 9 | 4 |
>
>
> I would like to know, what will be the values for variable "nitrate" if I 
> divide the values of fertilizer by half and change the equation to:
> nitrate=0.9*fertilizer2-0.02*flowrate+0.5*rain
>
> in a matrix like:
>
> | season | site | nitrate | fertilizer2 | flow rate |
> | spring | site1 | 0.2 | 1 | 1 |
> | spring | site2 | 1.2 | 1.5 | 1 |
> | spring | site3 | 2.2 | 2.5 | 2 |
> | summer | site1 | 3.2 | 0.5 | 2 |
> | summer | site2 | 4.2 | 1 | 2 |
> | summer | site3 | 5.2 | 1.5 | 2 |
> | fall | site1 | 6.2 | 2 | 3 |
> | fall | site2 | 7.2 | 2.5 | 3 |
> | fall | site3 | 8.2 | 3 | 3 |
> | winter | site1 | 9.2 | 2 | 4 |
> | winter | site2 | 10.2 | 4 | 4 |
> | winter | site3 | 11.2 | 4.5 | 4 |
>
>
> Would you please tell me how I can do this in R?
> Cheers
> Rezvan
>      From: David Winsemius 
>  To: rezvan hatami 
> Cc: "r-help@r-project.org" 
>  Sent: Monday, 27 June 2016, 1:20
>  Subject: Re: [R] How I can calculate the value of response variable
>
>
>> On Jun 26, 2016, at 3:23 AM, rezvan hatami via R-help  
>> wrote:
>>
>>  How I can calculate the value of response variable in a linear model of a 
>>matrix of several variables?Can somebody please answer me?
>>
>
>  You should explain in more detail why the answer to this question is not 
>just the `lm` function. See:
>
> ?lm
> ?predict.lm
>
>    That would deliver (after suitable invocation of the `predict` function) 
>not be the "value of the response variable" (since that would just be the 
>values in your data), but rather the conditional expectation of the response 
>variable given the values of the predictors.
>
>
>>
>> Cheers
>> Rezvan Hatami
>>    [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

  
[[alternative HTML version deleted]]

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

Re: [R] Fw: How I can calculate the value of response variable

2016-06-26 Thread rezvan hatami via R-help
Dear Bert
It is not a homework. I made this example up to ask my question. I am working 
on it in R, but my equations are complicated and if I put the codes in R here, 
I have to explain my whole project. I simply wanted to know what is the 
function for this so that I can be sure that I am doing the right thing.
Cheers
  From: Bert Gunter 
 To: rezvan hatami  
Cc: "r-help@r-project.org" 
 Sent: Monday, 27 June 2016, 10:34
 Subject: Re: [R] Fw: How I can calculate the value of response variable
   
Is this homework? This list tries to enforce  a no homework policy...

If not, it looks to me as if you have made no effort to learn R nor
have you read and followed the posting guide. We generally expect
posters to have made reasonable efforts to do both and demonstrate
what they have tried and how it has failed.

Cheers,
Bert Gunter





Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Jun 26, 2016 at 5:22 PM, rezvan hatami via R-help
 wrote:
>
>
>
> - Forwarded Message -
>  From: rezvan hatami 
>  To: David Winsemius 
>  Sent: Monday, 27 June 2016, 9:44
>  Subject: Re: [R] How I can calculate the value of response variable
>
> Dear DavidThank you for your answer. My equation is:
> nitrate=0.9*fertilizer-0.02*flowrate+0.5*rain
> my matrix:
> | season | site | nitrate | fertilizer1 | flow rate |
> | spring | site1 | 0.2 | 2 | 1 |
> | spring | site2 | 1.2 | 3 | 1 |
> | spring | site3 | 2.2 | 5 | 2 |
> | summer | site1 | 3.2 | 1 | 2 |
> | summer | site2 | 4.2 | 2 | 2 |
> | summer | site3 | 5.2 | 3 | 2 |
> | fall | site1 | 6.2 | 4 | 3 |
> | fall | site2 | 7.2 | 5 | 3 |
> | fall | site3 | 8.2 | 6 | 3 |
> | winter | site1 | 9.2 | 4 | 4 |
> | winter | site2 | 10.2 | 8 | 4 |
> | winter | site3 | 11.2 | 9 | 4 |
>
>
> I would like to know, what will be the values for variable "nitrate" if I 
> divide the values of fertilizer by half and change the equation to:
> nitrate=0.9*fertilizer2-0.02*flowrate+0.5*rain
>
> in a matrix like:
>
> | season | site | nitrate | fertilizer2 | flow rate |
> | spring | site1 | 0.2 | 1 | 1 |
> | spring | site2 | 1.2 | 1.5 | 1 |
> | spring | site3 | 2.2 | 2.5 | 2 |
> | summer | site1 | 3.2 | 0.5 | 2 |
> | summer | site2 | 4.2 | 1 | 2 |
> | summer | site3 | 5.2 | 1.5 | 2 |
> | fall | site1 | 6.2 | 2 | 3 |
> | fall | site2 | 7.2 | 2.5 | 3 |
> | fall | site3 | 8.2 | 3 | 3 |
> | winter | site1 | 9.2 | 2 | 4 |
> | winter | site2 | 10.2 | 4 | 4 |
> | winter | site3 | 11.2 | 4.5 | 4 |
>
>
> Would you please tell me how I can do this in R?
> Cheers
> Rezvan
>      From: David Winsemius 
>  To: rezvan hatami 
> Cc: "r-help@r-project.org" 
>  Sent: Monday, 27 June 2016, 1:20
>  Subject: Re: [R] How I can calculate the value of response variable
>
>
>> On Jun 26, 2016, at 3:23 AM, rezvan hatami via R-help  
>> wrote:
>>
>>  How I can calculate the value of response variable in a linear model of a 
>>matrix of several variables?Can somebody please answer me?
>>
>
>  You should explain in more detail why the answer to this question is not 
>just the `lm` function. See:
>
> ?lm
> ?predict.lm
>
>    That would deliver (after suitable invocation of the `predict` function) 
>not be the "value of the response variable" (since that would just be the 
>values in your data), but rather the conditional expectation of the response 
>variable given the values of the predictors.
>
>
>>
>> Cheers
>> Rezvan Hatami
>>    [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

  
[[alternative HTML version deleted]]

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

Re: [R] Fw: How I can calculate the value of response variable

2016-06-26 Thread Bert Gunter
Is this homework? This list tries to enforce  a no homework policy...

If not, it looks to me as if you have made no effort to learn R nor
have you read and followed the posting guide. We generally expect
posters to have made reasonable efforts to do both and demonstrate
what they have tried and how it has failed.

Cheers,
Bert Gunter





Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sun, Jun 26, 2016 at 5:22 PM, rezvan hatami via R-help
 wrote:
>
>
>
> - Forwarded Message -
>  From: rezvan hatami 
>  To: David Winsemius 
>  Sent: Monday, 27 June 2016, 9:44
>  Subject: Re: [R] How I can calculate the value of response variable
>
> Dear DavidThank you for your answer. My equation is:
> nitrate=0.9*fertilizer-0.02*flowrate+0.5*rain
> my matrix:
> | season | site | nitrate | fertilizer1 | flow rate |
> | spring | site1 | 0.2 | 2 | 1 |
> | spring | site2 | 1.2 | 3 | 1 |
> | spring | site3 | 2.2 | 5 | 2 |
> | summer | site1 | 3.2 | 1 | 2 |
> | summer | site2 | 4.2 | 2 | 2 |
> | summer | site3 | 5.2 | 3 | 2 |
> | fall | site1 | 6.2 | 4 | 3 |
> | fall | site2 | 7.2 | 5 | 3 |
> | fall | site3 | 8.2 | 6 | 3 |
> | winter | site1 | 9.2 | 4 | 4 |
> | winter | site2 | 10.2 | 8 | 4 |
> | winter | site3 | 11.2 | 9 | 4 |
>
>
> I would like to know, what will be the values for variable "nitrate" if I 
> divide the values of fertilizer by half and change the equation to:
> nitrate=0.9*fertilizer2-0.02*flowrate+0.5*rain
>
> in a matrix like:
>
> | season | site | nitrate | fertilizer2 | flow rate |
> | spring | site1 | 0.2 | 1 | 1 |
> | spring | site2 | 1.2 | 1.5 | 1 |
> | spring | site3 | 2.2 | 2.5 | 2 |
> | summer | site1 | 3.2 | 0.5 | 2 |
> | summer | site2 | 4.2 | 1 | 2 |
> | summer | site3 | 5.2 | 1.5 | 2 |
> | fall | site1 | 6.2 | 2 | 3 |
> | fall | site2 | 7.2 | 2.5 | 3 |
> | fall | site3 | 8.2 | 3 | 3 |
> | winter | site1 | 9.2 | 2 | 4 |
> | winter | site2 | 10.2 | 4 | 4 |
> | winter | site3 | 11.2 | 4.5 | 4 |
>
>
> Would you please tell me how I can do this in R?
> Cheers
> Rezvan
>   From: David Winsemius 
>  To: rezvan hatami 
> Cc: "r-help@r-project.org" 
>  Sent: Monday, 27 June 2016, 1:20
>  Subject: Re: [R] How I can calculate the value of response variable
>
>
>> On Jun 26, 2016, at 3:23 AM, rezvan hatami via R-help  
>> wrote:
>>
>>  How I can calculate the value of response variable in a linear model of a 
>> matrix of several variables?Can somebody please answer me?
>>
>
>   You should explain in more detail why the answer to this question is not 
> just the `lm` function. See:
>
> ?lm
> ?predict.lm
>
> That would deliver (after suitable invocation of the `predict` function) 
> not be the "value of the response variable" (since that would just be the 
> values in your data), but rather the conditional expectation of the response 
> variable given the values of the predictors.
>
>
>>
>> Cheers
>> Rezvan Hatami
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Fw: Aw: Re: Building a binary vector out of dichotomous variables

2016-06-17 Thread PIKAL Petr
Hi

Your approach seems to me rather tricky

This should work

make_bv <- function(dataset,  input_variables) {

dd <- which(names(dataset) %in% input_variables)
dat<-dataset[,dd]
x <- 10^(ncol(dat):0)
result <- cbind(dataset, binary_vec=x[1]+rowSums(sweep(dat, 2, x[-1], "*")))
result}

make_bv(dataset = ds_example,  input_variables = c("year2013", "year2015"))

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
> g.maub...@gmx.de
> Sent: Friday, June 17, 2016 9:19 AM
> To: r-help@r-project.org
> Subject: [R] Fw: Aw: Re: Building a binary vector out of dichotomous variables
>
> > Hi Tom,
> >
> > thanks for your reply.
> >
> > Yes, that's exactly what I am looking for. I did not know about the
> automatic type conversion in R.
> >
> > #-- cut --
> > ds_example <-
> >   structure(
> > list(
> >   year2013 = c(0, 0, 0, 1, 1, 1, 1, 0),
> >   year2014 = c(0,
> >0, 1, 1, 0, 0, 1, 1),
> >   year2015 = c(0, 1, 1, 1, 0, 1, 0, 0)
> > ),
> > .Names = c("year2013",
> >"year2014", "year2015"),
> > row.names = c(NA, 8L),
> > class = "data.frame"
> >   )
> >
> > #-- Proposal: works!
> > as.numeric(with(ds_example,paste(1,year2013,year2014,year2015,sep=''))
> > )
> >
> > # I store my know-how about R in functions for later use.
> >
> > #--´ Putting it in a function - does not work!
> > t_make_binary_vector <- function(dataset,
> >  input_variables,
> >  output_variable = "binary_vector") {
> >   dataset[output_variable] <- "1"
> >   print(dataset[output_variable])
> >
> >   for (variable in input_variables) {
> > print(variable)
> > dataset[output_variable] <- paste(dataset[output_variable],
> >   dataset[variable],
> >   sep='')
> >   }
> >
> >   # print(dataset[output_variable])
> >
> >   dataset[output_variable] <- as.integer(dataset[output_variable])
> >
> >   return(dataset)
> > }
> >
> > t_make_binary_vector(dataset = ds_example,
> >  input_variables = c("year2013", "year2014", 
> > "year2015"),
> >  output_variable = "binary_vector")
> >
> >
> > #-- Doesn't work either.
> > t_make_binary_vector <- function(dataset,
> >  input_variables,
> >  output_variable = "binary_vector") {
> >   dataset[output_variable] <- as.integer(paste(1, dataset[ ,
> > input_variables], sep = ''))
> >
> >   return(dataset)
> > }
> >
> > t_make_binary_vector(dataset = ds_example,
> >  input_variables = c("year2013", "year2014", 
> > "year2015"),
> >  output_variable = "binary_vector")
> >
> > #-- cut --
> >
> > Why is R taking the parameter value itself to paste it together instead of
> referencing the variable within the dataset?
> >
> > What did I get wrong about R? How can I fix it?
> >
> > Kind regards
> >
> > Georg
> >
> >
> > > Gesendet: Donnerstag, 16. Juni 2016 um 16:13 Uhr
> > > Von: "Tom Wright" 
> > > An: g.maub...@weinwolf.de
> > > Cc: "R. Help" 
> > > Betreff: Re: [R] Building a binary vector out of dichotomous
> > > variables
> > >
> > > Does this do what you want?
> > >
> > > as.numeric(with(ds_example,paste(1,year2013,year2014,year2015,sep=''
> > > )))
> > >
> > > On Thu, Jun 16, 2016 at 8:57 AM,   wrote:
> > > > Hi All,
> > > >
> > > > I need to build a binary vector made of a set of dichotomous variables.
> > > >
> > > > What I have so far is:
> > > >
> > > > -- cut --
> > > >
> > > > ds_example <-
> > > >   structure(
> > > > list(
> > > >   year2013 = c(0, 0, 0, 1, 1, 1, 1, 0),
> > > >   year2014 = c(0,
> > > >0, 1, 1, 0, 0, 1, 1),
> > > >   year2015 = c(0, 1, 1, 1, 0, 1, 0, 0)
> > > > ),
> > > > .Names = c("year2013",
> > > >"year2014", "year2015"),
> > > > row.names = c(NA, 8L),
> > > > class = "data.frame"
> > > >   )
> > > >
> > > > attach(ds_example)
> > > > base <- 1000
> > > > binary_vector <- base + year2013 * 100 + year2014 * 10 + year2015
> > > > detach(ds_example)
> > > >
> > > > binary_vector
> > > >
> > > > ds_example <- cbind(ds_example, binary_vector)
> > > >
> > > > varlist <- c("year2013", "year2014", "year2015")
> > > >
> > > > base <- 10^length(varlist)
> > > >
> > > > binary_vector <- NULL
> > > >
> > > > for (i in 1:3) {
> > > >   binary_vector <-
> > > >base +
> > > >ds_example [[varlist[i]]] * base / (10 ^ i) }
> > > >
> > > > ds_example <- cbind(ds_example, binary_vector)
> > > >
> > > > message("Wrong result!")
> > > > ds_example
> > > >
> > > > -- cut --
> > > >
> > > > How do I get vectors like  1000 1001 1011  1100 1101 1110 1010
> > > > for each case?
> > > >
> > > > Is there a better approach than mine?
> > > >
> > > > Kind regards
> > > >
> > > > Georg
> > > >
> > > > __

Re: [R] Fw: i need to install "Rclimdex"........Senior Scientists , BARI

2016-06-05 Thread Sarah Goslee
The RClimDex website has instructions for obtaining and installing
this package, and for obtaining and installing R if you also need to
do that:
http://etccdi.pacificclimate.org/software.shtml

You must follow those directions, as the necessary first step is
obtaining a download password from the maintainers.

Sarah

On Sun, Jun 5, 2016 at 5:23 AM, Ranjit Sen via R-help
 wrote:
>
>
>
> Dear Sir:
> This is Dr Ranjit Sen, Senior Scientific Officer, Soil Science Division, 
> Bangladesh Agricultural Research Institute(BARI). For my research on climatic 
> variability and extreme events of climate of Bangladesh, I need to install 
> the  Rclimdex software from R in my computer.
> I would be highly grateful to you if you help me in this regard such as how 
> to get it as well as how to install in my computer.
> With thank and very best regards.
>
> Sincerely,Dr Ranjit Sen, Senior Scientific Officer, Soil Science Division, 
> Bangladesh Agricultural Research Institute(BARI).
>
>

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


Re: [R] Fw: R STUDIO crashing

2016-05-19 Thread Bert Gunter
Rezvan:

"This is not help after keeping me waiting for long time. Such a waste
of time corresponding with you. "


You do understand that this is entirely a volunteer effort, do you
not? There is no guarantee that you will get any response at all, nor
that any that you do receive is actually helpful -- or even correct!
Caveat Emptor! (and your of getting useful help would probably be
improved by following the posting guide and exhibiting courteous,
respectful behavior to those who are volunteering their time to assist
you).


Cheers,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Thu, May 19, 2016 at 12:47 AM, rezvan hatami via R-help
 wrote:
>
>
>
> - Forwarded Message -
>  From: rezvan hatami 
>  To: Shige Song 
>  Sent: Thursday, 19 May 2016, 17:38
>  Subject: Re: [R] R STUDIO crashing
>
> I didn't say that there is a problem with R or Rstudio. I said, it keeps 
> crashing for whatever reason. If it is not crashing on your computer It 
> doesn't mean that it never might crash. This is not help after keeping me 
> waiting for long time. Such a waste of time corresponding with you.
>
>   From: Shige Song 
>  To: rezvan hatami 
> Cc: "r-help@r-project.org" 
>  Sent: Thursday, 19 May 2016, 14:55
>  Subject: Re: [R] R STUDIO crashing
>
> One thing for sure: It's not the fault of R nor Rstudio (because they are 
> doing fine on other people's computers, mine included). You can probably get 
> some help on the Rstudio support forum.
>
> On Wed, May 18, 2016 at 6:37 PM, rezvan hatami via R-help 
>  wrote:
>
> Hi there
> I have been using R for a while now. I am doing my PhD project with it. 
> Recently, it keeps crashing, mostly when I draw a graph and use XYPLOT code. 
> I even spent some money on cleaning registry, checking ram, deleting 
> unnecessary files from working directory. I used "plot(cars) and dev.off(). 
> First the">" sign disappears from the console and then if I try to remove the 
> plot or something else, the whole R freezes. When the ">" disappears, R 
> doesn't run the commands anymore. I searched all online questions and 
> answers, but I couldn't fix this. Please help me. PLEASE.
> Cheers
> Rezvan Hatami
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Fw: Generating 3Dplot in lattice package

2016-05-03 Thread William Dunlap via R-help
See if you can use is.nan() to figure out which values of B, Bmax, ...,
cause
the result to be NaN (not a number).  One possibility is if B were always
negative so abs(B)/max(B) could be negative: (negative)^(non-integer power)
is NaN.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, May 3, 2016 at 3:54 AM, T.Riedle  wrote:

> Something is wrong here. The formula
>
> pmin(psi/VaR,exp(((abs(B)/Bmax)^w2)*log((psi/VaR),2.718182)))
>
>
> provides a time series. Nevertheless, the returned values are incorrect
> and it produces NANs.
>
>
>
> 
> From: William Dunlap 
> Sent: 02 May 2016 20:04
> To: T.Riedle
> Cc: r-help@r-project.org
> Subject: Re: [R] Generating 3Dplot in lattice package
>
> For starters, use 'pmin' (parallel min) instead of 'min'.
>
> substitute(MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14))),
>  list(MIN=quote(pmin), K14=quote(VaR), ABS=quote(abs),
>   EXP=quote(exp), LN=quote(log), H14=quote(Bmax),
>   omega=quote(w2)))
> # pmin(psi/VaR, exp(((abs(Bmax)/peak)^w2) * log(psi/VaR)))
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Mon, May 2, 2016 at 11:31 AM, T.Riedle  tr...@kent.ac.uk>> wrote:
> Dear R users,
>
> I am trying to generate a 3D plot using the wireframe() function in the
> lattice package.
>
> The corresponding formula in Excel looks as follows and is applied to the
> wireframe() function:
>
> MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14)))
>
> I tried to "translate" this formula in R and the code looks as follows
>
>
> min(psi/VaR,exp(((abs(B)/Bmax)^w2)*log((psi/VaR),2.718182)))
>
>
>
> In this case I get only one value which is NAN but I should get a time
> series with 13000 values. Hence, I deleted the min() function and tried the
> wireframe() function:
>
>
>
> wireframe(inflator~exp((abs(B)/Bmax)^w2)*log((psi/VaR),base=2.718182),data=data_3Dplot)
>
> However, it doesn't work as the formula for the inflator is incorrect. It
> produces NANs although it shouldn't do that and actually doesn't do that in
> Excel. Furthermore, the results are totally different to those calculated
> by Excel.
>
> Can anyone help me with the formula and translate it correctly in terms of
> R? How do I get the time series? How do I get the values I get in Excel?
>
> I have attached the data as csv file to this email.
>
> Thank you very much for your help.
>
> __
> R-help@r-project.org mailing list -- To
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Fw: Generating 3Dplot in lattice package

2016-05-03 Thread David Winsemius

> On May 3, 2016, at 3:54 AM, T.Riedle  wrote:
> 
> Something is wrong here. The formula
> 
> pmin(psi/VaR,exp(((abs(B)/Bmax)^w2)*log((psi/VaR),2.718182)))
> 
> 
> provides a time series. Nevertheless, the returned values are incorrect and 
> it produces NANs.

The only thing we can conclude at the moment is that you have not provided 
sufficient information. The standard mailing list "sig" is there in an effort 
to prevent just this situation.

> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
David.
> 
> 
> 
> 
> From: William Dunlap 
> Sent: 02 May 2016 20:04
> To: T.Riedle
> Cc: r-help@r-project.org
> Subject: Re: [R] Generating 3Dplot in lattice package
> 
> For starters, use 'pmin' (parallel min) instead of 'min'.
> 
> substitute(MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14))),
> list(MIN=quote(pmin), K14=quote(VaR), ABS=quote(abs),
>  EXP=quote(exp), LN=quote(log), H14=quote(Bmax),
>  omega=quote(w2)))
> # pmin(psi/VaR, exp(((abs(Bmax)/peak)^w2) * log(psi/VaR)))
> 
> 
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
> 
> On Mon, May 2, 2016 at 11:31 AM, T.Riedle 
> mailto:tr...@kent.ac.uk>> wrote:
> Dear R users,
> 
> I am trying to generate a 3D plot using the wireframe() function in the 
> lattice package.
> 
> The corresponding formula in Excel looks as follows and is applied to the 
> wireframe() function:
> 
> MIN(psi/K14,EXP(((ABS(H14)/peak)^omega)*LN(psi/K14)))
> 
> I tried to "translate" this formula in R and the code looks as follows
> 
> 
> min(psi/VaR,exp(((abs(B)/Bmax)^w2)*log((psi/VaR),2.718182)))
> 
> 
> 
> In this case I get only one value which is NAN but I should get a time series 
> with 13000 values. Hence, I deleted the min() function and tried the 
> wireframe() function:
> 
> 
> wireframe(inflator~exp((abs(B)/Bmax)^w2)*log((psi/VaR),base=2.718182),data=data_3Dplot)
> 
> However, it doesn't work as the formula for the inflator is incorrect. It 
> produces NANs although it shouldn't do that and actually doesn't do that in 
> Excel. Furthermore, the results are totally different to those calculated by 
> Excel.
> 
> Can anyone help me with the formula and translate it correctly in terms of R? 
> How do I get the time series? How do I get the values I get in Excel?
> 
> I have attached the data as csv file to this email.
> 
> Thank you very much for your help.
> 
> 
> https://stat.ethz.ch/mailman/listinfo/r-help

David Winsemius
Alameda, CA, USA

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


Re: [R] FW: Multivariate ARIMA

2016-03-01 Thread Thomas Lofaro
Hi Paul,

Thanks so much for reaching out.  

I read through the link but I am not having any luck.  It seems the first part 
of the link refers to a single variable ARIMA model with no exogenous variable. 
 Then the link starts discussing forecasting.

Anyway, I have two columns of data in my matrix (each row represents a new 
month).  I want column A to predict Column B, where I can adjust the lag to be 
say 1,2, or 6 months.

Is there any example R code that accomplishes this that you know of?  Apologies 
for my lack of proficiency in the program.


-Original Message-
From: Paul Gilbert [mailto:pgilbert...@gmail.com] 
Sent: Monday, February 15, 2016 6:27 PM
To: Thomas Lofaro
Cc: r-help@r-project.org
Subject: Re: [R] FW: Multivariate ARIMA

See also package dse.  There are examples in the guide: 
http://cran.at.r-project.org/web/packages/dse/vignettes/Guide.pdf

Paul

On 02/14/2016 06:00 AM, r-help-requ...@r-project.org wrote:
> Date: Fri, 12 Feb 2016 18:12:37 + From: Thomas 
> Lofaro To:"r-help@R-project.org"
>  Subject: [R] FW: Multivariate ARIMA 
> Question Message-ID:
>  tlook.com>
>
>  Content-Type: text/plain; charset="UTF-8"
>
> Hi, sorry, I will try to make this short. Essentially, what I am 
> trying to do is run a multivariate ARIMA model predicting one variable 
> with another.  However, the only R packages I have found to 
> accommodate such an analysis are ARIMAX and VAR.  Unfortunately, there 
> don?t seem to be any good tutorials or demonstrations of how to 
> actually perform this analysis in practice, on my two columns of data.  
> I was wondering if anyone knew of a resource that might help (or one 
> that provided an example of r code to accomplish this).
> Thanks sooo much!

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


Re: [R] Fw: removing factor values in the main data frame

2016-03-01 Thread Jeff Newmiller
I advocate not converting to factor in the first place.  Delay that until you 
won't be wanting specific levels to be accounted for. 
-- 
Sent from my phone. Please excuse my brevity.

On March 1, 2016 9:33:31 AM PST, David L Carlson  wrote:
>You need to learn how to send emails in plain text since html gets
>mangled on r-help. See your message below. If I understand your
>question, it has to do with what happens to factor levels when you
>subset your data. Subsetting a factor does not remove empty factor
>levels. This is documented on the manual page for subset():
>
>"Factors may have empty levels after subsetting; unused levels are not
>automatically removed. See droplevels for a way to drop all unused
>levels from a data frame."
>
>
>David L Carlson
>Department of Anthropology
>Texas A&M University
>College Station, TX 77840-4352
>
>
>-Original Message-
>From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of hoda
>rahmati via R-help
>Sent: Tuesday, March 1, 2016 10:32 AM
>To: r-help@r-project.org
>Subject: [R] Fw: removing factor values in the main data frame
>
>Hi all,I have the following main data frame:(mydata)        $ TE : num
>40 40 20 20 20 20 20 20 20 40 ...        $ TR : num 49 49 28 28 28 28
>28 28 28 49 ...        $ COUNTRY : Factor w/ 27 levels
>"","AU","BA","BE",..: 8 8 8 8 8 ...among the COUNTRY I just need US and
>AU,first I get a subset to contain just these two countries:      
> submydata=subset(mydata,COUNTRY%in%c("US","AU"))     
> factor(submydata$COUNTRY) but after this when I get str of mydata
>again I have the same data frame with no changes in COUNTRY, however I
>want mydata to be like: 
>       $ TE : num 40 40 20 20 20 20 20 20 20 40 ...        $ TR : num
>49 49 28 28 28 28 28 28 28 49 ...        $ COUNTRY : Factor w/ 2 levels
>"","AU","US",..: 8 8 8 8 8 8 8 8 8 8Thanks for any help
>
>  
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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

Re: [R] Fw: removing factor values in the main data frame

2016-03-01 Thread David L Carlson
You need to learn how to send emails in plain text since html gets mangled on 
r-help. See your message below. If I understand your question, it has to do 
with what happens to factor levels when you subset your data. Subsetting a 
factor does not remove empty factor levels. This is documented on the manual 
page for subset():

"Factors may have empty levels after subsetting; unused levels are not 
automatically removed. See droplevels for a way to drop all unused levels from 
a data frame."


David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of hoda rahmati 
via R-help
Sent: Tuesday, March 1, 2016 10:32 AM
To: r-help@r-project.org
Subject: [R] Fw: removing factor values in the main data frame

Hi all,I have the following main data frame:(mydata)        $ TE : num 40 40 20 
20 20 20 20 20 20 40 ...        $ TR : num 49 49 28 28 28 28 28 28 28 49 ...    
    $ COUNTRY : Factor w/ 27 levels "","AU","BA","BE",..: 8 8 8 8 8 ...among 
the COUNTRY I just need US and AU,first I get a subset to contain just these 
two countries:        submydata=subset(mydata,COUNTRY%in%c("US","AU"))       
factor(submydata$COUNTRY) but after this when I get str of mydata again I have 
the same data frame with no changes in COUNTRY, however I want mydata to be 
like: 
       $ TE : num 40 40 20 20 20 20 20 20 20 40 ...        $ TR : num 49 49 28 
28 28 28 28 28 28 49 ...        $ COUNTRY : Factor w/ 2 levels "","AU","US",..: 
8 8 8 8 8 8 8 8 8 8Thanks for any help

  
[[alternative HTML version deleted]]

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

Re: [R] FW: Multivariate ARIMA

2016-02-15 Thread Paul Gilbert
See also package dse.  There are examples in the guide: 
http://cran.at.r-project.org/web/packages/dse/vignettes/Guide.pdf


Paul

On 02/14/2016 06:00 AM, r-help-requ...@r-project.org wrote:

Date: Fri, 12 Feb 2016 18:12:37 + From: Thomas
Lofaro To:"r-help@R-project.org"
 Subject: [R] FW: Multivariate ARIMA
Question Message-ID:


 Content-Type: text/plain; charset="UTF-8"

Hi, sorry, I will try to make this short. Essentially, what I am
trying to do is run a multivariate ARIMA model predicting one
variable with another.  However, the only R packages I have found to
accommodate such an analysis are ARIMAX and VAR.  Unfortunately,
there don?t seem to be any good tutorials or demonstrations of how to
actually perform this analysis in practice, on my two columns of
data.  I was wondering if anyone knew of a resource that might help
(or one that provided an example of r code to accomplish this).
Thanks sooo much!


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


Re: [R] Fw: Multiple Integrals

2015-08-30 Thread David Winsemius

On Aug 30, 2015, at 8:41 AM, Shant Ch via R-help wrote:

> Thank you very much to all for all your responses.
> 
> @Dr. Winsemius, E[f(X)] >=f(E(X)) if f is convex. Now we know |x| is convex 
> function, so clearly in this scenario if we compute the expectation of the 
> ((X1+X2+X3)/3-X4) and then take the absolute, then, we will get a lower bound 
> of the expectation I want to find. 
> 

I understood the error in my thinking when Jeff Newmiller pointed out the minus 
sign that I had missed.

Thanks;
David.


>  On Saturday, August 29, 2015 7:24 PM, David Winsemius 
>  wrote:
> 
> 
> 
> On Aug 29, 2015, at 11:35 AM, Shant Ch via R-help wrote:
> 
>> Hello Dr. Berry,
>> 
>> I know the theoretical side but note we are not talking about expectation of 
>> sums rather expectation of ABSOLUTE value of the function 
>> (X1/3+X2/3+X3/3-X4), i.e. E|X1/3+X2/3+X3/3-X4|  , I don't think this can be 
>> handled for log normal distribution by integrals by hand.
>> 
> 
> To Shnant Ch;
> 
> I admit to puzzlement (being a humble country doctor). Can you explain why 
> there should be a difference between the absolute value of an expectation for 
> a sum of values from a function, in this case dlnorm,  that is positive 
> definite versus an expectation simply of the sum of such values?
> 
> -- 
> 
> David Winsemius
> Alameda, CA, USA
> 
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA

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


Re: [R] Fw: Downloading R

2015-05-13 Thread MacQueen, Don
Hmmm. Follow the instructions at
   http://www.r-project.org/


After choosing a mirror, you will reach a page that says, in part:

 partial quote 
Source Code for all Platforms

Windows and Mac users most likely want to download the precompiled
binaries listed in the upper box, not the source code. The sources have to
be compiled before you can use them. If you do not know what this means,
you probably do not want to do it!

The latest release (2015-04-16, Full of Ingredients) R-3.2.0.tar.gz,
read what's new in the latest version.
 end partial quote 




Then click the link labeled "R-3.2.0.tar.gz"

-- 
Don MacQueen

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





On 5/11/15, 6:41 PM, "e.robin...@pnc.com"  wrote:

>> My name is Erick Robinson and I am a SAS administrator at PNC
>> Bank.  I have been tasked with installing R on two of our SAS servers,
>> but am having trouble downloading the source.  I have little background
>> in UNIX (our servers run On Solaris under Unix) and cannot get to the
>> site to download.  I clicked on the link in red and it took me to the
>> green arrow without any options to download.  I was going to download to
>> Windows and then FTP to the server.  What is the best way to download
>the source to our solaris server?  Thanks
>
>Erick Robinson
>Software Engineer Lead
>Retail MIS SAS Support
>
>PNC Technology and Operations
>23000 Mill Creek Blv.
>Hignland Hills, Oh  44122
>440-342-3100
>e.robin...@pnc.com
>
>
>
> 
>- Forwarded by Erick Robinson/TPS/CLE/PNC on 05/11/2015 09:39 PM -
>
>From:   Duncan Murdoch 
>To: e.robin...@pnc.com, r-wind...@r-project.org,
>Date:   05/11/2015 02:52 PM
>Subject:Re: Downloading R
>
>
>
>On 11/05/2015 2:37 PM, e.robin...@pnc.com wrote:
>> Hello,
>> 
>> My name is Erick Robinson and I am a SAS administrator at PNC
>> Bank.  I have been tasked with installing R on two of our SAS servers,
>> but am having trouble downloading the source.  I have little background
>> in UNIX (our servers run On Solaris under Unix) and cannot get to the
>> site to download.  I clicked on the link in red and it took me to the
>> green arrow without any options to download.  I was going to download to
>> Windows and then FTP to the server
>
>It is much easier to install from a tarball, not from the Subversion
>repository.  But more importantly, you're writing to the wrong place.
>If my hint is not sufficient, please write to R-help, not to R-windows.
> This is the development list for the Windows version, not a general
>support list.
>
>Duncan Murdoch
>
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> Erick Robinson
>> Software Engineer Lead
>> Retail MIS SAS Support
>> 
>> *PNC Technology and Operations*
>> 23000 Mill Creek Blv.
>> Hignland Hills, Oh  44122
>> 440-342-3100
>> e.robin...@pnc.com
>> 
>> 
>> 
>> 
>> 
>> The contents of this email are the property of PNC. If it was not
>> addressed to you, you have no legal right to read it. If you think you
>> received it in error, please notify the sender. Do not forward or copy
>> without permission of the sender. This message may be considered a
>> commercial electronic message under Canadian law or this message may
>> contain an advertisement of a product or service and thus may constitute
>> a commercial electronic mail message under US law. You may unsubscribe
>> at any time from receiving commercial electronic messages from PNC at
>> http://pages.e.pnc.com/globalunsub/
>> PNC, 249 Fifth Avenue, Pittsburgh, PA 15222; pnc.com
>> 
>
>
>
>The contents of this email are the property of PNC. If it was not
>addressed to you, you have no legal right to read it. If you think you
>received it in error, please notify the sender. Do not forward or copy
>without permission of the sender. This message may be considered a
>commercial electronic message under Canadian law or this message may
>contain an advertisement of a product or service and thus may constitute
>a commercial electronic mail message under US law. You may unsubscribe at
>any time from receiving commercial electronic messages from PNC at
>http://pages.e.pnc.com/globalunsub/
>PNC, 249 Fifth Avenue, Pittsburgh, PA 15222; pnc.com
>
>
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] FW: New package apex 1.0.0 released on CRAN

2015-04-16 Thread Bert Gunter
This sounds more appropriate for Bioconductor, if you haven't already
submitted/announced it there.

Cheers,
Bert

On Thursday, April 16, 2015, Jombart, Thibaut 
wrote:

>
> Dear all,
>
> (apologies for multiple posting)
>
> On behalf of the apex development team (E. Paradis, K. Schliep, Z. Kamvar,
> R. Harris and myself), I am happy to announce that apex has been released
> on CRAN:
> http://cran.r-project.org/web/packages/apex/index.html
>
> This package provides tools for reading, storing, handling and analysing
> genetic sequences from multiple genes, and is compatible with both ape and
> phangorn.
>
> For more information on apex, questions, requests, or to join us, check
> our github project at:
> https://github.com/thibautjombart/apex
>
> Best regards
> Thibaut
>
> ==
> Dr Thibaut Jombart
> MRC Centre for Outbreak Analysis and Modelling
> Department of Infectious Disease Epidemiology
> Imperial College - School of Public Health
> Norfolk Place, London W2 1PG, UK
> Tel. : 0044 (0)20 7594 3658
> thibautjombart 
> therepiproject 
> http://adegenet.r-forge.r-project.org/
> Twitter: @thibautjombart
>
>
> ___
> R-sig-genetics mailing list
> r-sig-genet...@r-project.org 
> https://stat.ethz.ch/mailman/listinfo/r-sig-genetics
>
> __
> R-help@r-project.org  mailing list -- To UNSUBSCRIBE and
> more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge is
certainly not wisdom."
Clifford Stoll

[[alternative HTML version deleted]]

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


Re: [R] FW: R demos or tutorials

2014-12-30 Thread Jeff Newmiller
If you entered

demo()

at the R prompt and got the stated error then I would venture that your 
installation is faulty. 

Another function that should work is

sessionInfo()

and the output of that function can be helpful to us in  troubleshooting.  
However, I would strongly consider looking into re-installing R from 
r--project.org.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On December 30, 2014 6:45:14 AM PST, Joseph Racine  
wrote:
>To whom is may concern,
>
>I am interested in working with R, and just downloaded the windows
>installation. Unfortunately when I tried to run some demos, I received
>an error (Error: could not find function "demo").
>
>Any suggestions?
>
>Also, if you have some tutorial packages to help gain some familiarity,
>please pass those on as well.
>
>Best regards and happy new year.
>
>Joe Racine
>
>Joseph K. Racine
>Data Scientist
>MDA Information Systems LLC
>Client Site: (434) 995-4454
>Cell: (571) 213-4236
>www.mdaus.com
>joseph.rac...@mdaus.com
>
>
>
>The information contained in this communication is
>confi...{{dropped:11}}
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] FW: R Statistics

2014-12-03 Thread Chel Hee Lee

Or, you may use this approach:

> attach(achtergrond)
> spits <- ifelse(uurenminuut >= 5.30 & uurenminuut < 9.30, "morning",
+ ifelse(uurenminuut >=16.30 & uurenminuut < 19.0, "evening",
+ "between"))
> table(spits)
spits
between evening morning
   1636 142 579
>

I personally like the approach presented by Bill Dunlap (in the previous 
message).  I think his approach is smart and nice.  You will see the 
same results as shown in the above:


> 
achtergrond$spits=cut(achtergrond$uurenminuut,c(-1.0,5.30,9.30,16.30,19.0,24.0),right=FALSE)
> levels(achtergrond$spits) <- 
c("between","morning","between","evening","between")

> table(achtergrond$spits)

between morning evening
   1636 579 142
>

You can also use function 'findInterval()' instead of using 'cut()'.  I 
hope this helps.


Chel Hee Lee


On 12/02/2014 02:04 PM, William Dunlap wrote:

You can do this in 2 steps - have cut() make a factor with a different
level for each time period
then use levels<-() to merge some of the levels.
> z <- cut(.5:3.5, breaks=c(0,1,2,3,4), labels=c("0-1", "1-2", "2-3",
"3-4"))
> levels(z)
[1] "0-1" "1-2" "2-3" "3-4"
> levels(z) <- c("between", "1-2", "between", "3-4") # or
levels(z)[c(1,3)] <- "between"
> str(z)
Factor w/ 3 levels "between","1-2",..: 1 2 1 3




Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Dec 2, 2014 at 11:32 AM, Dries David 
wrote:




Hey
I have a question about making a new variable in R. I have put my

dataset in attachment. I have to make a new variable "spits" where
spits=morning when uurenminuut (also a variabel) is between 5.30 and 9.30,
when uurenminuut is between 16.30 and 19.0 spits has to be equal to
evening. But here is my problem: for all the values not between 5.30- 9.30
and 16.30-19.0 spits must be equal to "between"


achtergrond$minuutdec=achtergrond$minuut/100
achtergrond$uurenminuut=achtergrond$uur+achtergrond$minuutdec


achtergrond$spits=cut(uurenminuut,c(-1.0,5.30,9.30,16.30,19.0,24.0),labels=c("between","morning","between","evening","between"),right=FALSE)


When I do this i get a warning message, because I use between more

than once as label. Between has to be one label that covers all values that
are not in morning and evening.


Could you help me with this?

Kind regards

Dries David






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




[[alternative HTML version deleted]]

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



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


Re: [R] FW: R Statistics

2014-12-02 Thread William Dunlap
You can do this in 2 steps - have cut() make a factor with a different
level for each time period
then use levels<-() to merge some of the levels.
   > z <- cut(.5:3.5, breaks=c(0,1,2,3,4), labels=c("0-1", "1-2", "2-3",
"3-4"))
   > levels(z)
   [1] "0-1" "1-2" "2-3" "3-4"
   > levels(z) <- c("between", "1-2", "between", "3-4") # or
levels(z)[c(1,3)] <- "between"
   > str(z)
   Factor w/ 3 levels "between","1-2",..: 1 2 1 3




Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Dec 2, 2014 at 11:32 AM, Dries David 
wrote:

>
> > > Hey
> > > I have a question about making a new variable in R. I have put my
> dataset in attachment. I have to make a new variable "spits" where
> spits=morning when uurenminuut (also a variabel) is between 5.30 and 9.30,
> when uurenminuut is between 16.30 and 19.0 spits has to be equal to
> evening. But here is my problem: for all the values not between 5.30- 9.30
> and 16.30-19.0 spits must be equal to "between"
> > >
> > > achtergrond$minuutdec=achtergrond$minuut/100
> > > achtergrond$uurenminuut=achtergrond$uur+achtergrond$minuutdec
> > >
> achtergrond$spits=cut(uurenminuut,c(-1.0,5.30,9.30,16.30,19.0,24.0),labels=c("between","morning","between","evening","between"),right=FALSE)
> > >
> > > When I do this i get a warning message, because I use between more
> than once as label. Between has to be one label that covers all values that
> are not in morning and evening.
> > >
> > > Could you help me with this?
> > >
> > > Kind regards
> > >
> > > Dries David
> > >
> >
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

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


Re: [R] FW: needs help in augented plot

2014-05-16 Thread Rolf Turner

On 16/05/14 19:45, Mir Salam wrote:

Dear Med venlig hilsen and all
Thanks a lot for your attention and valuable codes.  I produced the
graph using the follwing code. I fitted mixed effects dominant height
model. The grpah is showing plot-specific dominant height against
Age.




You are not very intuitive are you?  "Med venlig hilsen" is not a name. 
 It is the "complimentary closure" of a letter/email in Danish, 
literally translating into English as ``With friendly greetings''.
As a rudimentary Google search would have told you, and as a sensible 
person would have inferred from context.


cheers,

Rolf Turner

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


Re: [R] Fw: Save multiple plots as pdf or jpeg

2014-04-23 Thread ONKELINX, Thierry
Have a look at the knitr package. http://yihui.name/knitr/demo/minimal/

Best regards,

ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and 
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
thierry.onkel...@inbo.be
www.inbo.be

To call in the statistician after the experiment is done may be no more than 
asking him to perform a post-mortem examination: he may be able to say what the 
experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not ensure 
that a reasonable answer can be extracted from a given body of data.
~ John Tukey


-Oorspronkelijk bericht-
Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens 
Pavneet Arora
Verzonden: woensdag 23 april 2014 11:14
Aan: Jeff Newmiller
CC: r-help@r-project.org
Onderwerp: Re: [R] Fw: Save multiple plots as pdf or jpeg

Sorry I should have been more clearer. Let me repharse.

At the moment I have a loop that plots a histogram of the variable, along with 
rug and super-imposed normal curve over it. It does that for a lot of variables 
in the dataset and then compiles them into a pdf. Whereby each page on the pdf 
corresponds to the histogram of 1 variable.

However, it takes ages to load and takes up a lot of memory. So I was wondering 
if there is a way that before it gets compiled into a pdf, if I can convert my 
graphs into png or bitmaps images and then compile them into pdf?

This is my code so far:

pdf(file="C:/#temp/Histo and2.pdf") ##- Saves all plots in the same pdf file
for(k in 1:ncol(nums2)){hist(nums2[,k],freq=F,col="lightblue1",
#density=20   ##- Density -> Gives shaded bars
 main=names(nums2)[k],col.main="blue",cex.main=0.8,font=2,
 xlab=names(nums2)[k])  ##- Font=2 => bold

 #rug(jitter(nums2[,k]),side=1,col="antiquewhite3")

 lines(density(nums2[,k],na.rm=T),col="navy",lwd=2)  ##- Density
Function of data

 curve(dnorm(x,mean=mean(nums2[,k],na.rm=T),sd=sd(nums2[,k],na.rm=T)),
  col="brown",lwd=3,add=T)

#  readline(prompt="Press [enter] to
continue")
}
dev.off()
Hope this is much clearer?




From:   Jeff Newmiller 
To: Pavneet Arora/UK/RoyalSun@RoyalSun, r-help@r-project.org
Date:   22/04/2014 16:09
Subject:Re: [R] Fw: Save multiple plots as pdf or jpeg



Sounds like you are getting what you want... except that you used the word
"but". If you are not getting what you want, then what is it that you do
want? In particular, how do you intend to review or use many plots
generated at once if not in a PDF file?
---
Jeff NewmillerThe .   .  Go
Live...
DCN:Basics: ##.#.   ##.#.  Live
Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#. rocks...1k
---

Sent from my phone. Please excuse my brevity.

On April 22, 2014 6:59:55 AM PDT, starter 
wrote:
>That is what I was trying to achieve; i.e. plot all my graphs using a
>loop
>function. But somewhere in the loop it converts each graph into png or
>bitmap image and then compiles all these png or bitmap images in a pdf
>file.
>So each page in a pdf file is a bitmap or png picture of my graph.
>
>Does that make any sense?
>
>
>
>--
>View this message in context:
>
http://r.789695.n4.nabble.com/Fw-Save-multiple-plots-as-pdf-or-jpeg-tp4688801p4689256.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.





__

The following message has been automatically added to comply with the RSA
Group IT Security requirements:

This email arrived via the internet, over a secure Opportunistic TLS
encryption connection.
This means the email was sent using encryption but the senders domain has
not been verified for its authenticity.
As such you still need to be cautious about its origin and content.
Replies which contain sensitive information or legal/contractual
obligations are particul

Re: [R] Fw: Save multiple plots as pdf or jpeg

2014-04-23 Thread Pavneet Arora
Sorry I should have been more clearer. Let me repharse.

At the moment I have a loop that plots a histogram of the variable, along 
with rug and super-imposed normal curve over it. It does that for a lot of 
variables in the dataset and then compiles them into a pdf. Whereby each 
page on the pdf corresponds to the histogram of 1 variable.

However, it takes ages to load and takes up a lot of memory. So I was 
wondering if there is a way that before it gets compiled into a pdf, if I 
can convert my graphs into png or bitmaps images and then compile them 
into pdf?

This is my code so far:

pdf(file="C:/#temp/Histo and2.pdf") ##- Saves all plots in the same pdf 
file
for(k in 1:ncol(nums2)){hist(nums2[,k],freq=F,col="lightblue1", 
#density=20   ##- Density -> Gives shaded bars
 main=names(nums2)[k],col.main="blue",cex.main=0.8,font=2,
 xlab=names(nums2)[k])  ##- Font=2 => bold
 
 #rug(jitter(nums2[,k]),side=1,col="antiquewhite3")
 
 lines(density(nums2[,k],na.rm=T),col="navy",lwd=2)  ##- Density 
Function of data
 
 curve(dnorm(x,mean=mean(nums2[,k],na.rm=T),sd=sd(nums2[,k],na.rm=T)),
  col="brown",lwd=3,add=T)
 
#  readline(prompt="Press [enter] to 
continue")
}
dev.off()
Hope this is much clearer?




From:   Jeff Newmiller 
To: Pavneet Arora/UK/RoyalSun@RoyalSun, r-help@r-project.org
Date:   22/04/2014 16:09
Subject:Re: [R] Fw: Save multiple plots as pdf or jpeg



Sounds like you are getting what you want... except that you used the word 
"but". If you are not getting what you want, then what is it that you do 
want? In particular, how do you intend to review or use many plots 
generated at once if not in a PDF file?
---
Jeff NewmillerThe .   .  Go 
Live...
DCN:Basics: ##.#.   ##.#.  Live 
Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#. rocks...1k
---

Sent from my phone. Please excuse my brevity.

On April 22, 2014 6:59:55 AM PDT, starter  
wrote:
>That is what I was trying to achieve; i.e. plot all my graphs using a
>loop
>function. But somewhere in the loop it converts each graph into png or
>bitmap image and then compiles all these png or bitmap images in a pdf
>file. 
>So each page in a pdf file is a bitmap or png picture of my graph.
>
>Does that make any sense?
>
>
>
>--
>View this message in context:
>
http://r.789695.n4.nabble.com/Fw-Save-multiple-plots-as-pdf-or-jpeg-tp4688801p4689256.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.





__

The following message has been automatically added to comply with the RSA 
Group IT Security requirements:

This email arrived via the internet, over a secure Opportunistic TLS 
encryption connection. 
This means the email was sent using encryption but the senders domain has 
not been verified for its authenticity. 
As such you still need to be cautious about its origin and content.
Replies which contain sensitive information or legal/contractual 
obligations are particularly vulnerable. 
In these cases you should not reply unless you are authorised to do so.

If you have any questions, please speak to the Service Centre on x7979.
__


***
MORE TH>N is a trading style of Royal & Sun Alliance Insurance plc (No. 93792). 
Registered in England and Wales at St. Mark’s Court, Chart Way, Horsham, West 
Sussex, RH12 1XL. 

Authorised by the Prudential Regulation Authority and regulated by the 
Financial Conduct Authority and the Prudential Regulation Authority.


[[alternative HTML version deleted]]


Re: [R] Fw: Save multiple plots as pdf or jpeg

2014-04-22 Thread Jeff Newmiller
Sounds like you are getting what you want... except that you used the word 
"but". If you are not getting what you want, then what is it that you do want? 
In particular, how do you intend to review or use many plots generated at once 
if not in a PDF file?
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

On April 22, 2014 6:59:55 AM PDT, starter  wrote:
>That is what I was trying to achieve; i.e. plot all my graphs using a
>loop
>function. But somewhere in the loop it converts each graph into png or
>bitmap image and then compiles all these png or bitmap images in a pdf
>file. 
>So each page in a pdf file is a bitmap or png picture of my graph.
>
>Does that make any sense?
>
>
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/Fw-Save-multiple-plots-as-pdf-or-jpeg-tp4688801p4689256.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] Fw: Save multiple plots as pdf or jpeg

2014-04-22 Thread starter
That is what I was trying to achieve; i.e. plot all my graphs using a loop
function. But somewhere in the loop it converts each graph into png or
bitmap image and then compiles all these png or bitmap images in a pdf file. 
So each page in a pdf file is a bitmap or png picture of my graph.

Does that make any sense?



--
View this message in context: 
http://r.789695.n4.nabble.com/Fw-Save-multiple-plots-as-pdf-or-jpeg-tp4688801p4689256.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] Fw: Save multiple plots as pdf or jpeg

2014-04-16 Thread Uwe Ligges



On 16.04.2014 11:00, Pavneet Arora wrote:

Hello Uwe

Can you explain what you mean by "try to plot the sensity only with few
hundreds of segemnts"

>

Do you mean that I should take some kind of sample and do it? And if so
what's the best number for the sample and how do i ensure that its not
biased?


Just ensure that you various plots do not contain too many elements to 
be plotted. If you really need many of these, a bitmap graphics may be 
exceptionally a better idea.


Best,
Uwe Ligges










From:   Uwe Ligges 
To: Pavneet Arora/UK/RoyalSun@RoyalSun, r-help@r-project.org,
pavnee...@yahoo.co.uk
Date:   15/04/2014 14:08
Subject:Re: [R] Fw: Save multiple plots as pdf or jpeg



You have > 1e6 observations and your lines() have these many segments,
try to plot the sensity only with few hndreds of segemnts.

Best,
Uwe Ligges


On 15.04.2014 12:27, Pavneet Arora wrote:

Hello All,

I have multiple plots that I want to save it a single file. At the

moment,

I am saving as pdf. Each plot has a qqnorm, qqline, tiny histogram in

the

top left graph with its density drawn top of it and the normal
superimposed on the histogram.

As a result, the pdf takes forever to load and doesn?t let me print, as

it

runs out of memory. I was wondering if there is a way if I can save each
plot as jpeg and then export it on pdf. Will that make it quicker in
loading? If so, how can I do this? And if not, then what are the
alternatives.

The code that I have at the moment is as follows:



~

pdf(file="C:/qqnorm/qqnorms.pdf") ##- Saves all plots in the same pdf

file



for (k in 1:ncol(nums2)){
  par(mfrow=c(1,1))

##- QQNorm
  qqnorm(nums2[,k],col="lightblue",main=names(nums2)[k])
  qqline(nums2[,k],col="red",lwd=2)

##- Tiny Histogram
op = par(fig=c(.02,.5,0.4,0.98), new=TRUE)
  hist(nums2[,k],freq=F,col="blue",xlab="", ylab="", main="",
   axes=F,density=20)

##- Density of the variable
  lines(density(nums2[,k],na.rm=T), col="darkred", lwd=2)

##- Super-imposed Normal Density
curve(dnorm(x,mean=mean(nums2[,k],na.rm=T),sd=sd(nums2[,k],na.rm=T)),
col="black",lwd=3,add=T) ##- Footnote: title1 <- "nums2[k]"

library(moments)
  s_kurt <- kurtosis (nums2[,k])
  s_skew <- skewness (nums2[,k])
  mtxt <- paste ("Variable=",title1, ":" ,
 "Kurt=",round(s_kurt,digits=4), "Skew",
 round(s_skw,digits=4), sep=" ")

mtext (mtxt,col="green4",side=1,line=15.6,adj=0.0,cex=0.8,font=2,las=1)

}
dev.off()


~


Structure of My data:

str(nums2)
'data.frame':1355615 obs. of  39 variables:
   $ month   : int  1 1 1 1 1 1 1 1 1 1 ...
   $ Location_Easting_OSGR   : int  525680 524170 524520 526900
528060 524770 524220 525890 527350 524550 ...
   $ Location_Northing_OSGR  : int  178240 181650 182240 177530
179040 181160 180830 179710 177650 180810 ...
   $ Longitude   : num  -0.191 -0.212 -0.206 -0.174
-0.157 ...
   $ Latitude: num  51.5 51.5 51.5 51.5 51.5 ...
   $ Police_Force: int  1 1 1 1 1 1 1 1 1 1 ...
   $ Number_of_Vehicles  : int  1 1 2 1 1 2 2 1 2 2 ...
   $ Number_of_Casualties: int  1 1 1 1 1 1 1 2 2 5 ...
   $ Day_of_Week : int  3 4 5 6 2 3 5 6 7 7 ...
   $ Local_Authority__District_  : int  12 12 12 12 12 12 12 12 12 12
...
   $ X_1_st_Road_Class   : int  3 4 5 3 6 6 5 3 3 4 ...
   $ X_1_st_Road_Number  : int  3218 450 0 3220 0 0 0 315

3212

450 ...
   $ Road_Type   : int  6 3 6 6 6 6 6 3 6 6 ...
   $ Speed_limit : int  30 30 30 30 30 30 30 30 30 30
...
   $ Junction_Detail : int  0 6 0 0 0 0 3 0 6 3 ...
   $ Junction_Control: int  -1 2 -1 -1 -1 -1 4 -1 2 4 ...
   $ X_2_nd_Road_Class   : int  -1 5 -1 -1 -1 -1 6 -1 4 5 ...
   $ X_2_nd_Road_Number  : int  0 0 0 0 0 0 0 0 304 0 ...
   $ Pedestrian_Crossing_Human_Contro: int  0 0 0 0 0 0 0 0 0 0 ...
   $ Pedestrian_Crossing_Physical_Fac: int  1 5 0 0 0 0 0 0 5 8 ...
   $ Light_Conditions: int  1 4 4 1 7 1 4 1 4 1 ...
   $ Weather_Conditions  : int  2 1 1 1 1 2 1 1 1 1 ...
   $ Road_Surface_Conditions : int  2 1 1 1 2 2 1 1 1 1 ...
   $ Special_Conditions_at_Site  : int  0 0 0 0 0 6 0 0 0 0 ...
   $ Carriageway_Hazards : int  0 0 0 0 0 0 0 0 0 0 ...
   $ Urban_or_Rural_Area : int  1 1 1 1 1 1 1 1 1 1 ...
   $ Did_Police_Officer_Attend_Scene_: i

Re: [R] Fw: Save multiple plots as pdf or jpeg

2014-04-16 Thread Pavneet Arora
Hello Uwe

Can you explain what you mean by "try to plot the sensity only with few 
hundreds of segemnts"
Do you mean that I should take some kind of sample and do it? And if so 
what's the best number for the sample and how do i ensure that its not 
biased?






From:   Uwe Ligges 
To: Pavneet Arora/UK/RoyalSun@RoyalSun, r-help@r-project.org, 
pavnee...@yahoo.co.uk
Date:   15/04/2014 14:08
Subject:    Re: [R] Fw: Save multiple plots as pdf or jpeg



You have > 1e6 observations and your lines() have these many segments, 
try to plot the sensity only with few hndreds of segemnts.

Best,
Uwe Ligges


On 15.04.2014 12:27, Pavneet Arora wrote:
> Hello All,
>
> I have multiple plots that I want to save it a single file. At the 
moment,
> I am saving as pdf. Each plot has a qqnorm, qqline, tiny histogram in 
the
> top left graph with its density drawn top of it and the normal
> superimposed on the histogram.
>
> As a result, the pdf takes forever to load and doesn?t let me print, as 
it
> runs out of memory. I was wondering if there is a way if I can save each
> plot as jpeg and then export it on pdf. Will that make it quicker in
> loading? If so, how can I do this? And if not, then what are the
> alternatives.
>
> The code that I have at the moment is as follows:
>
> 
~
> pdf(file="C:/qqnorm/qqnorms.pdf") ##- Saves all plots in the same pdf 
file
>
>
> for (k in 1:ncol(nums2)){
>  par(mfrow=c(1,1))
>
> ##- QQNorm
>  qqnorm(nums2[,k],col="lightblue",main=names(nums2)[k])
>  qqline(nums2[,k],col="red",lwd=2)
>
> ##- Tiny Histogram
> op = par(fig=c(.02,.5,0.4,0.98), new=TRUE)
>  hist(nums2[,k],freq=F,col="blue",xlab="", ylab="", main="",
>   axes=F,density=20)
>
> ##- Density of the variable
>  lines(density(nums2[,k],na.rm=T), col="darkred", lwd=2)
>
> ##- Super-imposed Normal Density
> curve(dnorm(x,mean=mean(nums2[,k],na.rm=T),sd=sd(nums2[,k],na.rm=T)),
>col="black",lwd=3,add=T) ##- Footnote: title1 <- "nums2[k]"
>
> library(moments)
>  s_kurt <- kurtosis (nums2[,k])
>  s_skew <- skewness (nums2[,k])
>  mtxt <- paste ("Variable=",title1, ":" ,
> "Kurt=",round(s_kurt,digits=4), "Skew",
> round(s_skw,digits=4), sep=" ")
>
> mtext (mtxt,col="green4",side=1,line=15.6,adj=0.0,cex=0.8,font=2,las=1)
>
> }
> dev.off()
> 
~
>
> Structure of My data:
>
> str(nums2)
> 'data.frame':1355615 obs. of  39 variables:
>   $ month   : int  1 1 1 1 1 1 1 1 1 1 ...
>   $ Location_Easting_OSGR   : int  525680 524170 524520 526900
> 528060 524770 524220 525890 527350 524550 ...
>   $ Location_Northing_OSGR  : int  178240 181650 182240 177530
> 179040 181160 180830 179710 177650 180810 ...
>   $ Longitude   : num  -0.191 -0.212 -0.206 -0.174
> -0.157 ...
>   $ Latitude: num  51.5 51.5 51.5 51.5 51.5 ...
>   $ Police_Force: int  1 1 1 1 1 1 1 1 1 1 ...
>   $ Number_of_Vehicles  : int  1 1 2 1 1 2 2 1 2 2 ...
>   $ Number_of_Casualties: int  1 1 1 1 1 1 1 2 2 5 ...
>   $ Day_of_Week : int  3 4 5 6 2 3 5 6 7 7 ...
>   $ Local_Authority__District_  : int  12 12 12 12 12 12 12 12 12 12
> ...
>   $ X_1_st_Road_Class   : int  3 4 5 3 6 6 5 3 3 4 ...
>   $ X_1_st_Road_Number  : int  3218 450 0 3220 0 0 0 315 
3212
> 450 ...
>   $ Road_Type   : int  6 3 6 6 6 6 6 3 6 6 ...
>   $ Speed_limit : int  30 30 30 30 30 30 30 30 30 30
> ...
>   $ Junction_Detail : int  0 6 0 0 0 0 3 0 6 3 ...
>   $ Junction_Control: int  -1 2 -1 -1 -1 -1 4 -1 2 4 ...
>   $ X_2_nd_Road_Class   : int  -1 5 -1 -1 -1 -1 6 -1 4 5 ...
>   $ X_2_nd_Road_Number  : int  0 0 0 0 0 0 0 0 304 0 ...
>   $ Pedestrian_Crossing_Human_Contro: int  0 0 0 0 0 0 0 0 0 0 ...
>   $ Pedestrian_Crossing_Physical_Fac: int  1 5 0 0 0 0 0 0 5 8 ...
>   $ Light_Conditions: int  1 4 4 1 7 1 4 1 4 1 ...
>   $ Weather_Conditions  : int  2 1 1 1 1 2 1 1 1 1 ...
>   $ Road_Surface_Conditions : int  2 1 1 1 2 2 1 1 1 1 ...
>   $ Special_Conditions_at_Site  : int  0 0 0 0 0 6 0 0 0 0 ...
>   $ Carriageway_Hazards : int  0 0 0 0 0 0 0 0 

Re: [R] Fw: Save multiple plots as pdf or jpeg

2014-04-15 Thread Uwe Ligges
You have > 1e6 observations and your lines() have these many segments, 
try to plot the sensity only with few hndreds of segemnts.


Best,
Uwe Ligges


On 15.04.2014 12:27, Pavneet Arora wrote:

Hello All,

I have multiple plots that I want to save it a single file. At the moment,
I am saving as pdf. Each plot has a qqnorm, qqline, tiny histogram in the
top left graph with its density drawn top of it and the normal
superimposed on the histogram.

As a result, the pdf takes forever to load and doesn?t let me print, as it
runs out of memory. I was wondering if there is a way if I can save each
plot as jpeg and then export it on pdf. Will that make it quicker in
loading? If so, how can I do this? And if not, then what are the
alternatives.

The code that I have at the moment is as follows:

~
pdf(file="C:/qqnorm/qqnorms.pdf") ##- Saves all plots in the same pdf file


for (k in 1:ncol(nums2)){
 par(mfrow=c(1,1))

##- QQNorm
 qqnorm(nums2[,k],col="lightblue",main=names(nums2)[k])
 qqline(nums2[,k],col="red",lwd=2)

##- Tiny Histogram
op = par(fig=c(.02,.5,0.4,0.98), new=TRUE)
 hist(nums2[,k],freq=F,col="blue",xlab="", ylab="", main="",
  axes=F,density=20)

##- Density of the variable
 lines(density(nums2[,k],na.rm=T), col="darkred", lwd=2)

##- Super-imposed Normal Density
 curve(dnorm(x,mean=mean(nums2[,k],na.rm=T),sd=sd(nums2[,k],na.rm=T)),
   col="black",lwd=3,add=T) ##- Footnote: title1 <- "nums2[k]"

library(moments)
 s_kurt <- kurtosis (nums2[,k])
 s_skew <- skewness (nums2[,k])
 mtxt <- paste ("Variable=",title1, ":" ,
"Kurt=",round(s_kurt,digits=4), "Skew",
round(s_skw,digits=4), sep=" ")

mtext (mtxt,col="green4",side=1,line=15.6,adj=0.0,cex=0.8,font=2,las=1)

}
dev.off()
~

Structure of My data:

str(nums2)
'data.frame':1355615 obs. of  39 variables:
  $ month   : int  1 1 1 1 1 1 1 1 1 1 ...
  $ Location_Easting_OSGR   : int  525680 524170 524520 526900
528060 524770 524220 525890 527350 524550 ...
  $ Location_Northing_OSGR  : int  178240 181650 182240 177530
179040 181160 180830 179710 177650 180810 ...
  $ Longitude   : num  -0.191 -0.212 -0.206 -0.174
-0.157 ...
  $ Latitude: num  51.5 51.5 51.5 51.5 51.5 ...
  $ Police_Force: int  1 1 1 1 1 1 1 1 1 1 ...
  $ Number_of_Vehicles  : int  1 1 2 1 1 2 2 1 2 2 ...
  $ Number_of_Casualties: int  1 1 1 1 1 1 1 2 2 5 ...
  $ Day_of_Week : int  3 4 5 6 2 3 5 6 7 7 ...
  $ Local_Authority__District_  : int  12 12 12 12 12 12 12 12 12 12
...
  $ X_1_st_Road_Class   : int  3 4 5 3 6 6 5 3 3 4 ...
  $ X_1_st_Road_Number  : int  3218 450 0 3220 0 0 0 315 3212
450 ...
  $ Road_Type   : int  6 3 6 6 6 6 6 3 6 6 ...
  $ Speed_limit : int  30 30 30 30 30 30 30 30 30 30
...
  $ Junction_Detail : int  0 6 0 0 0 0 3 0 6 3 ...
  $ Junction_Control: int  -1 2 -1 -1 -1 -1 4 -1 2 4 ...
  $ X_2_nd_Road_Class   : int  -1 5 -1 -1 -1 -1 6 -1 4 5 ...
  $ X_2_nd_Road_Number  : int  0 0 0 0 0 0 0 0 304 0 ...
  $ Pedestrian_Crossing_Human_Contro: int  0 0 0 0 0 0 0 0 0 0 ...
  $ Pedestrian_Crossing_Physical_Fac: int  1 5 0 0 0 0 0 0 5 8 ...
  $ Light_Conditions: int  1 4 4 1 7 1 4 1 4 1 ...
  $ Weather_Conditions  : int  2 1 1 1 1 2 1 1 1 1 ...
  $ Road_Surface_Conditions : int  2 1 1 1 2 2 1 1 1 1 ...
  $ Special_Conditions_at_Site  : int  0 0 0 0 0 6 0 0 0 0 ...
  $ Carriageway_Hazards : int  0 0 0 0 0 0 0 0 0 0 ...
  $ Urban_or_Rural_Area : int  1 1 1 1 1 1 1 1 1 1 ...
  $ Did_Police_Officer_Attend_Scene_: int  1 1 1 1 1 1 1 1 1 1 ...
  $ year: int  2005 2005 2005 2005 2005 2005
2005 2005 2005 2005 ...
  $ m   : int  1 1 1 1 1 1 1 1 1 1 ...
  $ Qrtr: int  1 1 1 1 1 1 1 1 1 1 ...
  $ h2  : int  17 17 0 10 21 12 20 17 22 16 ...
  $ NumberVehGrp: int  1 1 2 1 1 2 2 1 2 2 ...
  $ NumberCasultGrp : int  1 1 1 1 1 1 1 2 2 5 ...
  $ lati_round  : num  51.5 51.5 51.5 51.5 51.5 ...
  $ longi_round : num  -0.19 -0.21 -0.21 -0.17 -0.16
-0.2 -0.21 -0.19 -0.17 -0.21 ...
  $ lati_2dp: num  51.5 51.5 51.5 51.5 51.5 ...
  $ lati_1dp: num  51.5 51.5 51.5 51.5 51.5 51.5
51.5 51.5 51.5 51.5 ...
  $ longi_2dp   : num  -0.19 -0.21 -0.21 -0.17 -0.16
-0.2 -0.21 -0.19 -0.17 -0.21 ...
  $ longi_1dp   : num  -0.2 -0.2 -0.2 -0.2 -0.2

Re: [R] FW: Reading output of a GLMM run in R

2014-04-13 Thread Ben Bolker
John Kane  inbox.com> writes:

> 
> Can you resend the information in plain text?  
> It looks like you sent it in html format and it is very close to
> completely unreadable.
> 
> John Kane
> Kingston ON Canada

  You've also posted this question at CrossValidated:

http://stats.stackexchange.com/questions/93601/
  reading-the-output-from-a-glmm-run-in-r

(broken URL to make Gmane happy).  Cross-posting between
StackOverflow forums and r mailing lists is not explicitly
prohibited by the mailing list guidelines (since those guidelines
predate StackOverflow), but it has a good chance of wasting
answerers' time (because you get parallel answers in both venues).
At least you should state in each place that you've cross-posted,
with a link.

  As I commented on CrossValidated, you haven't given enough
context (what R package or functions are you using??) to answer
the question.

  You should consider reading http://glmm.wikidot.com/faq

  If you prefer the R mailing lists to CV you should
probably post to r-sig-mixed-mod...@r-project.org rather than
here.


> 
> > -Original Message-
> > From: ruthy_  hotmail.co.uk
> > Sent: Sun, 13 Apr 2014 00:28:43 +
> > To: r-help  r-project.org
> > Subject: [R] FW: Reading output of a GLMM run in R
> > 
> > 
> > 
> > 
> > 
> > 
> > Hi, I am a complete novice and dummy when it comes to statistics so I
> > apologise in advance... I have been asked to report the results of my
> > GLMMs (I ran two) in a table. This table must state: effect, standard
> > error, test statistic, and P value, for all fixed effects. Unfortunately
> > I am struggling to read my output. The out put is as follows, if anyone
> > would be kind enough to help I would be very grateful and will know for
> > future reference which bit equates to what (also I have been told my
> > degrees of freedom are different for both the tests, could someone
> > explain why this is?). GLMM 1-run for predictors of step length. Response
> > variable = step length. fixed effects = depth and direction threshold.
> > random factor = individual Models: m2: step ~ (1 | ind) m1: step ~ Depth
> > * threshold + (1 | ind) Df AIC BIC logLik deviance Chisq Chi Df
> > Pr(>Chisq) m2 3 373235 373259 -186615 373229 m1 8 373225 373290 -186605
> > 373209 19.767 5 0.001382 ** --- Signif. codes: 0 ?***? 0.001 ?**? 0.01
> > ?*? 0.05 ?.? 0.1 ? ? 1 GLMM 2 -run to investigate potential predictors of
> > PDBA. response variables = depth and step length. fixed effect =
> > direction threshold. random factor = Individual Models: m3: PDBA ~ Depth
> > + (1 | ind) + thresholdepth m2: PDBA ~ step * threshold + Depth *
> > threshold + (1 | ind) Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
> > m3 6 -48205 -48157 24109 -48217 m2 11 -48430 -48341 24226 -48452 235.1 5
> > < 2.2e-16 *** --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1
> > ? ? 1 Models: m4: PDBA ~ step + (1 | ind) + step:threshold m2: PDBA ~
> > step * threshold + Depth * threshold + (1 | ind) Df AIC BIC logLik
> > deviance Chisq Chi Df Pr(>Chisq) m4 6 -48206 -48158 24109 -48218 m2 11
> > -48430 -48341 24226 -48452 233.81 5 < 2.2e-16 *** --- Signif. codes: 0
> > ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
> > [[alternative HTML version deleted]]
> > 
> > __
> > R-help  r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> 
> 
> 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] FW: Reading output of a GLMM run in R

2014-04-13 Thread John Kane
Can you resend the information in plain text?  It looks like you sent it in 
html format and it is very close to completely unreadable.

John Kane
Kingston ON Canada


> -Original Message-
> From: rut...@hotmail.co.uk
> Sent: Sun, 13 Apr 2014 00:28:43 +
> To: r-help@r-project.org
> Subject: [R] FW: Reading output of a GLMM run in R
> 
> 
> 
> 
> 
> 
> Hi, I am a complete novice and dummy when it comes to statistics so I
> apologise in advance... I have been asked to report the results of my
> GLMMs (I ran two) in a table. This table must state: effect, standard
> error, test statistic, and P value, for all fixed effects. Unfortunately
> I am struggling to read my output. The out put is as follows, if anyone
> would be kind enough to help I would be very grateful and will know for
> future reference which bit equates to what (also I have been told my
> degrees of freedom are different for both the tests, could someone
> explain why this is?). GLMM 1-run for predictors of step length. Response
> variable = step length. fixed effects = depth and direction threshold.
> random factor = individual Models: m2: step ~ (1 | ind) m1: step ~ Depth
> * threshold + (1 | ind) Df AIC BIC logLik deviance Chisq Chi Df
> Pr(>Chisq) m2 3 373235 373259 -186615 373229 m1 8 373225 373290 -186605
> 373209 19.767 5 0.001382 ** --- Signif. codes: 0 ?***? 0.001 ?**? 0.01
> ?*? 0.05 ?.? 0.1 ? ? 1 GLMM 2 -run to investigate potential predictors of
> PDBA. response variables = depth and step length. fixed effect =
> direction threshold. random factor = Individual Models: m3: PDBA ~ Depth
> + (1 | ind) + thresholdepth m2: PDBA ~ step * threshold + Depth *
> threshold + (1 | ind) Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq)
> m3 6 -48205 -48157 24109 -48217 m2 11 -48430 -48341 24226 -48452 235.1 5
> < 2.2e-16 *** --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1
> ? ? 1 Models: m4: PDBA ~ step + (1 | ind) + step:threshold m2: PDBA ~
> step * threshold + Depth * threshold + (1 | ind) Df AIC BIC logLik
> deviance Chisq Chi Df Pr(>Chisq) m4 6 -48206 -48158 24109 -48218 m2 11
> -48430 -48341 24226 -48452 233.81 5 < 2.2e-16 *** --- Signif. codes: 0
> ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


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] Fw: select .txt from .txt in a directory

2013-11-08 Thread Sarah Goslee
Hi,

I'm not particularly interested in opening unsolicited binary attachments.

Why don't you use dput() to provide part of your data to the R-help
list (copied on this email; emailing just me not being that useful).

You still haven't told us what you want to do with the named text
files - read them into R?

In general, you would read the file with the list of names into R,
then use a loop or a *apply construct to import each of those named
files. Based on what you've said, the fact that your desired list has
only 100 of the 300 total files is a red herring.

Sarah


On Fri, Nov 8, 2013 at 1:30 PM, Zilefac Elvis  wrote:
> Hi Sarah
> Attached are my data files.
> Btemperature_Stations is my main file.
> Temperature inventory is my 'wanted' file and is a subset of
> Btemperature_Stations.
> Using column 3 in both files, select the files in Temperature inventory from
> Btemperature_Stations.
> The .zip file contains the .txt files which you will extract to a folder and
> do the selection in R.
>
> Thanks,
> Atem.
>
-- 
Sarah Goslee
http://www.functionaldiversity.org

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


Re: [R] FW: Nadaraya-Watson kernel

2013-11-07 Thread Liaw, Andy
Use KernSmooth (one of the recommended packages that are included in R 
distribution).  E.g.,

> library(KernSmooth)
KernSmooth 2.23 loaded
Copyright M. P. Wand 1997-2009
> x <- seq(0, 1, length=201)
> y <- 4 * cos(2*pi*x) + rnorm(x)
> f <- locpoly(x, y, degree=0, kernel="epan", bandwidth=.1)
> plot(x, y)
> lines(f, lwd=2)

Andy

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Ms khulood aljehani
Sent: Tuesday, November 05, 2013 9:49 AM
To: r-h...@stat.math.ethz.ch
Subject: [R] FW: Nadaraya-Watson kernel

From: aljehan...@hotmail.com
To: r-help@r-project.org
Subject: Nadaraya-Watson kernel
Date: Tue, 5 Nov 2013 17:42:13 +0300




Hello
 
i want to compute the Nadaraya-Watson kernel estimation when the kernel 
function is Epanchincov kernel
i use the command
ksmooth(x, y, kernel="normal", bandwidth ,)
 
the argmunt ( kernel="normal" ) accept normal and box kernels
i want to compute it if the kerenl = Epanchincov
 
 
thank you
 
  
[[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.
Notice:  This e-mail message, together with any attachme...{{dropped:11}}

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


Re: [R] FW: Transposing the output of 'table'

2013-10-07 Thread peter dalgaard

On Oct 6, 2013, at 20:25 , Andrea Lamont wrote:

> If t(table(OBJECT)) does not work, does:
> u<-as.matrix(table(OBJ))
> t(u)
> 
> -i.e. use matrix operations?


Please try before posting...

table() results in a 1d table, i.e. a vector; t() of a vector is a row matrix, 
so it still displays horisontally. To get a column matrix, it works to 
transpose twice, but as.matrix works too, as others have already pointed out. I 
think my favorite is to use cbind(), which conveniently also allows you to set 
a heading:

> cbind(Freq=table(airquality$Month))
  Freq
5   31
6   30
7   31
8   31
9   30

- Peter D.

> 
> 
> 
> 
> On Sun, Oct 6, 2013 at 1:47 PM, LAMONT, ANDREA wrote:
> 
>> 
>> 
>> 
>> 
>> From: r-help-bounces@r-project.orgOn Behalf OfBerend Hasselman
>> Sent: Sunday, October 06, 2013 1:44:30 PM (UTC-05:00) Eastern Time (US &
>> Canada)
>> To: Dennis Fisher
>> Cc: r-h...@stat.math.ethz.ch
>> Subject: Re: [R] Transposing the output of 'table'
>> 
>> On 06-10-2013, at 19:30, Dennis Fisher  wrote:
>> 
>>> R 3.0.1
>>> OS X
>>> 
>>> Colleagues,
>>> 
>>> If I execute the command:
>>>  table(OBJECT)
>>> the output might look like:
>>> 1   2
>>> 25 336
>>> 
>>> I would like it to appear as:
>>>  1   25
>>>  2   336
>>> 
>>> I can accomplish this with:
>>>  TABLE   <- table(OBJECT)
>>>  data.frame(names(TABLE), as.numeric(TABLE))
>>> 
>>> However, I bet that a more clever approach exists?  Any takers?
>> 
>> 
>> Have you tried t(table(OBJECT)) ?
>> 
>> Berend
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>> 
> 
> 
> 
> -- 
> Andrea Lamont, MA
> Clinical-Community Psychology
> University of South Carolina
> Barnwell College
> Columbia, SC 29208
> 
> Please consider the environment before printing this email.
> 
> CONFIDENTIAL: This transmission is intended for the use of the
> individual(s) or entity to which it is addressed, and may contain
> information that is privileged, confidential, and exempt from disclosure
> under applicable law. Should the reader of this message not be the intended
> recipient(s), you are hereby notified that any dissemination, distribution,
> or copying of this communication is strictly prohibited.  If you are not
> the intended recipient, please contact the sender by reply email and
> destroy/delete all copies of the original message.
> 
>   [[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.

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

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


Re: [R] FW: Transposing the output of 'table'

2013-10-06 Thread Andrea Lamont
If t(table(OBJECT)) does not work, does:
u<-as.matrix(table(OBJ))
t(u)

-i.e. use matrix operations?




On Sun, Oct 6, 2013 at 1:47 PM, LAMONT, ANDREA wrote:

>
>
>
> 
> From: r-help-bounces@r-project.orgOn Behalf OfBerend Hasselman
> Sent: Sunday, October 06, 2013 1:44:30 PM (UTC-05:00) Eastern Time (US &
> Canada)
> To: Dennis Fisher
> Cc: r-h...@stat.math.ethz.ch
> Subject: Re: [R] Transposing the output of 'table'
>
> On 06-10-2013, at 19:30, Dennis Fisher  wrote:
>
> > R 3.0.1
> > OS X
> >
> > Colleagues,
> >
> > If I execute the command:
> >   table(OBJECT)
> > the output might look like:
> >  1   2
> > 25 336
> >
> > I would like it to appear as:
> >   1   25
> >   2   336
> >
> > I can accomplish this with:
> >   TABLE   <- table(OBJECT)
> >   data.frame(names(TABLE), as.numeric(TABLE))
> >
> > However, I bet that a more clever approach exists?  Any takers?
>
>
> Have you tried t(table(OBJECT)) ?
>
> Berend
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Andrea Lamont, MA
Clinical-Community Psychology
University of South Carolina
Barnwell College
Columbia, SC 29208

Please consider the environment before printing this email.

CONFIDENTIAL: This transmission is intended for the use of the
individual(s) or entity to which it is addressed, and may contain
information that is privileged, confidential, and exempt from disclosure
under applicable law. Should the reader of this message not be the intended
recipient(s), you are hereby notified that any dissemination, distribution,
or copying of this communication is strictly prohibited.  If you are not
the intended recipient, please contact the sender by reply email and
destroy/delete all copies of the original message.

[[alternative HTML version deleted]]

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


Re: [R] FW: Library update from version

2013-09-30 Thread Steve Lianoglou
Hi,

On Mon, Sep 30, 2013 at 12:44 PM, Ista Zahn  wrote:
> On Mon, Sep 30, 2013 at 2:49 PM, Steve Lianoglou
>  wrote:
>> Hi,
>>
>> On Mon, Sep 30, 2013 at 11:12 AM, Cem Girit  wrote:
>>> Hello,
>>>
>>>
>>>
>>> I recently installed version 3.0.1 of R on to a computer. I
>>> have a working installation for a Statconn application using R version
>>> 2.15.0 on another computer. I have many libraries under this old
>>> installation. Can I just copy them into the new library from the old, or do
>>> I install each one of them under the new R?
>>
>> No, you shouldn't do that.
>
> Really? Why not?

Because it has been my experience that people *just* do that (ie. the
*just* copy the libraries, as the OP asked).

But as you correctly point out:

> Note that the Windows upgrade FAQ
> (http://cran.r-project.org/bin/windows/base/rw-FAQ.html#What_0027s-the-best-way-to-upgrade_003f)
> says to do exactly that.

There is a way to copy the old package and then ensure that they are
updated to the versions that build correctly on the newest version of
R.


-steve

-- 
Steve Lianoglou
Computational Biologist
Bioinformatics and Computational Biology
Genentech

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


Re: [R] FW: Library update from version

2013-09-30 Thread Ista Zahn
On Mon, Sep 30, 2013 at 2:49 PM, Steve Lianoglou
 wrote:
> Hi,
>
> On Mon, Sep 30, 2013 at 11:12 AM, Cem Girit  wrote:
>> Hello,
>>
>>
>>
>> I recently installed version 3.0.1 of R on to a computer. I
>> have a working installation for a Statconn application using R version
>> 2.15.0 on another computer. I have many libraries under this old
>> installation. Can I just copy them into the new library from the old, or do
>> I install each one of them under the new R?
>
> No, you shouldn't do that.

Really? Why not? Note that the Windows upgrade FAQ
(http://cran.r-project.org/bin/windows/base/rw-FAQ.html#What_0027s-the-best-way-to-upgrade_003f)
says to do exactly that.

Best,
Ista
>
>> Also how can I get a list of
>> differences in two libraries so that I can use this list to update the new
>> one?
>
> A bit of googling could have provided several answers.
>
> This post in particular has a few answers from some people who know
> what they're doing w/ R, so probably a good place to start:
>
> http://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r-on-windows
>
> HTH,
> -steve
>
> --
> Steve Lianoglou
> Computational Biologist
> Bioinformatics and Computational Biology
> Genentech
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] FW: Library update from version

2013-09-30 Thread Dennis Murphy
In this case the OP probably does need to reinstall contributed
packages since going from 2.15.x to 3.0.y entails a major version
change in R.

Dennis

On Mon, Sep 30, 2013 at 11:49 AM, Steve Lianoglou
 wrote:
> Hi,
>
> On Mon, Sep 30, 2013 at 11:12 AM, Cem Girit  wrote:
>> Hello,
>>
>>
>>
>> I recently installed version 3.0.1 of R on to a computer. I
>> have a working installation for a Statconn application using R version
>> 2.15.0 on another computer. I have many libraries under this old
>> installation. Can I just copy them into the new library from the old, or do
>> I install each one of them under the new R?
>
> No, you shouldn't do that.
>
>> Also how can I get a list of
>> differences in two libraries so that I can use this list to update the new
>> one?
>
> A bit of googling could have provided several answers.
>
> This post in particular has a few answers from some people who know
> what they're doing w/ R, so probably a good place to start:
>
> http://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r-on-windows
>
> HTH,
> -steve
>
> --
> Steve Lianoglou
> Computational Biologist
> Bioinformatics and Computational Biology
> Genentech
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] FW: Library update from version

2013-09-30 Thread Steve Lianoglou
Hi,

On Mon, Sep 30, 2013 at 11:12 AM, Cem Girit  wrote:
> Hello,
>
>
>
> I recently installed version 3.0.1 of R on to a computer. I
> have a working installation for a Statconn application using R version
> 2.15.0 on another computer. I have many libraries under this old
> installation. Can I just copy them into the new library from the old, or do
> I install each one of them under the new R?

No, you shouldn't do that.

> Also how can I get a list of
> differences in two libraries so that I can use this list to update the new
> one?

A bit of googling could have provided several answers.

This post in particular has a few answers from some people who know
what they're doing w/ R, so probably a good place to start:

http://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r-on-windows

HTH,
-steve

-- 
Steve Lianoglou
Computational Biologist
Bioinformatics and Computational Biology
Genentech

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


Re: [R] FW: Nested and/or crossed and 2 level random factor

2013-07-11 Thread Bert Gunter
This is not the best place for this post.

Post instead to r-sig-mixed-models or r-sig-ecology .

Cheers,
Bert

On Thu, Jul 11, 2013 at 8:48 AM, Linda Bürgi  wrote:
>
>
>
>
> Dear All,
>
> I have two quick questions about my study design. For 4 years, once every 
> season, we destructively sampled larvae on bushes (the same bushes every 
> time) and measured parasitism on these larvae. We had 10 bushes per location 
> and two locations.
> We are interested in whether parasitism changed over the years and varied 
> with season. With repeated measures on bushes, and bushes nested in location, 
> my model looks like this:
>
> model<-glmmPQL(parasitism ~ year:season + year + season, 
> random=~1|location/bush, family=binomial)
>
> Question 1: A reviewer of our paper suggested that seasons are nested
> within years and that we should include this in the model. However, I
> think seasons are crossed with years, not nested. If that's the case,
> can I leave the model as is (as far as season and years are concerned)?
>
> Question 2: I know it is ridiculous to have location as a random factor since 
> it only has two levels. I've read a lot in the archives and people usually 
> suggest to leave that factor out altogether. But leaving it out is not an 
> option because levels of parasitism
> vary significantly with location (but that is of no interest to us,
> hence not really a fixed factor). Could I just include it as a covariate?  
> glmmPQL(parasitism ~ year:season + year + season + location, random=~1|bush, 
> family=binomial)?
>
> Thank you already for any answers and suggestions!
>
> PS. I used glmmPQL instead of lmer because without the over-/underdispersion 
> function in lmer everything was highly significant, whereas with glmmPQL it 
> is not.
>
>
>
> [[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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

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


Re: [R] Fw: Remove from mailing list

2013-06-26 Thread David Winsemius

On Jun 26, 2013, at 7:37 PM, dinesh wadhwani wrote:

> This has bounced back twice already - would help if anybody cna remove me 
> from the list and close my account. I have been deleting 100s of emails daily 
> from my yahoo inbox becaue i cannot get them to stop, even after i canceld  
> my account.
> 
> my currnet status is that i have an account, but have not subscribed via 
> email. please help.
> 

I replied privately to Mr Wadhwani just now. 

-- 
David.

> 
> - Forwarded Message -
> From: dinesh wadhwani 
> To: "r-help-ow...@r-project.org"  
> Sent: Wednesday, June 26, 2013 10:19 PM
> Subject: Fw: Remove from mailing list
> 
> 
> 
> Please help - I have tried several time and ways to stop these emails but 
> keep getting them.
> 
> 
> - Forwarded Message -
> From: Chuck Cleland 
> To: Dinesh Wadhwani  
> Sent: Wednesday, June 26, 2013 6:22 PM
> Subject: Re: Remove from mailing list
> 
> 
> 
> Hi Dinesh,
> 
>   I am not able to check the subscription list myself to see what might be 
> happening.  I suggest sending another message to r-help-ow...@r-project.org 
> in which you describe in detail the steps you took to unsubscribe or 
> otherwise turn off R-help mail.  Others who receive email at that address may 
> be able to track down the problem.
> 
> Chuck
> 
> 
> On 6/26/2013 12:30 PM, Dinesh Wadhwani wrote:
> 
> Yes, I tried that when I was active. I am no longer active, so my email 
> address is not recognized. I even tried opening a new junk gmail address and 
> updated my email address to that, but I am still getting emails in my yahoo 
> in box.
>> From: Chuck Cleland
>> Sent: 6/26/2013 11:59 AM
>> To: Dinesh Wadhwani
>> Cc: r-help-ow...@r-project.org
>> Subject: Re: Remove from mailing list
>> 
>> Hello Dinesh,
>> 
>>   Did you go to http://www.r-project.org/mail.html and then enter your 
>> subscription email address near the bottom where it says:
>> 
>> "To unsubscribe from R-help, get a password reminder, or change your 
>> subscription options enter your subscription email address:" 
>> 
>>   Once you log in there, you should be able to
> unsubscribed, stop delivery, or turn on digest mode, among other 
> configuration options.
>> 
>>   Was this among the ways that you tried?
>> 
>>   I hope this helps.
>> 
>> Chuck Cleland
>> 
>> 
>> On 6/26/2013 11:41 AM, Dinesh Wadhwani wrote:
>> 
>> Hi,
>>> 
>>> I have tried several different times and ways to stop getting emails when 
>>> anyone posts to the r-help list and have been unable to get it to work. Can 
>>> you please help?
>>> 
>>> My yahoo inbox keeps getting flooded with these posts and every reply and I 
>>> am getting these even after closing my account. 
>>> 
>>> Thanks,
>>> Dinesh
>>> 
>> 
>> -- 
> Chuck Cleland, Ph.D.
> Senior Research Scientist
> NYU College of Nursing 
> 726 Broadway, 10th floor
> New York, NY 10003
> tel: (212) 992-9417 (Tu, W, Th)
> tel: (732) 512-0171 (M, F) 
> 
> -- 
> Chuck Cleland, Ph.D.
> Senior Research Scientist
> NYU College of Nursing 
> 726 Broadway, 10th floor
> New York, NY 10003
> tel: (212) 992-9417 (Tu, W, Th)
> tel: (732) 512-0171 (M, F) 
>   [[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.

David Winsemius
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] FW: Kernel smoothing with bandwidth which varies with x

2013-05-23 Thread Uwe Ligges



On 23.05.2013 18:10, IOANNA wrote:

Hello all,

I would like to use the Nadaraya-Watson estimator assuming a Gaussian
kernel: So far I sued the
library(sm)
library(sm)
x<-runif(5000)
y<-rnorm(5000)
plot(x,y,col='black')
h1<-h.select(x,y,method='aicc')
lines(ksmooth(x,y,bandwidth=h1))

which works fine. What if my data were clustered requiring a bandwidth that
varies with x? How can I do that?


I'd start with trying to transform x so that the bandwidth can be fixed.

Uwe Ligges








Thanks in advance,
Ioanna

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

2013-05-15 Thread Bert Gunter
Outrageous!

http://www.r-project.org/





On Tue, May 14, 2013 at 11:53 PM, Ravishankar Kandallu <
ravishankar.kanda...@tcs.com> wrote:

> Dear Sir,
>
> Greetings.  I am Ravishankar from Platform Solutions function of Tata
> Consultancy Services, Mumbai India.  I am associated with team within
> Platform Solutions group that specializes in statistical modeling
> solutions to various clients.  We are exploring various statistical
> computing software tools for building statistical models and meet our
> client requirements.  In the process, we identified your R-programming
> environment as one of the possible means to serve the purpose.
> We submit our request for more details to you regarding the usage of R for
> commercial purposes. In this regard, we also solicit a discussion with you
> for our further perusal.  We earnestly look forward to your reply.
>
> Thanks & Regards,
>
> Ravishankar Kandallu
> Platform Solutions Analytics-Support
> Tata Consultancy Services Limited
> Gateway Park, Road No.13
> MIDC, Andheri (E)
> Mumbai - 400093,Maharashtra
> India
> Ph:- 912267795049
> Buzz:- 4295049
> Cell:- 9920935970
> Mailto: ravishankar.kanda...@tcs.com
> Website: http://www.tcs.com
> 
> Experience certainty.   IT Services
> Business Solutions
> Consulting
> 
> =-=-=
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>
> [[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.
>



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm

[[alternative HTML version deleted]]

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


Re: [R] Fw: Re: Help

2013-04-27 Thread Jeff Newmiller

On Sat, 27 Apr 2013, Zilefac Elvis wrote:


Hi Jeff,

Attached are sample files from the 110 files. When you delete those letters,
some values will stay put in that same cell.
Atem.


It looks like these are fixed format files. You should be using
read.fwf and write.fwf instead of read.table and write.table. Read
the help for those functions (e.g. ?read.fwf)

It is still not clear to me what you want the final result to look like, 
but you should have better luck reading the data with a fixed format

function.  You may well find that you no longer need to destroy the
contents of the files if you read the data you want correctly. I recommend
that you look closely at the source of your data for a detailed 
description of the data format to aid you in reading the data correctly.



- Forwarded Message -
From: Zilefac Elvis 
To: arun 
Sent: Saturday, April 27, 2013 9:14 PM
Subject: Re: Re: [R] Help


 Hi A.K,

Attached are example files. I have 110 of such and would like to perform the
analysis as described before. I would find T, F, Y, A, C, etc and delete
them. The letters are affixed to values in the data just to communicate an
idea. As before, find all -.99M and replace with NA.

Thanks so much.
Atem.




From: arun 
To: "zilefacel...@yahoo.com" 
Cc: R help 
Sent: Saturday, April 27, 2013 7:53 PM
Subject: Re: Re: [R] Help





Hi,
If you wanted to delete "T", "C","A", "F" and "Y" and replace "-999.99M"
with NA, it is possible, but the result would be stored in a list if
the number of elements deleted from each of the columns are different.   As
you didn't provide any reproducible example, I don't know whether equal
number of elements are replaced from each columns or not..

set.seed(28)
myfiles<- 
lapply(1:5,function(i)as.data.frame(matrix(sample(c(LETTERS,"-999.99M"),40*i,replace=TRUE),ncol=(
40*i)/8),stringsAsFactors=FALSE))
res<-lapply(myfiles,function(x){x[x=="-999.99M"]<-NA;lapply(x,function(y)
y[!y%in%c("T","C","A","F","Y")])})
res[[1]]
#$V1
#[1] "M" "X" "U" "X"
#
#$V2
#[1] "P" "Z" "S" "R" "Q" "W" "N" "I"
#
#$V3
#[1] "K" "S" NA  "M" "G" "G" "Z"
#
#$V4
#[1] "O" "M" "G" "G" "B" "X" "M"
#
#$V5
#[1] "I" "X" "P" "K" "R" "K"

A.K.

From: "zilefacel...@yahoo.com" 
To: arun 
Cc: R help 
Sent: Saturday, April 27, 2013 9:41 PM
Subject: Re: Re: [R] Help







Hi A.K,


Thanks for  this great help. I wish to find -999.99M and replace with NA.
All others like T, A, F etc should be deleted from the files.





Thanks for much.

-- Original Message --



From : arun
>To : Zilefac Elvis;
>Cc : R help;
>Sent : 27-04-2013 16:29
>Subject : Re: [R] Help
> 
>HI, "Find 'T','C','A','F' and 'Y', delete them from all the 110 files"
I assume that you meant to replace it with NA. set.seed(28)
myfiles<- 
lapply(1:5,function(i)as.data.frame(matrix(sample(c(LETTERS,"-999.99M"),40*i,replace=TRUE),ncol=(
40*i)/8),stringsAsFactors=FALSE)) myfiles[[1]]
#  V1 V2   V3 V4 V5
#1  A  P    K  O  Y
#2  C  Z    S  M  Y
#3  M  S -999.99M  G  I
#4  X  R    M  G  X
#5  C  Q    G  A  P
#6  U  W    G  B  K
#7  A  N    Z  X  R
#8  X  I    F  M  K res<-lapply(myfiles,function(x) {x1<-unlist(x);
x1[x1%in%c("-999.99M","T","C","A","F","Y")]<-NA;as.data.frame(matrix(x1,ncol=ncol(x)
),stringsAsFactors=FALSE)}) res[[1]] #   V1 V2   V3   V4   V5
#1    P    K    O 
#2    Z    S    M 
#3    M  S  G    I
#4    X  R    M    G    X
#5    Q    G  P
#6    U  W    G    B    K
#7    N    Z    X    R
#8    X  I  M    K lapply(seq_along(res),function(i)
write.table(res[[i]],paste0("file",i,".txt"),row.names=FALSE,quote=FALSE))
A.K. - Original Message -
From: Zilefac Elvis 
To: "r-help@r-project.org" 
Cc:
Sent: Saturday, April 27, 2013 11:20 AM
Subject: [R] Help Hello, I have a question and need your help urgently. I am
new to R but want to learn it. I have several files in a folder which I have
imported to R using :
temp = list.files(pattern="*.txt")
>myfiles = lapply(temp, read.delim)
The resulting files are on the workspace stored as List[110]. So they are
110 files in the list. Each file has several different columns and rows.
My question: I would like to find and replace -999.99M with NA; Find
'T','C','A','F' and 'Y', delete them from all the 110 files.
Then, I want to write.table all the corrected files back to a folder on my
computer.
Thanks for your help.
Atem. 
From: "r-help-requ...@r-project.org"   Sent: Friday, April 26, 2013 11:08 AM
Subject: confirm bfdc3137cee0135cf3c616295c9d0e2b3adfd392 Mailing list
subscription confirmation notice for mailing list R-help We have received a
request from 129.132.148.130 for subscription of r-help@r-project.org
mailing list.  To confirm that you want to be
added to this mailing list, simply reply to this message, keeping the
Subject: header intact.  Or visit this web page:   
https://stat.ethz.ch/mailman/confi

Re: [R] Fw: split date and time

2013-04-12 Thread Ye Lin
Thanks!


On Fri, Apr 12, 2013 at 3:30 PM, arun  wrote:

>
>
>
>
> - Forwarded Message -
> From: arun 
> To: Ye Lin 
> Cc:
> Sent: Friday, April 12, 2013 6:25 PM
> Subject: Re: [R] split date and time
>
>
>
> Hi Ye,
>
> Is this okay?
>
> dat2<-cbind(dat1[,-2],do.call(rbind,strsplit(dat1[,2],"
> ")),stringsAsFactors=FALSE)
>  dat2
> #  Number Value12
> #1  1 1 1/1/2013 0:00
> #2  2 2 1/1/2013 0:01
> #3  3 3 1/1/2013 0:03
>  colnames(dat2)[3:4]<- c("Date","Time")
>  dat2
> #  Number Value Date Time
> #1  1 1 1/1/2013 0:00
> #2  2 2 1/1/2013 0:01
> #3  3 3 1/1/2013 0:03
> str(dat2)
> #'data.frame':3 obs. of  4 variables:
>  #$ Number: int  1 2 3
>  #$ Value : int  1 2 3
>  #$ Date  : chr  "1/1/2013" "1/1/2013" "1/1/2013"
>  #$ Time  : chr  "0:00" "0:01" "0:03"
>
>
>
> 
> From: Ye Lin 
> To: arun 
> Sent: Friday, April 12, 2013 6:16 PM
> Subject: Re: [R] split date and time
>
>
>
>
>
> What if I have many columns, for example I have 50 columns in dat1, and
> say the "TimeStamp" column is the 10th, anyway to do that instead of
> listing all the other columns when building dat2?
>
>
> Thanks!
>
>
>
>
>
> On Fri, Apr 12, 2013 at 3:08 PM, arun  wrote:
>
> Hi,
> >dat1<- read.table(text="
> >Number,TimeStamp,Value
> >1,1/1/2013 0:00,1
> >2,1/1/2013 0:01,2
> >3,1/1/2013 0:03,3
> >",sep=",",header=TRUE,stringsAsFactors=FALSE)
> >dat2<-data.frame(Number=dat1[,1],do.call(rbind,strsplit(dat1[,2]," ")),
> Value=dat1[,3])
> > names(dat2)[2:3]<- c("Date","Time")
> > dat2
> >#  Number Date Time Value
> >#1  1 1/1/2013 0:00 1
> >#2  2 1/1/2013 0:01 2
> >#3  3 1/1/2013 0:03 3
> >A.K.
> >
> >
> >
> >
> >
> >- Original Message -
> >From: Ye Lin 
> >To: R help 
> >Cc:
> >Sent: Friday, April 12, 2013 5:49 PM
> >Subject: [R] split date and time
> >
> >Hi R experts,
> >
> >For example I have a dataset looks like this:
> >
> >
> >Number   TimeStamp   Value
> >1  1/1/2013 0:00 1
> >2 1/1/2013 0:01 2
> >3 1/1/2013 0:03 3
> >
> >How can I split the "TimeStamp" Column into two and return a new table
> like
> >this:
> >
> >Number   Date   Time   Value
> >1   1/1/2013 0:00 1
> >2 1/1/2013 0:01 2
> >3 1/1/2013 0:03 3
> >
> >Thank!
> >
> >[[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.
>

[[alternative HTML version deleted]]

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


Re: [R] Fw: Reversing data transformation

2013-04-06 Thread Uwe Ligges



On 06.04.2013 22:21, Beatriz González Domínguez wrote:



From: aguitatie...@hotmail.com
Sent: Friday, April 05, 2013 11:47 PM
To: r-help@r-project.org ; R Help
Subject: Reversing data transformation

Hi everybody,

I would be very grateful if you could give me your thoughts on the following 
issue.

I need to perform  Box-Cox (bcPower€�) transformation on my data. To do this, 
I calculated lambda using the function '€�powerTransform'€�.
   powerTransform(data)


We get:

Error: could not find function "powerTransform"


so that fucntion appears to be from some not mentioned package.



However, I got an error message when performing this function:
   Convergence failure: return code = 52
I was told by John Fox that the nature of my data was probably causing the 
problem so I applied the following transformation:
   powerTransform(1e7*(data - 0.99*(min(data   [1]

>

And it worked! However, now when I try to check the normality of my data,
   shapiro.test(data)
I get a new warning message:
   Error in shapiro.test(data) :
 ifault=6. This should not happen
I think this may be solved by removing the transformation I applied previously 
in [1], but I’m not sure how to do it properly.

Could anyone give me some advice?

MY DATA:
c(0.000103113, 0.000102948, 0.000104001, 0.000103794, 0.000104628,
9.2765e-05, 9.4296e-05, 9.5025e-05, 9.4978e-05, 9.8821e-05, 9.7586e-05,
9.6285e-05, 0.00010158, 0.000100919, 0.000103535, 0.000103321,
0.000102842, 0.000102315, 0.0001033, 0.000103691, 0.000102689,
0.000103248, 0.000101216, 0.000103127, 0.000103439, 0.000102818,
0.000103482, 0.00010227, 0.000104264, 0.000104672, 0.000104586,
0.000104516, 0.000104585, 0.000103804, 0.000103702, 0.000103405,
0.000104815, 0.000101718, 0.000101792, 0.000103273, 0.000102942,
0.000102522, 0.000103149, 0.0001036995, 0.0001039735, 0.0001014877,
0.000102796)



shapiro.test on this data works for me:

Shapiro-Wilk normality test

data:  data
W = 0.7314, p-value = 6.243e-08


Best,
Uwe Ligges


Thanks a lot!!

Bea




[[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] Fw: rpart

2013-01-28 Thread David Winsemius


On Jan 28, 2013, at 9:06 PM, carol white wrote:


Should I understand that this message was received?


It's always possible to check the Archives for this question.

--  
David.


Thanks


- Forwarded Message -
From: carol white 
To: "r-h...@stat.math.ethz.ch" 
Sent: Sunday, January 27, 2013 8:31 PM
Subject: rpart


Hi,
When I look at the summary of an rpart object run on my data, I get  
7 nodes but when I plot the rpart object, I get only 3 nodes. Should  
the number of nodes not match in the results of the 2 functions  
(summary and plot) or it is not always the same?


Look forward to your reply,

Carol

 summary(rpart.res)
Call:
rpart(formula = mydata$class ~ ., data = as.data.frame(t(mydata)))
  n= 62

 CP nsplit rel errorxerror  xstd
1 0.6363636  0 1.000 1.000 0.1712469
2 0.1363636  1 0.3636364 0.6818182 0.1532767
3 0.010  2 0.2272727 0.7727273 0.1596659

Variable importance
  Hsa.627   Hsa.692 Hsa.692.2  Hsa.3306   Hsa.601   Hsa.831  Hsa. 
1832  Hsa.2456

   19
13111010 8 6 6
 Hsa.8147  Hsa.1131 Hsa.692.1
6 5 5

Node number 1: 62 observations,complexity param=0.6363636
  predicted class=t  expected loss=0.3548387  P(node) =1
class counts:2240
   probabilities: 0.355 0.645
  left son=2 (14 obs) right son=3 (48 obs)
  Primary splits:
  Hsa.627   < 59.83to the left,  improve=15.05376, (0
missing)
  Hsa.8147  < 1696.23  to the right, improve=14.46790, (0 missing)
  Hsa.37937 < 379.39   to the right, improve=13.75358, (0 missing)
  Hsa.692.2 < 842.305  to the right, improve=12.38710, (0 missing)
  Hsa.1832  < 735.805  to the right, improve=11.90495, (0 missing)
  Surrogate splits:
  Hsa.692.2 < 1086.655 to the right, agree=0.903, adj=0.571, (0  
split)
  Hsa.3306  < 170.515  to the left,  agree=0.887, adj=0.500, (0  
split)
  Hsa.601   < 88.065   to the left,  agree=0.887, adj=0.500, (0  
split)

  Hsa.692   < 1251.99  to the right, agree=0.871, adj=0.429, (0
split)
  Hsa.831   < 281.54   to the left,  agree=0.871, adj=0.429, (0  
split)


Node number 2: 14 observations
  predicted class=n  expected loss=0  P(node) =0.2258065
class counts:14 0
   probabilities: 1.000 0.000

Node number 3: 48 observations,complexity param=0.1363636
  predicted class=t  expected loss=0.167  P(node) =0.7741935
class counts: 840
   probabilities: 0.167 0.833
  left son=6 (7 obs) right son=7 (41 obs)
  Primary splits:
  Hsa.8147  < 1722.605 to the right, improve=4.915215, (0 missing)
  Hsa.1832  < 681.145  to the right, improve=4.915215, (0
missing)
  Hsa.1410  < 49.985   to the left,  improve=4.915215, (0 missing)
  Hsa.2456  < 186.195  to the right, improve=4.915215, (0 missing)
  Hsa.11616 < 969.085  to the right, improve=4.915215, (0 missing)
  Surrogate splits:
  Hsa.1832  < 681.145  to the right, agree=1.000, adj=1.000, (0  
split)
  Hsa.2456  < 186.195  to the right, agree=1.000, adj=1.000, (0  
split)
  Hsa.692   < 1048.375 to the right, agree=0.979, adj=0.857, (0  
split)
  Hsa.692.1 < 1136.75  to the right, agree=0.979, adj=0.857, (0  
split)
  Hsa.1131  < 1679.54  to the right, agree=0.979, adj=0.857, (0  
split)


Node
number 6: 7 observations
  predicted class=n  expected loss=0.2857143  P(node) =0.1129032
class counts: 5 2
   probabilities: 0.714 0.286

Node number 7: 41 observations
  predicted class=t  expected loss=0.07317073  P(node) =0.6612903
class counts: 338
   probabilities: 0.073 0.927  
__

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

2012-12-12 Thread Jeff Newmiller
... origin pro?

Then why are you here?

It is not clear from your message that this has anything to do with R.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

vishal katoch  wrote:

>Hello,
>i am working in origin pro,
>i want to plot a graph as like a pdf attached but with black and white
>lines.
>here radial axis varies from 0 to 1. and angular axis from 0 degree to
>60 degree.and third axis which is depend on both radial and axial gives
>non intersecting lines.
>how can i read the data from plot for replot.
>vikas 
>
>
>
>
>
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/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] Fw: quantreg installation and conflicts with R 2.15.2

2012-12-01 Thread Uwe Ligges



On 30.11.2012 22:10, Brian S Cade wrote:

Just noticed that I get a similar error about object 'kronecker' in
"Matrix" package when trying to load "lme4".   So this is a more pervasive
problem.


Probably you have a mixture of packages for various versions of R around.

So after checking if all required packages are really installed, please run

update.packages(checkBuilt=TRUE)

Uwe Ligges





Brian

Brian S. Cade, PhD

U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bldg. C
Fort Collins, CO  80526-8818

email:  brian_c...@usgs.gov
tel:  970 226-9326
- Forwarded by Brian S Cade/BRD/USGS/DOI on 11/30/2012 02:07 PM -

From:
Brian S Cade/BRD/USGS/DOI
To:
R-help@r-project.org
Date:
11/30/2012 01:16 PM
Subject:
quantreg installation and conflicts with R 2.15.2


I recently lost the partitions on my hard drive (second time in 6 months)
so I had to have our IT folks image all my files over to a new drive.  I
completely reinstalled R (now 2.15.2) and all my libraries to my computer
(Dell Latitude running Windows 7).  A few of my previous workspaces
(created with R 2.14.1) can't be restored, reporting an error similar to
the one I get when I try to load "quantreg" package which requires
"SparseM" (see below).   So, not only will "quantreg" not load but some of
my workspaces can't be restored when being loaded (see below).  Not sure
about what this is about.   I asked Roger Koenker, the package maintainer,
but he is on travel and won't have chance to seriously investigate this
for awhile.  So I thought I would put it out to the R community and see if
anyone has any suggestions about why this conflict might be occurring.


library(quantreg)

Loading required package: SparseM
Error : object ?kronecker? is not exported by 'namespace:methods'
Error: package ?SparseM? could not be loaded

or

Error: object ?kronecker? is not exported by 'namespace:methods'
During startup - Warning message:
unable to restore saved data in C:\CADESTUFF\DATA\BarryNoon\.RData




Brian

Brian S. Cade, PhD

U. S. Geological Survey
Fort Collins Science Center
2150 Centre Ave., Bldg. C
Fort Collins, CO  80526-8818

email:  brian_c...@usgs.gov
tel:  970 226-9326

[[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] FW: Select a random subset of rows out of matrix

2012-11-21 Thread Rui Barradas

Hello,

It's not, in general, possible to fullfill the two constraints, to both 
select 80% of the rows and to select all x %in% sampled x. Maybe the 
following is a way close enough.


set.seed(244)
s <- sample(unique(dat$x), length(unique(dat$x))*0.8, prob = table(dat$x))
dat[dat$x %in% s,]


Hope this helps,

Rui Barradas
Em 21-11-2012 13:25, arun escreveu:

HI,
Your question is not very clear to me.

dat1<-data.frame(x=c(1,1,2,2,2,3,4,4),y=c(23,45,87,46,78,12,87,79))
If I select randomly 80% of data:
  dat1[sample(nrow(dat1),0.8*nrow(dat1)),]
#  x  y
#4 2 46
#6 3 12
#7 4 87
#3 2 87
#2 1 45
#8 4 79

In this case, it is a mix of all the records that was in the original data.  
So, if I understand correctly, then you want to get the original data, instead 
of the 80% data (as you want all the records).  But, suppose if the sample is:
  set.seed(244)
  dat2<-dat1[sample(nrow(dat1),0.8*nrow(dat1)),]
  dat2
#  x  y
#2 1 45
#7 4 87
#8 4 79
#1 1 23
#5 2 78
#4 2 46

You wanted to eliminate the records 3 from the original dataset.  Is that what 
you meant?
If that is the case:
dat1[dat1$x%in%dat2$x,]
#  x  y
#1 1 23
#2 1 45
#3 2 87
#4 2 46
#5 2 78
#7 4 87
#8 4 79

A.K.





- Original Message -
From: Madhu Ganganapalli 
To: "r-help@r-project.org" 
Cc:
Sent: Wednesday, November 21, 2012 4:10 AM
Subject: Re: [R] FW: Select a random subset of rows out of matrix

Hi,
   This is Madhu and I have a following doubt please give a solution...

**>i have the following data frame
from this i want to select a 80% of data randomly in such a way that
if the selected records are 1 and then we have to get the all records 
corresponding to 1
similarly for 2 also and soon. help me

 data<-data.frame(x=c(1,1,2,2,2,3,4,4,4),y=c(23,45,87,46,78,12,87,79));**


Regards,
Madhu.

 [[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] FW: Select a random subset of rows out of matrix

2012-11-21 Thread arun
HI,
Your question is not very clear to me.

dat1<-data.frame(x=c(1,1,2,2,2,3,4,4),y=c(23,45,87,46,78,12,87,79))
If I select randomly 80% of data:
 dat1[sample(nrow(dat1),0.8*nrow(dat1)),]
#  x  y
#4 2 46
#6 3 12
#7 4 87
#3 2 87
#2 1 45
#8 4 79

In this case, it is a mix of all the records that was in the original data.  
So, if I understand correctly, then you want to get the original data, instead 
of the 80% data (as you want all the records).  But, suppose if the sample is:
 set.seed(244)
 dat2<-dat1[sample(nrow(dat1),0.8*nrow(dat1)),]
 dat2
#  x  y
#2 1 45
#7 4 87
#8 4 79
#1 1 23
#5 2 78
#4 2 46

You wanted to eliminate the records 3 from the original dataset.  Is that what 
you meant?
If that is the case:
dat1[dat1$x%in%dat2$x,]
#  x  y
#1 1 23
#2 1 45
#3 2 87
#4 2 46
#5 2 78
#7 4 87
#8 4 79

A.K.





- Original Message -
From: Madhu Ganganapalli 
To: "r-help@r-project.org" 
Cc: 
Sent: Wednesday, November 21, 2012 4:10 AM
Subject: Re: [R] FW: Select a random subset of rows out of matrix

Hi,
  This is Madhu and I have a following doubt please give a solution...

**>i have the following data frame
from this i want to select a 80% of data randomly in such a way that
if the selected records are 1 and then we have to get the all records 
corresponding to 1
similarly for 2 also and soon. help me

    data<-data.frame(x=c(1,1,2,2,2,3,4,4,4),y=c(23,45,87,46,78,12,87,79));**


Regards,
Madhu.

    [[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] FW: Select a random subset of rows out of matrix

2012-11-21 Thread Madhu Ganganapalli
Hi,
  This is Madhu and I have a following doubt please give a solution...

**>i have the following data frame
from this i want to select a 80% of data randomly in such a way that
if the selected records are 1 and then we have to get the all records 
corresponding to 1
similarly for 2 also and soon. help me

data<-data.frame(x=c(1,1,2,2,2,3,4,4,4),y=c(23,45,87,46,78,12,87,79));**


Regards,
Madhu.

[[alternative HTML version deleted]]

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


Re: [R] FW: Two-line title in R legend

2012-11-12 Thread David Winsemius

On Nov 11, 2012, at 7:13 PM, Gabriel Toro wrote:

> Hi,
> 
> I am trying to use a legend title that is a bit too long for one line.  To 
> try to break the title in two lines, I am using
> 
> legend (title="Top of Title\nbottom of title",  etc.  )
> 
> R prints the title as two lines, but the top line is outside the legend box.
> 
> How can I trick the R legend function to make the legend box taller so that 
> it contains the top line?
> 

You should include an example with dummy data if you wnat tested solutions. You 
can try:

legend (title=atop("Top of Title","bottom of title"), ...  )

Plotmath expression are not allowed to have "\n" in them, as stated in the help 
page.

-- 
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] FW: Two-line title in R legend

2012-11-11 Thread David L Carlson
The top line is not outside the box in this example, but the bottom text
line is too close to the bottom. You can turn off drawing the box in
legend(). Store the return value of legend() which indicates where the box
would have been drawn and use rect() to add it after increasing the
dimension you need. In the example I lowered the bottom of the box by .1:

> plot(c(0:10), rnorm(11), ylim=c(-3, 3))
> pos <- legend(.5, 3, "Top of title\nBottom of title", pch=1,
+  bty="n")
> pos
$rect
$rect$w
[1] 2.558594

$rect$h
[1] 0.6723839

$rect$left
[1] 0.5

$rect$top
[1] 3


$text
$text$x
[1] 1.0625

$text$y
[1] 2.578779


> xleft <- pos$rect[["left"]]
> ytop <- pos$rect[["top"]]
> ybottom <- ytop - pos$rect[["h"]]
> xright <- xleft + pos$rect[["w"]]
> rect(xleft, ybottom-.1, xright, ytop)


--
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 Gabriel Toro
> Sent: Sunday, November 11, 2012 9:13 PM
> To: r-help@R-project.org
> Subject: [R] FW: Two-line title in R legend
> 
> Hi,
> 
> I am trying to use a legend title that is a bit too long for one line.
> To try to break the title in two lines, I am using
> 
>  legend (title="Top of Title\nbottom of title",  etc.  )
> 
> R prints the title as two lines, but the top line is outside the legend
> box.
> 
> How can I trick the R legend function to make the legend box taller so
> that it contains the top line?
> 
> Thanks,
> 
> Gabriel
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Fw: 95% Q-Q Plot error message

2012-11-04 Thread R. Michael Weylandt
Please don't double post.

And we'll need a reproducible example:
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

Michael

On Sun, Nov 4, 2012 at 6:50 PM,   wrote:
> Can someone please help with the below - thanks!
>
> Warning messages:
> 1: Not plotting observations with leverage one:
> 7
> 2: Not plotting observations with leverage one:
> 7
>> print(qqPlot(fit),envelop=.95);
> Error in model.frame.default(formula = Y ~ X - 1, drop.unused.levels =
> TRUE) :
> variable lengths differ (found for 'X')
> In addition: Warning message:
> In matrix(yhat, n, reps) :
> data length [9] is not a sub-multiple or multiple of the number of rows
> [8]
>
> __
> The information transmitted, including any attachments, is intended only for 
> the person or entity to which it is addressed and may contain confidential 
> and/or privileged material. Any review, retransmission, dissemination or 
> other use of, or taking of any action in reliance upon, this information by 
> persons or entities other than the intended recipient is prohibited, and all 
> liability arising therefrom is disclaimed. If you received this in error, 
> please contact the sender and delete the material from any computer. 
> PricewaterhouseCoopers LLP is a Delaware limited liability partnership.  This 
> communication may come from PricewaterhouseCoopers LLP or one of its 
> subsidiaries.
>
> [[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] FW: replace repeated id in a pedigree list

2012-10-31 Thread Terry Therneau

> I use kinship package of R and it doesn't create a kinship matrix with 
repeated id.

The kinship package is out of date, use the kinship2 and coxme packages (it was split into 
two parts).  Then the problem you describe no longer exists -- the kinship function no 
longer requires each subject id to be unique across all pedigrees.


pedlist <- with(mydata, pedgiree(id, fa_id, mo_id, sex, famid=famid))
kmat <- kinship(pedlist)
fit <- coxme(Surv(time, status) ~ x1 + x2 +... + (1| famid/id), varlist=kmat)

The pedlist object contains all the families, plot(pedlist[4]) would pull out and plot the 
4th family.

The column labels of kmat will be of the form "famid/id"


To solve your original problem (though you don't need to) create a single 
unified id.
uid <- paste(famid, id, sep='/')
idlist <- unique(uid)

newid <- match(uid, idlist)
newmom <- match(paste(famid, mo_id, sep='/'), idlist)
newdad <- match(paste(famid, fa_id, sep='/'), idlist)


Terry Therneau
author of kinship and coxme, but not :-) the maintainer of kinship2

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


Re: [R] FW: replace repeated id in a pedigree list

2012-10-30 Thread Rui Barradas

Hello,

Ok, try the following.


fun <- function(x, d, last){
new <- last
if(any(d)){
ii <- which(d)
for(i in ii){
new <- new + 1
old <- x$ID[i]
x$ID[i] <- new
x$FA_ID[x$FA_ID == old] <- new
x$MO_ID[x$MO_ID == old] <- new
}
} else new <- FALSE
list(new = new, DF = x)
}

lastid <- nrow(dat)
idx <- duplicated(dat$ID)
sp <- split(dat, dat$FAMID)
dup <- split(idx, dat$FAMID)
result <- vector("list", length(sp))

for(i in seq_along(sp)){
ret <- fun(sp[[i]], dup[[i]], lastid)
result[[i]] <- ret$DF
if(ret$new) lastid <- ret$new
}
d2 <- do.call(rbind, result)
# check (should be zero)
sum(duplicated(d2$ID))


Hope this helps,

Rui Barradas
Em 30-10-2012 11:22, Roberta Carriero escreveu:



From: roberta...@hotmail.it
To: smartpink...@yahoo.com
Subject: RE: [R] replace repeated id in a pedigree list
Date: Tue, 30 Oct 2012 09:51:50 +0100







You are right! I want to "replace the second 6 with a new ID". For example I have id 6 
which is repeated 2 times. In family 1 it appears one time. In family 37 I should replace id 6 with 
a new id whenever it appears, not only as founder but also as father. It is important to use a new 
id which doesn't exist in all the pedigrees belonging to the "Pedigree.txt" file. Thank 
you for help RegardsRoberta

FAMIDIDFA IDMO IDSEXSTATUS> 110020> 123122> 143112> 15311
0> 163110> 173122> 183110> 193110> 1103120> 111 
   3110> 130010 372770020> 3754654754822> 3754954754812> 37
550655110> 3755155255322> 3755255455510> 375560020> 3755765512
0> 37558655122> 37559655110> 37560655112> 3760010> 3755400
10> 3756155456210> 375620020> 375550020> 3756352155810> 373060 
   010> 3752130630712> 37   !

 56452155822> 3756552155812> 373070022> 
37566655110> 37548655122> 3756765512
2> 3756856155610> 3754756827710> 37553002 
   0> Date: Mon, 29 Oct 2012 20:23:56 -0700

From: smartpink...@yahoo.com
Subject: Re: [R] replace repeated id in a pedigree list
To: roberta...@hotmail.it

Hi,

I am a bit confused by this statement
"I want to replace repeated individual identifiers with new id and to
replace them not only in id column but also in father and mother id
columns"

In the dataset, you have repeated identifiers for ID, FAID and MOID.

For eg.
source("Pedigree.txt")
  head(dat1)
#  FAMID ID FAID MOID SEX STATUS
#1 1  100   2  0
#2 1  231   2  2
#3 1  431   1  2
#4 1  531   1  0
#5 1  631   1  0
#6 1  731   2  2

dat2<-dat1[duplicated(dat1$ID)|duplicated(dat1$ID,fromLast=TRUE),]
dat3<-dat2[order(dat2$ID),]
  head(dat3)
#FAMID ID FAID MOID SEX STATUS
#5   1  631   1  0
#60337  600   1  0
#17  2 2000   1  0
#46929 2000   1  0
#21  2 24   12   16   1  0
#53332 2400   1  0
  dat1$ID[duplicated(dat1$ID)|duplicated(dat1$ID,fromLast=TRUE)]
#  [1]   6  20  24  29  30  31  47  62  63  95  96  99 100  93 101 102  83 105
  #[19] 107 112 113 115 117 108 142 155 146 157 161  96 167 177 105 107 192 108
  #[37] 203 204 113 212 221 228 229 107 236 239 223 155 146 251 157 258 260 257
  #[55] 256 277 279 212 260  83 288 296 251 294 306 303 307 296 328 339 328 342
  #[73] 333 338 345 258 177 257 192 256 382 378 377 167 404 410 203 204 413 113
  #[91] 422 115 426 427 117 411 412 434 435  20  29 449  30  31 450 404 464 479
#[109] 480 481 413 483 484 434 476 477  47 288  24 506 500 501 339 328 516 294
#[127] 306 521 303 333 307 516 306 543 545 307 277   6 306 521 307 112 506 500
#[145] 501 596 598 599 598  62  63 229 236 239 627 619 620 599 638 645 650 651
#[163] 643 642 646 653  95  99 100 663  93 101 638 674 464 411 645 650 671 412
#[181] 651 672 646 696 686 685 411 671 378 377 412 672 653 733 435 760 650 651
#[199] 643 642 686 102 685 221 228 101 223 480 142 481 382 733 596 161 476 477
#[217] 696 627 674 760 645 650 651 619 646 620 239 410 422 426 427 479 483 484
#[235] 663  29 449 545  31 450 279 177 342 943 947 192 949 338 345 945 944 177
#[253] 543 943 947 192 949 945 944 410 333 427

#The same way you can get the repeated FAID and MOID
dat1$FAID[duplicated

Re: [R] FW: [r] How to pick colums from a ragged array?

2012-10-23 Thread Stuart Leask
So I get my list of IDs to exclude from:

g.rr<-do.call(rbind, g.r)[1]
dim(g.rr)
g.rr[1:(dim(g.rr)[1]/2)]

Many thanks.

Stuart

-Original Message-
From: Rui Barradas [mailto:ruipbarra...@sapo.pt] 
Sent: 23 October 2012 13:42
To: Stuart Leask
Cc: r-help@r-project.org
Subject: Re: FW: [R] [r] How to pick colums from a ragged array?

Hello,

You're right, getRepeat returns a list of data.frames, one per each ID. 
To put them all in the same df use

do.call(rbind, g.r)

Rui Barradas
Em 23-10-2012 13:36, Stuart Leask escreveu:
> Sorry, I must be a bit thick.!
> getRepeat gives me the data with duplicates - but I don't seem to be able to 
> manipulate the result. It looks like a list of dataframes:
>
>> g.r<-getRepeat(id.d)
>> dim(g.r)
> NULL
>> summary(g.r)
>   Length Class  Mode
> [1,] 2  data.frame list
> [2,] 2  data.frame list
> [3,] 2  data.frame list
>
> This leaves me with the same problem I had with my ragged array i.e. how do I 
> put all the second elements from this long list of data frames, into a single 
> list?
>
> I need to end up with a list of all the IDs that have duplicate first (or 
> last) DATES.
>
> Stuart
>
> -Original Message-
> From: Leask Stuart
> Sent: 23 October 2012 13:17
> To: 'Rui Barradas'
> Cc: 'r-help@r-project.org'
> Subject: RE: [R] [r] How to pick colums from a ragged array?
>
> Ah, no, my method does fail.
> Consider an ID that has a duplicate DATE that isn't the first date, but it's 
> first date is the same as another ID's first date that IS a duplicate.
> Test data is all - see below it failing.
>
> So, I remain very grateful for your function!
>
> Stuart
>
>
> ID <- c(58,58,58,58,167,167,323,323,323,323,323,323,323
> ,547,794,814,814,814,814,814,814,841,841,841,841,841
> ,841,841,841,841,910,910,910,910,910,910,999,1019,1019
> ,1019)
>
> DATE <-
>   c(20060821,20061207,20080102,20090904,20040205,20040205,2005
>   ,20060111,20071119,20080107,20080407,20080521,20080711,20041005
>   ,20070905,20020814,20021125,20040429,20040429,20071205,20080227
>   ,20050421,20050421,20060428,20060602,20060816,20061025,20061129
>   ,20070112,20070514, 19870508,20040205,20040205, 20091120,20091210
>   ,20091224,20050503,19870508,19870508,19880330)
>
>   id.d <- cbind (ID,DATE )
> # rag.a  <-  split ( id.d [ ,2 ], id.d [ ,1])   # create ragged 
> array, 1-n DATES for every NAME
>   # Inelegant attempt to remove IDs that only have one entry:
> # rag.s <-tapply  (id.d [ ,2], id.d [ ,1], sum) #add up the dates 
> per row
>   # Since DATE is in 'year mo da', if there's only one date, sum will be less 
> than 210:
> # rag.t <- rag.s [ rag.s > 2100 ]
> # multi.dates <- rownames ( rag.t ) # all the IDs 
> with >1 date
> # rag.am <- rag.a [ multi.dates ]   # rag.am only has 
> IDs with > 1 Date
>
> how.many <- ave(id.d[,1], id.d[,1], id.d[,2], FUN = length)
> nd.b<- id.d[how.many > 1, ]
>
> #ni<-dim(nd.b)[1]
> #nd.IDs<-nd.b[1:(ni/2)*2,1] # list of IDs with dups
> #nd.DATEs<-nd.b[1:(ni/2)*2,2] # list of dup'd dates
>
> earliest<-tapply(DATE,ID,min)  # table of mins
> rownames(earliest[earliest%in%nd.b])   # IDs of dups with min
> # This suggests ID 910 has a duplicate earliest, and it doesn't - it has a 
> non-earliest duplicate, # and an earliest date that is the same as another 
> ID's earliest+duplicate.
>
>
> -Original Message-
> From: Leask Stuart
> Sent: 23 October 2012 12:38
> To: 'Rui Barradas'
> Cc: r-help@r-project.org
> Subject: RE: [R] [r] How to pick colums from a ragged array?
>
> Thanks Rui - your initial, very elegant suggestion, has spurred me on!
>
> 1. As you noticed, my example data had no examples of duplicate first dates 
> (DOH!) I have corrected this, and added a test - an ID that has a duplicate 
> which is not the earliest DATE, but is the same DATE an earliest/duplicate 
> for another ID.
>
> 2. Your suggestion gave me all the duplicates:
>
> how.many  <-  ave ( id.d [ ,1], id.d [,1], id.d [,2], FUN = length)
> nd.b<- id.d [ how.many  > 1,  ]
>
> 3. I can then simply make a table of earliest DATEs by ID, and then see which 
> DATEs in this table are shared:
>
> earliest <- tapply ( DATE, ID, min)
> rownames(earliest[earliest%in%nd.b])
>
> This seems to work - and it does seem exclude IDs which have a duplicate date 
> which is the same as a minimum date for another ID.
> I'm trying to work out why!
>
>
> Many, many thanks for the gift of that function. I will compare the two 
> approaches (and assume that mine is flawed!).
>
>
> Stuart
>
>
> 
>
> ID <- c(58,58,58,58,167,167,323,323,323,323,323,323,323
> ,547,794,814,814,814,814,814,814,841,841,841,841,841
> ,841,841,841,841,910,910,910,910,910,910,999,1019,1019
> ,1019)
>
> DATE <-
>   c(20060821,20061207,20080102,20090904,20040205,20040205,2005
>   ,20060111,20071119,20080107,20080407,20080521,20080711,20041005
>   ,20070905,200

Re: [R] FW: [r] How to pick colums from a ragged array?

2012-10-23 Thread Rui Barradas

Hello,

You're right, getRepeat returns a list of data.frames, one per each ID. 
To put them all in the same df use


do.call(rbind, g.r)

Rui Barradas
Em 23-10-2012 13:36, Stuart Leask escreveu:

Sorry, I must be a bit thick.!
getRepeat gives me the data with duplicates - but I don't seem to be able to 
manipulate the result. It looks like a list of dataframes:


g.r<-getRepeat(id.d)
dim(g.r)

NULL

summary(g.r)

  Length Class  Mode
[1,] 2  data.frame list
[2,] 2  data.frame list
[3,] 2  data.frame list

This leaves me with the same problem I had with my ragged array i.e. how do I 
put all the second elements from this long list of data frames, into a single 
list?

I need to end up with a list of all the IDs that have duplicate first (or last) 
DATES.

Stuart

-Original Message-
From: Leask Stuart
Sent: 23 October 2012 13:17
To: 'Rui Barradas'
Cc: 'r-help@r-project.org'
Subject: RE: [R] [r] How to pick colums from a ragged array?

Ah, no, my method does fail.
Consider an ID that has a duplicate DATE that isn't the first date, but it's 
first date is the same as another ID's first date that IS a duplicate.
Test data is all - see below it failing.

So, I remain very grateful for your function!

Stuart


ID <- c(58,58,58,58,167,167,323,323,323,323,323,323,323
,547,794,814,814,814,814,814,814,841,841,841,841,841
,841,841,841,841,910,910,910,910,910,910,999,1019,1019
,1019)

DATE <-
  c(20060821,20061207,20080102,20090904,20040205,20040205,2005
  ,20060111,20071119,20080107,20080407,20080521,20080711,20041005
  ,20070905,20020814,20021125,20040429,20040429,20071205,20080227
  ,20050421,20050421,20060428,20060602,20060816,20061025,20061129
  ,20070112,20070514, 19870508,20040205,20040205, 20091120,20091210
  ,20091224,20050503,19870508,19870508,19880330)

  id.d <- cbind (ID,DATE )
# rag.a  <-  split ( id.d [ ,2 ], id.d [ ,1])   # create ragged 
array, 1-n DATES for every NAME
  # Inelegant attempt to remove IDs that only have one entry:
# rag.s <-tapply  (id.d [ ,2], id.d [ ,1], sum) #add up the dates 
per row
  # Since DATE is in 'year mo da', if there's only one date, sum will be less 
than 210:
# rag.t <- rag.s [ rag.s > 2100 ]
# multi.dates <- rownames ( rag.t ) # all the IDs with 
>1 date
# rag.am <- rag.a [ multi.dates ]   # rag.am only has IDs 
with > 1 Date

how.many <- ave(id.d[,1], id.d[,1], id.d[,2], FUN = length)
nd.b<- id.d[how.many > 1, ]

#ni<-dim(nd.b)[1]
#nd.IDs<-nd.b[1:(ni/2)*2,1] # list of IDs with dups
#nd.DATEs<-nd.b[1:(ni/2)*2,2] # list of dup'd dates

earliest<-tapply(DATE,ID,min)  # table of mins
rownames(earliest[earliest%in%nd.b])   # IDs of dups with min
# This suggests ID 910 has a duplicate earliest, and it doesn't - it has a 
non-earliest duplicate, # and an earliest date that is the same as another ID's 
earliest+duplicate.


-Original Message-
From: Leask Stuart
Sent: 23 October 2012 12:38
To: 'Rui Barradas'
Cc: r-help@r-project.org
Subject: RE: [R] [r] How to pick colums from a ragged array?

Thanks Rui - your initial, very elegant suggestion, has spurred me on!

1. As you noticed, my example data had no examples of duplicate first dates 
(DOH!) I have corrected this, and added a test - an ID that has a duplicate 
which is not the earliest DATE, but is the same DATE an earliest/duplicate for 
another ID.

2. Your suggestion gave me all the duplicates:

how.many  <-  ave ( id.d [ ,1], id.d [,1], id.d [,2], FUN = length)
nd.b<- id.d [ how.many  > 1,  ]

3. I can then simply make a table of earliest DATEs by ID, and then see which 
DATEs in this table are shared:

earliest <- tapply ( DATE, ID, min)
rownames(earliest[earliest%in%nd.b])

This seems to work - and it does seem exclude IDs which have a duplicate date 
which is the same as a minimum date for another ID.
I'm trying to work out why!


Many, many thanks for the gift of that function. I will compare the two 
approaches (and assume that mine is flawed!).


Stuart




ID <- c(58,58,58,58,167,167,323,323,323,323,323,323,323
,547,794,814,814,814,814,814,814,841,841,841,841,841
,841,841,841,841,910,910,910,910,910,910,999,1019,1019
,1019)

DATE <-
  c(20060821,20061207,20080102,20090904,20040205,20040205,2005
  ,20060111,20071119,20080107,20080407,20080521,20080711,20041005
  ,20070905,20020814,20021125,20040429,20040429,20071205,20080227
  ,20050421,20050421,20060428,20060602,20060816,20061025,20061129
  ,20070112,20070514, 19870409,19870508,19870508, 20091120,20091210
  ,20091224,20050503,19870508,19870508,19880330)

  id.d <- cbind (ID,DATE )

how.many <- ave(id.d[,1], id.d[,1], id.d[,2], FUN = length)
nd.b<- id.d[how.many > 1, ]

earliest <- tapply  ( DATE, ID, min)# table of earliest 
DATEs
rownames (earliest [earliest %in% nd.b ] )   # IDs of duplicates at the 
earliest date for that individual. I think...





Re: [R] FW: Create and Assign value into a variable from Another variable

2012-08-28 Thread Maarten Kruijver
You probably want to use get(), which is the converse of assign():

rbind(get(Variable_1), data.frame(read.csv("c:\\My2ndData.csv")))


On Tue, Aug 28, 2012 at 11:16 AM, Akkara, Antony (GE Energy, Non-GE) <
antony.akk...@ge.com> wrote:

>
> Ok.
> Here I have a variable called "Variable_1".
>
> Variable_1 <- "MyDataFrame"
>
> Here I want to create another variable, by assigning the value of
>  "Variable_1" .
> So, it will come like,
>
> Assign(Variable_1,data.frame(read.csv("c:\\Mydata.csv")))   --->[this was
> the 1st requirement, now I got the solution]
>
> Now, " MyDataFrame " is a variable and containing some values in that.
> And Now, the problem what is I need to do "rbind" into the variable "
> MyDataFrame ".
>
> I tried to do,
> rbind(as.character(Variable_1), data.frame(read.csv("c:\\My2ndData.csv")))
>
> and I tried this too
>
> rbind(as.name(Variable_1), data.frame(read.csv("c:\\My2ndData.csv")))
>
> and I getting the error like
>
> Error: " object of type 'symbol' is not subsettable "
>
>
> Here I am getting stuck !
>
>
> - Thanks
> Antony
>
>
> -Original Message-
> From: Bert Gunter [mailto:gunter.ber...@gene.com]
> Sent: Tuesday, August 28, 2012 1:46 PM
> To: Akkara, Antony (GE Energy, Non-GE)
> Cc: r-help@r-project.org
> Subject: Re: [R] Create and Assign value into a variable from Another
> variable
>
> Post a small reproducible example to clarify what you want to do.
>
> -- Bert
>
> On Mon, Aug 27, 2012 at 11:48 PM, Rantony  wrote:
> > Hi,
> >
> > Here i have a variable named "MyVariable" containing particular name
> >
> > For eg:-
> > MyVariable <- "UnitNo"
> >
> > Here my requirement is, i need to get "UnitNo" as another variable by
> > reading "MyVariable"
> >
> > i need  "UnitNo" as variable name and need to assign some value into
> that.
> >
> > i had tried with as.name(MyVariable ) and as.character(MyVariable) -
> > Its getting that value, but im unable to assign something into that
> > variable.
> >
> > Could you please help me ?
> >
> > - Thank you
> > Antony
> >
> >
> >
> > --
> > View this message in context:
> > http://r.789695.n4.nabble.com/Create-and-Assign-value-into-a-variable-
> > from-Another-variable-tp4641515.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.
>
>
>
> --
>
> Bert Gunter
> Genentech Nonclinical Biostatistics
>
> Internal Contact Info:
> Phone: 467-7374
> Website:
>
> http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Fw: Extract upper case letters

2012-06-28 Thread mdvaan
Thanks, all solutions worked like a charm.

Math


arun kirshna wrote
> 
> - Forwarded Message -
> From: arun 
> To: mdvaan 
> Cc: R help 
> Sent: Thursday, June 28, 2012 1:44 AM
> Subject: Re: [R] Extract upper case letters
> 
> Hi,
> 
> Try this:
> t <- "TheWeatherIsVeryNice"
>  t1<-gsub("[:A-Z:]","",t)
>  t1
> [1] "heeatherseryice"
> 
> 
> t2<-gsub("[:a-z:]","",t)
>> t2
> [1] "TWIVN"
> 
> 
> A.K.
> 
> 
> 
> 
> - Original Message -
> From: mdvaan 
> To: r-help@
> Cc: 
> Sent: Wednesday, June 27, 2012 3:15 PM
> Subject: [R] Extract upper case letters
> 
> t <- "TheWeatherIsVeryNice"
> 
> How do I extract the upper case letters? - TWIVN
> 
> Thanks!
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Extract-upper-case-letters-tp4634664.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@ mailing list
> https://stat.ethz.ch/mailman/listinfo/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@ mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


--
View this message in context: 
http://r.789695.n4.nabble.com/Extract-upper-case-letters-tp4634664p4634802.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] FW: R help - shell() in Linux

2012-06-24 Thread Sarah Goslee
You don't tell us what you're trying to do, but system() might be useful.

Sarah

On Sun, Jun 24, 2012 at 5:19 PM, 蓁蓁 李  wrote:
>
> Hi,
>
> I have a question. When I run R script in Windows, I can use shell() 
> function. But there is no such a function in Linux machine, what I should do 
> in the Linux machine?
>
> Thanks a lot!
> Jess
>
>



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

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


Re: [R] FW: Multivariate Normal and loops

2012-06-17 Thread R. Michael Weylandt
It's requested to cc the list on our back-and-forths so that i) you
can get help faster (I was moving all yesterday and it's a Hallmark
holiday in the US today) since others may respond; ii) others can
benefit by reading the archives.



On Sun, Jun 17, 2012 at 4:34 AM, Giulia Motta  wrote:
>
>
> the problem is that i want to do something like
> http://www.eco.uc3m.es/~jgonzalo/teaching/PhDTimeSeries/gonzalojec94.pdf in
> page 13
> with theta= 0.5, sigma = 0.5, a1=0 a2=-1 beta= 1
> and so i have to give a name (ewt, ezt) at the erratic component of my
> multivariate normal
> 
> From: letamo...@hotmail.com
> To:
> Subject: RE: [R] Multivariate Normal and loops
> Date: Sun, 17 Jun 2012 09:03:25 +
>
>
> I'm very grateful to you!
> But i'm wondering how i can do this, creating a matrix in which i can
> numerate every element?
> I don't know if i'm clear (probably not).
> Thank you very much
>

Unfortunately, I'm not totally clear as to what you are looking for
here. You can add row and column names (labels) with code like

rownames(A) <- c("a","cat","dog")

and then subscript appropriately:

A["cat",]

will pull out all columns (the empty index after the comma) in the row
labelled "cat". This is all documented in the manual I suggested to
you.

If there's something else you mean, try being a little clearer (using
examples from other programming languages if you know them is always
good) and we'll see what we can do.

Best,
Michael

>
>> From: michael.weyla...@gmail.com
>> Date: Fri, 15 Jun 2012 10:34:05 -0500
>> Subject: Re: [R] Multivariate Normal and loops
>> To: letamo...@hotmail.com
>> CC: r-help@r-project.org
>>
>> I don't think you need loops at all actually :-) [The main thing to
>> working with R vs. C is "vectorization" -- embrace it now and life
>> will be much better]
>>
>> You could do something like this:
>>
>> library(MASS) # Provides a multivariate normal distribution
>>
>> mvrnorm(100, c(1,5), matrix(c(2,1,1,2), ncol = 2))
>>
>> This gives you 100 samples of a multivariate normal with mean vector
>> (1,5) and covariance matrix
>>
>> (2, 1,
>> 1, 2)
>>
>> Feel free to tweak as necessary and type ?mvrnorm to see more
>> documentation.
>>
>> Hopefully this gets you started.
>>
>> For more on vectorization, see the "Introduction to R" that comes with
>> R. You can get it by typing help.start() at your command prompt.
>>
>> Hope this helps,
>> Michael
>>
>> On Fri, Jun 15, 2012 at 9:26 AM, Cassie  wrote:
>> > Hi,
>> > i'm not english and i'm not very familiar to R, and i'm asking if you
>> > can
>> > help me.
>> > I'm wondering how to create a multivariate normal an then repeat this
>> > for a
>> > sample of T=1000, and the save this result.
>> > Thank you very much for your helping
>> >
>> > --
>> > View this message in context:
>> > http://r.789695.n4.nabble.com/Multivariate-Normal-and-loops-tp4633504.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] FW: averaging two tables (rows with columns)

2012-05-10 Thread Rui Barradas
Hello,

After all the trouble, workable datasets.

I have a doubt on what you want.
By looking at the two results data.frames, I don't believe they match the
problem description.
The average columns are wrong. Look at line 1 in table3a. I has speciesXX
with a value of 0.14
but speciesXX does NOT occur in table2.

First Error ---> You are using the value of SpeciesXY in table2.

And even if speciesXX and SpeciesXY were the same, the value in table1,
Plot1 is zero.

Second Error ---> You are counting values that are not in the plots.

If I'm right, and only in that case, try the following

fun <- function(df1, df2){
y <- df2[, -1]
y <- t(y)
colnames(y) <- tolower(df2[, 1])
names(df1) <- tolower(names(df1))
cnames <- intersect(names(df1), colnames(y))
x <- as.matrix(df1[, cnames])
y <- as.matrix(y[, cnames])
count <- apply(x, 1, sum, na.rm=TRUE)
res <- (x %*% t(y))/count
rownames(res) <- df1[, 1]
res
}
fun(table1, table2)

Now, correct the first error, assuming it's the species name in table1
that's wrong.

tb1 <- table1
colnames(tb1)[5] <- "speciesXY"
tb1
fun(tb1, table2)

And correct the second, recording speciesXY (or XX) as 1 in Plot1.

tb1$speciesXY[1] <- 1
fun(tb1, table2)
# output
   EnviA EnviB EnviC
Plot1 0.175  0.28  0.18
Plot2 0.100  0.15  0.18
plot3 0.175  0.28  0.18
plot4  NaN   NaN   NaN

Finally, as you can see, the output of fun() is in a different format.
It is possible to change that (obvious) but not worth the trouble if I'm
wrong.

Give some feedback.
Hope this helps,

Rui Barradas

Kristi Glover wrote
> 
> oppps,  Now I used 'dput' function. Again I am sending. I am so sorry for
> inconvenience. 
> HI R userI am sorry that my data was not readable formate in the last
> email. Agin I am trying to send it. hope this time, that  table can be
> readable.As I mentioned earlier that I was struggling to figure out on how
> I can calculate the average from the two tables in R. Any one can help me?
> really your helpwould be grateful- I am spending so much time to figure it
> out. It should not be so hard, I think.I have very big data but I have
> created a hypothetical data for simplification.for exampleI have : table
> 1Table 1: species occurrence data> dput(table1)structure(list(X =
> structure(1:4, .Label = c("Plot1", "Plot2", "plot3", "plot4"), class =
> "factor"), speciesX = c(1L, 0L, 1L, 0L), speciesY = c(0L, 1L, 0L, 0L),
> speciesZ = c(1L, 1L, 0L, 1L), speciesXX = c(0L, 0L, 1L, 0L)), .Names =
> c("X", "speciesX", "speciesY", "speciesZ", "speciesXX"), class =
> "data.frame", row.names = c(NA, -4L))
> Table 2: table 2. species tolerance data> dput(table2)structure(list(X =
> structure(c(1L, 3L, 2L), .Label = c("SpeciesX", "SpeciesXY", "SpeciesY"),
> class = "factor"), EnviA = c(0.21, 0.1, 0.14), EnviB = c(0.4, 0.15, 0.16),
> EnviC = c(0.17, 0.18, 0.19)), .Names = c("X", "EnviA", "EnviB", "EnviC"),
> class = "data.frame", row.names = c(NA, -3L))> You may noticed that table
> 2 does not have species Z which was in tableTable 3: Now I want to get the
> average value of species tolerance in each plot based on each
> environmental value (EnviA or EnviB etc).The example of the out come
> (final table I was looking for it).Results table 3a: averages species
> tolerance in each plot based on EnviAsuch as: > 
> dput(table3a)structure(list(X = structure(1:4, .Label = c("plot1",
> "plot2", "plot3", "plot4"), class = "factor"), speciesX = c(0.21, NA, NA,
> 0.21), speciesY = c(NA, 0.1, NA, NA), speciesZ = structure(c(1L, 1L, 1L,
> 1L), .Label = "Nodata", class = "factor"), speciesXX = c(0.14, NA, 0.14,
> NA), av!
>  erage = c(0.175, 0.1, 0.14, 0.21)), .Names = c("X", "speciesX",
> "speciesY", "speciesZ", "speciesXX", "average"), class = "data.frame",
> row.names = c(NA, -4L))
> Table 3b
> Result table 3b: average species tolerance in plot based on EnviB> 
> dput(table3b) structure(list(X = structure(1:4, .Label = c("plot1",
> "plot2", "plot3", "plot4"), class = "factor"), speciesX = c(0.4, NA, NA,
> 0.4), speciesY = c(NA, 0.15, NA, NA), speciesZ = structure(c(1L, 1L, 1L,
> 1L), .Label = "Nodata", class = "factor"), speciesXX = c(0.16, NA, 0.16,
> NA), average = c(0.28, 0.15, 0.16, 0.4)), .Names = c("X", "speciesX",
> "speciesY", "speciesZ", "speciesXX", "average"), class = "data.frame",
> row.names = c(NA, -4L))I hope this time the data would be readable
> formate. Would any one help me how I can calculate these?ThanksKristi
> Golver==
> 
> 
> again 
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@ mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


--
View this message in context: 
http://r.789695.n4.nabble.com/averaging-two-tables-rows-with-c

Re: [R] FW: averaging two tables (rows with columns)

2012-05-10 Thread John Kane
Well I'd suggest learning to use the return key.  It really helps improve the 
readability of a posting.

Three of the for files came through okay but table3a has a problem.  It looks 
like some kind of extraneous charater(s) got into it but a second or so of 
editing makes it work so we have all 4 tables now.



John Kane
Kingston ON Canada


> -Original Message-
> From: kristi.glo...@hotmail.com
> Sent: Thu, 10 May 2012 14:36:51 -0300
> To: r-help@r-project.org
> Subject: Re: [R] FW: averaging two tables (rows with columns)
> 
> 
> oppps,  Now I used 'dput' function. Again I am sending. I am so sorry for
> inconvenience.
> HI R userI am sorry that my data was not readable formate in the last
> email. Agin I am trying to send it. hope this time, that  table can be
> readable.As I mentioned earlier that I was struggling to figure out on
> how I can calculate the average from the two tables in R. Any one can
> help me? really your helpwould be grateful- I am spending so much time to
> figure it out. It should not be so hard, I think.I have very big data but
> I have created a hypothetical data for simplification.for exampleI have :
> table 1Table 1: species occurrence data> dput(table1)structure(list(X =
> structure(1:4, .Label = c("Plot1", "Plot2", "plot3", "plot4"), class =
> "factor"), speciesX = c(1L, 0L, 1L, 0L), speciesY = c(0L, 1L, 0L, 0L),
> speciesZ = c(1L, 1L, 0L, 1L), speciesXX = c(0L, 0L, 1L, 0L)), .Names =
> c("X", "speciesX", "speciesY", "speciesZ", "speciesXX"), class =
> "data.frame", row.names = c(NA, -4L))
> Table 2: table 2. species tolerance data> dput(table2)structure(list(X =
> structure(c(1L, 3L, 2L), .Label = c("SpeciesX", "SpeciesXY", "SpeciesY"),
> class = "factor"), EnviA = c(0.21, 0.1, 0.14), EnviB = c(0.4, 0.15,
> 0.16), EnviC = c(0.17, 0.18, 0.19)), .Names = c("X", "EnviA", "EnviB",
> "EnviC"), class = "data.frame", row.names = c(NA, -3L))> You may noticed
> that table 2 does not have species Z which was in tableTable 3: Now I
> want to get the average value of species tolerance in each plot based on
> each environmental value (EnviA or EnviB etc).The example of the out come
> (final table I was looking for it).Results table 3a: averages species
> tolerance in each plot based on EnviAsuch as: >
> dput(table3a)structure(list(X = structure(1:4, .Label = c("plot1",
> "plot2", "plot3", "plot4"), class = "factor"), speciesX = c(0.21, NA, NA,
> 0.21), speciesY = c(NA, 0.1, NA, NA), speciesZ = structure(c(1L, 1L, 1L,
> 1L), .Label = "Nodata", class = "factor"), speciesXX = c(0.14, NA, 0.14,
> NA), av!
>  erage = c(0.175, 0.1, 0.14, 0.21)), .Names = c("X", "speciesX",
> "speciesY", "speciesZ", "speciesXX", "average"), class = "data.frame",
> row.names = c(NA, -4L))
> Table 3b
> Result table 3b: average species tolerance in plot based on EnviB>
> dput(table3b) structure(list(X = structure(1:4, .Label = c("plot1",
> "plot2", "plot3", "plot4"), class = "factor"), speciesX = c(0.4, NA, NA,
> 0.4), speciesY = c(NA, 0.15, NA, NA), speciesZ = structure(c(1L, 1L, 1L,
> 1L), .Label = "Nodata", class = "factor"), speciesXX = c(0.16, NA, 0.16,
> NA), average = c(0.28, 0.15, 0.16, 0.4)), .Names = c("X", "speciesX",
> "speciesY", "speciesZ", "speciesXX", "average"), class = "data.frame",
> row.names = c(NA, -4L))I hope this time the data would be readable
> formate. Would any one help me how I can calculate these?ThanksKristi
> Golver==
> 
> 
> again
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


Send your photos by email in seconds...
TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if3
Works in all emails, instant messengers, blogs, forums and social networks.

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


Re: [R] FW: averaging two tables (rows with columns)

2012-05-10 Thread John Kane
Kristi
The tables , if read in edit mode are vagely  readable but please just do as 
Petr and I suggest.
Use the dput command.

If you have the table in an R data.frame all you need to do is use the command 
dput(mytable)

I read your two tables into R and did that . Note I called them dat1 & dat2.  
table is a command in R and it is best not to use it as a variable name.


Results 

1> dput(dat1)

structure(list(X = c("Plot1", "Plot2", "plot3", "plot4"), speciesX = c(1L, 
0L, 1L, 0L), speciesY = c(0L, 1L, 0L, 0L), speciesZ = c(1L, 1L, 
0L, 1L), speciesXX = c(0L, 0L, 1L, 0L)), .Names = c("X", "speciesX", 
"speciesY", "speciesZ", "speciesXX"), class = "data.frame", row.names = c(NA, 
-4L))

1> dput(dat2)

structure(list(X = c("SpeciesX", "SpeciesY", "SpeciesXY"), EnviA = c(0.21, 
0.1, 0.14), EnviB = c(0.4, 0.15, 0.16), EnviC = c(0.17, 0.18, 
0.19)), .Names = c("X", "EnviA", "EnviB", "EnviC"), class = "data.frame", 
row.names = c("1", 
"2", "3"))
1> 

Now you just need to stick  variable name and an <- in front of the dput 
material and paste it into R
Like THIS
 mytable1  <- structure(list(X = c("Plot1", "Plot2", "plot3", "plot4"), 
speciesX = c(1L, 
0L, 1L, 0L), speciesY = c(0L, 1L, 0L, 0L), speciesZ = c(1L, 1L, 
0L, 1L), speciesXX = c(0L, 0L, 1L, 0L)), .Names = c("X", "speciesX", 
"speciesY", "speciesZ", "speciesXX"), class = "data.frame", row.names = c(NA, 
-4L))

and paste it into R.

Now we probably can get somewhere.

John Kane
Kingston ON Canada


> -Original Message-
> From: kristi.glo...@hotmail.com
> Sent: Thu, 10 May 2012 14:18:50 -0300
> To: r-help@r-project.org
> Subject: [R] FW: averaging two tables (rows with columns)
> 
> 
> Hi R-usuar,
> I still find the table is not in readable formate. I now forwarded the
> email.hope it works. I sent it to my account . It was perfect- but when I
> sent it to R help- then it comes with unreadable formate. This is my last
> try. If not, then I will try to do in Excel manually. cheers,
> 
> From: kristi.glo...@hotmail.com
> To: kristi.glo...@hotmail.com
> Subject: RE: [R] averaging two tables (rows with columns)
> Date: Thu, 10 May 2012 14:06:41 -0300
> 
> 
> 
> 
> 
> Hi John , Petr and R userI am sorry that my data was not readable formate
> in the last email. Agin I am trying to send it. hope this time, that
> table can be readable.
> As I mentioned earlier that I was struggling to figure out on how I can
> calculate the average from the two tables in R. Any one can help me?
> really your helpwould be grateful- I am spending so much time to figure
> it out. It should not be so hard, I think.I have very big data but I have
> created a hypothetical data for simplification.for example
> I have : table 1
> Table 1: species occurrence data> table1  X speciesX speciesY
> speciesZ speciesXX1 Plot1101 02 Plot2
> 011 03 plot3100
> 14 plot4001 0
> 
> Table 2: table 2. species tolerance data
> >table2  X EnviA EnviB EnviC1  SpeciesX  0.21  0.40
> 0.172  SpeciesY  0.10  0.15  0.183 SpeciesXY  0.14  0.16  0.19
> 
> You may noticed that table 2 does not have species Z which was in table
> 
> Table 3: Now I want to get the average value of species tolerance in each
> plot based on each environmental value (EnviA or EnviB etc).The example
> of the out come (final table I was looking for it).
> Results table 1a: averages species tolerance in each plot based on EnviA
> such as:
>> table3.a  X speciesX speciesY speciesZ speciesXX average1 plot1
>> 0.21   NA   Nodata  0.14   0.1752 plot2   NA  0.1
>> NodataNA   0.1003 plot3   NA   NA   Nodata  0.14
>> 0.1404 plot4 0.21   NA   NodataNA   0.210Table 4
> 
>> table3.b: Result table 1b: average species tolerance in plot based on
>> EnviB  X speciesX speciesY speciesZ speciesXX average1 plot1
>> 0.4   NA   Nodata  0.160.282 plot2   NA 0.15
>> NodataNA0.153 plot3   NA   NA   Nodata  0.16
>> 0.164 plot4  0.4   NA   NodataNA0.40
> I hope this time the data would be readable formate. Would any one help
> me how I can calculate these?Thanks
> Kristi Golver==
> 
> 
> 
>> Date: Thu, 10 May 2012 08:01:11 -0800
>> From: jrkrid...@inbox.com
>> Subject: RE: [R] averaging two tables (rows with columns)
>> To: kristi.glo...@hotmail.com; r-help@r-project.org
>> 
>> Kristi,
>> Your data has come through in a totally unreadable layout.
>> 
>> Have a look at ?dput as a handy way to present sample data.  Just run
>> dput(mydata), copy the output and paste into the email.
>> 
>> John Kane
>> Kingston ON Canada
>> 
> 
> 
>   [[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 

Re: [R] FW: averaging two tables (rows with columns)

2012-05-10 Thread Kristi Glover

oppps,  Now I used 'dput' function. Again I am sending. I am so sorry for 
inconvenience. 
HI R userI am sorry that my data was not readable formate in the last email. 
Agin I am trying to send it. hope this time, that  table can be readable.As I 
mentioned earlier that I was struggling to figure out on how I can calculate 
the average from the two tables in R. Any one can help me? really your 
helpwould be grateful- I am spending so much time to figure it out. It should 
not be so hard, I think.I have very big data but I have created a hypothetical 
data for simplification.for exampleI have : table 1Table 1: species occurrence 
data> dput(table1)structure(list(X = structure(1:4, .Label = c("Plot1", 
"Plot2", "plot3", "plot4"), class = "factor"), speciesX = c(1L, 0L, 1L, 0L), 
speciesY = c(0L, 1L, 0L, 0L), speciesZ = c(1L, 1L, 0L, 1L), speciesXX = c(0L, 
0L, 1L, 0L)), .Names = c("X", "speciesX", "speciesY", "speciesZ", "speciesXX"), 
class = "data.frame", row.names = c(NA, -4L))
Table 2: table 2. species tolerance data> dput(table2)structure(list(X = 
structure(c(1L, 3L, 2L), .Label = c("SpeciesX", "SpeciesXY", "SpeciesY"), class 
= "factor"), EnviA = c(0.21, 0.1, 0.14), EnviB = c(0.4, 0.15, 0.16), EnviC = 
c(0.17, 0.18, 0.19)), .Names = c("X", "EnviA", "EnviB", "EnviC"), class = 
"data.frame", row.names = c(NA, -3L))> You may noticed that table 2 does not 
have species Z which was in tableTable 3: Now I want to get the average value 
of species tolerance in each plot based on each environmental value (EnviA or 
EnviB etc).The example of the out come (final table I was looking for 
it).Results table 3a: averages species tolerance in each plot based on 
EnviAsuch as: >  dput(table3a)structure(list(X = structure(1:4, .Label = 
c("plot1", "plot2", "plot3", "plot4"), class = "factor"), speciesX = c(0.21, 
NA, NA, 0.21), speciesY = c(NA, 0.1, NA, NA), speciesZ = structure(c(1L, 1L, 
1L, 1L), .Label = "Nodata", class = "factor"), speciesXX = c(0.14, NA, 0.14, 
NA), av!
 erage = c(0.175, 0.1, 0.14, 0.21)), .Names = c("X", "speciesX", "speciesY", 
"speciesZ", "speciesXX", "average"), class = "data.frame", row.names = c(NA, 
-4L))
Table 3b
Result table 3b: average species tolerance in plot based on EnviB>  
dput(table3b) structure(list(X = structure(1:4, .Label = c("plot1", 
"plot2", "plot3", "plot4"), class = "factor"), speciesX = c(0.4, NA, NA, 0.4), 
speciesY = c(NA, 0.15, NA, NA), speciesZ = structure(c(1L, 1L, 1L, 1L), .Label 
= "Nodata", class = "factor"), speciesXX = c(0.16, NA, 0.16, NA), average = 
c(0.28, 0.15, 0.16, 0.4)), .Names = c("X", "speciesX", "speciesY", "speciesZ", 
"speciesXX", "average"), class = "data.frame", row.names = c(NA, -4L))I hope 
this time the data would be readable formate. Would any one help me how I can 
calculate these?ThanksKristi Golver==


again 

  
[[alternative HTML version deleted]]

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


Re: [R] FW: averaging two tables (rows with columns)

2012-05-10 Thread Sarah Goslee
Kristi,

Several people have already suggested you use dput() to provide your data.

In R,
dput(table1)
dput(table2)

Then copy and paste the output of those commands into your email.

There's no way to reliably copy and paste your raw data: using dput()
is the best way to provide it.

Sarah

On Thu, May 10, 2012 at 1:18 PM, Kristi Glover
 wrote:
>
> Hi R-usuar,
> I still find the table is not in readable formate. I now forwarded the 
> email.hope it works. I sent it to my account . It was perfect- but when I 
> sent it to R help- then it comes with unreadable formate. This is my last 
> try. If not, then I will try to do in Excel manually. cheers,
>
> From: kristi.glo...@hotmail.com
> To: kristi.glo...@hotmail.com
> Subject: RE: [R] averaging two tables (rows with columns)
> Date: Thu, 10 May 2012 14:06:41 -0300
>
>
>
>
>
> Hi John , Petr and R userI am sorry that my data was not readable formate in 
> the last email. Agin I am trying to send it. hope this time, that  table can 
> be readable.
> As I mentioned earlier that I was struggling to figure out on how I can 
> calculate the average from the two tables in R. Any one can help me? really 
> your helpwould be grateful- I am spending so much time to figure it out. It 
> should not be so hard, I think.I have very big data but I have created a 
> hypothetical data for simplification.for example
> I have : table 1
> Table 1: species occurrence data> table1      X speciesX speciesY speciesZ 
> speciesXX1 Plot1        1        0        1         02 Plot2        0        
> 1        1         03 plot3        1        0        0         14 plot4       
>  0        0        1         0
>
> Table 2: table 2. species tolerance data
>>table2                  X EnviA EnviB EnviC1  SpeciesX  0.21  0.40  0.172  
>>SpeciesY  0.10  0.15  0.183 SpeciesXY  0.14  0.16  0.19
>
> You may noticed that table 2 does not have species Z which was in table
>
> Table 3: Now I want to get the average value of species tolerance in each 
> plot based on each environmental value (EnviA or EnviB etc).The example of 
> the out come (final table I was looking for it).
> Results table 1a: averages species tolerance in each plot based on EnviA
> such as:
>> table3.a      X speciesX speciesY speciesZ speciesXX average1 plot1     0.21 
>>       NA   Nodata      0.14   0.1752 plot2       NA      0.1   Nodata        
>> NA   0.1003 plot3       NA       NA   Nodata      0.14   0.1404 plot4     
>> 0.21       NA   Nodata        NA   0.210Table 4
>
>> table3.b: Result table 1b: average species tolerance in plot based on EnviB  
>>     X speciesX speciesY speciesZ speciesXX average1 plot1      0.4       NA  
>>  Nodata      0.16    0.282 plot2       NA     0.15   Nodata        NA    
>> 0.153 plot3       NA       NA   Nodata      0.16    0.164 plot4      0.4     
>>   NA   Nodata        NA    0.40
> I hope this time the data would be readable formate. Would any one help me 
> how I can calculate these?Thanks
> Kristi Golver==
>
>
>
>> Date: Thu, 10 May 2012 08:01:11 -0800
>> From: jrkrid...@inbox.com
>> Subject: RE: [R] averaging two tables (rows with columns)
>> To: kristi.glo...@hotmail.com; r-help@r-project.org
>>
>> Kristi,
>> Your data has come through in a totally unreadable layout.
>>
>> Have a look at ?dput as a handy way to present sample data.  Just run 
>> dput(mydata), copy the output and paste into the email.
>>
>> 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] FW: Combined grouped and stacked bargraph

2012-04-25 Thread Nicola Van Wilgen
Dear John and R-list

Thank you for your comment. Here are my data in the dput format:

cs.not.log.bp <- (
structure(c(168, 69, 16, 69, 41, 6, 148, 6, 5, 4, 7, 4, 4, 2, 
7, 2, 4, 2, 4, 2, 1, 0, 2, 0), .Dim = c(4L, 6L), .Dimnames = list(
c("IUCN.Terrestrial", "IUCN.Marine", "National.CS.Terrestrial", 
"National.CS.Marine"), c("NE", "LC", "NT", "VU", "EN", "CR"
))) )

The database format is shown below, where columns represent conservation
status and the rows are two classification methods each split into
marine and terrestrial:

 NE  LC NT VU EN CR
IUCN.Terrestrial168  41  5  4  4  1
IUCN.Marine  69   6  4  2  2  0
National.CS.Terrestrial  16 148  7  7  4  2
National.CS.Marine   69   6  4  2  2  0

I would like to plot the conservation status according to two
classifications (i.e. my groups - IUCN status and national status), and
for each of those groups I would like data for the marine and
terrestrial species to be stacked. 

I have tried the following code (where cs.not.log.bp is my data), but it
does not work:

barplot(cs.not.log.bp[c(1:2),], xlab = "Conservation status", ylab =
"Number of species", col = c("grey90","grey80"), ylim = c(0,250), space
= 2)

barplot(cs.not.log.bp[c(3:4),], col = c("grey60","grey30"), beside =
T,add = T,names.arg = NA)

legend("topright",c("IUCN Terrestrial","IUCN Marine","National CS
Terrestrial","National CS Marine"),  col =
c("grey90","grey80","grey60","grey30"), pch = 15)

What happens is that some of the data in the second group stacks onto
the first group and then the remainder forms a second group. I would
like only "like" data (i.e. from the same database row) to stack within
a group.

There was one other similar post on the R-list
(http://r.789695.n4.nabble.com/barplot-question-td3670861.html ) where
the user had the same problem as I did, but it does not seem that this
was resolved.

Please let me know if you have any suggestions.

Thanks and best wishes,

Nicola

-Original Message-
From: John Kane [mailto:jrkrid...@inbox.com] 
Sent: 25 April 2012 02:58 PM
To: Nicola Van Wilgen; r-help@r-project.org
Subject: RE: [R] FW: Combined grouped and stacked bargraph

Hi Nicola,

You have provided the code and data as requested the data is in a very
unfriendly format.

If you would  supply the data in an easily useable format so that the
readers here can work with it it would help.

Since it looks like you have a small data set the easiest thing is to
use dput()  [see ?dput for information] and then just paste the output
into your email.  I expect you would get faster and better answers.


John Kane
Kingston ON Canada


> -Original Message-
> From: nicola.vanwil...@sanparks.org
> Sent: Wed, 25 Apr 2012 14:42:49 +0200
> To: r-help@r-project.org
> Subject: [R] FW: Combined grouped and stacked bargraph
> 
> Dear R list,
> 
> It appears that my request from yesterday got a bit garbled. I have
> tried to rephrase and retype it - please let me know if you can help
me
> - I am having some trouble drawing a bar-graph with two groups, both
of
> which are stacked.
> 
> I would like to plot the conservation status according to two
> classifications (i.e. my groups - IUCN status and national status),
and
> for each of those groups I would like data for the marine and
> terrestrial species to be stacked. My data look like this (where the
> names for the columns are conservation status': NE, LC, NT, VU, EN and
> CR; and the matrix name is cs.not.log.bp):
> 
> IUCN.Terrestrial168  41  5  4  4  1
> 
> IUCN.Marine  69   6  4  2  2  0
> 
> National.CS.Terrestrial  16 148  7  7  4  2
> 
> National.CS.Marine   69   6  4  2  2  0
> 
> I have tried the following code, but it does not work:
> 
> barplot(cs.not.log.bp[c(1:2),], xlab = "Conservation status", ylab =
> "Number of species", col = c("grey90","grey80"),names = cs.names, ylim
=
> c(0,250), space = 2)
> 
> barplot(cs.not.log.bp[c(3:4),], col = c("grey60","grey30"), beside =
> T,add = T,names.arg = NA)
> 
> legend("topright",c("IUCN Terrestrial","IUCN Marine","National CS
> Terrestrial","National CS Marine"),  col =
> c("grey90","grey80","grey60","grey30"), pch = 15)
> 
> What happens is that some of the data in the second group stacks onto
> the first group and then the remainder forms a second group. I would
> like only "like" data (i.e. from the same database row) to stack
within

Re: [R] FW: Combined grouped and stacked bargraph

2012-04-25 Thread John Kane
Hi Nicola,

You have provided the code and data as requested the data is in a very 
unfriendly format.

If you would  supply the data in an easily useable format so that the readers 
here can work with it it would help.

Since it looks like you have a small data set the easiest thing is to use 
dput()  [see ?dput for information] and then just paste the output into your 
email.  I expect you would get faster and better answers.


John Kane
Kingston ON Canada


> -Original Message-
> From: nicola.vanwil...@sanparks.org
> Sent: Wed, 25 Apr 2012 14:42:49 +0200
> To: r-help@r-project.org
> Subject: [R] FW: Combined grouped and stacked bargraph
> 
> Dear R list,
> 
> It appears that my request from yesterday got a bit garbled. I have
> tried to rephrase and retype it - please let me know if you can help me
> - I am having some trouble drawing a bar-graph with two groups, both of
> which are stacked.
> 
> I would like to plot the conservation status according to two
> classifications (i.e. my groups - IUCN status and national status), and
> for each of those groups I would like data for the marine and
> terrestrial species to be stacked. My data look like this (where the
> names for the columns are conservation status': NE, LC, NT, VU, EN and
> CR; and the matrix name is cs.not.log.bp):
> 
> IUCN.Terrestrial168  41  5  4  4  1
> 
> IUCN.Marine  69   6  4  2  2  0
> 
> National.CS.Terrestrial  16 148  7  7  4  2
> 
> National.CS.Marine   69   6  4  2  2  0
> 
> I have tried the following code, but it does not work:
> 
> barplot(cs.not.log.bp[c(1:2),], xlab = "Conservation status", ylab =
> "Number of species", col = c("grey90","grey80"),names = cs.names, ylim =
> c(0,250), space = 2)
> 
> barplot(cs.not.log.bp[c(3:4),], col = c("grey60","grey30"), beside =
> T,add = T,names.arg = NA)
> 
> legend("topright",c("IUCN Terrestrial","IUCN Marine","National CS
> Terrestrial","National CS Marine"),  col =
> c("grey90","grey80","grey60","grey30"), pch = 15)
> 
> What happens is that some of the data in the second group stacks onto
> the first group and then the remainder forms a second group. I would
> like only "like" data (i.e. from the same database row) to stack within
> a group.
> 
> There was one other similar post on the R-list
> (http://r.789695.n4.nabble.com/barplot-question-td3670861.html ) where
> the user had the same problem as I did, but it does not seem that this
> was resolved.
> 
> Please let me know if you have any suggestions.
> 
> Thanks and best wishes,
> 
> Nicola
> 
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Nicola Van Wilgen
> Sent: 24 April 2012 01:12 PM
> To: r-help@r-project.org
> Subject: [R] Combined grouped and stacked bargraph
> 
> Dear R list,
> 
> 
> 
> I am having some trouble drawing a bar-graph with two groups, both of
> which are stacked.
> 
> 
> 
> A sample of my data (IUCN and national conservation status for marine
> and terrestrial species) look like this:
> 
> Status
> 
> IUCN Terrestrial
> 
> IUCN Marine
> 
> National CS Terrestrial
> 
> National CS Marine
> 
> NE
> 
> 168
> 
> 69
> 
> 16
> 
> 69
> 
> LC
> 
> 41
> 
> 6
> 
> 148
> 
> 6
> 
> NT
> 
> 5
> 
> 4
> 
> 7
> 
> 4
> 
> VU
> 
> 4
> 
> 2
> 
> 7
> 
> 2
> 
> EN
> 
> 4
> 
> 2
> 
> 4
> 
> 2
> 
> CR
> 
> 1
> 
> 0
> 
> 2
> 
> 0
> 
> 
> 
> I would like to plot the conservation status for two groups (IUCN status
> and national status), and for each of those groups I would like data for
> the marine and terrestrial species to be stacked. I needed to transpose
> the data to plot correctly, so my data in the code below look like this
> (where the names for data in the columns are NE, LC, NT, VU, EN and CR;
> and the matrix name is cs.not.log.bp):
> 
> 
> 
> IUCN.Terrestrial168  41  5  4  4  1
> 
> IUCN.Marine  69   6  4  2  2  0
> 
> National.CS.Terrestrial  16 148  7  7  4  2
> 
> National.CS.Marine   69   6  4  2  2  0
> 
> 
> 
> I have tried the following code, but it does not work:
> 
> 
> 
> barplot(cs.not.log.bp[c(1:2),], xlab = "Conservation status", ylab =
> "Number of species", col = c("grey90","grey80"),
> 
>   names = cs.names, ylim = c(0,250), space = 2)
> 
> barplot(cs.not.log.bp[c(3:4),], col = c("grey60","grey30"), beside =
> T,add = T,names.arg = NA)
> 
> legend("topright",c("IUCN Terrestrial","IUCN Marine","National CS
> Terrestrial","National CS Marine"),
> 
>   col = c("grey90","grey80","grey60","grey30"), pch = 15)
> 
> 
> 
> What happens is that some of the data in the second group stacks onto
> the first group and then the remainder forms a second group. I would
> like only "like" data to stack within a group.
> 
> 
> 
> There was one other similar post on the R-list
> (http://r.789695.n4.nabble.com/barplot-question-td3670861.html ) where
> the user had the same problem as I did, but it does not seem that this
> was resolved.
> 
> 
> 
> Please let me know if you have any suggestions.
>

Re: [R] FW: fdp and Rgraphviz

2012-03-23 Thread Uwe Ligges

1. Why do you ask here rather than the author of thr webpage?
2. Reading the comments suggests you are lacking a graphviz installation 
that includes the fdp command.


Uwe Ligges







On 23.03.2012 13:09, Heba S wrote:









Hello,
I am beginner user of R. I am trying to use GeneNet package. I started by the 
example on this link:
http://strimmerlab.org/software/genenet/download/arabidopsis-net.R
However I am getting an error at this line:system("fdp -T svg -o arthdyn.svg 
arthdyn.dot") # SVG format
sh: fdp: command not found

I tried to search how to intall the fdp command but could not find explanation. 
I am running my code on Rstudio .95.263 and Mac OS X 10.6.8
Can you please help me to solve this problem or is there is another way to 
visualize the network
Thanks,
H   
[[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] FW: NaN from function

2012-02-23 Thread Petr Savicky
On Thu, Feb 23, 2012 at 04:40:07PM -, Ted Harding wrote:
[...]
> A basic solution for this special case would be
> 
>   zt=function(x){
> if (sd(x) == 0) return(0*x) else return( (x-mean(x))/sd(x) )
>   }
> 
> This should cover the case where length(table(x))==1 (see also below).
> 
> I'm not happy about your conditions
> 
>   if (length(table(x)>1))
>   if (length(table(x)==1))
> 
> since they ask for "length(table(x)>1)", which doesn't seem
> to represent any natural criterion. E.g.:
> 
>   length(table(1:10)>1)
>   # [1] 10
>   length(table(rep(1,10))>1)
>   # [1] 1
> 
>   if(length(table(1:10)>1)) y <- "Yes" else y <- "No" ; y
>   # [1] "Yes"
>   if(length(table(rep(1,10))>1)) y <- "Yes" else y <- "No" ; y
>   # [1] "Yes"
> 
>   length(table(1:10)==1)
>   # [1] 10
>   length(table(rep(1,10))==1)
>   # [1] 1
>   
>   if(length(table(1:10)==1)) y <- "Yes" else y <- "No" ; y
>   # [1] "Yes"
>   if(length(table(rep(1,10))==1)) y <- "Yes" else y <- "No" ; y
>   # [1] "Yes"
> 
> I suspect you meant to write
> 
>   if (length(table(x))>1)
> and
>   if (length(table(x)))==1)
> 
> since this distinguishes between two more more different values
> (length(table(x)) > 1) and all equal values (length(table(x)) == 1).

Hi.

The condition length(table(x)) > 1 may also be written as
lentgh(unique(x)) > 1. These two conditions are usually
equivalent, but not always due to the rounding to 15 digits
performed in table(). For example

  x <- 1 + (0:10)*2^-52
  length(table(x))  # [1] 1
  length(unique(x)) # [1] 11
  sd(x) # [1] 7.364386e-16
  diff(x)   # [1] 2.220446e-16 2.220446e-16 2.220446e-16 ...

Petr Savicky.

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


Re: [R] FW: NaN from function

2012-02-23 Thread Ted Harding
On 23-Feb-2012 Jonathan Williams wrote:
> Dear Helpers,
> I wrote a simple function to standardise variables if they
> contain more than one value. If the elements of the variable
> are all identical, then I want the function to return zero.
> 
> When I submit variables whose elements are all identical to
> the function, it returns not zero, but NaNs.
> 
> zt=function(x){if (length(table(x)>1)) y=(x-mean(x))/sd(x) else if
> (length(table(x)==1)) y=0; return(y)}
> 
> zt(c(1:10))
>#[1] -1.4863011 -1.1560120 -0.8257228 -0.4954337 -0.1651446  0.1651446 
>#0.4954337  0.8257228  1.1560120  1.4863011
> 
> zt(rep(1,10))
>#[1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
> 
> Would you be so kind as to point out what I am doing wrong, here?
> How can I obtain zeros from my function, instead of NaNs?
> (I obtain NaNs also if I set the function to zt=function(x){
>  if (length(table(x)>1)) y=(x-mean(x))/sd(x) else if
> (length(table(x)==1)) y=rep(0, length(x)); return(y)} ).
> 
> Thanks, in advance, for your help,
> Jonathan Williams

The issue here, Jonathan, is that when you evaluate
(x-mean(x))/sd(x) for a vector x whose elements are all equal,
not only is (x-mean(x)) = 0, but also sd(x) = 0, so you are
asking the function to return the result of 0/0. Since this
is undefined, the result is NaN.

A basic solution for this special case would be

  zt=function(x){
if (sd(x) == 0) return(0*x) else return( (x-mean(x))/sd(x) )
  }

This should cover the case where length(table(x))==1 (see also below).

I'm not happy about your conditions

  if (length(table(x)>1))
  if (length(table(x)==1))

since they ask for "length(table(x)>1)", which doesn't seem
to represent any natural criterion. E.g.:

  length(table(1:10)>1)
  # [1] 10
  length(table(rep(1,10))>1)
  # [1] 1

  if(length(table(1:10)>1)) y <- "Yes" else y <- "No" ; y
  # [1] "Yes"
  if(length(table(rep(1,10))>1)) y <- "Yes" else y <- "No" ; y
  # [1] "Yes"

  length(table(1:10)==1)
  # [1] 10
  length(table(rep(1,10))==1)
  # [1] 1
  
  if(length(table(1:10)==1)) y <- "Yes" else y <- "No" ; y
  # [1] "Yes"
  if(length(table(rep(1,10))==1)) y <- "Yes" else y <- "No" ; y
  # [1] "Yes"

I suspect you meant to write

  if (length(table(x))>1)
and
  if (length(table(x)))==1)

since this distinguishes between two more more different values
(length(table(x)) > 1) and all equal values (length(table(x)) == 1).

Ted.



-
E-Mail: (Ted Harding) 
Date: 23-Feb-2012  Time: 16:40:03
This message was sent by XFMail

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


Re: [R] FW: Problems with R

2012-02-20 Thread David Winsemius


On Feb 20, 2012, at 10:26 AM, Thorsten Pöllinger wrote:


Dears,

I am a new R user and I am trying to analyze my data sets, R gives  
me a default when I type in the regression formula as following:


fit1=gamlss(tot_remun_revenue$tot_remun.y~tot_remun_revenue 
$revenue.x,family=NO)


Most regression functions work best with a data argument and then a  
formula that uses just column names.



Fehler in model.frame.default(formula = tot_remun_revenue 
$tot_remun.y ~  :
 ungültiger Typ (NULL) für die Variable 'tot_remun_revenue 
$tot_remun.y' Is there anything wrong in my data set, as the  
instruction is directly copied from lectures I had about R? Attached  
please find the data set as .csv. Best regards and thanks in  
advance! Thorsten Poellinger 	


You mailer probably did not properly indicate that the .csv file was  
an acceptable file type. You may want to send a followup after  
renaming the file to .txt before attaching,... and you  
should include the data input commands you used.


--
David Winsemius, MD
West Hartford, CT

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


  1   2   3   >