Re: [R] reshape non-square matrix

2014-02-28 Thread Jeff Newmiller
library(reshape2) mx <- matrix( 1:12, nrow=3 ) mxdf <- melt( mx ) names( mxdf ) <- c( "m", "n", "value" ) --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. L

Re: [R] a geographical factor

2014-02-28 Thread Rolf Turner
On 01/03/14 16:36, Bill wrote: Hi, Thanks. I see that quadrats, Divides window into rectangular quadrats and returns the quadrats as a tessellation. Do you know what they mean by window? Yes, I do. And so would you if you read the documentation that comes with spatstat. Perhaps start with ?s

Re: [R] reshape non-square matrix

2014-02-28 Thread Rolf Turner
On 01/03/14 14:49, Chirag Gupta wrote: Hi list I have a matrix of size m x n (m and n are different, hence non square!) I want to melt it in such a way that I get a df of 3 columns. m ,n Surely you mean i, j (i = 1, ..., m), j = 1, ..., n). and cell value in the original matrix. Yes:

[R] reshape non-square matrix

2014-02-28 Thread Chirag Gupta
Hi list I have a matrix of size m x n (m and n are different, hence non square!) I want to melt it in such a way that I get a df of 3 columns. m ,n and cell value in the original matrix. Any suggestions? -- *Chirag Gupta* Department of Crop, Soil, and Environmental Sciences, 115 Plant Sciences

[R] Multilevel analysis for ordinal responses

2014-02-28 Thread shkingdom
Dear all, I need to fit a multielvel model for an ordinal response. Does R have a command for conducting a multilevel ordinal logistic regression when the model violates the parallel regression or proportional odds assumption? Additionally, are there any tests to check the parallel regression assu

Re: [R] How to change the label size in axis

2014-02-28 Thread Jim Lemon
On 03/01/2014 02:08 PM, Jun Shen wrote: Hi everyone, I am using the axis command to draw extra axis on the right. How do I change the text size of the labels as in axis (4, at=c(1:9), labels='some text', las=1). I can't find an argument to change the text size for the labels. Thanks. Hi Jun

Re: [R] a geographical factor

2014-02-28 Thread Bill
Hi, Thanks. I see that quadrats, Divides window into rectangular quadrats and returns the quadrats as a tessellation. Do you know what they mean by window? And I saw this: W <- square(10) Z <- quadrats(W, 4, 5) plot (Z) data

Re: [R] Map plotting in a box

2014-02-28 Thread Jim Lemon
On 03/01/2014 01:53 AM, Ciara O'Hara wrote: Hi everyone, I am using the script below to create a map plot of Ireland. library(ncdf)library(maps)library(mapdata)library(maptools)library(RColorBrewer)shapefile<-readShapeLines("C:\\Users\\sophysics\\Desktop\\IRL_adm\\IRL_adm1.shp")file<-open.ncdf("C

Re: [R] a geographical factor

2014-02-28 Thread Rolf Turner
I'm too lazy to figure out the details of what you are trying to do, but I think it is possible that you might find the facilities of the spatstat package useful and that these might save you some wheel-reinvention. Look in particular at the quadrats(), tess() and im() functions. cheers,

[R] How to change the label size in axis

2014-02-28 Thread Jun Shen
Hi everyone, I am using the axis command to draw extra axis on the right. How do I change the text size of the labels as in axis (4, at=c(1:9), labels='some text', las=1). I can't find an argument to change the text size for the labels. Thanks. Jun [[alternative HTML version deleted]]

Re: [R] Problem importing file in R after switching from windows to Ubuntu

2014-02-28 Thread Ista Zahn
Hi Christian, I know you've checked many times, but it is very likely that you are not typing the file name correctly, or that the file is not where you think it is. Please run these lines and post the output back here: setwd("~/Documents/DATABASES/Functional_Annotations") list.files() Best, Ist

Re: [R] New to R

2014-02-28 Thread Ista Zahn
Hi George, Please keep the R mailing list copied--I've added them back. The example on the webpage you listed is wrong, in a way that would be obvious if you took the time to familiarize yourself with the basics of R. stocks has no names. Best, Ista On Fri, Feb 28, 2014 at 6:45 PM, George Kat

[R] a geographical factor

2014-02-28 Thread Bill
Hi. I have a dataframe called radSamp which looks like this: > head(radSamp[,c(3,4,5)]) Latitude Longitude Value 1 39.16094 140.488345 2 32.84428 -117.224047 3 35.80605 139.378928 4 35.07816 -106.612350 5 35.83174 136.202735 6 34.78944 137.949632 This is radiation d

Re: [R] (no subject)

2014-02-28 Thread arun
HI Farnoosh, Try: D1= c("5/25/2012 14:48", "5/29/2012 16:53",  "6/1/2012 18:30") D2= c("6/8/2012 21:26", "6/11/2012 15:10" , "6/14/2012 17:57") as.numeric(as.POSIXct(D2,format="%m/%d/%Y %H:%M")-as.POSIXct(D1,format="%m/%d/%Y %H:%M")) #days #[1] 14.27639 12.92847 12.97708 #or as.numeric(difftime(a

Re: [R] aggregate and sum on some columns fromduplicate rows

2014-02-28 Thread arun
If, 'dat' is the dataset: res <- as.data.frame(do.call(rbind,lapply(split(dat,list(dat$St.Sam,dat$Sp),drop=TRUE),function(x) c(unlist(x[1,1:4]),colSums(x[,5:6])  row.names(res) <- 1:nrow(res) res    St.Sam  Sp Var1 Var2 NT PT 1  ST1.S1 Sp1   12   aa 23 37 2  ST1.S2 Sp1   25   dd 29 66 3  ST2.

[R] [R-pkgs] new package: hrr version 1.0.1

2014-02-28 Thread Leonardo Di Donato
Dear R users, as I often have to visually divide my R output into blocks, especially when I create R executable scripts, I created hrr in the hope that this simple package might come in handy to you. I released it to CRAN today. It is a simple package to create and print fully customisable horizo

Re: [R] aggregate and sum on some columns fromduplicate rows

2014-02-28 Thread arun
Hi, You could use ?ddply library(plyr) cbind(ddply(dat,.(St.Sam,Sp),function(x) x[!duplicated(x$Var1),])[,-c(5:6)],ddply(dat,.(St.Sam,Sp),colwise(sum,.(NT,PT)))[,-c(1:2)])    St.Sam  Sp Var1 Var2 NT PT 1  ST1.S1 Sp1   12   aa 23 37 2  ST1.S1 Sp2   32   bb 45 26 3  ST1.S1 Sp3   47   cc 89 35 4  ST

[R] Problem importing file in R after switching from windows to Ubuntu

2014-02-28 Thread Christian De Santis
Dear R List, today i have installed Ubuntu as i decided to give this a try after running R in windows was always running out of memory in making my figures. I have copied my working folders into Ubuntu and changed the WD and the \\ into /. I tried to re run the script and it was going all well

Re: [R] Map plotting in a box

2014-02-28 Thread Ray Brownrigg
On 01/03/14 03:53, Ciara O'Hara wrote: > Hi everyone, > I am using the script below to create a map plot of Ireland. > library(ncdf)library(maps)library(mapdata)library(maptools)library(RColorBrewer)shapefile<-readShapeLines("C:\\Users\\sophysics\\Desktop\\IRL_adm\\IRL_adm1.shp")file<-open.ncdf("C

Re: [R] aggregate and sum on some columns fromduplicate rows

2014-02-28 Thread ltdm
Hi again, Sorry for disturbing. After posting I suddenly found a solution. As it may help someone else here it goes. df du1 <- duplicated(df[,c("St.Sam","Species")],fromLast = F) du2 <- duplicated(df[,c("St.Sam","Species")],fromLast = T) X <- df[du1|du2,] aggRows <- aggregate(cbind(NT,PT) ~St.Sam

Re: [R] Saving a map as a postscript file

2014-02-28 Thread David Winsemius
On Feb 28, 2014, at 8:22 AM, Ciara O'Hara wrote: > Hi all, > I am running the script below to produce a map. The problem I am having is > saving it as a postscript file. A postscript file is created, but it is > blank. I have also run this is linux (with different paths) and I get the > same

[R] aggregate and sum on some columns fromduplicate rows

2014-02-28 Thread ltdm
Hi list, I have a dataframe df looking like this one: St.SamSpVar1 Var2NTPT ST1.S1Sp112aa2032 ST1.S1Sp232bb4526 ST1.S1Sp112aa 3 5 ST1.S1Sp347cc8935 ST1.S2Sp125dd2966 ST1.S2Sp2

Re: [R] Solving Classification problems in R

2014-02-28 Thread Sergio Fonda
I did forget that reading LDA package could also help Sergio Il 28/feb/2014 19:39 "Luca Cerone" ha scritto: > Now I feel quite stupid :) I was assuming that since there is a > "Clustering" one there would have been a "Classification" one as well > :) > Thanks for pointing it out to me! > Luca Cer

Re: [R] pivot table

2014-02-28 Thread jim holtman
Is this what you want: > x id agency offer month product 1 1 a L genstar 2 2 b M feb meteor 3 3 c N genmoon 4 4 d O marchmoon > require(reshape2) > dcast(x, agency + offer ~ product, fun = length) Using product as value column: use value

Re: [R] which(rsts$date<2011-03-01)

2014-02-28 Thread jim holtman
You need to write: rstst=rsts[-which(rsts$date 2011-03-01 [1] 2007 Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Fri, Feb 28, 2014 at 4:20 PM, Bill wrote: > Hello, I have a dataframe called rsts. It

[R] which(rsts$date<2011-03-01)

2014-02-28 Thread Bill
Hello, I have a dataframe called rsts. It looks like this: > head(rsts) date Value 1 2012-08-0745 2 2013-11-1047 3 2014-01-2828 4 2013-10-2250 5 2013-06-1335 6 2013-05-2832 where I ran as.Date(date) to get the date column as date objects. I tried this: rstst=rsts[-

Re: [R] data.frmae : Error: unexpected numeric constant in:

2014-02-28 Thread Beáta Nagy
I used copy -paste. I will try to find the mistake. I know the "source" , but is is more complicated, because I have to define the hierarchical structure of the table before I load this 6000 or more records, then I fill in the table whit this frequencies. Thanks Bea 2014-02-28 0:19 GMT+01:00 Dav

Re: [R] do calculation within expression(), text in plot

2014-02-28 Thread William Dunlap
>Unfortunately I can't get R to do the calculation for cor(nou,dak) when I >use expression().. > >text(0,2.2,expression(paste(r[Pearson],"=", cor(nou,dak) , sep= " > ")),pos=4, >cex=1.5) Use bquote() and its .() operator, as in with(mtcars, { plot(wt, mpg) text(4, 3

Re: [R] include sql statements

2014-02-28 Thread Duncan Murdoch
On 28/02/2014 5:16 AM, Streng Ge-heim wrote: Hi, first of all: I am new to R. Anyway, I would like to include sql files in my r-script, which I load via source("scriptname") in the CLI. The sql files (i.e. "stmt.sql") contains select statements with joins, line breaks, various characters, they

[R] Points to spatial polygons

2014-02-28 Thread Adrian Antonescu
Hi All, With the risk of asking an obvious question: I have use the following code to generate hexagonal tessellation: lambertCRS<-"+proj=laea" coords1<-matrix(c(-30,31,-30,80,50,80,50,31,-30,31),ncol=2, byrow=TRUE) coords=project(coords1,lambertCRS) pg=Polygon(coords) HexPts=spsample(pg, type=

[R] sub function problem

2014-02-28 Thread Massimiliano Tripoli
Dear all, I write a R function that it should handles strings like removing spaces at the beginning or returning NA according an IF condition. Here you are the code: corregge.CF <- function(stringa){ nc <- nchar(stringa) stringa <- sub("^ ", "", stringa) stringa <- sub(" +$", "", stri

Re: [R] Data Rearrangement

2014-02-28 Thread arun
HI Dila, You have to order it afterwards. res <- transform(melt(dat,id.var=c("Year","Day")),Month=match(variable,month.abb),Amount=value)[,-c(3:4)] res1 <- res[with(res,order(Year,Month,Day)),] A.K. On Friday, February 28, 2014 2:16 AM, dila radi wrote: Dear Arun, Thank you so much for yo

[R] Saving a map as a postscript file

2014-02-28 Thread Ciara O'Hara
Hi all, I am running the script below to produce a map. The problem I am having is saving it as a postscript file. A postscript file is created, but it is blank. I have also run this is linux (with different paths) and I get the same thing (blank postscript file). Does anyone know how to do thi

[R] (no subject)

2014-02-28 Thread Ma Rw
Hai There are in the r package called poLCA and this package using the latent class. Is there a package to resolve latent profile and what and how we can support the answer with an example Thank you [[alternative HTML version deleted]] __ R-h

[R] Map plotting in a box

2014-02-28 Thread Ciara O'Hara
Hi everyone, I am using the script below to create a map plot of Ireland. library(ncdf)library(maps)library(mapdata)library(maptools)library(RColorBrewer)shapefile<-readShapeLines("C:\\Users\\sophysics\\Desktop\\IRL_adm\\IRL_adm1.shp")file<-open.ncdf("C:\\Users\\sophysics\\Desktop\\TempData\\avera

[R] include sql statements

2014-02-28 Thread Streng Ge-heim
Hi, first of all: I am new to R. Anyway, I would like to include sql files in my r-script, which I load via source("scriptname") in the CLI. The sql files (i.e. "stmt.sql") contains select statements with joins, line breaks, various characters, they can be quite long. My question is, is there a

[R] pivot table

2014-02-28 Thread lara.palandra
hi..i would create a pivot table in R and i would create two levels of columns. I'll try to explain better. I have a table so done: id agency offer month product 1 aL gen star 2 bM feb meteor 3

[R] do calculation within expression(), text in plot

2014-02-28 Thread Tonja Krueger
Dear Helpers, I would like to add some text to my plot, containing a variable and the calculated value for the variable. As I would like to produce many plots, I hope this can be done automatically. Unfortunately I can't get R to do the calculation for cor(nou,dak) when I

[R] Importance Sampling and a bunch of questions

2014-02-28 Thread Pooja Voladoddi
I have gone through quite a few papers but they all fail to give me the intuition. So i posted here : http://stackoverflow.com/questions/22060675/r-monte-carlo-integration-using-importance-sampling/22064557?noredirect=1#22064557 and here (CrossValidated): http://stats.stackexchange.com/question

[R] stepAIC with lm

2014-02-28 Thread renzo89
Hi everybody,I'm a beginner in R so this question it could may simple for u (I hope it).I need to study the interaction between 4 independent variables (x1, x2, x3, x4) and a dependent variable (y). So I've used a list of regression models (using the "lm" function) as:REGR.LIN<-lm(y~0+x1+x2+x3+x4)n

Re: [R] Solving Classification problems in R

2014-02-28 Thread Luca Cerone
Now I feel quite stupid :) I was assuming that since there is a "Clustering" one there would have been a "Classification" one as well :) Thanks for pointing it out to me! Luca Cerone Tel: +34 692 06 71 28 Skype: luca.cerone On Fri, Feb 28, 2014 at 6:38 PM, Prof Brian Ripley wrote: > http://cran

Re: [R] New to R

2014-02-28 Thread Ista Zahn
Please give a reproducible example. When I run your code I get "object 'stocks' not found". So what is stocks? On Thu, Feb 27, 2014 at 11:24 PM, George Katsuras wrote: > I successfully downloaded and loaded the stockPortfolio and quadprog > packages, but when I entered the following command I go

Re: [R] how is the model resample performance calculated by caret?

2014-02-28 Thread Max Kuhn
On Fri, Feb 28, 2014 at 1:13 AM, zhenjiang zech xu wrote: > Dear all, > > I did a 5-repeat of 10-fold cross validation using partial least square > regression model provided by caret package. Can anyone tell me how are the > values in plsTune$resample calculated? Is that predicted on each hold-out

Re: [R] Solving Classification problems in R

2014-02-28 Thread Prof Brian Ripley
http://cran.r-project.org/web/views/MachineLearning.html for a task view you missed. On 28/02/2014 17:10, Luca Cerone wrote: Thanks for the advices Sergio and Jean-Olivier. Of course I forgot, but I am interested in supervised classification! I'll go through the packages you suggested to me! An

Re: [R] logit estimation is not convergent!

2014-02-28 Thread Prof Brian Ripley
On 28/02/2014 16:07, mei_yuan wrote: Dear all, I estimate a logit model with the function glm and I have estimation not convergent. Is it possible to increase the maximal number of iterartion in the function glm? Or any other suggestion? Thanks! Yes. See the help page, which refers you to ?

Re: [R] Solving Classification problems in R

2014-02-28 Thread Luca Cerone
Thanks for the advices Sergio and Jean-Olivier. Of course I forgot, but I am interested in supervised classification! I'll go through the packages you suggested to me! Any ideas for Neural Networks and Random Forests instead? Luca Cerone Tel: +34 692 06 71 28 Skype: luca.cerone On Fri, Feb 28,

Re: [R] Data Rearrangement

2014-02-28 Thread JiHO
You actually want cast() from the reshape package, not melt(). I would recommend using dcast() from reshape2, the newer version of reshape. Jean-Olivier Irisson — Université Pierre et Marie Curie Laboratoire d'Océanographie de Villefranche 181 Chemin du Lazaret 06230 Villefranche-sur-Mer Tel: +33

Re: [R] Solving Classification problems in R

2014-02-28 Thread JiHO
Do you mean supervised or unsupervised classification. If supervised, I have had great success using gradient boosted classification in package gbm. multinomial distribution will get you multiple classes and it will select relevant predictors by itself given the training data. Not sure about the

Re: [R] Solving Classification problems in R

2014-02-28 Thread Sergio Fonda
Focus on MASS, CCA and e1071 packages Brgds, Sergio Il 28/feb/2014 17:47 "Luca Cerone" ha scritto: > Dear all, > I would like some advices on R packages to solve classification problems. > I have tried to search among the Task views, but couldn't find anything. > > Can somebody recommend me some

[R] Solving Classification problems in R

2014-02-28 Thread Luca Cerone
Dear all, I would like some advices on R packages to solve classification problems. I have tried to search among the Task views, but couldn't find anything. Can somebody recommend me some packages? Some of the features I am looking for: - deal with multiple classes - use customized cost functions

[R] logit estimation is not convergent!

2014-02-28 Thread mei_yuan
Dear all, I estimate a logit model with the function glm and I have estimation not convergent. Is it possible to increase the maximal number of iterartion in the function glm? Or any other suggestion? Thanks! Mei-Yuan Chen Department of Finance National Chung Hsing University Taichung, Taiwa

Re: [R] Conditional polygon colouring

2014-02-28 Thread David Carlson
The simplest way is to use clip(): > clip(0, 33, -1, 0) > polygon(ff,gg,col=2) > clip(0, 33, 0, 1) > polygon(ff,gg,col=4) - David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: r-help

Re: [R] expressions (nesting, substitution, 2-stage evaluation)

2014-02-28 Thread William Dunlap
> e.g. this doesn't work: > > vectorA = c( bquote("TNF-"*alpha), bquote("IFN-"*gamma) ) > > for(ii in vectorA) { > plot(0:1,0:1) > title(main = paste("asdfsadf",ii)) > } Use bquote's .() operator in the call to plot() or title(), as in: par(mfrow=c(2,1)) for(ii in vectorA) { pl

[R] Conditional polygon colouring

2014-02-28 Thread mamuash bukana
Dear R users I want to paint parts of a polygon with different colours conditional to values of the variable. Example: f<-seq(1,33) g<-sin(f) i<-rep(0,33) ff<-c(f,rev(f)) gg<-c(g,rev(i)) plot(ff,gg,type="n") polygon(ff,gg,col=2) # but I wanted to plot areas below and above the x-axis with diff

Re: [R] expressions (nesting, substitution, 2-stage evaluation)

2014-02-28 Thread Bert Gunter
David: Oh yes! That is certainly the "right" way. Much better than what I suggested. I actually first thought about doing this, but didn't get the form right (I wanted to substitute within the expression, rather than substituting the whole expression).Of course,one can always use bquote() instead

[R] OrchardSprays reference

2014-02-28 Thread Scherber, Christoph
Dear all, Does anyone have a PDF of the classic OrchardSprays reference (data(OrchardSprays)): C. G. Butler, D. J. Finney, P. Schiele (1943) Experiments on the poisoning of honeybees by insecticidal and fungicidal sprays used in orchards. Ann Appl Biol 30:143–150. Thanks very much and best wis

Re: [R] Data Rearrangement

2014-02-28 Thread PIKAL Petr
Hi Did you try what I had suggested? In what aspect it does not fulfil your request? Petr From: dila radi [mailto:dilarad...@gmail.com] Sent: Friday, February 28, 2014 9:25 AM To: PIKAL Petr Subject: Re: [R] Data Rearrangement Dear Petr, Im so sorry for the inconvenience caused by the data.