Re: [R] Splitting a vector

2013-12-10 Thread Jeff Newmiller
You don't need to wrap 1:12 in c(). Since matrices are just folded vectors, you can convert vector X to a matrix Xm: Xm - matrix( X, nrow=3 ) and access columns to get your your sub-vectors: Xm[,1] Xm[,2] and so on.

[R] read.csv interpreting numbers as factors

2013-12-10 Thread Bill
Why does R interpret a column of numbers in a csv file as a factor when using read.csv() and how can I prevent that. The data looks like 9928 3502 146 404 1831 686 249 I tried kick=read.csv(kick.csv,stringsAsFactors =FALSE) as well as kick=read.csv(kick.csv) Thanks On Mon, Dec 2, 2013 at 5:16

Re: [R] read.csv interpreting numbers as factors

2013-12-10 Thread Jeff Newmiller
It is bad netiquette to hijack an existing thread for a new topic. Please start a new email thread when changing topics. If your data really consists of what you show, then read.csv won't behave that way. I suggest that you open the file in a text editor and look for odd characters. They may

Re: [R] read.csv interpreting numbers as factors

2013-12-10 Thread Barry Rowlingson
On Tue, Dec 10, 2013 at 10:06 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: It is bad netiquette to hijack an existing thread for a new topic. Please start a new email thread when changing topics. If your data really consists of what you show, then read.csv won't behave that way. I

Re: [R] Need help figuring out sapply (and similar functions) with multiple parameter user defined function

2013-12-10 Thread PIKAL Petr
In that case you need correct those cases inside the function. Everything else stays same. Something like fff - function(x) { tb-table(x) if(max(tb)==min(tb)) res - None else res - names(which.max(table(x))) } Regards Petr From: Walter Anderson [mailto:wandrso...@gmail.com] Sent: Monday,

Re: [R] lattice: superposed boxplots with same colors forrectanglesandumbrellas and filled boxes

2013-12-10 Thread Gerrit Eichner
Thank you very much, Rich, for the fast and very helpful reply! It helped me to reach my goal. Regards -- Gerrit PS: I extended your solution to a version that allows slightly finer control over the components of the boxplots, in particular if one wants to combine it with, e.g.,

[R] Problem to predict new data with mclust

2013-12-10 Thread Welma Pereira
Hi, I am trying to use mclust to cluster some data (train_pca_10), I get the clusters, but when I try to use the model to predict new data (test1) I get this error mClust2 - Mclust(train_pca_10,G=2) pred-predict.Mclust(mClust2,test1) Error in if (warn) warning(WARNING) : argument is of length

Re: [R] Multiple Lorenz curves in one diagram - populations with different n

2013-12-10 Thread S Ellison
I want to plot on the same diagram, curves from two different populations, that have different n. How can I do this? Use lines() as well as plot() S *** This email and any attachments are confidential. Any use...{{dropped:8}}

[R] rbind/timestamp problem

2013-12-10 Thread Georg Hörmann
Hello world, I am stuck somehow... I am trying to add a timestamp to a sensitivity matrix: #this code works: sensitivity=data.frame(mtype=1,cdate=2) sensitivity=rbind(sensitivity,c(mtype=2,cdate=2)) # this code does not work - no idea why

Re: [R] rbind/timestamp problem

2013-12-10 Thread jim holtman
try this: sensitivity=rbind(sensitivity,data.frame(mtype=2,cdate=as.POSIXct(Sys.time(), origin=1970-01-01))) sensitivity mtype cdate 1 1 2013-12-10 09:35:53 2 2 2013-12-10 09:37:02 The 'c' function is coercing to numeric. If you want to 'rbind' rows to a dataframe,

Re: [R] Add column to DF based on 2 columns in another DF

2013-12-10 Thread arun
Hi, Try: library(reshape2) m1 - melt(LookupTable,id.vars=Str) m2 - m1 res - merge(MainDataFrame,m1,by.x=c(Str,index),by.y=c(Str,variable)) res[order(res$Str),c(3:6,1:2,7)] #or library(plyr) colnames(m2)[-1] - c(index,index_num)  m2$index - as.character(m2$index)  

Re: [R] How can I find nonstandard or control characters in a large file?

2013-12-10 Thread Earl F Glynn
andrewH wrote: However, my suspicion is that there are some funky characters, either control characters or characters with some non-standard encoding, somewhere in this 14 gig file. Moreover, I am concerned that these characters may cause me trouble down the road even if I use a different

Re: [R] Problem to predict new data with mclust

2013-12-10 Thread Sarah Goslee
Hi, It's unlikely that anyone will be able to see your problem without a reproducible example. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Are you using the mclust package? That would be the first thing we need to know. Then, have you worked through

Re: [R] Using assign with mapply

2013-12-10 Thread Julio Sergio Santana
David Winsemius dwinsemius at comcast.net writes: So what happens if you try this: mapply(assign, kkk$vars, kkk$vals, MoreArgs = list(envir = .GlobalEnv) Yes, it works in certain situations, as well as the equivalent code: kkk - data.frame(vars=c(var1, var2, var3),

Re: [R] 3-D interpretation

2013-12-10 Thread Sarah Goslee
Hi Shane, On Tue, Dec 10, 2013 at 10:35 AM, Shane Carey careys...@gmail.com wrote: Hi, im trying to create a 3-D interpretation of a geological fault using the akima package. But my code fails below highlighted in red: Does anyone have any ideas why this is. This is a plain-text email list,

Re: [R] 3-D interpretation

2013-12-10 Thread Shane Carey
Hi, I have since solved that problem, but now R keeps crashing. I have over 20,000 points. Can R handle that amount? Cheers On Tue, Dec 10, 2013 at 3:35 PM, Shane Carey careys...@gmail.com wrote: Hi, im trying to create a 3-D interpretation of a geological fault using the akima package.

[R] 3-D interpretation

2013-12-10 Thread Shane Carey
Hi, im trying to create a 3-D interpretation of a geological fault using the akima package. But my code fails below highlighted in red: Does anyone have any ideas why this is. Thanks dat-read.delim(D:\\fault.txt,header=T,sep=,) library(rgl) # data rgl.spheres(dat$X,dat$Z , dat$Y,1,color=red)

Re: [R] 3-D interpretation

2013-12-10 Thread Sarah Goslee
Hi, On Tue, Dec 10, 2013 at 10:42 AM, Shane Carey careys...@gmail.com wrote: Hi, I have since solved that problem, It would be useful to post the solution, for the archives, so that others with the same problem can benefit from your insight. but now R keeps crashing. I have over 20,000

Re: [R] 3-D interpretation

2013-12-10 Thread Shane Carey
Hi Sarah, here is some of the data: structure(list(X = c(9816966.951, 9816963.08, 9816947.516, 9816939.51, 9816924.005, 9816916.096, 9816901.984, 9816896.967, 9816892.928, 9816890.743, 9816886.427, 9816884.006, 9816879.185, 9816876.468, 9816871.027, 9816868.276, 9816863.404, 9816860.712,

Re: [R] 3-D interpretation

2013-12-10 Thread David Carlson
The error says you have duplicate points in dat so you need to set duplicate= to tell interp() how to handle them. ?interp - David L Carlson Department of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From:

Re: [R] 3-D interpretation

2013-12-10 Thread Shane Carey
Hey David, I set it equal to the mean. duplicate=mean but still no joy, Thanks On Tue, Dec 10, 2013 at 4:28 PM, David Carlson dcarl...@tamu.edu wrote: The error says you have duplicate points in dat so you need to set duplicate= to tell interp() how to handle them. ?interp

Re: [R] 3-D interpretation

2013-12-10 Thread Shane Carey
it just keeps crashing on me, It seems to crash on this line rgl.surface(akima.li$x,akima.li$y,akima.li$z,color=green,alpha=c(0.5)) On Tue, Dec 10, 2013 at 4:32 PM, David Carlson dcarl...@tamu.edu wrote: I guess you will have to give us a reproducible example. Are you still getting the same

Re: [R] 3-D interpretation

2013-12-10 Thread David Carlson
I guess you will have to give us a reproducible example. Are you still getting the same error message? David From: Shane Carey [mailto:careys...@gmail.com] Sent: Tuesday, December 10, 2013 10:30 AM To: dcarl...@tamu.edu Cc: r-help@r-project.org Subject: Re: [R] 3-D interpretation Hey David,

Re: [R] rbind/timestamp problem

2013-12-10 Thread Georg Hörmann
Thank you, now it works. I would never have never found the source of the problem. I am trying to build a data frame with results from a sensitivity analysis for a model. I use rbind because the number of rows is unkown and i use the timestamp as a hint for the students that they do not

Re: [R] growth curve estimation

2013-12-10 Thread Dániel Kehl
Dear Vito, Robert and David, thank you for your replies, although I made some step forward on my own, your answers helped a lot and gave me more insight. The only question I have left is why this code gives me an error (and that is what David asked for): m1 - lms(BMI,age,data=adatok_fiu,

[R] If-statement in for-loop

2013-12-10 Thread gncl dzgn
Hi everyone, you might find my question elementary but I am a beginner and unfortunately I can't fix the problem. So, I simulate this following algorithm and some values of c are NA. Therefore, I should add these following two if-statements but I don't know how I should do it in a for-loop.

Re: [R] adding tables

2013-12-10 Thread Eik Vettorazzi
How about this: t2 - table(c(10,11,12,13)) t1 -table(c(1,1,2,4,5)) t12-(rbind(as.data.frame(t1),as.data.frame(t2))) xtabs(Freq~.,t12) it works for overlapping tables t2 - table(c(10,11,12,13,1,2)) t1 -table(c(1,1,2,4,5,11,12)) t12-(rbind(as.data.frame(t1),as.data.frame(t2))) xtabs(Freq~.,t12)

Re: [R] Problem to predict new data with mclust

2013-12-10 Thread Welma Pereira
Btw I am using mclust, and basically wanted to reproduce the mstep and estep of the Mclust algorithm for new data. Any help is appreaciated! On 10 December 2013 21:23, Welma Pereira welma.pere...@gmail.com wrote: Hi, Thanks for the hint Sarah. So here is my problem again: (files train_pca

Re: [R] Problem to predict new data with mclust

2013-12-10 Thread Sarah Goslee
Many people do not want to download and open random attachments. That's why I suggested dput() with part of your data. dput(head(yourdata, 20)) is enough for many problems, though it's good to try it out. Or use one of the datasets built into R. Sarah On Tue, Dec 10, 2013 at 3:23 PM, Welma

[R] Get average model after dredge function ran in a loop

2013-12-10 Thread Catarina Ferreira
Dear all I'm a beginner in R and I'm trying to get the final model after I run the dredge function for 10 times (with a loop): ###Building the Model Coy.glm0-glm(pa ~ shrub + snowdep + tree + bio5 + bio6 + bio12 + log(human+1), data=Coy.pa, family=binomial) summary(Coy.glm0)

Re: [R] Need help figuring out sapply (and similar functions) with multiple parameter user defined function

2013-12-10 Thread Walter Anderson
Petr, Thank you for you assistance. Particularly this last bit. It really helped me understand exactly how your solution worked and why I was confused by rapply processing rows. It was apply that could process rows (and/or columns) of a matrix, Anyway for anyone who wants the version of

[R] Add column to DF based on 2 columns in another DF

2013-12-10 Thread bcrombie
LookupTable - read.table(header = TRUE, stringsAsFactors = FALSE, text=Str IND13 IND12 IND11 IND07 IND06 1 517 529 562 562 567 2 517 529 562 562 568 3 517 529

Re: [R] Fwd: Datatable manipulation

2013-12-10 Thread Nitisha jha
Hi, I have a doubt after a long time :) . I have a function which has sqldf statements and it works fine when I call it from console but when I am calling that function within another function, it gives me the error that *Error in sqliteExecStatement(con, statement, bind.data) : * * RS-DBI

[R] data distribution for lme

2013-12-10 Thread peyman
Hi folks, I am using the lme package of R, and am wondering if it is assumed that the dependent factor (what we fit for; y in many relevant texts) has to have a normal Gaussian distribution? Is there any margins where some skewness in the data is accepted and how within R itself one could check

Re: [R] Fwd: Datatable manipulation

2013-12-10 Thread arun
Hi, Check these links: http://stackoverflow.com/questions/19626534/r-issue-error-in-sqliteexecstatementcon-statement-bind-data-no-such-tabl http://r.789695.n4.nabble.com/Problem-with-SQLDF-Error-in-sqliteExecStatement-con-statement-bind-data-RS-DBI-driver-error-in-state-td4621931.html A.K.

Re: [R] Add column to DF based on 2 columns in another DF

2013-12-10 Thread bcrombie
Thanks, AK. That gets the job done and I learned 2 ways to do it. Much appreciated as always. -- View this message in context: http://r.789695.n4.nabble.com/Add-column-to-DF-based-on-2-columns-in-another-DF-tp4681950p4681969.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] data distribution for lme

2013-12-10 Thread Bert Gunter
This is not really an R question -- it is statistics. In any case, you should do better posting this on the R-Sig-Mixed-Models list, which concerns itself with matters like this. However, I'll hazard a guess at an answer: maybe. (Vague questions elicit vague answers). Cheers, Bert On Tue, Dec

[R] radial.plot shaded region

2013-12-10 Thread Hodge, Steven
I'm working with radial.plot in the plotrix package. Is there a way to show a shaded region for a specific range of values in radial.lim? For example: # test data from radial.plot{plotrix} testlen-c(sin(seq(0,1.98*pi,length=100))+2+rnorm(100)/10) testpos-seq(0,1.98*pi,length=100) # the

Re: [R] radial.plot shaded region

2013-12-10 Thread Jim Lemon
On 12/11/2013 10:33 AM, Hodge, Steven wrote: I'm working with radial.plot in the plotrix package. Is there a way to show a shaded region for a specific range of values in radial.lim? For example: # test data from radial.plot{plotrix} testlen-c(sin(seq(0,1.98*pi,length=100))+2+rnorm(100)/10)

Re: [R] data distribution for lme

2013-12-10 Thread Andrew Robinson
No - it is assumed to be conditionally normal, that is, normal conditional on the model. So you should be looking at the distributions of the residuals rather than of the response variable, as an indicator for whether or not the model assumptions are satisfied. Skewness in the residuals may or

Re: [R] fisher.test - can I use non-integer expected values?

2013-12-10 Thread David Winsemius
On Dec 10, 2013, at 2:04 PM, bakerwl wrote: I seem to be able to use expected values that are decimal (e.g., 1.33) when using chisq.test but not when using fisher.test. There are no expected values in the input to fisher.test. This happens when using an array/matrix as input. Fisher.test

Re: [R] data distribution for lme

2013-12-10 Thread Rolf Turner
See inline below. On 12/11/13 11:28, Bert Gunter wrote: This is not really an R question -- it is statistics. In any case, you should do better posting this on the R-Sig-Mixed-Models list, which concerns itself with matters like this. However, I'll hazard a guess at an answer: maybe. (Vague

Re: [R] radial.plot shaded region

2013-12-10 Thread David Winsemius
On Dec 10, 2013, at 4:24 PM, Jim Lemon wrote: On 12/11/2013 10:33 AM, Hodge, Steven wrote: I'm working with radial.plot in the plotrix package. Is there a way to show a shaded region for a specific range of values in radial.lim? For example: # test data from radial.plot{plotrix}

Re: [R] fisher.test - can I use non-integer expected values?

2013-12-10 Thread bakerwl
David, Thanks for your reply--I appreciate your thoughts. I will look at prop.test. The reason I chose fisher.test over chisq.test is that fisher.test is more appropriate when observed counts are not numerous--empty cells and cells with counts 5 are less a problem. Expected values are needed

Re: [R] radial.plot shaded region

2013-12-10 Thread Jim Lemon
On 12/11/2013 11:24 AM, Jim Lemon wrote: ... There may be a solution using the radial.pie function, and if I find it, I'll post it. Hi Steve, Here it is. Just call radial.pie twice to get the annulus, then call radial.grid with the appropriate arguments, and then you can add whatever

Re: [R] data distribution for lme

2013-12-10 Thread Bert Gunter
Thanks Rolf and Andrew. I was entirely too careless and should take a trip to the woodshed (google David Stockman woodshed for the reference). The correct answer therefore is: maybe for the residuals, for the right model, of course. But I still think the crowd on r-sig-mixed-models is the right

Re: [R] fisher.test - can I use non-integer expected values?

2013-12-10 Thread David Winsemius
On Dec 10, 2013, at 6:55 PM, bakerwl wrote: David, Thanks for your reply--I appreciate your thoughts. I will look at prop.test. The reason I chose fisher.test over chisq.test is that fisher.test is more appropriate when observed counts are not numerous--empty cells and cells with counts

Re: [R] fisher.test - can I use non-integer expected values?

2013-12-10 Thread David Winsemius
On Dec 10, 2013, at 8:21 PM, David Winsemius wrote: On Dec 10, 2013, at 6:55 PM, bakerwl wrote: David, Thanks for your reply--I appreciate your thoughts. I will look at prop.test. The reason I chose fisher.test over chisq.test is that fisher.test is more appropriate when observed

Re: [R] fisher.test - can I use non-integer expected values?

2013-12-10 Thread Peter Langfelder
On Tue, Dec 10, 2013 at 6:55 PM, bakerwl bake...@uwyo.edu wrote: Expected values are needed to test a null hypothesis against observed counts, but if total observed counts are 20 for 3 categories, then a null hypothesis of a random effect would use expected values = 6.67 in each of the 3

Re: [R] Stochastic Dominance Analysis

2013-12-10 Thread Peter Maclean
Do anyone now R packages that run/test stochastic dominance with respect to a function (SDRF) and/or stochastic efficiency with respect to a function (SERF)? Peter Maclean Department of Economics UDSM [[alternative HTML version deleted]] __

[R] setting effect plot parameters

2013-12-10 Thread otoolem
I have tried to set parameters of an effects plot with moderate success, but I'm finding that although the plot(effect()) method uses trellis graphics (via the lattice package), not all aspects of the plot can be controlled by standard trellis graphics. I am able to set any parameters that are

Re: [R] Splitting a vector

2013-12-10 Thread Long Vo
This does what I needed. However, as the output is a list object, is there any way to apply a function to such object? For example if I want to compute the mean for the 4th subvectors, I can't simply use: # Y=split(X,as.numeric(gl(length(X),3,length(X mean(Y[4]) # as the error message

[R] SDM using BIOMOD2 error message

2013-12-10 Thread lindsiebug9
Hi I am working on Species Distribution Modeling in R using BIOMOD2. When picking my algorithms to model I keep getting an error message about length (pred) this is the code that I'm using library(knitr) library(markdown) library(rgdal) library(raster) library(shapefiles)