Re: [R] font size in graphs...can R read Windows settings?

2016-07-27 Thread Duncan Mackay
Hi Dan For devices png, pdf, postscript and ? others the pointsize argument controls the font size which is modified by cex For lattice there are the settings in trellis.par.get() trellis.par.get()$fontsize $text [1] 12 $points [1] 8 which you can set and there is no real need to change font

Re: [R] Lattice barchart legend with panel.barchart

2016-07-27 Thread Duncan Mackay
Hi Following Pauls reply you may like to increase the panel space available by using useOuterStrips which makes the smaller proportions easier to see and compare If you also wanted to change colours auto.key is the better option. Colours are a bit garish See ?xyplot and panel.barchart library(

Re: [R] [FORGED] Lattice barchart legend with panel.barchart

2016-07-27 Thread Seth Bigelow
Works great, thank you Paul! On Wed, Jul 27, 2016 at 5:24 PM, Paul Murrell wrote: > Hi > > Try this ... > > barchart(Class~Freq|Sex + Age, Titan, > groups=Survived, > panel = titanpanel, > stack=TRUE, layout=c(4,1), > key=simpleKey(title="Survived", text=level

Re: [R] Aggregate matrix in a 2 by 2 manor

2016-07-27 Thread David Winsemius
> On Jul 27, 2016, at 12:02 PM, Jeff Newmiller wrote: > > An alternative (more compact, not necessarily faster, because apply is still > a for loop inside): > > f <- function( m, nx, ny ) { > # redefine the dimensions of my > a <- array( m > , dim = c( ny >, n

Re: [R] font size in graphs...can R read Windows settings?

2016-07-27 Thread Jeff Newmiller
What if it is being used on a platform other than Windows? This problem is more challenging than you seem to think it is. I would suggest including a kind of "par" argument to your function that lets the user change your defaults. -- Sent from my phone. Please excuse my brevity. On July 27, 2

Re: [R] Reference for aov()

2016-07-27 Thread pdalgd
In general, some assembly is required. This stuff doesn't quit fit in a one page email. You may want to start playing around with model.matrix and qr() to see the light. One tricky bit is how much you know already. There is some risk for me of having to rewrite a linear algebra textbook... I'l

Re: [R] [FORGED] Lattice barchart legend with panel.barchart

2016-07-27 Thread Paul Murrell
Hi Try this ... barchart(Class~Freq|Sex + Age, Titan, groups=Survived, panel = titanpanel, stack=TRUE, layout=c(4,1), key=simpleKey(title="Survived", text=levels(Titan$Survived), rectangles=TRUE, points=FALSE, columns=2)) Paul On 28/07

[R] Lattice barchart legend with panel.barchart

2016-07-27 Thread Seth Bigelow
I have constructed a barchart that requires a panel call, but the panel reduces the facsimiles of bars in the legend to small colored circles. You can see this behavior in the following example: Titan <- as.data.frame(Titanic) titanpanel <- function(x,y,...){ panel.barchart(x,y,...) } barchart(C

[R] font size in graphs...can R read Windows settings?

2016-07-27 Thread Dalthorp, Daniel
Hi All, I am putting together a package that (among other things) draws some nice graphs for users. I place some explanatory text on figs using "text" and "mtext". But the size of the text depends on the Windows display settings: Smaller (100%), medium (125%) or larger (150%) (In Windows 7... Contr

[R] Help on improving an algorithm

2016-07-27 Thread li li
Hi all, I have four matrix tmp_a, tmp_b, tmp_c and tmp_d whose dimensions are shown as below. I want to take one row from each of these matrices and then put the four selected rows into a matrix. I want to count the number of such matrices for which the vector of row sum is less than or equal to (

Re: [R] Reference for aov()

2016-07-27 Thread Justin Thong
Hi Peter, Thank you for your good answer. I am sorry for the late reply. *An ortogonalized model matrix generates a decomposition of the model space into orthogonal subspaces corresponding to the terms of the model. Projections onto each of the subspaces are easily worked out. E.g., for a two-w

Re: [R] Windows 10 Application Compatibility Check | FreeWare R Statistical Environment v3.2.2

2016-07-27 Thread John C Frain
Sorry if my earlier remarks were unfair to City but their request reminded me of some problems that I had with using R, similar software and the obstacles placed in my way by an IT Department many years ago. If it is of any help I have R installed on a Desktop and two laptops (running 64-bit Window

Re: [R] how to create column names for the matrix

2016-07-27 Thread lily li
Thanks, this works. I thought the code should put in the for loop, but it turns out an extra line. On Wed, Jul 27, 2016 at 12:50 PM, wrote: > Hello, > > Try > > > chars = c('A','B','C','D') > matrix1 = matrix(nrow = length(1:100), ncol = length(1:5)*length(chars)) > k = 0 > for(i in 1:length(1:5

Re: [R] Reduce woes

2016-07-27 Thread David Winsemius
> On Jul 27, 2016, at 8:20 AM, Stefan Kruger wrote: > > Hi - > > I'm new to R. > > In other functional languages I'm familiar with you can often seed a call > to reduce() with a custom accumulator. Here's an example in Elixir: > > map = %{"one" => [1, 1], "three" => [3], "two" => [2, 2]} > ma

Re: [R] Time format issue

2016-07-27 Thread David Winsemius
> On Jul 27, 2016, at 5:03 AM, Ismail SEZEN wrote: > > >>> The time column is factor. I want to convert each time to the following >>> format: >>> >>> 20111211003000 >>> >>> 20111211013000 >>> >>> 2011121102 >>> >>> (Year)(month)(date)(hr)(min)(sec) >> >>> newTimeDt <- strptime(Time, f

Re: [R] Reducing execution time

2016-07-27 Thread jeremiah rounds
Correction to my code. I created a "doc" variable because I was thinking of doing something faster, but I never did the change. grep needed to work on the original source "dat" to be used for counting. Fixed: combs = structure(list(V1 = c(65L, 77L, 55L, 23L, 34L), V2 = c(23L, 34L, 34L, 77L, 65L

Re: [R] Reducing execution time

2016-07-27 Thread jeremiah rounds
If I understood the request this is the same programming task as counting words in a document and counting character sequences in a string or matching bytes in byte arrays (though you don't want to go down that far) You can do something like what follows. There are also vectorized greps in strin

Re: [R] Stack dataframes into a matrix

2016-07-27 Thread David Winsemius
> On Jul 27, 2016, at 8:56 AM, Anamika Chaudhuri wrote: > > > Y<-matrix(1:40,ncol=2) > Y1<-Y/60 # estimates of p > > #print(Y1) > > sigma2<- > matrix(c(var(Y1[,1]),cov(Y1[,1],Y1[,2]),cov(Y1[,1],Y1[,2]),var(Y1[,2])),2,2) > #print(sigma2) > > rho<-sigma2[1,2]/sqrt(sigma2[1,1]*sigma2[2,2]) > #

Re: [R] Aggregate matrix in a 2 by 2 manor

2016-07-27 Thread Jeff Newmiller
An alternative (more compact, not necessarily faster, because apply is still a for loop inside): f <- function( m, nx, ny ) { # redefine the dimensions of my a <- array( m , dim = c( ny , nrow( m ) %/% ny , ncol( m ) %/% nx ) )

Re: [R] how to create column names for the matrix

2016-07-27 Thread Hervé Pagès
On 07/27/2016 11:49 AM, lily li wrote: If replace 1:5 to char2 = c('east','west','south','north','central'), how to put on column names with the original structure? Thanks again. Have you tried to actually "replace 1:5 with char2", literally? You need to try things before you ask. That's the o

Re: [R] how to create column names for the matrix

2016-07-27 Thread Hervé Pagès
I see. But please understand that initializing the values is not the same as setting the colnames. How providing this almost-impossible- to-read initialization code helps with respect to your question which is about setting the colnames? I know people often asked you to show the code in your prev

Re: [R] how to create column names for the matrix

2016-07-27 Thread ruipbarradas
Hello, Try chars = c('A','B','C','D') matrix1 = matrix(nrow = length(1:100), ncol = length(1:5)*length(chars)) k = 0 for(i in 1:length(1:5)){  # or more simply just for(i in 1:5)   for(j in 1:length(chars)){     k = k+1     matrix1[,k] = k   } } matrix1 tmp <- expand.grid(chars, 1:5, stringsAsFac

Re: [R] how to create column names for the matrix

2016-07-27 Thread lily li
If replace 1:5 to char2 = c('east','west','south','north','central'), how to put on column names with the original structure? Thanks again. On Wed, Jul 27, 2016 at 12:40 PM, Hervé Pagès wrote: > Hi, > > > On 07/27/2016 11:17 AM, lily li wrote: > >> Hi all, >> >> I want to ask that how to create

Re: [R] how to create column names for the matrix

2016-07-27 Thread lily li
Thanks. I shorten a more complex matrix to this example, but use the original structure of the code. The original matrix has all characters instead of 1:5. On Wed, Jul 27, 2016 at 12:42 PM, Hervé Pagès wrote: > On 07/27/2016 11:40 AM, Hervé Pagès wrote: > >> Hi, >> >> On 07/27/2016 11:17 AM, li

Re: [R] how to create column names for the matrix

2016-07-27 Thread Hervé Pagès
On 07/27/2016 11:40 AM, Hervé Pagès wrote: Hi, On 07/27/2016 11:17 AM, lily li wrote: Hi all, I want to ask that how to create column names for a matrix. For example, the matrix below, the column names should be: 1-A, 1-B, 1-C, 1-D, 2-A, 2-B, 2-C, 2-D, 3-A, etc. Thanks for your help. chars =

Re: [R] how to create column names for the matrix

2016-07-27 Thread Hervé Pagès
Hi, On 07/27/2016 11:17 AM, lily li wrote: Hi all, I want to ask that how to create column names for a matrix. For example, the matrix below, the column names should be: 1-A, 1-B, 1-C, 1-D, 2-A, 2-B, 2-C, 2-D, 3-A, etc. Thanks for your help. chars = c('A','B','C','D') matrix1 = matrix(nrow = l

Re: [R] Reducing execution time

2016-07-27 Thread sri vathsan
Hi, It is not a just 79 triplets. As I said, there are 79 codes. I am making triplets out of that 79 codes and matching the triplets in the list. Please find the dput of the data below. > dput(head(newd,10)) structure(list(uniq_id = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10"), hi = c("1

[R] how to create column names for the matrix

2016-07-27 Thread lily li
Hi all, I want to ask that how to create column names for a matrix. For example, the matrix below, the column names should be: 1-A, 1-B, 1-C, 1-D, 2-A, 2-B, 2-C, 2-D, 3-A, etc. Thanks for your help. chars = c('A','B','C','D') matrix1 = matrix(nrow = length(1:100), ncol = length(1:5)*length(chars)

Re: [R] Have any of you succesfully used VS Code with R? How have you set this up?

2016-07-27 Thread Ista Zahn
Hi Luis, What features do you want? What did you try? What was missing? I've not used VSCode, but for Atom check out https://atom.io/packages/repl, https://atom.io/packages/language-r, https://atom.io/packages/autocomplete-r, and possibly https://atom.io/packages/hydrogen Best, Ista On Wed, Jul

Re: [R] Reducing execution time

2016-07-27 Thread Sarah Goslee
You said you had 79 triplets and 8000 records. When I compared 100 triplets to 1 records it took 86 seconds. So obviously there is something you're not telling us about the format of your data. If you use dput() to provide actual examples, you will get better results than if we on Rhelp have

Re: [R] Reducing execution time

2016-07-27 Thread sri vathsan
Hi, Thanks for the solution. But I am afraid that after running this code still it takes more time. It has been an hour and still it is executing. I understand the delay because each triplet has to compare almost 9000 elements. Regards, Sri On Wed, Jul 27, 2016 at 9:02 PM, Sarah Goslee wrote:

Re: [R] Reduce woes

2016-07-27 Thread Peter Langfelder
If you have a simple list of vectors (call it lst), use lengths = sapply(lst, length) In general, you may want to look at functions lapply and sapply which apply a function over a list, in this case the function length(). Peter On Wed, Jul 27, 2016 at 8:20 AM, Stefan Kruger wrote: > Hi - > > I

Re: [R] Stack dataframes into a matrix

2016-07-27 Thread Anamika Chaudhuri
Hi David, Thanks for your response. rbind doesnot seem to work. Here is a reproducible example Y<-matrix(1:40,ncol=2) Y1<-Y/60 # estimates of p #print(Y1) sigma2<- matrix(c(var(Y1[,1]),cov(Y1[,1],Y1[,2]),cov(Y1[,1],Y1[,2]),var(Y1[,2])),2,2) #print(sigma2) rho<-sigma2[1,2]/sqrt(sigma2[1,1]*sigm

[R] Reduce woes

2016-07-27 Thread Stefan Kruger
Hi - I'm new to R. In other functional languages I'm familiar with you can often seed a call to reduce() with a custom accumulator. Here's an example in Elixir: map = %{"one" => [1, 1], "three" => [3], "two" => [2, 2]} map |> Enum.reduce(%{}, fn ({k,v}, acc) -> Map.update(acc, k, Enum.count(v),

[R] Have any of you succesfully used VS Code with R? How have you set this up?

2016-07-27 Thread Luis Cota
I've been keen to use either VSCode or Atom and have not had much success. Any suggestions? Regards, - Luis --- This communication may contain confidential and/or privileged information. If you are not the intended recipient (or have re

[R] How to set up a dynamic panel data model with pgmm from plm pacakge?

2016-07-27 Thread Striessnig, Erich
\n<< Hi, I am trying to set up a dynamic panel data model using the pgmm function from the plm package. The formula that I want to estimate is something like this: [y(t) - y(t-1)] ~ [x(t) - x(t-1)] + [x(t-1) - y(t-1)] where the lagged value of the dependent variable should be instrumen

[R] How to use fuzzy_partition with fuzzy_trapezoid

2016-07-27 Thread Arthur Stilben
Hello, guys! I tried to do that: > teste = fuzzy_partition( varnames = c( "a", "b" ), FUN = fuzzy_trapezoid, > corners = c( 0, 1, 2, 3), corners = c(4, 5, 6, 7)) Error in FUN(i, ...) : argumento formal "corners" corresponde a múltiplos argumentos especificados So, how can I use fuzzy_partiti

Re: [R] probelm with xlab ylab and xaxp barplot

2016-07-27 Thread Abdoulaye Sarr
Hi Marc, I have something very close now, and think to leave it like that. Thank you so much for your help to solve the problem. Cheers, asarr On Mon, Jul 25, 2016 at 6:03 PM, Marc Schwartz wrote: > Hi, > > First, I noted again that you still have: > >xaxp=c(181,2005,1) > > in the first

Re: [R] about netcdf files

2016-07-27 Thread lily li
Hi Jon, The versions are: raster_2.5-2 sp_1.2-3 On Wed, Jul 27, 2016 at 9:31 AM, Jon Skoien wrote: > Hi Lily, > > You can ignore the first three lines, they are just for information. > Which version of raster do you have? I see that the attempt to read the > crs-variable was not wrapped in a t

Re: [R] Aggregate matrix in a 2 by 2 manor

2016-07-27 Thread David L Carlson
This should be faster. It uses apply() across the blocks. > ilon <- seq(1,8,nx) > ilat <- seq(1,4,ny) > cells <- as.matrix(expand.grid(ilat, ilon)) > blocks <- apply(cells, 1, function(x) tst[x[1]:(x[1]+1), x[2]:(x[2]+1)]) > block.means <- colMeans(blocks) > tst_2x2 <- matrix(block.means, 2, 4) >

Re: [R] Windows 10 Application Compatibility Check | FreeWare R Statistical Environment v3.2.2

2016-07-27 Thread Marc Schwartz
Hi, With the caveat that I speak for myself only, a few comments: 1. Given that Citi appears to have been running R on Windows 7 for some period of time, I am not sure that they are looking for reasons to deny users access to R. They are simply looking for some indication that R will run on Win

Re: [R] Reducing execution time

2016-07-27 Thread Sarah Goslee
Hi, It's really a good idea to use dput() or some other reproducible way to provide data. I had to guess as to what your data looked like. It appears that order doesn't matter? Given than, here's one approach: combs <- structure(list(V1 = c(65L, 77L, 55L, 23L, 34L), V2 = c(23L, 34L, 34L, 77L, 6

Re: [R] about netcdf files

2016-07-27 Thread Jon Skoien
Hi Lily, You can ignore the first three lines, they are just for information. Which version of raster do you have? I see that the attempt to read the crs-variable was not wrapped in a try-call in earlier versions. Upgrading might help. Best, Jon On 7/27/2016 5:13 PM, lily li wrote: > Hi Jon,

Re: [R] Reducing execution time

2016-07-27 Thread sri vathsan
Hi, Apologizes for the less information. Basically, myCombos is a matrix with 3 variables which is a triplet that is a combination of 79 codes. There are around 3lakh combination as such and it looks like below. V1 V2 V3 65 23 77 77 34 65 55 34 23 23 77 34 34 65 55 Each triplet will compare in

Re: [R] Windows 10 Application Compatibility Check | FreeWare R Statistical Environment v3.2.2

2016-07-27 Thread John C Frain
When I first graduated some 50 years ago I worked in the Department of Finance. On small piece of my work involved getting CPI data from the CSO and doing some calculations. A specific person in the CSO (Central Statistics Office) usually supplied this information and this fact was always recorded

Re: [R] Reducing execution time

2016-07-27 Thread Bert Gunter
Not entirely sure I understand, but match() is already vectorized, so you should be able to lose the supply(). This would speed things up a lot. Please re-read ?match *carefully* . Bert On Jul 27, 2016 6:15 AM, "sri vathsan" wrote: Hi, I created list of 3 combination numbers (mycombos, around

Re: [R] Reducing execution time

2016-07-27 Thread Thierry Onkelinx
A reproducible example makes your problem easier to understand. 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 stat

[R] Reducing execution time

2016-07-27 Thread sri vathsan
Hi, I created list of 3 combination numbers (mycombos, around 3 lakh combinations) and counting the occurrence of those combination in another list. This comparision list (mylist) is having around 8000 records.I am using the following code. myCounts <- sapply(1:nrow(myCombos), FUN=function(i) {

Re: [R] Likelihood ratio test in porl (MASS)

2016-07-27 Thread Faradj Koliev
Dear Achim Zeileis, dear John Fox, Thank you for your time! Both worked well. lrtest(Restrict, Full) #Df LogLik Df Chisq Pr(>Chisq) 1 27 -882.00 2 28 -866.39 1 31.212 2.313e-08 *** anova(Restrict, Full) Resid. df Resid. Dev TestDf LR stat. Pr

Re: [R] Time format issue

2016-07-27 Thread Ismail SEZEN
>> The time column is factor. I want to convert each time to the following >> format: >> >> 20111211003000 >> >> 20111211013000 >> >> 2011121102 >> >> (Year)(month)(date)(hr)(min)(sec) > >> newTimeDt <- strptime(Time, format="%d%b%y:%H:%M") >> newTimeDt > [1] "2011-12-27 00:30:00 PST" "20

Re: [R] Likelihood ratio test in porl (MASS)

2016-07-27 Thread Fox, John
Dear Faradj Koliev, There is an anova() method for "polr" objects that computes LR chisquare tests for nested models, so a short answer to your question is anova(Full, Restricted). The question, however, seems to reflect some misunderstandings. First aov() fits linear analysis-of-variance mode

[R] Aggregate matrix in a 2 by 2 manor

2016-07-27 Thread Anthoni, Peter (IMK)
Hi all, I need to aggregate some matrix data (1440x720) to a lower dimension (720x360) for lots of years and variables I can do double for loop, but that will be slow. Anybody know a quicker way? here an example with a smaller matrix size: tst=matrix(1:(8*4),ncol=8,nrow=4) tst_2x2=matrix(NA,nc

Re: [R] Likelihood ratio test in porl (MASS)

2016-07-27 Thread Achim Zeileis
On Wed, 27 Jul 2016, Faradj Koliev wrote: Dear all, A quick question: Let?s say I have a full and a restricted model that looks something like this: Full<- polr(Y ~ X1+X2+X3+X4, data=data, Hess = TRUE, method="logistic?) # ordered logistic regression Restricted<- polr(Y ~ X1+X2+X3, data=da

[R] Likelihood ratio test in porl (MASS)

2016-07-27 Thread Faradj Koliev
Dear all, A quick question: Let’s say I have a full and a restricted model that looks something like this: Full<- polr(Y ~ X1+X2+X3+X4, data=data, Hess = TRUE, method="logistic”) # ordered logistic regression Restricted<- polr(Y ~ X1+X2+X3, data=data, Hess = TRUE, method="logistic”) # or

Re: [R] about netcdf files

2016-07-27 Thread Jon Skoien
I think you get the error because you passed the object from nc_open(), you should rather pass the filename of the netCDF, so: pre = brick("sample_precip_daily.nc") From the test-file, this gives you a RasterBrick-object with 5*9 pixels and 7305 layers. Then you can extract data.frames of each