Re: [R] how to read a local JSON file

2015-06-06 Thread Jim Lemon
Hi Ye Lin, Looks like the file was read, but there is no linefeed at the end of the last line. You could probably stick one in using a text or hex editor and you won't get the warning. Jim On Sun, Jun 7, 2015 at 3:50 PM, Ye Lin wrote: > Hi All, > > I downloaded a data file from dropbox and its

Re: [R] Changing colours for heatmap plot

2015-06-06 Thread Jim Lemon
Hi John, As heat.colors is a function that returns a vector of colors specified by the "n" argument, you could write something like this: my_custom_colors<-function(n,color_vector="lightgray") return(rep(color_vector,length.out=n))) and then pass the desired color vector to it: green_n_black<-c(

[R] how to read a local JSON file

2015-06-06 Thread Ye Lin
Hi All, I downloaded a data file from dropbox and its in JSON format. here is my code: library(RJSONIO) data <- fromJSON(file='C:/Users/Downloads/sample.json') Lines <- readLines("C:/Users/Downloads/sample.json") df <- as.data.frame(t(sapply(Lines, fromJSON))) I got this error message: incomplet

Re: [R] R to HTML problem

2015-06-06 Thread Jim Lemon
Hi Pijush, Does this do what you want? #title~"Output of Class Prediction" cat("The output result is given below\n") iris.df<-cbind(iris[1:10,1:4],rep("",10),iris[1:10,1:4]) names(iris.df)<-c(names(iris)[1:4],"",names(iris)[1:4]) delim.table(iris.df,html=TRUE) Save the result as "sample.R" in the

Re: [R] Simulating data from a nested design

2015-06-06 Thread Jim Silverton
Hi, I am trying to 'create' a nested design with A, B nested in A and C nested in B. C is random and the others are fixed. Does anyone have any idea how to do this? I would also like to try the other nested designs with all random and all effects fixed. -- Thanks, Jim. [[alternative HTM

Re: [R] if else statement for rain data to define zero for dry and one to wet

2015-06-06 Thread William Dunlap
Your f1() has an unneeded for loop in it. f1a <- function(mat) mat > 0.1, 1, 0) would do the same thing in a bit less time. However, I think that a simple mat > 0.1 would be preferable. The resulting TRUEs and FALSEs are easier to interpret than the 1s and 0s that f1a() produces and arithme

Re: [R] if else statement for rain data to define zero for dry and one to wet

2015-06-06 Thread Dennis Murphy
I'm sorry, but I have to take issue with this particular use case of ifelse(). When the goal is to generate a logical vector, ifelse() is very inefficient. It's better to apply a logical condition directly to the object in question and multiply the result by 1 to make it numeric/integer rather than

Re: [R] A-priori contrasts with type III sums of squares in R

2015-06-06 Thread John Fox
Dear Rachel, Anova() won't give you a breakdown of the SS for each term into 1 df components (there is no split argument, as you can see if you look at ?Anova). Because, with the exception of GzrTreat, your contrasts are not orthogonal in the row basis of the design (apparently you're using the de

Re: [R] if else statement for rain data to define zero for dry and one to wet

2015-06-06 Thread roslinazairimah zakaria
Thank you jim. On Saturday, June 6, 2015, Jim Lemon wrote: > Hi rosalinazairimah, > I think the problem is that you are using "if" instead of "ifelse". Try > this: > > wet_dry<-function(x,thresh=0.1) { > for(column in 1:dim(x)[2]) x[,column]<-ifelse(x[,column]>=thresh,1,0) > return(x) > } > we

Re: [R] if else statement for rain data to define zero for dry and one to wet

2015-06-06 Thread Jim Lemon
Hi rosalinazairimah, I think the problem is that you are using "if" instead of "ifelse". Try this: wet_dry<-function(x,thresh=0.1) { for(column in 1:dim(x)[2]) x[,column]<-ifelse(x[,column]>=thresh,1,0) return(x) } wet_dry(dt) and see what you get. Also, why can I read your message perfectly w

[R] A-priori contrasts with type III sums of squares in R

2015-06-06 Thread Rachael Blake
I am analyzing data using a factorial three-way ANOVA with a-priori contrasts and type III sums of squares. (Please don't comment about type I SS vs. type III SS. That's not the point of my question. I have read at length about the choice between types of SS and have made my decision.) I get t

Re: [R] Error in eigen(nhatend)

2015-06-06 Thread Prof J C Nash (U30A)
It looks like the matrix nhatend (for Numerical Hessian AT END) has some NAs or Infs. Suggest you turn off the Hessian calculation by argument hessian=FALSE (that is the default) and control=list(kkt=FALSE) (the default is TRUE for "small" problems") Then take the resulting final parameters a

Re: [R] S4 / operator "[" : Compatibility issue between lme4 and kml

2015-06-06 Thread Martin Morgan
On 06/05/2015 10:52 AM, Martin Maechler wrote: Christophe Genolini on Fri, 5 Jun 2015 00:36:42 -0700 writes: > Hi all, > There is a compatibility issue between the package 'lme4' and my package > 'kml'. I define the "[" operator. It works just fine in my package (1). If I

Re: [R] S4 / operator "[" : Compatibility issue between lme4 and kml

2015-06-06 Thread cgenolin
Thanks a lot for your time. Two questions: 1/ Shall I submit a bug report? 2/ In your point 2), I cannot find the verb... Is my english not good enough to understand it, or is it a "not-ended" sentence? :-) -- View this message in context: http://r.789695.n4.nabble.com/S4-operator-Compatibil