[R] Merging Issue

2016-06-17 Thread Farnoosh Sheikhi via R-help
Hi all, 
I have two data sets similar like below and wanted to merge them with variable 
"deps". As this is a sample data with small sample size, I don't have any 
problem using command merge. However, the actual data set has ~60,000 
observations with a lot of repeated measures. For example, for a given ID I 
have 100 different dates and groups. Thee problem is using "merge" command 
gives me a lot of duplicates that I can't even track. I was wondering if there 
is any other way to merge such a data.Any help is appreciated. Thanks.
## Data ASubject<- c("2", "2", "2", "3", "3", "3", "4", "4", "5", "5", "5", 
"5")dates<-seq(as.Date('2011-01-01'),as.Date('2011-01-12'),by = 1) deps<-c("A", 
"B", "C", "C", "D", "A", "F", "G", "A", "F", "A", "D")df <- data.frame(Subject, 
dates, deps)
## Data Bloc<-c("CA","NY", "CA", "NY", "WA", "WA")grp<-c("DE", "OC", "DE", 
"OT", "DE", "OC")deps<-c("A","B","C", "D", "F","G")df2<-data.frame(loc, grp, 
deps )
dat<-merge(df, df2, by="deps")
 


[[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] row.names c(NA, -length) vs. c(NA, +length)

2016-06-17 Thread William Dunlap via R-help
The default row.names on a data.frame made by the core-R data.frame
function are of the the form c(NA, -NROW(dataFrame)).  The dplyr package
has a 'data_frame' function that uses c(NA, +NROW(dataFrame)) instead.  The
tibble package also has a data_frame function, but it uses the negative
length.

As far as I can see, the positive and negative forms mean the same thing.
Is there any reason for the difference?  It makes testing a bit difficult
since all.equal() says they are the the same but identical() says they
differ.

> base::.row_names_info(dplyr::data_frame(X=101:110), 0)
[1] NA 10
> base::.row_names_info(tibble::data_frame(X=101:110), 0)
[1]  NA -10
> base::.row_names_info(base::data.frame(X=101:110), 0)
[1]  NA -10
>
> packageDescription("dplyr")$Author
[1] "Hadley Wickham [aut, cre],\n  Romain Francois [aut],\n  RStudio [cph]"
> packageDescription("tibble")$Author
[1] "Hadley Wickham [aut],\n  Romain Francois [aut],\n  Kirill Müller [aut,
cre],\n  RStudio [cph]"
> packageDescription("base")$Author
[1] "R Core Team and contributors worldwide"


Bill Dunlap
TIBCO Software
wdunlap tibco.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] Fwd: Matrix Constraints in R Optim

2016-06-17 Thread Jeff Newmiller
Always reply-to-all to keep the mailing list informed... I don't do private 
consulting online. 

You look like you have plain text worked out, but we still cannot run your 
code. 

Read the Posting Guide and [1]. You cannot attach Excel files here (and many R 
users can't or won't do that anyway) so you need to figure out dput. You will 
know you have a reproducible example when you don't read from any files and the 
code produces the error you are asking about when run in a newly opened R 
session.  I think you should (!) only need the dput of my.data.var, definition 
of Error.func, and the call to optim if you do it right. 

[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
-- 
Sent from my phone. Please excuse my brevity.

On June 17, 2016 3:10:41 PM PDT, Narendra Modi  wrote:
>how to do that Jeff? I am newbie to R.
>
>I am posting the whole message again here and I made sure it is in
>plain-text format.
>
>
>
>
>
>
>my.data.matrix.inj <- as.matrix(my.data)  #convert DATA FRAME to MATRIX
>my.data.matrix.inj
>
>
>my.data.2 <- readWorksheetFromFile(file,sheet=2,startRow=1)
>str(my.data.2)  # DATA FRAME
>my.data.matrix.time <- as.matrix(my.data.2)  #convert DATA FRAME to
>MATRIX
>my.data.matrix.time
>
>my.data <- readWorksheetFromFile(file,sheet=3,startRow=1)
>str(my.data)  # DATA FRAME
>my.data.matrix.prod <- as.matrix(my.data)  #convert DATA FRAME to
>MATRIX
>my.data.matrix.prod
>
>
> # my.data.var <- vector("numeric",length = 24)
> # my.data.var
>
>my.data.var <- c(10,0.25,0.25,0.25,0.25,0.25,
> 10,0.25,0.25,0.25,0.25,0.25,
> 10,0.25,0.25,0.25,0.25,0.25,
> 10,0.25,0.25,0.25,0.25,0.25)
>my.data.var
>
>my.data.qo <- c(5990,150,199,996)   #Pre-Waterflood Production
>my.data.timet0 <- 0 # starting condition for time
>
>#FUNCTION
>Qjk.Cal.func <- function(my.data.timet0,my.data.qo,my.data.matrix.time,
> my.data.matrix.inj,
>my.data.matrix.prod,my.data.var,my.data.var.mat)
>{
>
>  qjk.cal.matrix <- matrix(,nrow = nrow(my.data.matrix.prod),
>ncol=ncol(my.data.matrix.prod))
>
>  count <- 1
>  number <- 1
>  for(colnum in 1:ncol(my.data.matrix.prod))   # loop through all PROD
>wells columns
>  {
>sum <-0
>for(row in 1:nrow(my.data.matrix.prod)) #loop through all the rows
>{
>  sum <-0
>  deltaT <-0
>  expo <-0
>
>
>for(column in 1:ncol(my.data.matrix.inj)) #loop through all
>the injector columns to get the PRODUCT SUM
> {
>sum = sum +
>my.data.matrix.inj[row,column]*my.data.var.mat[colnum,number+column]
> }
>
>  if(count<2)
>  {
>deltaT<- my.data.matrix.time[row]
>  }
>  else
>  {deltaT <- my.data.matrix.time[row]-my.data.matrix.time[row-1]}
>
>
>  expo <- exp(-deltaT/my.data.var.mat[colnum,1])
># change here too
>
>  if(count<2)
>  {
>qjk.cal.matrix[row,colnum] = my.data.qo[colnum]*expo + (1-expo)*sum
>  }
>  else
>  {
>qjk.cal.matrix[row,colnum]=qjk.cal.matrix[row-1,colnum]*expo +
>(1-expo)*sum
>  }
>  count <- count+1
>}
>
>count <-1
>  }
>
>  qjk.cal.matrix  # RETURN CALCULATED MATRIX TO THE ERROR FUNCTION
>
>}
>
>
># ERROR FUNCTION - FINDS DIFFERENCE BETWEEN CAL. MATRIX AND ORIGINAL
>MATRIX. Miminize the Error by changing my.data.var
>
>Error.func <- function(my.data.var)
>{
>  #First convert vector(my.data.var) to MATRIX aand send it to
>calculate new MATRIX
>  my.data.var.mat <- matrix(my.data.var,nrow =
>ncol(my.data.matrix.prod),ncol = ncol(my.data.matrix.inj)+1,byrow =
>TRUE)
>
>Calc.Qjk.Value <-
>Qjk.Cal.func(my.data.timet0,my.data.qo,my.data.matrix.time,
> my.data.matrix.inj,
>my.data.matrix.prod,my.data.var,my.data.var.mat)
>
>
>  diff.values <- my.data.matrix.prod-Calc.Qjk.Value#FIND
>DIFFERENCE BETWEEN CAL. MATRIX AND ORIGINAL MATRIX
>
>
>  Error <- ((colSums ((diff.values^2), na.rm = FALSE, dims =
>1))/nrow(my.data.matrix.inj))^0.5#sum of square root of the diff
>  print(paste(Error))
>
>  Error_total <- sum(Error,na.rm=FALSE)/ncol(my.data.matrix.prod)   #
>total avg error
>
>
>  Error_total
>}
>
># OPTIMIZE
>
>sols<-optim(my.data.var,Error.func,method="L-BFGS-B",upper=c(Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1),
>lower=c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),control=list(maxit
>=1000))
>sols
>
>
>
>
>
>
>On Fri, Jun 17, 2016 at 4:55 PM, Jeff Newmiller
> wrote:
>>
>> Your code is corrupt because you failed to send your email in plain
>text format.
>>
>> You also don't appear to have all data needed to reproduce the
>problem. Use the dput function to generate R code form of a sample of
>your data.
>> --
>> Sent from my phone. Please excuse my brevity.
>>
>> On June 17, 2016 1:07:21 PM PDT, Priyank Dwivedi
> wrote:
>> >By mistake, I sent it earlier to the wrong address.
>> >
>> >-- Forwarded message 

Re: [R] Problems with Mann-Kendall trend test

2016-06-17 Thread Morteza Firouzi via R-help
Dear,
You have to store your data as a Time-Series (ts), first. To define a column of 
data as ts, you may use this:
library(timeSeries)Nile <- read.csv(file.choose(), header=F)#If your data is 
monthly, you may define the frequency as 12, for annual ts set freq. as 1.
#If your data starts from for e.g., 1990, then:NileTS <- ts(Nile, frequency=1, 
start=c(1990,1))#To plot the time seriesplot.ts(NileTS)
Morteza
 
 

On Saturday, June 18, 2016 3:47 AM, lily li  wrote:
 

 Dear R users,

Can anyone help me with mann-kendall trend test? I tried to use the newest
packages 'trend', and the function mk.test, but had problems in applying
the input data.

For example, res <- mk.test(Nile), Nile is a time-series data. But when I
use my dataset, with one column which is a time-series data, it says
"error: input must be ts object". How to do this? Thanks for your 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.


  
[[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] Problems with Mann-Kendall trend test

2016-06-17 Thread Jeff Newmiller
Not reproducible. Use dput to generate R code form of your data along with the 
code that gave you the error, and set the email to plain text only when you 
send it so it doesn't get corrupted when the html is stripped on the mailing 
list. 
-- 
Sent from my phone. Please excuse my brevity.

On June 17, 2016 12:47:07 PM PDT, lily li  wrote:
>Dear R users,
>
>Can anyone help me with mann-kendall trend test? I tried to use the
>newest
>packages 'trend', and the function mk.test, but had problems in
>applying
>the input data.
>
>For example, res <- mk.test(Nile), Nile is a time-series data. But when
>I
>use my dataset, with one column which is a time-series data, it says
>"error: input must be ts object". How to do this? Thanks for your 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.

[[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] Fwd: Matrix Constraints in R Optim

2016-06-17 Thread Jeff Newmiller
Your code is corrupt because you failed to send your email in plain text 
format. 

You also don't appear to have all data needed to reproduce the problem. Use the 
dput function to generate R code form of a sample of your data. 
-- 
Sent from my phone. Please excuse my brevity.

On June 17, 2016 1:07:21 PM PDT, Priyank Dwivedi  wrote:
>By mistake, I sent it earlier to the wrong address.
>
>-- Forwarded message --
>From: Priyank Dwivedi 
>Date: 17 June 2016 at 14:50
>Subject: Matrix Constraints in R Optim
>To: r-help-ow...@r-project.org
>
>
>Hi,
>
>Below is the code snippet I wrote in R:
>
>The basic idea is to minimize error by optimizing set of values (in
>this
>scenario 12) in the form of a matrix. I defined the matrix elements as
>vector "*my.data.var" * and then stacked it into a matrix called
>"*my.data.var.mat"
>in the error function. *
>
>The only part that I can't figure out is "what if the column sum in
>the *my.data.var.mat
>needs to be <=1"; that's the constraint/s.. Where do I introduce it in
>the
>OPTIM solver or elsewhere?*
>
>
>
>
>
>
>*my.data.matrix.inj* <- as.matrix(my.data)  #convert DATA FRAME to
>MATRIX
>my.data.matrix.inj
>
>
>*my.data.matrix.time* <- as.matrix(my.data.2)  #convert DATA FRAME to
>MATRIX
>my.data.matrix.time
>
>
>*my.data.matrix.prod* <- as.matrix(my.data)  #convert DATA FRAME to
>MATRIX
>my.data.matrix.prod
>
>
>*my.data.var* <-
>c(2,0.8,0.5,0.2,0.2,0.1,10,0.01,0.02,0.2,0.1,0.01,2,0.8,0.5,0.2,0.2,0.1,10,0.01,0.02,0.2,0.1,0.01,2,0.8,0.5,0.2,0.2,0.1,10,0.01,0.02,0.2,0.1,0.01)
>my.data.var
>
>*my.data.qo* <- c(5990,150,199,996)   #Pre-Waterflood Production
>
>*my.data.timet0* <- 0 # starting condition for time
>
>
>*#FUNCTIONQjk.Cal.func* <-
>function(my.data.timet0,my.data.qo,my.data.matrix.time,
> my.data.matrix.inj,
>my.data.matrix.prod,my.data.var,my.data.var.mat)
>{
>
>  qjk.cal.matrix <- matrix(,nrow = nrow(my.data.matrix.prod),
>ncol=ncol(my.data.matrix.prod))
>
>  count <- 1
>  number <- 1
>  for(colnum in 1:ncol(my.data.matrix.prod))   # loop through all PROD
>wells columns
>  {
>sum <-0
>for(row in 1:nrow(my.data.matrix.prod)) #loop through all the rows
>{
>  sum <-0
>  deltaT <-0
>  expo <-0
>
>
>for(column in 1:ncol(my.data.matrix.inj)) #loop through all the
>injector columns to get the PRODUCT SUM
> {
>sum = sum +
>my.data.matrix.inj[row,column]*my.data.var.mat[colnum,number+column]
> }
>
>  if(count<2)
>  {
>deltaT<- my.data.matrix.time[row]
>  }
>  else
>  {deltaT <- my.data.matrix.time[row]-my.data.matrix.time[row-1]}
>
>
>  expo <- exp(-deltaT/my.data.var.mat[colnum,1])  #
>change here too
>
>  if(count<2)
>  {
>qjk.cal.matrix[row,colnum] = my.data.qo[colnum]*expo + (1-expo)*sum
>  }
>  else
>  {
>qjk.cal.matrix[row,colnum]=qjk.cal.matrix[row-1,colnum]*expo +
>(1-expo)*sum
>  }
>  count <- count+1
>}
>
>count <-1
>  }
>
>  qjk.cal.matrix  # RETURN CALCULATED MATRIX TO THE ERROR FUNCTION
>
>}
>
>
>*# ERROR FUNCTION* - FINDS DIFFERENCE BETWEEN CAL. MATRIX AND ORIGINAL
>MATRIX. Miminize the Error by changing my.data.var
>
>*Error.func* <- function(my.data.var)
>{
> #First convert vector(my.data.var) to MATRIX aand send it to calculate
>new MATRIX
>  *my.data.var.mat* <- matrix(my.data.var,nrow =
>ncol(my.data.matrix.prod),ncol = ncol(my.data.matrix.inj)+1,byrow =
>TRUE)
>
>*  Calc.Qjk.Value* <-
>Qjk.Cal.func(my.data.timet0,my.data.qo,my.data.matrix.time,
> my.data.matrix.inj,
>my.data.matrix.prod,my.data.var,my.data.var.mat)
>
>
>  diff.values <- my.data.matrix.prod-Calc.Qjk.Value#FIND DIFFERENCE
>BETWEEN CAL. MATRIX AND ORIGINAL MATRIX
>
>
>  Error <- ((colSums ((diff.values^2), na.rm = FALSE, dims =
>1))/nrow(my.data.matrix.inj))^0.5#sum of square root of the diff
>  print(paste(Error))
>
>Error_total <- sum(Error,na.rm=FALSE)/ncol(my.data.matrix.prod)   #
>total
>avg error
>
>
> * Error_total*
>}
>
># OPTIMIZE
>
>*optim*(*my.data.var*
>,Error.func,method="L-BFGS-B",upper=c(Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1))
>
>
>
>-- 
>Best Regards,
>PD
>
>
>
>-- 
>Best Regards,
>Priyank Dwivedi
>
>   [[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, 

[R] Problems with Mann-Kendall trend test

2016-06-17 Thread lily li
Dear R users,

Can anyone help me with mann-kendall trend test? I tried to use the newest
packages 'trend', and the function mk.test, but had problems in applying
the input data.

For example, res <- mk.test(Nile), Nile is a time-series data. But when I
use my dataset, with one column which is a time-series data, it says
"error: input must be ts object". How to do this? Thanks for your 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] Fwd: Matrix Constraints in R Optim

2016-06-17 Thread Priyank Dwivedi
By mistake, I sent it earlier to the wrong address.

-- Forwarded message --
From: Priyank Dwivedi 
Date: 17 June 2016 at 14:50
Subject: Matrix Constraints in R Optim
To: r-help-ow...@r-project.org


Hi,

Below is the code snippet I wrote in R:

The basic idea is to minimize error by optimizing set of values (in this
scenario 12) in the form of a matrix. I defined the matrix elements as
vector "*my.data.var" * and then stacked it into a matrix called
"*my.data.var.mat"
in the error function. *

The only part that I can't figure out is "what if the column sum in
the *my.data.var.mat
needs to be <=1"; that's the constraint/s.. Where do I introduce it in the
OPTIM solver or elsewhere?*






*my.data.matrix.inj* <- as.matrix(my.data)  #convert DATA FRAME to MATRIX
my.data.matrix.inj


*my.data.matrix.time* <- as.matrix(my.data.2)  #convert DATA FRAME to MATRIX
my.data.matrix.time


*my.data.matrix.prod* <- as.matrix(my.data)  #convert DATA FRAME to MATRIX
my.data.matrix.prod


*my.data.var* <-
c(2,0.8,0.5,0.2,0.2,0.1,10,0.01,0.02,0.2,0.1,0.01,2,0.8,0.5,0.2,0.2,0.1,10,0.01,0.02,0.2,0.1,0.01,2,0.8,0.5,0.2,0.2,0.1,10,0.01,0.02,0.2,0.1,0.01)
my.data.var

*my.data.qo* <- c(5990,150,199,996)   #Pre-Waterflood Production

*my.data.timet0* <- 0 # starting condition for time


*#FUNCTIONQjk.Cal.func* <-
function(my.data.timet0,my.data.qo,my.data.matrix.time,
 my.data.matrix.inj,
my.data.matrix.prod,my.data.var,my.data.var.mat)
{

  qjk.cal.matrix <- matrix(,nrow = nrow(my.data.matrix.prod),
ncol=ncol(my.data.matrix.prod))

  count <- 1
  number <- 1
  for(colnum in 1:ncol(my.data.matrix.prod))   # loop through all PROD
wells columns
  {
sum <-0
for(row in 1:nrow(my.data.matrix.prod)) #loop through all the rows
{
  sum <-0
  deltaT <-0
  expo <-0


for(column in 1:ncol(my.data.matrix.inj)) #loop through all the
injector columns to get the PRODUCT SUM
 {
sum = sum +
my.data.matrix.inj[row,column]*my.data.var.mat[colnum,number+column]
 }

  if(count<2)
  {
deltaT<- my.data.matrix.time[row]
  }
  else
  {deltaT <- my.data.matrix.time[row]-my.data.matrix.time[row-1]}


  expo <- exp(-deltaT/my.data.var.mat[colnum,1])  #
change here too

  if(count<2)
  {
qjk.cal.matrix[row,colnum] = my.data.qo[colnum]*expo + (1-expo)*sum
  }
  else
  {
qjk.cal.matrix[row,colnum]=qjk.cal.matrix[row-1,colnum]*expo +
(1-expo)*sum
  }
  count <- count+1
}

count <-1
  }

  qjk.cal.matrix  # RETURN CALCULATED MATRIX TO THE ERROR FUNCTION

}


*# ERROR FUNCTION* - FINDS DIFFERENCE BETWEEN CAL. MATRIX AND ORIGINAL
MATRIX. Miminize the Error by changing my.data.var

*Error.func* <- function(my.data.var)
{
  #First convert vector(my.data.var) to MATRIX aand send it to calculate
new MATRIX
  *my.data.var.mat* <- matrix(my.data.var,nrow =
ncol(my.data.matrix.prod),ncol = ncol(my.data.matrix.inj)+1,byrow = TRUE)

*  Calc.Qjk.Value* <-
Qjk.Cal.func(my.data.timet0,my.data.qo,my.data.matrix.time,
 my.data.matrix.inj,
my.data.matrix.prod,my.data.var,my.data.var.mat)


  diff.values <- my.data.matrix.prod-Calc.Qjk.Value#FIND DIFFERENCE
BETWEEN CAL. MATRIX AND ORIGINAL MATRIX


  Error <- ((colSums ((diff.values^2), na.rm = FALSE, dims =
1))/nrow(my.data.matrix.inj))^0.5#sum of square root of the diff
  print(paste(Error))

  Error_total <- sum(Error,na.rm=FALSE)/ncol(my.data.matrix.prod)   # total
avg error


 * Error_total*
}

# OPTIMIZE

*optim*(*my.data.var*
,Error.func,method="L-BFGS-B",upper=c(Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1,Inf,1,1,1,1,1))



-- 
Best Regards,
PD



-- 
Best Regards,
Priyank Dwivedi

[[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] merging df with world map

2016-06-17 Thread MacQueen, Don
And you can check what David and Jeff suggested like this:

intersect( df$COUNTRY, world_map$region )

If they have any values in common, that command will show them. (Note that
I said values in common, not countries in common.)

WARNING:
It appears that you have each country appearing more than once in both of
the data frames. Even if the country names were spelled the same (which
they are not in the first few rows), I would not care to predict the
outcome of a many-to-many merge. It probably won't make sense for showing
the data on a map.

-Don

-- 
Don MacQueen

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





On 6/17/16, 1:06 PM, "R-help on behalf of ch.elahe via R-help"
 wrote:

>Hi all,
>I want to use world map in ggplot2 and show my data on world map. my df
>is:
>
>
>$ COUNTRY   : chr  "DE" "DE" "FR" "FR" ..
>
>$ ContrastColor : int  9 9 9 9 13 9 9 9 9 ..
>
>$ quant : Factor w/ 4 levels "FAST","SLOW",..I need to
>merge my df with world_map data which is like this:
>
>
>world_map=map_data("world")
>data.frame':   99338 obs. of  6 variables:
>$ long : num  -69.9 -69.9 -69.9 -70 -70.1 ...
>$ lat  : num  12.5 12.4 12.4 12.5 12.5 ...
>$ group: num  1 1 1 1 1 1 1 1 1 1 ...
>$ order: int  1 2 3 4 5 6 7 8 9 10 ...
>$ region   : chr  "Aruba" "Aruba" "Aruba" "Aruba" ...
>$ subregion: chr  NA NA NA NA ...
>but by merging my df with world map data I get a data frame with zero
>observation in it,I use this command for merging:
>
>
>world_map=merge(world_map,df,by.x="region",by.y="COUNTRY")
>str(world_map)
>
>'data.frame':   0 obs. of  133 variables:
>$ region: chr
>$ long  : num
>$ lat   : num
>$ group : num
>$ order : int
>$ subregion : chr
>does anyone know what is the problem of this merging that I am currently
>using?
>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] merging df with world map

2016-06-17 Thread David Winsemius

> On Jun 17, 2016, at 1:06 PM, ch.elahe via R-help  wrote:
> 
> Hi all,
> I want to use world map in ggplot2 and show my data on world map. my df is:
> 
> 
>$ COUNTRY   : chr  "DE" "DE" "FR" "FR" ..
> 
>$ ContrastColor : int  9 9 9 9 13 9 9 9 9 ..
> 
>$ quant : Factor w/ 4 levels "FAST","SLOW",..I need to merge 
> my df with world_map data which is like this:
> 
> 
>world_map=map_data("world")
>data.frame':   99338 obs. of  6 variables:
>$ long : num  -69.9 -69.9 -69.9 -70 -70.1 ...
>$ lat  : num  12.5 12.4 12.4 12.5 12.5 ...
>$ group: num  1 1 1 1 1 1 1 1 1 1 ...
>$ order: int  1 2 3 4 5 6 7 8 9 10 ...
>$ region   : chr  "Aruba" "Aruba" "Aruba" "Aruba" ...
>$ subregion: chr  NA NA NA NA ...
> but by merging my df with world map data I get a data frame with zero 
> observation in it,I use this command for merging:
> 
> 
>world_map=merge(world_map,df,by.x="region",by.y="COUNTRY")
>str(world_map) 
> 
>'data.frame':   0 obs. of  133 variables:
>$ region: chr 
>$ long  : num 
>$ lat   : num 
>$ group : num 
>$ order : int 
>$ subregion : chr
> does anyone know what is the problem of this merging that I am currently 
> using?
> thanks for any help!

I would not expect a merger based on the one hand on two letter initials to 
match on the other hand fully spelled-out country names.


-- 

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] merging df with world map

2016-06-17 Thread Jeff Newmiller
You should look at your own data before you post. The information in COUNTRY is 
not the same as the information in region.

Also, dput is better than str for posting questions. 
-- 
Sent from my phone. Please excuse my brevity.

On June 17, 2016 1:06:29 PM PDT, "ch.elahe via R-help"  
wrote:
>Hi all,
>I want to use world map in ggplot2 and show my data on world map. my df
>is:
>
>
>$ COUNTRY   : chr  "DE" "DE" "FR" "FR" ..
>
>$ ContrastColor : int  9 9 9 9 13 9 9 9 9 ..
>
>$ quant : Factor w/ 4 levels "FAST","SLOW",..I need to
>merge my df with world_map data which is like this:
>
>
>world_map=map_data("world")
>data.frame':   99338 obs. of  6 variables:
>$ long : num  -69.9 -69.9 -69.9 -70 -70.1 ...
>$ lat  : num  12.5 12.4 12.4 12.5 12.5 ...
>$ group: num  1 1 1 1 1 1 1 1 1 1 ...
>$ order: int  1 2 3 4 5 6 7 8 9 10 ...
>$ region   : chr  "Aruba" "Aruba" "Aruba" "Aruba" ...
>$ subregion: chr  NA NA NA NA ...
>but by merging my df with world map data I get a data frame with zero
>observation in it,I use this command for merging:
>
>
>world_map=merge(world_map,df,by.x="region",by.y="COUNTRY")
>str(world_map) 
>
>'data.frame':   0 obs. of  133 variables:
>$ region: chr 
>$ long  : num 
>$ lat   : num 
>$ group : num 
>$ order : int 
>$ subregion : chr
>does anyone know what is the problem of this merging that I am
>currently using?
>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.

[[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] extracting coefficients from ar() output

2016-06-17 Thread David Winsemius

> On Jun 17, 2016, at 11:34 AM, T.Riedle  wrote:
> 
> Thank you very much.
> Here is the error message.
> 
>> WriteXLS(coefar,ExcelFileName = "R.xls",SheetNames="test")
> Error in WriteXLS(coefar, ExcelFileName = "R.xls", SheetNames = "test") : 
>  'x' must be the name of a data frame, the name of a list of data frames, a 
> data frame object, a list object of data frames.

sos::findFn("writeXLS")

So after tracking down the package that has writeXLS (also named writeXLS), I 
see that the example in the help page quotes the names of dataframe objects and 
the help page says the x values should be _character_ (rather than R 
symbol/names). You didn't provide a character vector as the first argument 
which, since it was unnamed, was therefore matched to the 'x' parameter.

-- 
David.
> 
> -Original Message-
> From: David Winsemius [mailto:dwinsem...@comcast.net] 
> Sent: 17 June 2016 19:27
> To: T.Riedle
> Cc: peter dalgaard; R-help@r-project.org
> Subject: Re: [R] extracting coefficients from ar() output
> 
> 
>> On Jun 17, 2016, at 11:23 AM, T.Riedle  wrote:
>> 
>> Thank you very much, Peter. I played a bit and found a solution. 
>>> rollingarmaols<-rollapply(data,width=36,function(data) 
>>> ar(data,order.max=1,method="ols"))
>>> coefar<-apply(rollingarmaols, 1, getElement, "ar")
>>> head(coefar,50)
>> [1] 0.9430692 0.9140253 0.9236898 0.9426744 0.9465110 0.9318470 
>> 0.9033054 0.9206048 0.9243736 0.9129082 [11] 0.9181811 0.9350779 
>> 0.9464205 0.9410245 0.9335568 0.9201928 0.8869414 0.8320984 0.8185671 
>> 0.7989182 [21] 0.7454876 0.6388364 0.6797046 0.6704642 0.7077033 
>> 0.8895698 0.8755445 0.8965050 0.8969068 0.8891385 [31] 0.9284835 
>> 0.9628297 0.9674624 0.9524462 0.9423693 0.9629843 0.9996613 1.295 
>> 0.9845222 0.9877242 [41] 0.9582863 0.9596756 0.9415847 0.9471677 
>> 0.9447052 0.9324048 0.9171082 0.8928825 0.9133751 0.9203662
>> 
>> I am trying to export the data to Excel using WriteXLS:
>>> WriteXLS(coefar, ExcelFileName = "R.xls", SheetNames = test)
> 
> Just a guess (since you didn't include the error message) but do you have a 
> length-1 character vector named `test`. I thought not. So try using 
> SheetNames = 'test'
> 
> --
> David.
>> 
>> Unfortunately, it doesn't work. How can I export the data to Excel?
>> 
>> -Original Message-
>> From: peter dalgaard [mailto:pda...@gmail.com]
>> Sent: 16 June 2016 18:49
>> To: William Dunlap
>> Cc: T.Riedle; R-help@r-project.org
>> Subject: Re: [R] extracting coefficients from ar() output
>> 
>> 
>>> On 16 Jun 2016, at 17:07 , William Dunlap via R-help  
>>> wrote:
>>> 
>>> help(ar) should tell you how to get the coefficients.  If, like me, 
>>> you don't read help files, you can use str() to look at the structure 
>>> of ar's output.
>> 
>> Also notice that the output of rollapply is not an ar object. More likely a 
>> list of them, so  try rollingarma[[i]]$ar or maybe lapply(rollingarma, 
>> function(x)x$ar) or sapply(rollingarma, "[[", "ar") or...
>> 
>>> 
 str(a <- ar(sin(1:30), aic=TRUE))
>>> List of 14
>>> $ order   : int 2
>>> $ ar  : num [1:2] 1.011 -0.918
>>> $ var.pred: num 0.0654
>>> $ x.mean  : num 0.00934
>>> $ aic : Named num [1:15] 61.215 53.442 0 0.985 2.917 ...
>>> ..- attr(*, "names")= chr [1:15] "0" "1" "2" "3" ...
>>> $ n.used  : int 30
>>> $ order.max   : num 14
>>> $ partialacf  : num [1:14, 1, 1] 0.5273 -0.9179 -0.1824 -0.0477 -0.0393 ...
>>> $ resid   : num [1:30] NA NA -0.0145 -0.0734 -0.0725 ...
>>> $ method  : chr "Yule-Walker"
>>> $ series  : chr "sin(1:30)"
>>> $ frequency   : num 1
>>> $ call: language ar(x = sin(1:30), aic = TRUE)
>>> $ asy.var.coef: num [1:2, 1:2] 0.00583 -0.00308 -0.00308 0.00583
>>> - attr(*, "class")= chr "ar"
 a$ar
>>> [1]  1.0112512 -0.9178554
>>> 
>>> 
>>> 
>>> 
>>> Bill Dunlap
>>> TIBCO Software
>>> wdunlap tibco.com
>>> 
>>> On Thu, Jun 16, 2016 at 4:34 AM, T.Riedle  wrote:
>>> 
 Hi everybody,
 
 I am trying to run an AR1 model using the ar() function as shown below.
 
> rollingarma<-rollapply(data,width=36,function(data)
> ar(data,aic=TRUE))
> head(rollingarma,50)
order arvar.pred x.mean   aicn.used order.max
 partialacf resid  methodseries
 [1,] 1 0.7433347 1.382908 49.99861 Numeric,16 36 15
 Numeric,15 Numeric,36 "Yule-Walker" "data"
 [2,] 1 0.7410181 1.565755 49.94778 Numeric,16 36 15
 Numeric,15 Numeric,36 "Yule-Walker" "data"
 [3,] 1 0.7636966 1.660581 49.86861 Numeric,16 36 15
 Numeric,15 Numeric,36 "Yule-Walker" "data"
 
 
 I get the table as shown above if I use head().
 
 How can I extract the ar coefficients from this table? I have 
 already tried coef() and rollingarma$ar but both do not work.
 What can I do?
 
 Thanks for your help.
 
 
  [[alternative HTML 

[R] merging df with world map

2016-06-17 Thread ch.elahe via R-help
Hi all,
I want to use world map in ggplot2 and show my data on world map. my df is:


$ COUNTRY   : chr  "DE" "DE" "FR" "FR" ..

$ ContrastColor : int  9 9 9 9 13 9 9 9 9 ..

$ quant : Factor w/ 4 levels "FAST","SLOW",..I need to merge my 
df with world_map data which is like this:


world_map=map_data("world")
data.frame':   99338 obs. of  6 variables:
$ long : num  -69.9 -69.9 -69.9 -70 -70.1 ...
$ lat  : num  12.5 12.4 12.4 12.5 12.5 ...
$ group: num  1 1 1 1 1 1 1 1 1 1 ...
$ order: int  1 2 3 4 5 6 7 8 9 10 ...
$ region   : chr  "Aruba" "Aruba" "Aruba" "Aruba" ...
$ subregion: chr  NA NA NA NA ...
but by merging my df with world map data I get a data frame with zero 
observation in it,I use this command for merging:


world_map=merge(world_map,df,by.x="region",by.y="COUNTRY")
str(world_map) 

'data.frame':   0 obs. of  133 variables:
$ region: chr 
$ long  : num 
$ lat   : num 
$ group : num 
$ order : int 
$ subregion : chr
does anyone know what is the problem of this merging that I am currently using?
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.


Re: [R] Excluding coordinates that fall within a circle

2016-06-17 Thread Bert Gunter
...
and adding, perhaps, to what David and Jeff told you:

Let ctr = c(ctr.lat, ctr.long) be the center of a bird colony (this
can be vectorized for many centers).

Then you need to figure out how much change in latitude and longitude
a distance of 500 meters is at that ctr (I think latitudes are easy;
it's longitudes that vary in distance depending on where you. But I
hasten to add that I ain't an expert). You can approximate this by
pretending the latitudes and longitude are perpendicular on a plane
unless you are close to the poles.I strongly suspect there are
functions in geostatistics and/or ecology packages that do this:
search (e.g. web or rseek.org) on "convert distance to latitude and
longitude" or similar (this seemed to yield useful results when I
tried it). Then apply David's (and Jeff's) suggestions.

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 Fri, Jun 17, 2016 at 10:26 AM, Alice Domalik  wrote:
> Hi List,
>
> I'm working with some bird tracking data, and to filter the data set, I need 
> to exclude points taken at the colony.
> I would like to exclude coordinates from within a 500 meter radius of a point 
> centered on the colony.
> However, as an R novice, I'm not sure how to accomplish this.
>
> My df looks like this:
>
> AnimalID Latitude Longitude Datetime
>
> Any suggestions would be greatly appreciated.
>
>
> [[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] extracting coefficients from ar() output

2016-06-17 Thread T.Riedle
Thank you very much.
Here is the error message.

> WriteXLS(coefar,ExcelFileName = "R.xls",SheetNames="test")
Error in WriteXLS(coefar, ExcelFileName = "R.xls", SheetNames = "test") : 
  'x' must be the name of a data frame, the name of a list of data frames, a 
data frame object, a list object of data frames.

-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net] 
Sent: 17 June 2016 19:27
To: T.Riedle
Cc: peter dalgaard; R-help@r-project.org
Subject: Re: [R] extracting coefficients from ar() output


> On Jun 17, 2016, at 11:23 AM, T.Riedle  wrote:
> 
> Thank you very much, Peter. I played a bit and found a solution. 
>> rollingarmaols<-rollapply(data,width=36,function(data) 
>> ar(data,order.max=1,method="ols"))
>> coefar<-apply(rollingarmaols, 1, getElement, "ar")
>> head(coefar,50)
> [1] 0.9430692 0.9140253 0.9236898 0.9426744 0.9465110 0.9318470 
> 0.9033054 0.9206048 0.9243736 0.9129082 [11] 0.9181811 0.9350779 
> 0.9464205 0.9410245 0.9335568 0.9201928 0.8869414 0.8320984 0.8185671 
> 0.7989182 [21] 0.7454876 0.6388364 0.6797046 0.6704642 0.7077033 
> 0.8895698 0.8755445 0.8965050 0.8969068 0.8891385 [31] 0.9284835 
> 0.9628297 0.9674624 0.9524462 0.9423693 0.9629843 0.9996613 1.295 
> 0.9845222 0.9877242 [41] 0.9582863 0.9596756 0.9415847 0.9471677 
> 0.9447052 0.9324048 0.9171082 0.8928825 0.9133751 0.9203662
> 
> I am trying to export the data to Excel using WriteXLS:
>> WriteXLS(coefar, ExcelFileName = "R.xls", SheetNames = test)

Just a guess (since you didn't include the error message) but do you have a 
length-1 character vector named `test`. I thought not. So try using SheetNames 
= 'test'

--
David.
> 
> Unfortunately, it doesn't work. How can I export the data to Excel?
> 
> -Original Message-
> From: peter dalgaard [mailto:pda...@gmail.com]
> Sent: 16 June 2016 18:49
> To: William Dunlap
> Cc: T.Riedle; R-help@r-project.org
> Subject: Re: [R] extracting coefficients from ar() output
> 
> 
>> On 16 Jun 2016, at 17:07 , William Dunlap via R-help  
>> wrote:
>> 
>> help(ar) should tell you how to get the coefficients.  If, like me, 
>> you don't read help files, you can use str() to look at the structure 
>> of ar's output.
> 
> Also notice that the output of rollapply is not an ar object. More likely a 
> list of them, so  try rollingarma[[i]]$ar or maybe lapply(rollingarma, 
> function(x)x$ar) or sapply(rollingarma, "[[", "ar") or...
> 
>> 
>>> str(a <- ar(sin(1:30), aic=TRUE))
>> List of 14
>> $ order   : int 2
>> $ ar  : num [1:2] 1.011 -0.918
>> $ var.pred: num 0.0654
>> $ x.mean  : num 0.00934
>> $ aic : Named num [1:15] 61.215 53.442 0 0.985 2.917 ...
>> ..- attr(*, "names")= chr [1:15] "0" "1" "2" "3" ...
>> $ n.used  : int 30
>> $ order.max   : num 14
>> $ partialacf  : num [1:14, 1, 1] 0.5273 -0.9179 -0.1824 -0.0477 -0.0393 ...
>> $ resid   : num [1:30] NA NA -0.0145 -0.0734 -0.0725 ...
>> $ method  : chr "Yule-Walker"
>> $ series  : chr "sin(1:30)"
>> $ frequency   : num 1
>> $ call: language ar(x = sin(1:30), aic = TRUE)
>> $ asy.var.coef: num [1:2, 1:2] 0.00583 -0.00308 -0.00308 0.00583
>> - attr(*, "class")= chr "ar"
>>> a$ar
>> [1]  1.0112512 -0.9178554
>> 
>> 
>> 
>> 
>> Bill Dunlap
>> TIBCO Software
>> wdunlap tibco.com
>> 
>> On Thu, Jun 16, 2016 at 4:34 AM, T.Riedle  wrote:
>> 
>>> Hi everybody,
>>> 
>>> I am trying to run an AR1 model using the ar() function as shown below.
>>> 
 rollingarma<-rollapply(data,width=36,function(data)
 ar(data,aic=TRUE))
 head(rollingarma,50)
>>> order arvar.pred x.mean   aicn.used order.max
>>> partialacf resid  methodseries
>>> [1,] 1 0.7433347 1.382908 49.99861 Numeric,16 36 15
>>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>>> [2,] 1 0.7410181 1.565755 49.94778 Numeric,16 36 15
>>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>>> [3,] 1 0.7636966 1.660581 49.86861 Numeric,16 36 15
>>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>>> 
>>> 
>>> I get the table as shown above if I use head().
>>> 
>>> How can I extract the ar coefficients from this table? I have 
>>> already tried coef() and rollingarma$ar but both do not work.
>>> What can I do?
>>> 
>>> Thanks for your 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.
>>> 
>> 
>>  [[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
>> 

Re: [R] Excluding coordinates that fall within a circle

2016-06-17 Thread Jeff Newmiller
This is mostly a domain-specific question about coordinate conversion and 
algebra, not really about R. However, there are packages that could be useful 
for this problem that are discussed in the CRAN "Analysis of Spatial Data" Task 
View [1] and on the R-sig-geo mailing list [2].

Some points to get you started:

1) You need to know about georeferencing coordinate systems. In particular, 
what LatLon system are the coordinates you have measured in. The range of 
values in your data will be something to mention when you ask your question on 
R-sig-geo if they are to help you figure that out. 

2) A small sample of your data extracted from R with the dput function will be 
helpful. 

3) Read the Posting Guide. Note in particular that you need to tell your email 
client to use plain text format if you want to insure that the recipients see 
what you sent instead of some garbled version of it. 

[1] https://cran.r-project.org/view=Spatial
[2] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
-- 
Sent from my phone. Please excuse my brevity.

On June 17, 2016 10:26:32 AM PDT, Alice Domalik  wrote:
>Hi List, 
>
>I'm working with some bird tracking data, and to filter the data set, I
>need to exclude points taken at the colony. 
>I would like to exclude coordinates from within a 500 meter radius of a
>point centered on the colony. 
>However, as an R novice, I'm not sure how to accomplish this. 
>
>My df looks like this: 
>
>AnimalID Latitude Longitude Datetime 
>
>Any suggestions would be greatly appreciated. 
>
>
>   [[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] extracting coefficients from ar() output

2016-06-17 Thread David Winsemius

> On Jun 17, 2016, at 11:23 AM, T.Riedle  wrote:
> 
> Thank you very much, Peter. I played a bit and found a solution. 
>> rollingarmaols<-rollapply(data,width=36,function(data) 
>> ar(data,order.max=1,method="ols"))
>> coefar<-apply(rollingarmaols, 1, getElement, "ar")
>> head(coefar,50)
> [1] 0.9430692 0.9140253 0.9236898 0.9426744 0.9465110 0.9318470 0.9033054 
> 0.9206048 0.9243736 0.9129082
> [11] 0.9181811 0.9350779 0.9464205 0.9410245 0.9335568 0.9201928 0.8869414 
> 0.8320984 0.8185671 0.7989182
> [21] 0.7454876 0.6388364 0.6797046 0.6704642 0.7077033 0.8895698 0.8755445 
> 0.8965050 0.8969068 0.8891385
> [31] 0.9284835 0.9628297 0.9674624 0.9524462 0.9423693 0.9629843 0.9996613 
> 1.295 0.9845222 0.9877242
> [41] 0.9582863 0.9596756 0.9415847 0.9471677 0.9447052 0.9324048 0.9171082 
> 0.8928825 0.9133751 0.9203662
> 
> I am trying to export the data to Excel using WriteXLS:
>> WriteXLS(coefar, ExcelFileName = "R.xls", SheetNames = test)

Just a guess (since you didn't include the error message) but do you have a 
length-1 character vector named `test`. I thought not. So try using SheetNames 
= 'test'

-- 
David.
> 
> Unfortunately, it doesn't work. How can I export the data to Excel?
> 
> -Original Message-
> From: peter dalgaard [mailto:pda...@gmail.com] 
> Sent: 16 June 2016 18:49
> To: William Dunlap
> Cc: T.Riedle; R-help@r-project.org
> Subject: Re: [R] extracting coefficients from ar() output
> 
> 
>> On 16 Jun 2016, at 17:07 , William Dunlap via R-help  
>> wrote:
>> 
>> help(ar) should tell you how to get the coefficients.  If, like me, 
>> you don't read help files, you can use str() to look at the structure 
>> of ar's output.
> 
> Also notice that the output of rollapply is not an ar object. More likely a 
> list of them, so  try rollingarma[[i]]$ar or maybe lapply(rollingarma, 
> function(x)x$ar) or sapply(rollingarma, "[[", "ar") or...
> 
>> 
>>> str(a <- ar(sin(1:30), aic=TRUE))
>> List of 14
>> $ order   : int 2
>> $ ar  : num [1:2] 1.011 -0.918
>> $ var.pred: num 0.0654
>> $ x.mean  : num 0.00934
>> $ aic : Named num [1:15] 61.215 53.442 0 0.985 2.917 ...
>> ..- attr(*, "names")= chr [1:15] "0" "1" "2" "3" ...
>> $ n.used  : int 30
>> $ order.max   : num 14
>> $ partialacf  : num [1:14, 1, 1] 0.5273 -0.9179 -0.1824 -0.0477 -0.0393 ...
>> $ resid   : num [1:30] NA NA -0.0145 -0.0734 -0.0725 ...
>> $ method  : chr "Yule-Walker"
>> $ series  : chr "sin(1:30)"
>> $ frequency   : num 1
>> $ call: language ar(x = sin(1:30), aic = TRUE)
>> $ asy.var.coef: num [1:2, 1:2] 0.00583 -0.00308 -0.00308 0.00583
>> - attr(*, "class")= chr "ar"
>>> a$ar
>> [1]  1.0112512 -0.9178554
>> 
>> 
>> 
>> 
>> Bill Dunlap
>> TIBCO Software
>> wdunlap tibco.com
>> 
>> On Thu, Jun 16, 2016 at 4:34 AM, T.Riedle  wrote:
>> 
>>> Hi everybody,
>>> 
>>> I am trying to run an AR1 model using the ar() function as shown below.
>>> 
 rollingarma<-rollapply(data,width=36,function(data) 
 ar(data,aic=TRUE))
 head(rollingarma,50)
>>> order arvar.pred x.mean   aicn.used order.max
>>> partialacf resid  methodseries
>>> [1,] 1 0.7433347 1.382908 49.99861 Numeric,16 36 15
>>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>>> [2,] 1 0.7410181 1.565755 49.94778 Numeric,16 36 15
>>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>>> [3,] 1 0.7636966 1.660581 49.86861 Numeric,16 36 15
>>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>>> 
>>> 
>>> I get the table as shown above if I use head().
>>> 
>>> How can I extract the ar coefficients from this table? I have already 
>>> tried coef() and rollingarma$ar but both do not work.
>>> What can I do?
>>> 
>>> Thanks for your 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.
>>> 
>> 
>>  [[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.
> 
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 
> Frederiksberg, Denmark
> Phone: (+45)38153501
> Office: A 4.23
> Email: pd@cbs.dk  Priv: pda...@gmail.com
> 
> __
> 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 

Re: [R] extracting coefficients from ar() output

2016-06-17 Thread T.Riedle
Thank you very much, Peter. I played a bit and found a solution. 
> rollingarmaols<-rollapply(data,width=36,function(data) 
> ar(data,order.max=1,method="ols"))
> coefar<-apply(rollingarmaols, 1, getElement, "ar")
> head(coefar,50)
 [1] 0.9430692 0.9140253 0.9236898 0.9426744 0.9465110 0.9318470 0.9033054 
0.9206048 0.9243736 0.9129082
[11] 0.9181811 0.9350779 0.9464205 0.9410245 0.9335568 0.9201928 0.8869414 
0.8320984 0.8185671 0.7989182
[21] 0.7454876 0.6388364 0.6797046 0.6704642 0.7077033 0.8895698 0.8755445 
0.8965050 0.8969068 0.8891385
[31] 0.9284835 0.9628297 0.9674624 0.9524462 0.9423693 0.9629843 0.9996613 
1.295 0.9845222 0.9877242
[41] 0.9582863 0.9596756 0.9415847 0.9471677 0.9447052 0.9324048 0.9171082 
0.8928825 0.9133751 0.9203662

I am trying to export the data to Excel using WriteXLS:
> WriteXLS(coefar, ExcelFileName = "R.xls", SheetNames = test)

Unfortunately, it doesn't work. How can I export the data to Excel?

-Original Message-
From: peter dalgaard [mailto:pda...@gmail.com] 
Sent: 16 June 2016 18:49
To: William Dunlap
Cc: T.Riedle; R-help@r-project.org
Subject: Re: [R] extracting coefficients from ar() output


> On 16 Jun 2016, at 17:07 , William Dunlap via R-help  
> wrote:
> 
> help(ar) should tell you how to get the coefficients.  If, like me, 
> you don't read help files, you can use str() to look at the structure 
> of ar's output.

Also notice that the output of rollapply is not an ar object. More likely a 
list of them, so  try rollingarma[[i]]$ar or maybe lapply(rollingarma, 
function(x)x$ar) or sapply(rollingarma, "[[", "ar") or...

> 
>> str(a <- ar(sin(1:30), aic=TRUE))
> List of 14
> $ order   : int 2
> $ ar  : num [1:2] 1.011 -0.918
> $ var.pred: num 0.0654
> $ x.mean  : num 0.00934
> $ aic : Named num [1:15] 61.215 53.442 0 0.985 2.917 ...
>  ..- attr(*, "names")= chr [1:15] "0" "1" "2" "3" ...
> $ n.used  : int 30
> $ order.max   : num 14
> $ partialacf  : num [1:14, 1, 1] 0.5273 -0.9179 -0.1824 -0.0477 -0.0393 ...
> $ resid   : num [1:30] NA NA -0.0145 -0.0734 -0.0725 ...
> $ method  : chr "Yule-Walker"
> $ series  : chr "sin(1:30)"
> $ frequency   : num 1
> $ call: language ar(x = sin(1:30), aic = TRUE)
> $ asy.var.coef: num [1:2, 1:2] 0.00583 -0.00308 -0.00308 0.00583
> - attr(*, "class")= chr "ar"
>> a$ar
> [1]  1.0112512 -0.9178554
> 
> 
> 
> 
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
> 
> On Thu, Jun 16, 2016 at 4:34 AM, T.Riedle  wrote:
> 
>> Hi everybody,
>> 
>> I am trying to run an AR1 model using the ar() function as shown below.
>> 
>>> rollingarma<-rollapply(data,width=36,function(data) 
>>> ar(data,aic=TRUE))
>>> head(rollingarma,50)
>>  order arvar.pred x.mean   aicn.used order.max
>> partialacf resid  methodseries
>> [1,] 1 0.7433347 1.382908 49.99861 Numeric,16 36 15
>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>> [2,] 1 0.7410181 1.565755 49.94778 Numeric,16 36 15
>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>> [3,] 1 0.7636966 1.660581 49.86861 Numeric,16 36 15
>> Numeric,15 Numeric,36 "Yule-Walker" "data"
>> 
>> 
>> I get the table as shown above if I use head().
>> 
>> How can I extract the ar coefficients from this table? I have already 
>> tried coef() and rollingarma$ar but both do not work.
>> What can I do?
>> 
>> Thanks for your 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.
>> 
> 
>   [[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.

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

__
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] Excluding coordinates that fall within a circle

2016-06-17 Thread Tom Wright
I'm no expert here but I have recently been playing with the package
'geosphere' it contains plenty of options to calculate distance
between two coordinates specified as lat and long.

install.packages('geosphere') # only needed once

library(geosphere)
coord1 <- c(43.60923,-79.322799)
coord2 <- c(43.683266,-79.323703)

distHaversine(coord1,coord2)

Once you have a vector of distances you can then filter your df

df <- df[df$distance < radius,]

On Fri, Jun 17, 2016 at 1:26 PM, Alice Domalik  wrote:
> Hi List,
>
> I'm working with some bird tracking data, and to filter the data set, I need 
> to exclude points taken at the colony.
> I would like to exclude coordinates from within a 500 meter radius of a point 
> centered on the colony.
> However, as an R novice, I'm not sure how to accomplish this.
>
> My df looks like this:
>
> AnimalID Latitude Longitude Datetime
>
> Any suggestions would be greatly appreciated.
>
>
> [[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] Excluding coordinates that fall within a circle

2016-06-17 Thread David Winsemius

> On Jun 17, 2016, at 10:26 AM, Alice Domalik  wrote:
> 
> Hi List, 
> 
> I'm working with some bird tracking data, and to filter the data set, I need 
> to exclude points taken at the colony. 
> I would like to exclude coordinates from within a 500 meter radius of a point 
> centered on the colony. 
> However, as an R novice, I'm not sure how to accomplish this. 
> 
> My df looks like this: 
> 
> AnimalID Latitude Longitude Datetime 


Use the first argument of the "[" function to select rows that meet your 
requirement. I constructed values in hte unit square and select only items in 
hte corners by excluding values within 0.5 units of the center, (0.5,0.5)


dfrm <- data.frame(ID=1:100, lat=runif(100), long=runif(100), 
   Datetime=as.POSIXct(runif(100)*1,origin="1970-01-01") )
reduced <- dfrm[ (dfrm$lat - .5)^2+(dfrm$long-.5)^2 > .25 , ]
with( reduced, plot(lat,long) )



Rplot.pdf
Description: Adobe PDF document


Probably should have plotted (long, lat), and it might have been more eser 
freindly to use subset instead of `[ logical-vector, ]`  but I think this 
demonstrates the essential steps.

-- 

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] Excluding coordinates that fall within a circle

2016-06-17 Thread MacQueen, Don
This would be a good question for R-sig-geo.

To do it properly, there would be a few steps:

1. transform from lat/long (units=degrees) to projected coordinate system
(units = meters)

2. find one of the R functions for calculating distances (there are
several)

3. subset the data according to your distance threshold

The sp package provides a lot of the fundamental tools for these kinds of
things.

The spDists() function in the sp package may take care of both steps 1 and
2.

The overhead required to learn R's spatial capabilities can be
significant, but I think will be worth it if you will be needing to do a
lot of spatial manipulations.

-Don

-- 
Don MacQueen

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





On 6/17/16, 10:26 AM, "R-help on behalf of Alice Domalik"
 wrote:

>Hi List, 
>
>I'm working with some bird tracking data, and to filter the data set, I
>need to exclude points taken at the colony.
>I would like to exclude coordinates from within a 500 meter radius of a
>point centered on the colony.
>However, as an R novice, I'm not sure how to accomplish this.
>
>My df looks like this:
>
>AnimalID Latitude Longitude Datetime
>
>Any suggestions would be greatly appreciated.
>
>
>   [[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.


[R] Excluding coordinates that fall within a circle

2016-06-17 Thread Alice Domalik
Hi List, 

I'm working with some bird tracking data, and to filter the data set, I need to 
exclude points taken at the colony. 
I would like to exclude coordinates from within a 500 meter radius of a point 
centered on the colony. 
However, as an R novice, I'm not sure how to accomplish this. 

My df looks like this: 

AnimalID Latitude Longitude Datetime 

Any suggestions would be greatly appreciated. 


[[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] Obtaining and extracting cells sample in cross-tabulation

2016-06-17 Thread MacQueen, Don
I don't know exactly what you mean, but perhaps this will get you started:

This:
subset(Data, X4==1 & X5==1, select=c(X1, X2, X3))
will extract the continuous variables in the cross-tabulation cell for
which X4 and X5 are both equal to one. Similar commands will extract the
other cells.

Of course, this gets tedious if your categorical variables have more than
two levels.

-Don

-- 
Don MacQueen

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





On 6/17/16, 5:25 AM, "R-help on behalf of Gafar Matanmi Oyeyemi"
 wrote:

>Hello everyone,
>I'm writing a function in R but was stalked.
>I have a data set that contains mixture of categorical and continuous
>variables. I want to use the categorical variables to cross-tabulate the
>data and extract the observations in the resulting cells that contain only
>continuous variables.
>
>Data.
>X1   X2   X3   X4   X5
>2.4  5.3  4.80  1
>4.2  3.2  4.81  1
>3.3  4.4  5.10  0
>5.2  1.1  2.51  0
>.
>.
>.
>3.7  2.8  3.80  1
>
>Thanks.
>
>   [[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.


[R] import of data set and warning from R CMD check

2016-06-17 Thread Pascal A. Niklaus
Hi all,

When checking an R package, I get:

|Consider adding importFrom("datasets","CO2")

(this data set is used in some example code)

However, when I add the suggested 'importFrom' statement to NAMESPACE 
(using roxygen2), I get
|
|Error :object ‘CO2’ is not exported by 'namespace:datasets'|
||
|I understand that datasets are not exported, and the comment printed by 
'R CMD check' seems not to have any consequences, but it nevertheless 
seems inconsistent to me. But maybe I miss something here...

Pascal

|

-- 

Dr. Pascal A. Niklaus
Department of Evolutionary Biology and Environmental Studies
University of Zurich
Winterthurerstrasse 190
CH-8057 Zurich / Switzerland




[[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] what is the best way to process the following data?

2016-06-17 Thread William Dunlap via R-help
You can make a step-number variable with cumsum(grepl("^Step ", ...)) and
use it as the splitting variable in split.  E.g.,

> dat <- read.table(yourFile, stringsAsFactors=FALSE, sep="|",
colClasses=c("NULL", "character", "character", "character"),
col.names=c("Junk","Date","Time","Type"))
> dat <- with(dat, data.frame(DateTime=as.POSIXct(paste(Date, Time),
format="%m/%d/%Y %H:%M:%S"), Type=Type, stringsAsFactors=FALSE))
> head(dat)
 DateTime   Type
1 2016-06-16 03:44:16   Step 001
2 2016-06-16 03:44:16 Initialization
3 2016-06-16 03:44:16Filters
4 2016-06-16 03:45:03Split Items
5 2016-06-16 03:46:20   Sort
6 2016-06-16 03:46:43  Check
> split(dat, cumsum(grepl("^Step ", dat$Type)))
$`1`
  DateTimeType
1  2016-06-16 03:44:16Step 001
2  2016-06-16 03:44:16  Initialization
...
13 2016-06-16 04:06:33 BOP processing for 7,960 items has finished

$`2`
  DateTimeType
14 2016-06-16 04:06:34Step 002
15 2016-06-16 04:06:35  Initialization
...



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Thu, Jun 16, 2016 at 8:42 PM, Satish Vadlamani <
satish.vadlam...@gmail.com> wrote:

> Hello,
> I have multiple text files with the format shown below (see the two files
> that I pasted below). Each file is a log of multiple steps that the system
> has processed and for each step, it has shown the start time of the process
> step. For example, in the data below, the filter started at
> |06/16/2016|03:44:16
>
> How to read this data so that Step 001 is one data frame, Step 002 is
> another, and so on. After I do this, I will then compare the Step 001 times
> with and without parallel process.
>
> For example, the files pasted below "no_parallel_process_SLS_4.txt" and
> "parallel_process_SLS_4.txt" will make it clear what I am trying to do. I
> want to compare the parallel process times taken for each step with the non
> parallel process times.
>
> If there are better ways of performing this task that what I am thinking,
> could you let me know? Thanks in advance.
>
> Satish Vadlamani
>
> >> parallel_process_file.txt
>
> |06/16/2016|03:44:16|Step 001
> |06/16/2016|03:44:16|Initialization
> |06/16/2016|03:44:16|Filters
> |06/16/2016|03:45:03|Split Items
> |06/16/2016|03:46:20|Sort
> |06/16/2016|03:46:43|Check
> |06/16/2016|04:01:13|Save
> |06/16/2016|04:04:35|Update preparation
> |06/16/2016|04:04:36|Update comparison
> |06/16/2016|04:04:38|Update
> |06/16/2016|04:04:38|Update
> |06/16/2016|04:06:01|Close
> |06/16/2016|04:06:33|BOP processing for 7,960 items has finished
> |06/16/2016|04:06:34|Step 002
> |06/16/2016|04:06:35|Initialization
> |06/16/2016|04:06:35|Filters
> |06/16/2016|04:07:14|Split Items
> |06/16/2016|04:08:57|Sort
> |06/16/2016|04:09:06|Check
> |06/16/2016|04:26:36|Save
> |06/16/2016|04:39:29|Update preparation
> |06/16/2016|04:39:31|Update comparison
> |06/16/2016|04:39:43|Update
> |06/16/2016|04:39:45|Update
> |06/16/2016|04:44:28|Close
> |06/16/2016|04:45:26|BOP processing for 8,420 items has finished
> |06/16/2016|04:45:27|Step 003
> |06/16/2016|04:45:27|Initialization
> |06/16/2016|04:45:27|Filters
> |06/16/2016|04:48:50|Split Items
> |06/16/2016|04:55:15|Sort
> |06/16/2016|04:55:40|Check
> |06/16/2016|05:13:35|Save
> |06/16/2016|05:17:34|Update preparation
> |06/16/2016|05:17:34|Update comparison
> |06/16/2016|05:17:36|Update
> |06/16/2016|05:17:36|Update
> |06/16/2016|05:19:29|Close
> |06/16/2016|05:19:49|BOP processing for 8,876 items has finished
> |06/16/2016|05:19:50|Step 004
> |06/16/2016|05:19:50|Initialization
> |06/16/2016|05:19:50|Filters
> |06/16/2016|05:20:43|Split Items
> |06/16/2016|05:22:14|Sort
> |06/16/2016|05:22:29|Check
> |06/16/2016|05:37:27|Save
> |06/16/2016|05:38:43|Update preparation
> |06/16/2016|05:38:44|Update comparison
> |06/16/2016|05:38:45|Update
> |06/16/2016|05:38:45|Update
> |06/16/2016|05:39:09|Close
> |06/16/2016|05:39:19|BOP processing for 5,391 items has finished
> |06/16/2016|05:39:20|Step 005
> |06/16/2016|05:39:20|Initialization
> |06/16/2016|05:39:20|Filters
> |06/16/2016|05:39:57|Split Items
> |06/16/2016|05:40:21|Sort
> |06/16/2016|05:40:24|Check
> |06/16/2016|05:46:01|Save
> |06/16/2016|05:46:54|Update preparation
> |06/16/2016|05:46:54|Update comparison
> |06/16/2016|05:46:54|Update
> |06/16/2016|05:46:55|Update
> |06/16/2016|05:47:24|Close
> |06/16/2016|05:47:31|BOP processing for 3,016 items has finished
> |06/16/2016|05:47:32|Step 006
> |06/16/2016|05:47:32|Initialization
> |06/16/2016|05:47:32|Filters
> |06/16/2016|05:47:32|Update preparation
> |06/16/2016|05:47:32|Update comparison
> |06/16/2016|05:47:32|Update
> |06/16/2016|05:47:32|Close
> |06/16/2016|05:47:33|BOP processing for 0 items has finished
> |06/16/2016|05:47:33|Step 007
> |06/16/2016|05:47:33|Initialization
> 

Re: [R] Obtaining and extracting cells sample in cross-tabulation

2016-06-17 Thread David L Carlson
Your request is not clear. If you want to analyze the numeric variables by the 
groups formed by the categorical variables, try something like this.

> # Create reproducible data
> set.seed(42)
> x <- data.frame(matrix(rnorm(75, 5), 25), X4=sample(0:1, 25, 
+ replace=TRUE), X5=sample(0:1, 25, replace=TRUE))
> head(x)
X1   X2   X3 X4 X5
1 6.370958 4.569531 5.321925  1  0
2 4.435302 4.742731 4.216161  0  1
3 5.363128 3.236837 6.575728  1  1
4 5.632863 5.460097 5.642899  0  1
5 5.404268 4.360005 5.089761  1  1
6 4.893875 5.455450 5.276551  1  1
> # Use split() to create a list of data frames
> grps <- apply(x[, 4:5], 1, paste0, collapse="")
> x.grps <- split(x[, 1:3], grps)
> names(x.grps)
[1] "00" "01" "10" "11"
> x.grps[["00"]] # or x.grps[[1]]
 X1   X2   X3
8  4.905341 6.035104 5.089833
9  7.018424 4.391074 2.006910
14 4.721211 2.585792 6.399737
16 5.635950 5.205999 6.302543
18 2.343545 5.758163 6.038506
19 2.559533 4.273295 5.920729
20 6.320113 3.631719 5.720878
23 4.828083 6.444101 5.623518

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



-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of PIKAL Petr
Sent: Friday, June 17, 2016 9:24 AM
To: Gafar Matanmi Oyeyemi; r-help@r-project.org
Subject: Re: [R] Obtaining and extracting cells sample in cross-tabulation

Hi

did you try table or xtabs?

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Gafar
> Matanmi Oyeyemi
> Sent: Friday, June 17, 2016 2:25 PM
> To: r-help@r-project.org
> Subject: [R] Obtaining and extracting cells sample in cross-tabulation
>
> Hello everyone,
> I'm writing a function in R but was stalked.
> I have a data set that contains mixture of categorical and continuous
> variables. I want to use the categorical variables to cross-tabulate the data
> and extract the observations in the resulting cells that contain only
> continuous variables.
>
> Data.
> X1   X2   X3   X4   X5
> 2.4  5.3  4.80  1
> 4.2  3.2  4.81  1
> 3.3  4.4  5.10  0
> 5.2  1.1  2.51  0
> .
> .
> .
> 3.7  2.8  3.80  1
>
> Thanks.
>
>   [[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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any 

Re: [R] Non Linear Solver - Optim in R

2016-06-17 Thread Narendra Modi
Ooops. I can change that real quick.

Any help on the problem itself Ranjan?

Thanks!

On Fri, Jun 17, 2016 at 9:22 AM, Ranjan Maitra <
maitra.mbox.igno...@inbox.com> wrote:

> You need to send e-mail from a properly identifiable address (which has a
> correct name/e-mail address) and not a made-up scam address. You can easily
> be reported for impersonation!
>
> Ranjan
>
>
> On Fri, 17 Jun 2016 08:51:59 -0500 Narendra Modi 
> wrote:
>
> > Hello,
> > Resending this message in "Plain-text".
> >
> > Thank you for the add to the list.
> >
> > I have written a R snippet to solve a non-linear problem using Optim
> solver.
> >
> > The parameters to be solved are supposed to be in a matrix form as
> attached
> >
> > such that summation of columns is <=1 except for the first column. ie,
> > P1.F1j + P2.F1j <=1 ,  P1.F2j + P2.F2j <=1 ,  P1.F3j + P2.F3j <=1 and so
> > on..
> >
> > Since OPTIM solver considers "pars" only as vector, I defined the vector
> as
> >
> > my.data.var <- vector("numeric",length = 12)
> >
> > and in the OPTIM solver, I passed it as
> >
> > optim(my.data.var, Error.func, method="L-BFGS-B",
> > upper=c(Inf,1,1,1,1,1,Inf,1,1,1,1,1))
> >
> > Then in the error function, I stacked the vector into a matrix as :
> >
> > my.data.var.mat <- matrix(my.data.var,nrow = 2, ncol = 6,byrow = TRUE)
> >
> > So, my first question is how do I define the constraints for each column
> > except the first one in the OPTIM solver? As you can see, with the UPPER
> > limit in the OPTIM solver, I can fix the upper bound, but there is no way
> > for me set the summation constraint to <=1.
> >
> > Do I need a different solver for this scenario which allows me to use
> > Matrix elements as parameters?
> >
> > Thanks!
>
>
> --
> Important Notice: This mailbox is ignored: e-mails are set to be deleted
> on receipt. Please respond to the mailing list if appropriate. For those
> needing to send personal or professional e-mail, please use appropriate
> addresses.
>
> 
> 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 -- 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] Obtaining and extracting cells sample in cross-tabulation

2016-06-17 Thread PIKAL Petr
Hi

did you try table or xtabs?

Cheers
Petr

> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Gafar
> Matanmi Oyeyemi
> Sent: Friday, June 17, 2016 2:25 PM
> To: r-help@r-project.org
> Subject: [R] Obtaining and extracting cells sample in cross-tabulation
>
> Hello everyone,
> I'm writing a function in R but was stalked.
> I have a data set that contains mixture of categorical and continuous
> variables. I want to use the categorical variables to cross-tabulate the data
> and extract the observations in the resulting cells that contain only
> continuous variables.
>
> Data.
> X1   X2   X3   X4   X5
> 2.4  5.3  4.80  1
> 4.2  3.2  4.81  1
> 3.3  4.4  5.10  0
> 5.2  1.1  2.51  0
> .
> .
> .
> 3.7  2.8  3.80  1
>
> Thanks.
>
>   [[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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
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] Non Linear Solver - Optim in R

2016-06-17 Thread Ranjan Maitra
You need to send e-mail from a properly identifiable address (which has a 
correct name/e-mail address) and not a made-up scam address. You can easily be 
reported for impersonation!

Ranjan


On Fri, 17 Jun 2016 08:51:59 -0500 Narendra Modi  wrote:

> Hello,
> Resending this message in "Plain-text".
> 
> Thank you for the add to the list.
> 
> I have written a R snippet to solve a non-linear problem using Optim solver.
> 
> The parameters to be solved are supposed to be in a matrix form as attached
> 
> such that summation of columns is <=1 except for the first column. ie,
> P1.F1j + P2.F1j <=1 ,  P1.F2j + P2.F2j <=1 ,  P1.F3j + P2.F3j <=1 and so
> on..
> 
> Since OPTIM solver considers "pars" only as vector, I defined the vector as
> 
> my.data.var <- vector("numeric",length = 12)
> 
> and in the OPTIM solver, I passed it as
> 
> optim(my.data.var, Error.func, method="L-BFGS-B",
> upper=c(Inf,1,1,1,1,1,Inf,1,1,1,1,1))
> 
> Then in the error function, I stacked the vector into a matrix as :
> 
> my.data.var.mat <- matrix(my.data.var,nrow = 2, ncol = 6,byrow = TRUE)
> 
> So, my first question is how do I define the constraints for each column
> except the first one in the OPTIM solver? As you can see, with the UPPER
> limit in the OPTIM solver, I can fix the upper bound, but there is no way
> for me set the summation constraint to <=1.
> 
> Do I need a different solver for this scenario which allows me to use
> Matrix elements as parameters?
> 
> Thanks!


-- 
Important Notice: This mailbox is ignored: e-mails are set to be deleted on 
receipt. Please respond to the mailing list if appropriate. For those needing 
to send personal or professional e-mail, please use appropriate addresses.


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 -- 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] Non Linear Solver - Optim in R

2016-06-17 Thread Narendra Modi
Hello,
Resending this message in "Plain-text".

Thank you for the add to the list.

I have written a R snippet to solve a non-linear problem using Optim solver.

The parameters to be solved are supposed to be in a matrix form as attached

such that summation of columns is <=1 except for the first column. ie,
P1.F1j + P2.F1j <=1 ,  P1.F2j + P2.F2j <=1 ,  P1.F3j + P2.F3j <=1 and so
on..

Since OPTIM solver considers "pars" only as vector, I defined the vector as

my.data.var <- vector("numeric",length = 12)

and in the OPTIM solver, I passed it as

optim(my.data.var, Error.func, method="L-BFGS-B",
upper=c(Inf,1,1,1,1,1,Inf,1,1,1,1,1))

Then in the error function, I stacked the vector into a matrix as :

my.data.var.mat <- matrix(my.data.var,nrow = 2, ncol = 6,byrow = TRUE)

So, my first question is how do I define the constraints for each column
except the first one in the OPTIM solver? As you can see, with the UPPER
limit in the OPTIM solver, I can fix the upper bound, but there is no way
for me set the summation constraint to <=1.

Do I need a different solver for this scenario which allows me to use
Matrix elements as parameters?

Thanks!
__
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] Obtaining and extracting cells sample in cross-tabulation

2016-06-17 Thread Gafar Matanmi Oyeyemi
Hello everyone,
I'm writing a function in R but was stalked.
I have a data set that contains mixture of categorical and continuous
variables. I want to use the categorical variables to cross-tabulate the
data and extract the observations in the resulting cells that contain only
continuous variables.

Data.
X1   X2   X3   X4   X5
2.4  5.3  4.80  1
4.2  3.2  4.81  1
3.3  4.4  5.10  0
5.2  1.1  2.51  0
.
.
.
3.7  2.8  3.80  1

Thanks.

[[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] Kendall heat map

2016-06-17 Thread Shane Carey
I also need the significance value

Thanks

On Fri, Jun 17, 2016 at 11:11 AM, boB Rudis  wrote:

> Did you try:
>
> cor(mat, method="kendall", use="pairwise")
>
> That only provides the matrix (so the equiv of the $r list component),
> but that seems to be all you need.
>
> On Fri, Jun 17, 2016 at 5:47 AM, Shane Carey  wrote:
> > Hi,
> >
> > I was hoping someone could help me. I was wondering are there any
> libraries
> > available to undertake a kendall correlation on a matrix of data, in the
> > same way as what can be undertaken with the rcorr function:
> >
> > cormatrix = rcorr(as.matrix(A), type='spearman')
> > cordata = melt(cormatrix$r)
> > ggplot(cordata, aes(x=Var1, y=Var2, fill=value)) +
> >   geom_tile() + xlab("") + ylab("")
> >
> > Thanks
> >
> > --
> > Le gach dea ghui,
> > Shane
> >
> > [[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.
>



-- 
Le gach dea ghui,
Shane

[[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] Kendall heat map

2016-06-17 Thread boB Rudis
Did you try:

cor(mat, method="kendall", use="pairwise")

That only provides the matrix (so the equiv of the $r list component),
but that seems to be all you need.

On Fri, Jun 17, 2016 at 5:47 AM, Shane Carey  wrote:
> Hi,
>
> I was hoping someone could help me. I was wondering are there any libraries
> available to undertake a kendall correlation on a matrix of data, in the
> same way as what can be undertaken with the rcorr function:
>
> cormatrix = rcorr(as.matrix(A), type='spearman')
> cordata = melt(cormatrix$r)
> ggplot(cordata, aes(x=Var1, y=Var2, fill=value)) +
>   geom_tile() + xlab("") + ylab("")
>
> Thanks
>
> --
> Le gach dea ghui,
> Shane
>
> [[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] Kendall heat map

2016-06-17 Thread Jim Lemon
Hi Shane,
Try the "Kendall" package.

Jim


On Fri, Jun 17, 2016 at 7:47 PM, Shane Carey  wrote:
> Hi,
>
> I was hoping someone could help me. I was wondering are there any libraries
> available to undertake a kendall correlation on a matrix of data, in the
> same way as what can be undertaken with the rcorr function:
>
> cormatrix = rcorr(as.matrix(A), type='spearman')
> cordata = melt(cormatrix$r)
> ggplot(cordata, aes(x=Var1, y=Var2, fill=value)) +
>   geom_tile() + xlab("") + ylab("")
>
> Thanks
>
> --
> Le gach dea ghui,
> Shane
>
> [[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.


[R] Kendall heat map

2016-06-17 Thread Shane Carey
Hi,

I was hoping someone could help me. I was wondering are there any libraries
available to undertake a kendall correlation on a matrix of data, in the
same way as what can be undertaken with the rcorr function:

cormatrix = rcorr(as.matrix(A), type='spearman')
cordata = melt(cormatrix$r)
ggplot(cordata, aes(x=Var1, y=Var2, fill=value)) +
  geom_tile() + xlab("") + ylab("")

Thanks

-- 
Le gach dea ghui,
Shane

[[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] filter a data.frame in dependence of a column value

2016-06-17 Thread Enrico Schumann
On Fri, 17 Jun 2016, Matthias Weber  writes:

> Hello togehter,
>
> i have short question, maybe anyone can help me.
>
> I have a data.frame like this one:
>
>NO   ORDER
> 1 1530 for Mr. Muller (10.0 -> 11.2)
> 2 1799 for Mr Giulani
> 3 1888 for Mr. Marius (11.2 -> 12)
>
> I need a solution, which only contains the values in brackets. The result 
> should look like the following:
>
>NO   ORDER
> 1 1530 for Mr. Muller (10.0 -> 11.2)
> 2 1888 for Mr. Marius (11.2 -> 12)
>
> I tried it with the following code, but that doesn't work.
>
> data4.1<-data3[data3$ORDER%in% "[(]*->*[)]",]
>
> maybe anyone can help me.
>
> Thank you.
>
> Best regards
>
> Mat
>

Try ?grepl instead of %in%.

x <- c("for Mr. Muller (10.0 -> 11.2)",
   "for Mr Giulani",
   "for Mr. Marius (11.2 -> 12)")

grepl("[(].*->.*[)]", x)




-- 
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

__
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] filter a data.frame in dependence of a column value

2016-06-17 Thread Thierry Onkelinx
Dear Mat,

You can use grepl() to select based on are regular expression.

subset(data3, grepl("\\(.*\\)", ORDER))

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

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

2016-06-17 9:49 GMT+02:00 Matthias Weber :

> Hello togehter,
>
> i have short question, maybe anyone can help me.
>
> I have a data.frame like this one:
>
>NO   ORDER
> 1 1530 for Mr. Muller (10.0 -> 11.2)
> 2 1799 for Mr Giulani
> 3 1888 for Mr. Marius (11.2 -> 12)
>
> I need a solution, which only contains the values in brackets. The result
> should look like the following:
>
>NO   ORDER
> 1 1530 for Mr. Muller (10.0 -> 11.2)
> 2 1888 for Mr. Marius (11.2 -> 12)
>
> I tried it with the following code, but that doesn't work.
>
> data4.1<-data3[data3$ORDER%in% "[(]*->*[)]",]
>
> maybe anyone can help me.
>
> Thank you.
>
> Best regards
>
> Mat
>
> [[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] filter a data.frame in dependence of a column value

2016-06-17 Thread Matthias Weber
Hello togehter,

i have short question, maybe anyone can help me.

I have a data.frame like this one:

   NO   ORDER
1 1530 for Mr. Muller (10.0 -> 11.2)
2 1799 for Mr Giulani
3 1888 for Mr. Marius (11.2 -> 12)

I need a solution, which only contains the values in brackets. The result 
should look like the following:

   NO   ORDER
1 1530 for Mr. Muller (10.0 -> 11.2)
2 1888 for Mr. Marius (11.2 -> 12)

I tried it with the following code, but that doesn't work.

data4.1<-data3[data3$ORDER%in% "[(]*->*[)]",]

maybe anyone can help me.

Thank you.

Best regards

Mat

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

Re: [R] help for fine mappting

2016-06-17 Thread PIKAL Petr
Hi Greg

Seems to me that spending some time with R tutorial would be way forward for 
you.

Something like that could work, but without some fake (but resembling real) 
data it is untested.

result <- data.frame(ss=rep(NA, nrow(ref)), ll= rep(NA, nrow(ref)), mm= rep(NA, 
nrow(ref)))

for (i in 1:nrow(ref)) {
sel <- map$ SNP_chr==ref$CHR & map$POS >= ref$POS_start[i] & map$POS < 
ref$POS_end[i]
result1 <- sum( map$post_prob[sel] )
result2 <- length( map$post_prob[sel] )
result3 <- min( map$p[sel] )
result[i, ] <-c(result1, result2, result3)
}

Cheers
Petr


From: greg holly [mailto:mak.hho...@gmail.com]
Sent: Thursday, June 16, 2016 10:04 PM
To: PIKAL Petr 
Subject: Re: [R] help for fine mappting

Hi Petr;

I got chance to try your codes. Once again thanks a lot. It seems the results3 
is correct after I modified the "sel" as
sel <- map$ SNP_chr==ref$CHR & map$POS >= ref$POS_start[1] & map$POS < 
ref$POS_end[1] in the your codes:

sel <- map$POS >= ref$POS_start[1] & map$POS < ref$POS_end[1]
result1 <- sum( map$post_prob[sel] )
result2 <- length( map$post_prob[sel] )
result3 <- min( map$p[sel] )

and results3 is output of only the dirst row in "ref"file. I need results of 
other rows which I have 560 rows in "ref" file. I think I need a loop which 
more difficult part for me as I am beginner in R. In addition I need a output 
at the end as follow which has 560 rows.

All the best
Greg

structure(list(CHR = structure(1:2, .Label = c("chr1", "chr22"
), class = "factor"), POS = c(312127953L, 46487552L), POS_start = c(32036927L,
45766451L), POS_end = c(3232240262, 46801601), snp = 
structure(1:2, .Label = c("rs1143427",
"rs55958907"), class = "factor"), alle1l = structure(1:2, .Label = c("G",
"T"), class = "factor"), allel2 = structure(1:2, .Label = c("A",
"G"), class = "factor"), fr = c(0.278, 0.974), effec = c(0.6,
0.106), SE = c(0.015, 0.027), P = c(0.000156, 7.63e-05), post_prob = c(0.229,
0.125), n = c(612L, 4218L)), .Names = c("CHR", "POS", "POS_start",
"POS_end", "snp", "alle1l", "allel2", "fr", "effec", "SE", "P",
"post_prob", "n"), class = "data.frame", row.names = c(NA, -2L
))

On Thu, Jun 16, 2016 at 9:28 AM, PIKAL Petr 
> wrote:
Hi

Did you test my suggestions? If not, why not? If yes, in what respect they did 
not work?

sel <- map$POS >= ref$POS_start[1] & map$POS < ref$POS_end[1]
result1 <- sum( map$post_prob[sel] )
result2 <- length( map$post_prob[sel] )
result3 <- min( map$p[sel] )

should give you desired values. It is up to you how do you want to organise 
them, as from your examples I do not have faintest idea what you want to do.

And keep your responds to r help list, I cc’d it.

Cheers
Petr

From: greg holly [mailto:mak.hho...@gmail.com]
Sent: Thursday, June 16, 2016 3:06 PM
To: PIKAL Petr >
Subject: Re: [R] help for fine mappting

Hi PIKAL;

Thanks so much your writing. I am sorry if I could not explain precisely. All 
information in ref file are exist in map file. So they are in common. Ref file 
has about 560 and map file has 27 million rows.That is CHR column common in 
both and all value given ref$POS_start & ref$POS_end columns  are exist in 
map$POS.

Thanks in advance,

Greg

On Thu, Jun 16, 2016 at 3:16 AM, PIKAL Petr 
> wrote:
Hi

From posted ref and map you cannot obtain final file need, they have nothing in 
common.

answers see in line

> -Original Message-
> From: R-help 
> [mailto:r-help-boun...@r-project.org] On 
> Behalf Of greg holly
> Sent: Wednesday, June 15, 2016 5:21 PM
> To: r-help@r-project.org
> Subject: [R] help for fine mappting
>
> dear all;
>
>
> I am sorry for this posting. I have got help from Jim, Bert, Jeff and PIKAL
> on similar issue before. I tried to modify Jim`s code to the real data but
> it did not work. Now I am posting first two rows the imitation of real data
> using dput() format (please see at the bottom).  I have two data sets,
> data=map and data=ref. The first to rows of each data set are given below.
> Data map has more than 27 million and data ref has about 560 rows.
> Basically I need run two different tasks. My R codes for these task are
> given below but they do not work properly. I sincerely do appreciate your
> helps.
>
>
>
> Regards,
>
> Greg
>
>
>
> Task 1)
>
> For example, the first and second columns for row 1 in data ref are chr1,
> 6457839 and 6638389. So I need write an R code normally first look the
> first row in ref (which they are chre1 6457839  and 6638389) than summing
> the column of "map$post_prob" and give the number of map$snp falls
> between
> 6457839  and 6638389 that  their cumulative sum is >0.85. Then do the same
> for the second, thirdin ref. At the end I would like a table gave below
> (need_ouput). 

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

2016-06-17 Thread G . Maubach
> 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
> > >
> > > __
> > > 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 

Re: [R] Y in Kohonen xyf function

2016-06-17 Thread K. Elo

Hi again!

According to '?xyf', the function is expecting following parameters:

(1) data = a matrix, with each row representing an object.

So, please ensure that your data is a matrix

(2) Y = property that is to be modelled. In case of classification, Y is 
a matrix of zeros, with exactly one '1' in each row indicating the 
class. For prediction of continuous properties, Y is a vector. A 
combination is possible, too, but one then should take care of 
appropriate scaling.


Once again, no data frame here, but a scaled vector or a matrix.

Your could try following steps (I assume 'df' to be you data frame):

--- snip ---
set.seed(7)
training <- sample(nrow(df), 120)
Xtraining <- scale(df[training,])
Xtest <- scale(df[-training,],
   center = attr(Xtraining, "scaled:center"),
   scale = attr(Xtraining, "scaled:scale"))

xyf.df <- xyf(Xtraining,
  factor(df.classes[training]),
  grid = somgrid(5, 5, "hexagonal"))

--- snip ---

Let us know - with output, please - what happens. The point is, if this 
works, then you could try in experimenting the parameter 
'factor(df.classes[training]'. It seems to, that also here you need a 
matrix or a list as a base, not a data frame.


This might also be of interest for your: 
https://www.jstatsoft.org/article/view/v021i05/v21i05.pdf


HTH,
Kimmo

16.06.2016, 17:30, chalabi.el...@yahoo.de wrote:

Hi Kimmo,

Thanks for your reply, Here is a part of my df:


 'data.frame':  562 obs. of 128 variables
 $ TE :int 37 37 35 34 37 37 35 33 32 ...
 $ TR :int 11 11 8 13 11 8 15 12 8 .
 $ BW :int 150 191 128 145 200 191 
 $speed   :int 4 4 3 3 2 1 4 1 2 3 ..
and I want to cluster my data based on speed, to see the coming costumer's 
protocols fall into which speed group and I think I need to bring this speed 
column in Y element of xyf


On Thursday, June 16, 2016 2:29 PM, K. Elo  wrote:
Hi!

Some sample data could help us to help you...

But have you read '?xyf' in order to ensure that your 'Y' is what 'xyf'
expects it to be?

What kind of error messages do you get?

Regards,
Kimmo

16.06.2016, 15:13, ch.elahe via R-help wrote:

Is there any answer?


Hi all, I have a df and I want to use supervised Self Organizing Map
to do classification. I should use Kohonen library and xyf function
from it. As you know the xyf function looks like this and I have
problem defining my Y:

xyf(data,Y,grid=somgrid(),rlen=100,alpha=c(0.05,0.01)) I want to do
classification based on a column which shows the speed that a
protocols is run, and this column is the following:

$speed   :num 4 4 3 3 3 1 1 1 2 1 4 4 3 numbers from 1 to 4 show the
speed from very fast to very slow protocols. so the property I want
to be modeled is df$speed, but I don't know how should I bring it in
xyf function. Does anyone know how to do that? I also added my train
set ans test set:

dt=sort(sample(nrow(df),nrow(df)*.7)) train=df[dt,]
Xtraining=scale(trian) Xtest=scale(-trian)
center=attr(Xtrianing,"scaled:center")
scale=attr(Xtraining,"scaled:scale")
xyf(Xtraining,,grid=somgrid(10,10,"hexagonal"))


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.



__
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] question - how to subcribe to this list

2016-06-17 Thread Hong Yu

First, I am using “Windows Live Mail”, and not able to reply with usual format. 
 Sorry for that.

I am a bit confused, since you can email to the list.  It seems that you have 
subscribed here.

In general, you can go to the official website https://www.r-project.org/.  
There you follow the menu link “mailing lists”, and then you can find the 
mailing groups of interest and subscribe to them.

Also, I believe on the official site, you should be able to view message 
histories.

HTH



From: Satish Vadlamani 
Sent: Friday, June 17, 2016 2:38 PM
To: R help 
Subject: [R] question - how to subcribe to this list

Hello All:
I posted one question in the past and another today and hope to get the
same excellent help that I got last time.

My question is this: is there any way to subcribe to the forum so that I
can see the questions and answers posted to r-help?

Thanks,

-- 

Satish Vadlamani

[[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] question - how to subcribe to this list

2016-06-17 Thread Satish Vadlamani
Hello All:
I posted one question in the past and another today and hope to get the
same excellent help that I got last time.

My question is this: is there any way to subcribe to the forum so that I
can see the questions and answers posted to r-help?

Thanks,

-- 

Satish Vadlamani

[[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] what is the best way to process the following data?

2016-06-17 Thread Satish Vadlamani
Hello,
I have multiple text files with the format shown below (see the two files
that I pasted below). Each file is a log of multiple steps that the system
has processed and for each step, it has shown the start time of the process
step. For example, in the data below, the filter started at
|06/16/2016|03:44:16

How to read this data so that Step 001 is one data frame, Step 002 is
another, and so on. After I do this, I will then compare the Step 001 times
with and without parallel process.

For example, the files pasted below "no_parallel_process_SLS_4.txt" and
"parallel_process_SLS_4.txt" will make it clear what I am trying to do. I
want to compare the parallel process times taken for each step with the non
parallel process times.

If there are better ways of performing this task that what I am thinking,
could you let me know? Thanks in advance.

Satish Vadlamani

>> parallel_process_file.txt

|06/16/2016|03:44:16|Step 001
|06/16/2016|03:44:16|Initialization
|06/16/2016|03:44:16|Filters
|06/16/2016|03:45:03|Split Items
|06/16/2016|03:46:20|Sort
|06/16/2016|03:46:43|Check
|06/16/2016|04:01:13|Save
|06/16/2016|04:04:35|Update preparation
|06/16/2016|04:04:36|Update comparison
|06/16/2016|04:04:38|Update
|06/16/2016|04:04:38|Update
|06/16/2016|04:06:01|Close
|06/16/2016|04:06:33|BOP processing for 7,960 items has finished
|06/16/2016|04:06:34|Step 002
|06/16/2016|04:06:35|Initialization
|06/16/2016|04:06:35|Filters
|06/16/2016|04:07:14|Split Items
|06/16/2016|04:08:57|Sort
|06/16/2016|04:09:06|Check
|06/16/2016|04:26:36|Save
|06/16/2016|04:39:29|Update preparation
|06/16/2016|04:39:31|Update comparison
|06/16/2016|04:39:43|Update
|06/16/2016|04:39:45|Update
|06/16/2016|04:44:28|Close
|06/16/2016|04:45:26|BOP processing for 8,420 items has finished
|06/16/2016|04:45:27|Step 003
|06/16/2016|04:45:27|Initialization
|06/16/2016|04:45:27|Filters
|06/16/2016|04:48:50|Split Items
|06/16/2016|04:55:15|Sort
|06/16/2016|04:55:40|Check
|06/16/2016|05:13:35|Save
|06/16/2016|05:17:34|Update preparation
|06/16/2016|05:17:34|Update comparison
|06/16/2016|05:17:36|Update
|06/16/2016|05:17:36|Update
|06/16/2016|05:19:29|Close
|06/16/2016|05:19:49|BOP processing for 8,876 items has finished
|06/16/2016|05:19:50|Step 004
|06/16/2016|05:19:50|Initialization
|06/16/2016|05:19:50|Filters
|06/16/2016|05:20:43|Split Items
|06/16/2016|05:22:14|Sort
|06/16/2016|05:22:29|Check
|06/16/2016|05:37:27|Save
|06/16/2016|05:38:43|Update preparation
|06/16/2016|05:38:44|Update comparison
|06/16/2016|05:38:45|Update
|06/16/2016|05:38:45|Update
|06/16/2016|05:39:09|Close
|06/16/2016|05:39:19|BOP processing for 5,391 items has finished
|06/16/2016|05:39:20|Step 005
|06/16/2016|05:39:20|Initialization
|06/16/2016|05:39:20|Filters
|06/16/2016|05:39:57|Split Items
|06/16/2016|05:40:21|Sort
|06/16/2016|05:40:24|Check
|06/16/2016|05:46:01|Save
|06/16/2016|05:46:54|Update preparation
|06/16/2016|05:46:54|Update comparison
|06/16/2016|05:46:54|Update
|06/16/2016|05:46:55|Update
|06/16/2016|05:47:24|Close
|06/16/2016|05:47:31|BOP processing for 3,016 items has finished
|06/16/2016|05:47:32|Step 006
|06/16/2016|05:47:32|Initialization
|06/16/2016|05:47:32|Filters
|06/16/2016|05:47:32|Update preparation
|06/16/2016|05:47:32|Update comparison
|06/16/2016|05:47:32|Update
|06/16/2016|05:47:32|Close
|06/16/2016|05:47:33|BOP processing for 0 items has finished
|06/16/2016|05:47:33|Step 007
|06/16/2016|05:47:33|Initialization
|06/16/2016|05:47:33|Filters
|06/16/2016|05:47:34|Split Items
|06/16/2016|05:47:34|Sort
|06/16/2016|05:47:34|Check
|06/16/2016|05:47:37|Save
|06/16/2016|05:47:37|Update preparation
|06/16/2016|05:47:37|Update comparison
|06/16/2016|05:47:37|Update
|06/16/2016|05:47:37|Update
|06/16/2016|05:47:37|Close
|06/16/2016|05:47:37|BOP processing for 9 items has finished
|06/16/2016|05:47:37|Step 008
|06/16/2016|05:47:37|Initialization
|06/16/2016|05:47:37|Filters
|06/16/2016|05:47:38|Update preparation
|06/16/2016|05:47:38|Update comparison
|06/16/2016|05:47:38|Update
|06/16/2016|05:47:38|Close
|06/16/2016|05:47:38|BOP processing for 0 items has finished




>> no_parallel_process_file.txt

|06/15/2016|22:52:46|Step 001
|06/15/2016|22:52:46|Initialization

|06/15/2016|22:52:46|Filters

|06/15/2016|22:54:21|Split Items

|06/15/2016|22:55:10|Sort

|06/15/2016|22:55:15|Check

|06/15/2016|23:04:43|Save

|06/15/2016|23:06:38|Update preparation

|06/15/2016|23:06:38|Update comparison

|06/15/2016|23:06:39|Update

|06/15/2016|23:06:39|Update

|06/15/2016|23:12:04|Close

|06/15/2016|23:13:16|BOP processing for 7,942 items has finished

|06/15/2016|23:13:17|Step 002
|06/15/2016|23:13:17|Initialization

|06/15/2016|23:13:17|Filters

|06/15/2016|23:16:27|Split Items

|06/15/2016|23:20:18|Sort

|06/15/2016|23:20:34|Check

|06/16/2016|00:08:08|Save

|06/16/2016|00:26:19|Update preparation

|06/16/2016|00:26:20|Update comparison

|06/16/2016|00:26:30|Update

|06/16/2016|00:26:31|Update

|06/16/2016|00:42:31|Close

|06/16/2016|00:45:09|BOP processing for 8,400