[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

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

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)

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

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 Jun

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

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

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

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 on

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 :

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 a

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

[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

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 e

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

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

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.

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.

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(

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 colon

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 you

[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

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

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

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

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, repla

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

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

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

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

[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

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

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 l

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

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

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

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 Assur

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

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(dat

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

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

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 '