Re: [R] Using apply with more than one matrix

2014-04-30 Thread David Winsemius
On Apr 30, 2014, at 9:32 PM, Waichler, Scott R wrote: >> I would ask you to look at this loop-free approach and ask if this is not >> equally valid? >> >> ans <- matrix(NA, ncol=2, nrow=2) >> ind.not.na <- which(!is.na(a1)) >> ans[] <- condition1*a1[,,ind.not.na[1]]+ m2 # two matrices of equal

Re: [R] Using apply with more than one matrix

2014-04-30 Thread Waichler, Scott R
> I would ask you to look at this loop-free approach and ask if this is not > equally valid? > > ans <- matrix(NA, ncol=2, nrow=2) > ind.not.na <- which(!is.na(a1)) > ans[] <- condition1*a1[,,ind.not.na[1]]+ m2 # two matrices of equal > dimensions, one logical. > ans > [,1] [,2] > [1,] NA

Re: [R] Using apply with more than one matrix

2014-04-30 Thread David Winsemius
On Apr 30, 2014, at 6:03 PM, Waichler, Scott R wrote: > Here is a working example with no random parts. Thanks for your patience and > if I'm still off the mark with my presentation I'll drop the matter. > > v <- c(NA, 1.5, NA, NA, > NA, 1.1, 0.5, NA, > NA, 1.3, 0.4, 0.9) > a1 <-

Re: [R] help using extrafont package | R graphics

2014-04-30 Thread Yixuan Qiu
Hi Evan, If you just need one font, you may try the showtext package. Here is a piece of code that you can test: library(showtext) # If you have this font installed font.add("gara", "gara.ttf") # Or you can install a similar one from Google Font # font.add.google("EB Garamond", "gara") # Try some

[R] A combinatorial assignment problem

2014-04-30 Thread Ravi Varadhan
Hi, I have this problem: K candidates apply for a job. There are R referees available to review their resumes and provide feedback. Suppose that we would like M referees to review each candidate (M < R). How would I assign candidates to referees (or, conversely, referees to candidates)? Th

[R] Problems with hmisc under WIndows 8

2014-04-30 Thread Renger van Nieuwkoop
Hi I use hmisc on a Windows 9-x64 machine and it causes an error: running command 'cd "C:\Users\Renger\AppData\Local\Temp\Rtmp4IOgfH" & pdflatex -interaction=scrollmode "C:\Users\Renger\AppData\Local\Temp\Rtmp4IOgfH\file1b9482a7388"' had status 127 It also gives an API error 2. The file is in

[R] Tobit model with panel data

2014-04-30 Thread phil
Hi all, I just started to work with R a couple of weeks ago. Right now I would like to regress an independent variable on a couple of explanatory variables. The dependent variable is left censored in the sense that all negative values and zero are set equal to one. This is done because I want to t

[R] Fitting a Mixture of Noncentral Student t Distributions to a one-dimensional sample

2014-04-30 Thread Johannes Moser
Dear R community, I`d like to extract the parameters of a two-component mixture distribution of noncentral student t distributions which was fitted to a one-dimensional sample. There are many packages for R that are capable of handling mixture distributions in one way or another. Some in the

Re: [R] Using apply with more than one matrix

2014-04-30 Thread Richard M. Heiberger
Try ?mapply Description: 'mapply' is a multivariate version of 'sapply'. 'mapply' applies 'FUN' to the first elements of each ... argument, the second elements, the third elements, and so on. Arguments are recycled if necessary. Rich On Wed, Apr 30, 2014 at 9:03 PM, Waich

Re: [R] set axis limit in lattice

2014-04-30 Thread Duncan Mackay
If you just want to limit the axis just insert as arguments for the x axis xlim = c(min, max), and for the y ylim = c(min,max) , where min and max correspond to the appropriate min and max for the x and y axes As for the panel.groups you mention medians where I was using means - if you want me

Re: [R] Using apply with more than one matrix

2014-04-30 Thread Waichler, Scott R
Here is a working example with no random parts. Thanks for your patience and if I'm still off the mark with my presentation I'll drop the matter. v <- c(NA, 1.5, NA, NA, NA, 1.1, 0.5, NA, NA, 1.3, 0.4, 0.9) a1 <- array(v, dim=c(2,2,3)) m1 <- matrix(c(NA, 1.5, 2.1, NA), ncol=2, by

Re: [R] help using extrafont package | R graphics

2014-04-30 Thread Law, Jason
On my system, the name of the Garamond font file is GARA.TTF. Thus, font_import(pattern = 'GARA') will work, but font_import(pattern="gara") won't. Unfortunately, font_import seems to fail rather ungracefully when there is no match to a pattern. Jason -Original Message- From: r-h

Re: [R] Using apply with more than one matrix

2014-04-30 Thread David Winsemius
On Apr 30, 2014, at 1:21 PM, Waichler, Scott R wrote: > Ok, here is a toy example. I want to use a custom function that depends on > more than one matrix/array as input, and I can't figure out how to do that > with apply. > > v <- c(NA, 1.5, NA, NA, > NA, 1.1, 0.5, NA, > NA, 1.3,

Re: [R] R 3.1 changes to type.convert causing strings where I used to get numeric

2014-04-30 Thread David Winsemius
I though that change in NEWS re: type.convert referenced the fact that numbers which were longer than could be represented accurately within the constraints of class numeric were now being read in as characters which would give you the option to later convert with one of the bignum packages. You

Re: [R] R 3.1 changes to type.convert causing strings where I used to get numeric

2014-04-30 Thread David Winsemius
I though that change in NEWS re: type.convert referenced the fact that numbers which were longer than could be represented accurately within the constraints of class numeric were now being read in as characters which would give you the option to later convert with one of the bignum packages. You

Re: [R] Question about rgamma when the shape and the scale are vectors, not scalars

2014-04-30 Thread Greg Snow
Your command will generate 3 random values from gamma distributions, the first will be from a gamma with shape a[1] and scale b[1], then the 2nd will come from a gamma with shape a[2] and scale b[2] and the 3rd will have shape a[3] and scale b[3]. On Wed, Apr 30, 2014 at 3:00 PM, Stefano Sofia wr

[R] Question about rgamma when the shape and the scale are vectors, not scalars

2014-04-30 Thread Stefano Sofia
Dear list users, could somebody explain to me which is the meaning of rgamma(3, a, b) when both a and b are two vectors of length 3? I know that a is the shape and b is the scale, but I thought that they could only be scalars. Thank you for your help Stefano AV

Re: [R] systemfit package is not compatible with R-3.0.2 version.

2014-04-30 Thread David Winsemius
On Apr 30, 2014, at 5:19 AM, Ramesh Das wrote: > Dear all, > I am in problem for installing the package "systemfit" in R-3.0.2 version. > The error message is showing is as mentioned below. Now there is R-3.0.2 > version is there. so kindly anyone help me to solve this problem. > > > Warning in

Re: [R] R 3.1 changes to type.convert causing strings where I used to get numeric

2014-04-30 Thread Duncan Murdoch
On 30/04/2014, 4:20 PM, Bos, Roger wrote: Dear R-help, I recently upgraded to R 3.1 patched and code that ran fine previously and now giving a lot of errors because the data is coming in as strings instead of numeric. I can fix my code to wrapping each item I want to use with as.numeric(), b

Re: [R] Using apply with more than one matrix

2014-04-30 Thread Waichler, Scott R
Ok, here is a toy example. I want to use a custom function that depends on more than one matrix/array as input, and I can't figure out how to do that with apply. v <- c(NA, 1.5, NA, NA, NA, 1.1, 0.5, NA, NA, 1.3, 0.4, 0.9) a1 <- array(v, dim=c(2,2,3)) m1 <- matrix(c(NA, 1.5, 2.1,

[R] R 3.1 changes to type.convert causing strings where I used to get numeric

2014-04-30 Thread Bos, Roger
Dear R-help, I recently upgraded to R 3.1 patched and code that ran fine previously and now giving a lot of errors because the data is coming in as strings instead of numeric. I can fix my code to wrapping each item I want to use with as.numeric(), but that seems very inefficient. I looked at

Re: [R] Using apply with more than one matrix

2014-04-30 Thread Bert Gunter
Scott: Your problem specification is rather vague: What do you mean by "use"? In general, matrices are merely vectors with a dim attribute, so if you can do what you want with them as vectors, then that will work for them as matrices. For example: > m1<- matrix(1:6, nr=3) > m2 <- matrix(11:16, n

Re: [R] Using apply with more than one matrix

2014-04-30 Thread Ranjan Maitra
Hi Scott, You could set up a three-dimensional array and then use apply on the desired dimension (MARGIN in apply language). HTH! Many thanks, Ranjan On Wed, 30 Apr 2014 17:54:48 + "Waichler, Scott R" wrote: > Hi, > > I want to apply a custom function to all the elements of one matrix.

[R] Using apply with more than one matrix

2014-04-30 Thread Waichler, Scott R
Hi, I want to apply a custom function to all the elements of one matrix. The function uses the value in the same i,j in a second matrix. How can I use apply() or similar function to avoid nested loops in i and j? Thanks, Scott Waichler Pacific Northwest National Laboratory Richland, WA, USA

Re: [R] Lavaan Model Specification

2014-04-30 Thread Jeremy Miles
No picture attached, and you don't tell us what your trouble is, but your model has -4 df, so it's incorrectly specified. Take out these lines: congressmanAttitudes ~~ congressmenPerceptConstiuentAttitudes congressmenPerceptConstiuentAttitudes ~~ constiuentAttitudes rollCallBehav ~~ congressmenPe

[R] Error in matrix: too many elements specified

2014-04-30 Thread Van Dijk, Diana
Hi, I am working on a computer 64-bit OS, with 7.8 GB usable memory (RAM). The allocated quota by my administrator is 12 GB. Now, I use R's 'spdep' package to run an hedonic pricing model, using the function errorsarlm and the following data: 1) A spatial weights matrix, converted from a

[R] Lavaan Model Specification

2014-04-30 Thread Patzelt, Edward
R Community - I'm trying to build the model in the image below, but having troubles correctly specifying the syntax: library(lavaan) library(semPlot) lower <- matrix(c(1, 0, 0, 0, .475, 1, 0, 0, .738, .643, 1, 0, .608, .721, .823, 1), 4, 4, byrow = TRUE) colnames(lower) <- rownames(lower) <-

Re: [R] Reshape large Data Frame to new format

2014-04-30 Thread Arunkumar Srinivasan
Hi Dark, Sorry for the late response. Since you asked for a `data.table` solution as well, here's one: require(data.table) dt <- as.data.table(rawData) dt[, GRP := (0:(.N-1L))%/%25L, by=PersonID] dt[, `:=`(var="codes", N = 1:.N), by=list(PersonID, GRP)] dcast.data.table(dt, PersonID+GRP ~ var+N,

[R] systemfit package is not compatible with R-3.0.2 version.

2014-04-30 Thread Ramesh Das
Dear all, I am in problem for installing the package "systemfit" in R-3.0.2 version. The error message is showing is as mentioned below. Now there is R-3.0.2 version is there. so kindly anyone help me to solve this problem. Warning in install.packages : package ‘systemfit ’ is not available

Re: [R] Kindly help me

2014-04-30 Thread Ramesh Das
Thanks lot again to all. On Wed, Apr 30, 2014 at 2:32 PM, Rui Barradas wrote: > Hello, > > The package is Zelig, not zelig, R is case sensitive. > Try > > install.packages("Zelig", dependencies = TRUE) > > > And can't you update your version of R? It's now R 3.1.0. > > Hope this helps, > > Rui

[R] SPOT package non-conformable arrays

2014-04-30 Thread Quentin Delivré
Hello everyone I'm relatively new in R coding and I have a problem using the function forrBuilder, from SPOT package. > fitC <- forrBuilder(xe, ye, 1e-3, 1e2, "optim-L-BFGS-B" , 100,0,1,FALSE) Error in x - matrix(rep(xmin, s), nrow = s, byrow = TRUE) : non-conformable arrays > traceback() 2: sp

Re: [R] R: re: dataframe

2014-04-30 Thread arun
Hi, In this case, you may have to use:  dat1[sapply(dat1,function(x) any(grepl("\\bC\\b",x))) & sapply(dat1,function(x) any(grepl("Au5",x)))] o066_010    o066_022    o066_029    o066_034    o066_068    o066_072 1  sample  sample  sample  sample  sample  sample 2  

Re: [R] R: re: dataframe

2014-04-30 Thread arun
Hi James, I guess the problem was because the columns you tried were factors. Suppose `dat1` is your dataset (first). library(stringr) indx <- grep("sample", colnames(dat1)) toGrep <- read.table(text = str_trim(gsub("[sample.]", " ", colnames(dat1)[indx])),     header = FALSE, stringsAsFactors

Re: [R] Simulative data production

2014-04-30 Thread Lorenz, David
Merve, I'm not 100 percent sure I understand everything that you want. But start with the simulated likert scale data. The code that you have is not very efficient and it has at least one typo. I do not know if columns or rows represent the persons, so I'll set up as NROW and NCOL. An efficient

Re: [R] position of a string in a data frame

2014-04-30 Thread Jim Lemon
How about: testdf<-data.frame(names=c("min","max","sum"),a=1:3,b=4:6,c=c(5,7,9)) which(tolower(as.matrix(testdf)) == "sum",arr.ind=TRUE) row col [1,] 3 1 as.matrix coerces all elements to the lowest (character) mode, no? Does it unclass anything like the example below? Jim On 04/30/2

Re: [R] position of a string in a data frame

2014-04-30 Thread Duncan Murdoch
On 30/04/2014, 8:02 AM, Frede Aakmann Tøgersen wrote: Try > foo <- data.frame(oid = 1:3, functions = c("mean", "sum", "sd"), type = c(TRUE, FALSE, TRUE)) foo oid functions type 1 1 mean TRUE 2 2 sum FALSE 3 3sd TRUE foo == "sum" oid functions type

Re: [R] position of a string in a data frame

2014-04-30 Thread Frede Aakmann Tøgersen
Try > foo <- data.frame(oid = 1:3, functions = c("mean", "sum", "sd"), type = > c(TRUE, FALSE, TRUE)) > foo oid functions type 1 1 mean TRUE 2 2 sum FALSE 3 3sd TRUE > foo == "sum" oid functions type [1,] FALSE FALSE FALSE [2,] FALSE TRUE FALSE [

Re: [R] R Cairo Installation - Cannot find cairo.h!

2014-04-30 Thread Jose-Marcio Martins
Hi, On 04/28/2014 09:26 PM, Fong Chun Chan wrote: ./configure --prefix=/home/fong/usr/local I set the my CAIRO_LIBS and CAIRO_CLAGS environment variables in my ~/.bashrc: export CAIRO_LIBS=${HOME}/usr/local/lib export CAIRO_CFLAGS=${HOME}/usr/local/include maybe export CAIRO_LIBS=-L${HOME

[R] position of a string in a data frame

2014-04-30 Thread carol white
Hi, It might be a primitive question but how to find the position of a string in a data frame? Suppose I search the word "sum" (case insensitive) in a data frame and it is in the 7th row, 3rd column, how to retrieve the indices 7, 3? I tried to use grep with tapply but it doesn't work. Many tha

Re: [R] Kindly help me

2014-04-30 Thread Rui Barradas
Hello, The package is Zelig, not zelig, R is case sensitive. Try install.packages("Zelig", dependencies = TRUE) And can't you update your version of R? It's now R 3.1.0. Hope this helps, Rui Barradas Em 29-04-2014 19:30, Ramesh Das escreveu: Dear all, I have a problem in installing the the