[R] How to validate the cluster analysis?

2015-06-09 Thread My List
All, I am new to the world of statistics. I am interested in finding out the validation techniques employed on a cluster analysis. Any point of reference or site would be helpful. I have read about the clValid package and usage of the function on cluster.stats() in the fpc package. Thanks in Adva

Re: [R] graphs, need urgent help [from Rosa Oliveira]

2015-06-09 Thread Rosa Oliveira
Dear Don, I done the plot and the lines, and it’s fine. I’ll have 10 values on sample. It’s generating (on simulation), that’s why that huge outlier, and the other missing points. The graph I’ve done, is just an example, just to illustrate what I have to get, but off course with 10 points in s

Re: [R] graphs, need urgent help [from Rosa Oliveira]

2015-06-09 Thread Don McKenzie
The R function plot() will draw the first line and the two axes. You need to tell it which subsample of your data to plot, as in my example below. So start with those two observations for which “sample” = 10. But if you want separate lines for each unique value of “sample”, your lines will conn

Re: [R] graphs, need urgent help (deadline :( )

2015-06-09 Thread Rosa Oliveira
Dear Don and all, I’ve read the tutorial and tried several codes before posting :) I’m really naive. what I was trying to : is something like the graph in the picture I drawee. Is it more clear now? Atenciosamente, Rosa Oliveira -- __

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

2015-06-09 Thread Rachael Blake
Thank you for replying, John! I am not using treatment contrasts in this analysis. I am specifying options(contrasts=c("contr.sum", "contr.poly")) earlier in my code in order to get interpretable results from the Type III SS. However, I did not include that code in the example becaus

Re: [R] graphs, need urgent help (deadline :( )

2015-06-09 Thread Don McKenzie
The answer lies in learning to use the help (and knowing where to start). Did you look at the tutorial that comes with the R installation? ?plot ?lines ?par In the last, look for the descriptions of “col” and “lty”. Using plot() and lines(), and subsetting the four unique values of “sample

Re: [R] Summarizing data based on Date

2015-06-09 Thread Shivi82
HI All, I am able to get the desired result. Thanks for extending help. while reading the csv file I made some changes as : Test<-read.csv("Testdata.csv", head=TRUE, stringsAsFactors = FALSE, strip.white = TRUE) with this character var were not changed to factors. Then aggregation was simple:

[R] %OSn in time formats: is it only valid for formatting, but invalid for parsing?

2015-06-09 Thread Brent via R-help
Consider this R code: time = as.POSIXct(1433867059, origin = "1970-01-01") print(time) print( as.numeric(time) ) timeFormat = "%Y-%m-%d %H:%M:%OS3" tz = "EST" timestamp = format(time, format = timeFormat, tz = tz) print(timestamp) timeParsed = as.POSIXct(timestamp, format = timeFormat, tz = tz)

Re: [R] more complex by with data.table???

2015-06-09 Thread Ista Zahn
Hi Ramiro, There is a demonstration of this on the data.table wiki at https://rawgit.com/wiki/Rdatatable/data.table/vignettes/datatable-intro-vignette.html. You can do dt[, lapply(.SD, mean), by=name] or dt[, as.list(colMeans(.SD)), by=name] BTW, there are pretty straightforward ways to do thi

Re: [R] more complex by with data.table???

2015-06-09 Thread jim holtman
try this: > dt[ + , { + result <- list() + for (i in names(.SD)){ + result[[i]] <- myFunction(unlist(.SD[, i, with = FALSE])) + } + result + } + , by = name + ] name var1 var2 var3 1:a 2.0 22 42 2:b 7.5 28 48 > J

Re: [R] Different random intercepts but same random slope for groups

2015-06-09 Thread Ben Bolker
li li gmail.com> writes: > [snip] > I'd like to fit a random intercept and random slope model. In my > data, there are three groups. I want to have different random > intercept for each group but the same random slope effect for all > three groups. I used the following R command. > However,

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

2015-06-09 Thread John Fox
Dear Rachel, How about this (using the data and model you sent originally)? > linearHypothesis(EpiLM, "GzrTreatpresence = 0") Linear hypothesis test Hypothesis: GzrTreatpresence = 0 Model 1: restricted model Model 2: log_EpiChla ~ TempTreat * GzrTreat * ShadeTreat Res.Df RSS Df Sum of S

Re: [R] Different random intercepts but same random slope for groups

2015-06-09 Thread Bert Gunter
Thierry: I don't think so. It looks to me like her syntax/understanding is confused. I think the call should be: mod2 <- lmer(result ~ group*time+(group + time|lot), na.action=na.omit, data=alldata) Her request for "the same random slope for each group" -- I assume it's for time -- means to me

Re: [R] Cross tabulation with top one variable and side as multiple variables

2015-06-09 Thread John Kane
We probably should have a better idea of what the raw data looks like and perhaps a bit better idea of what the analyis is to show. Have a look at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and http://adv-r.had.co.nz/Reproducibility.html for some sugge

Re: [R] Different random intercepts but same random slope for groups

2015-06-09 Thread Thierry Onkelinx
Your model is too complex for the data. This gives you two options: a) simplify the model and b) get more data. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assuranc

[R] more complex by with data.table???

2015-06-09 Thread Ramiro Barrantes
Hello, I am trying to do something that I am able to do with the "by" function within data.frame but can't figure out how to achieve with data.table. Consider dt<-data.table(name=c(rep("a",5),rep("b",6)),var1=0:10,var2=20:30,var3=40:50) myFunction <- function(x) { mean(x) } I am aware that I c

[R] Different random intercepts but same random slope for groups

2015-06-09 Thread li li
Hi all, I'd like to fit a random intercept and random slope model. In my data, there are three groups. I want to have different random intercept for each group but the same random slope effect for all three groups. I used the following R command. However, there seems to be some problem. Any sugge

Re: [R] Cross tabulation with top one variable and side as multiple variables

2015-06-09 Thread Jeff Newmiller
There are two issues here... calculation and presentation. The table function from base R can work with many variables. If your data set is so large that you have problems with memory then you could investigate data.table or sqldf packages, which perform the computations but do not present the d

[R] graphs, need urgent help (deadline :( )

2015-06-09 Thread Rosa Oliveira
Hi, another naive question (i’m pretty sure :( ) I’m trying to plot a multiple line graph: regionsample factora factorbfactorc 0.1 10 0.895 0.903 0.378 0.2 10 0.811 0.865 0.688 0.1 20 0.735 0.966 0.611 0.2 20

Re: [R] Cross tabulation with top one variable and side as multiple variables

2015-06-09 Thread David Winsemius
On Jun 9, 2015, at 1:40 AM, jagadishpchary wrote: > Hi: > > I have a huge data with lot of variables and I need to check the trend > variations from year to year. In order to do so, I have to cross tabulate > the year variable as top (constant) and all the remaining variables as side > (attached

[R] Warning message when using lmer function

2015-06-09 Thread li li
I got the following warning message when using the lmer function. Does anyone know what is the implication? Thanks! Warning message: In anova(model, ddf = "lme4") : bytecode version mismatch; using eval __ R-help@r-project.org mailing list -- To UNSUBSC

Re: [R] how to reach a txt file like this?

2015-06-09 Thread Boris Steipe
This is (almost) json data (but see NOTE below); there are several packages that deal with json, jsonlite for example. R > data <- '[{"ID":"A", "Name":"Tom", "Age":"18"},{"ID":"B", "Name":"Jim", "Age":"19"}]' R > install.packages("jsonlite") R > library(jsonlite) R > myDf <- fromJSON(data, sim

Re: [R] subsetting a dataframe

2015-06-09 Thread Ryan Derickson
Lots of ways to do this, I use %in% with bracket notation [row, column]. The empty column argument below returns all columns but you could have conditional logic there as well. dd[dd$rows %in% test_rows, ] On Mon, Jun 8, 2015 at 6:44 PM, Bogdan Tanasa wrote: > Dear all, > > would appreciate y

[R] Cross tabulation with top one variable and side as multiple variables

2015-06-09 Thread jagadishpchary
Hi: I have a huge data with lot of variables and I need to check the trend variations from year to year. In order to do so, I have to cross tabulate the year variable as top (constant) and all the remaining variables as side (attached the cross tabulation report). I have searched the forums but th

Re: [R] web scraping image

2015-06-09 Thread boB Rudis
You can also do it with rvest & httr (but that does involve some "parsing"): library(httr) library(rvest) url <- "http://nwis.waterdata.usgs.gov/nwis/peak?site_no=12144500&agency_cd=USGS&format=img"; html(url) %>% html_nodes("img") %>% html_attr("src") %>% paste0("http://nwis.waterdata.usg

Re: [R] Cross-over Data with Kenward-Roger correction

2015-06-09 Thread Ben Bolker
knouri yahoo.com> writes: > > Dear all:for the folowing data, a two-period, two treatment (A=1 vs. B=2) > cross-over is fitted > using the folowing SAS code.  > data one; [snip] > run; > proc mixed data=one method=reml; > class Sbj Per Trt; >    model PEF = Per Trt /ddfm=kr; >    repeated Trt

Re: [R] how to reach a txt file like this?

2015-06-09 Thread John McKown
On Tue, Jun 9, 2015 at 11:24 AM, Ye Lin wrote: > ​Hey All, I have a txt data file that looks like this: > > ​[{“ID”:“A”,“Name":"Tom", "Age":"18"},{“ID”:“B”,“Name":"Jim", "Age":"19"}] > > > ​How can I read this into R as a data frame? I have used readLines to read > all the lines but dont know how

Re: [R] Unordered combinations with repetition

2015-06-09 Thread William Dunlap
That combnWithRepetition (based on combn) can use much less memory (and time) than the algorithm in prob:::urnsamples.default with replace=TRUE, ordered=FALSE. Perhaps urnsamples() could be updated to use combn instead of unique(as.matrix(expand.grid())). See the urn chapter in Feller vol. 1. Bi

Re: [R] Summarizing data based on Date

2015-06-09 Thread John Kane
Hi, As David said have a look at str(test). You have a factor in there or else that weird "list(format(test$CR_DT,"%m"))" command in aggregate() is mucking things up. What is "list(format(test$CR_DT,"%m"))" intended to do? No ,a quick test says it is mucking something else up and not giving t

[R] how to reach a txt file like this?

2015-06-09 Thread Ye Lin
​Hey All, I have a txt data file that looks like this: ​[{“ID”:“A”,“Name":"Tom", "Age":"18"},{“ID”:“B”,“Name":"Jim", "Age":"19"}] ​How can I read this into R as a data frame? I have used readLines to read all the lines but dont know how to deal with column names and inputs. Thanks for your help

Re: [R] Unordered combinations with repetition

2015-06-09 Thread William Dunlap
> combnWithRepetition <- function(n, k) combn(n+k-1, k) - seq(from=0, len=k) > combnWithRepetition(2, 2) [,1] [,2] [,3] [1,]112 [2,]122 > combnWithRepetition(3, 2) [,1] [,2] [,3] [,4] [,5] [,6] [1,]111223 [2,]123233

Re: [R] load a very big .RData - error reading from connection

2015-06-09 Thread Boris Steipe
There are several possible reasons and you have really told us nothing that might help isolating the problem. 600 MB is large, but not "very" large. R and your OS should not be expected to have a problem with files of that size. First of all, you'll need to document why you expect this should wo

Re: [R] Summarizing data based on Date

2015-06-09 Thread David L Carlson
What does the following command print out? str(test) The error message indicates that test$CHG_WT is not numeric. - David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:

Re: [R] load a very big .RData - error reading from connection

2015-06-09 Thread carol white via R-help
yes and doesn't help.600MB Thanks Carol On Tuesday, June 9, 2015 12:22 PM, Jim Lemon wrote: Hi carol, Have you tried renaming the file to something like "my.RData"? And just how big is it? Jim On Tue, Jun 9, 2015 at 5:50 AM, carol white via R-help wrote: > Hi,How is it possible t

Re: [R] Summarizing data based on Date

2015-06-09 Thread Shivi82
Hi Petr I researched a lot over the net and R manual as well based on which I revamped my code and came to the code as: test$CR_DT <- as.Date(test$CR_DT, '%d-%b-%y') iii<- aggregate(test$CHG_WT,list(format(test$CR_DT,"%m")),FUN=sum) However it still gives me the error as below: Error in Summary

Re: [R] mismatch between match and unique causing ecdf (well, approxfun) to fail

2015-06-09 Thread Meyners, Michael
Thanks Martin. Yep, I understand it is documented and my code wasn't as it should've been -- the confusion comes from the fact that it worked ok for hundreds of situations that seem very much alike, but one situation breaks. I agree that you typically can't be sure about having only numerical d

Re: [R] load a very big .RData - error reading from connection

2015-06-09 Thread Jim Lemon
Hi carol, Have you tried renaming the file to something like "my.RData"? And just how big is it? Jim On Tue, Jun 9, 2015 at 5:50 AM, carol white via R-help wrote: > Hi,How is it possible to load a very big .RData that can't be loaded it's > very big and the following error msg is displayed > >

Re: [R] Unordered combinations with repetition

2015-06-09 Thread Thomas Chesney
Thank you Nicholas. I've found that Urnsamples in the prob package does it too: urnsamples(1:2, size = 2, replace = TRUE, ordered = FALSE) Thomas From: WRAY NICHOLAS [nicholas.w...@ntlworld.com] Sent: Tuesday, June 09, 2015 10:52 AM To: Thomas Chesney Cc:

Re: [R] Unordered combinations with repetition

2015-06-09 Thread WRAY NICHOLAS
You could try expand.grid -- you'd prob need to modify what's beneath *a=c(0,1,2)* *b=c(0,1)* *c=c(0,1)* *y<-list()* *y[[1]]<-a* *y[[2]]<-b* *y[[3]]<-c* *expand.grid(y)* This code gives all combinations On 9 June 2015 at 10:11, Thomas Chesney wrote: > Does anyone know of a function tha

[R] Unordered combinations with repetition

2015-06-09 Thread Thomas Chesney
Does anyone know of a function that will return all unordered combinations of n elements from a list with repetition? The combs function in caTools will do this without repetition: combs(1:2, 2) [,1] [,2] [1,]12 What I'd like is: 1 1 1 2 2 2 Thank you, Thomas Chesney This me