[R] How can I apply “Sapply” in R with multiple codes in one function?

2013-12-09 Thread kmmoon100
Hello everybody, I am a new R user..(still;;;). I have a simple sapply function example for calculating mean and sd of splited data scale. My data contains half hourly wind speed with direction. I want to know daily weibull distribution for my study for 13 years. That is why my dataset is

Re: [R] growth curve estimation

2013-12-09 Thread Vito M. R. Muggeo
dear Daniel, yet another package performing growth modelling is quantregGrowth. It uses quantile regressions with B-splines and quadratic penalties to ensure flexible estimation with additional noncrossing and monotonicity (optional) constraints. The paper underlying the package is here:

Re: [R] tune an support vector machine

2013-12-09 Thread Uwe Bohne
This is the solution fpr the problem. Its not the cleanest one i guess but it works just the way i wanted. If anybody has better performing or cleaner code, please send it to me. best regards Uwe type-sample(c(-1,1) , 20, replace = TRUE ) weight-sample(c(20:50),20,

Re: [R] Why daisy() in cluster library failed to exclude NA when computing dissimilarity

2013-12-09 Thread Martin Maechler
Gundala Viswanath gunda...@gmail.com on Sun, 8 Dec 2013 16:11:12 +0900 writes: Hi, According to daisy function from cluster documentation, it can compute dissimilarity when NA (missing) value(s) is present.

Re: [R] combine glmnet and coxph (and survfit) with strata()

2013-12-09 Thread Aaron Mackey
I'm also curious how to use glmnet with survfit -- specifically, for use with interval regression (which, under the hood, is implemented using survfit). Can you show how you converted your Surv object formula to a design matrix for use with glmnet? Thanks, -Aaron On Sun, Dec 8, 2013 at 12:45

[R] multiple bar for barchart

2013-12-09 Thread Adel ESSAFI
Hello list, I have the following data on dm table dm Group.1 V1 V2 V3V4 V5 V6 V7 V8 1 C/L NA 15.5 732179 875270.6 -143091.46 1107270 1088300 18964.40 2 C/S NA 15.5 803926 850352.1 -46426.03 1395710 1312310 83403.30 3 D/D NA 15.5

[R] notch filter in R

2013-12-09 Thread Soeren Groettrup
Hi everybody, I am dealing with a time series of eeg data and I need to filter them with a notch filter. However, I could only find the function notch() in the RTisean package. Unfortunately, this function is not implemented yet. Is there another package/function in R which performs such a

Re: [R] notch filter in R

2013-12-09 Thread Bretschneider (R)
Dear Soeren Groettrup, Re: I am dealing with a time series of eeg data and I need to filter them with a notch filter. However, I could only find the function notch() in the RTisean package. Unfortunately, this function is not implemented yet. Is there another package/function in R which

Re: [R] multiple bar for barchart

2013-12-09 Thread Richard M. Heiberger
Start here dm - read.table(text= Group.1 V1 V2 V3V4 V5 V6 V7 V8 1 C/L NA 15.5 732179 875270.6 -143091.46 1107270 1088300 18964.40 2 C/S NA 15.5 803926 850352.1 -46426.03 1395710 1312310 83403.30 3 D/D NA 15.5 751660 857828.2

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

2013-12-09 Thread PIKAL Petr
Hi You probably missed this Instead of those tricky ifs (uff uff) you can use either of these df[df[,2]==2,2]-3 df$C-as.numeric(as.character(factor(df$C, labels=c(0,2,3 df A B C 1 0 3 3 2 0 1 2 3 0 3 2 4 1 0 3 5 1 0 3 6 2 3 2 7 1 3 2 8 2 3 3 9 1 1 0 10 0 0 3 And here I am lost

Re: [R] How can I apply “Sapply” in R with multiple codes in one function?

2013-12-09 Thread Jeff Newmiller
There is a no-homework policy on this mailing list (see the Posting Guide mentioned at the bottom of every email). If this is not assigned homework then at the very least you need to understand R and your problem well enough to provide a reproducible example [1] before we can communicate about

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

2013-12-09 Thread PIKAL Petr
Hi you are still rather cryptic. If you said you want to extract prevalent choices in each row it would save me (and you) a lot of time. Import data and make necessary chnages survey.results - read.csv(SamplePairedComparisonData.csv) survey.results[survey.results[,3]==2,3]-3 # Convert column

Re: [R] [BioC] Why daisy() in cluster library failed to exclude NA when computing dissimilarity

2013-12-09 Thread James W. MacDonald
Hi Gundala, This question isn't about a Bioconductor package, so should be asked on R-help instead. Best, Jim On Sunday, December 08, 2013 2:11:12 AM, Gundala Viswanath wrote: Hi, According to daisy function from cluster documentation, it can compute dissimilarity when NA (missing)

Re: [R] GAM Assumption Tests

2013-12-09 Thread Mike.lang
it's a pity, but thanks anyway! -- View this message in context: http://r.789695.n4.nabble.com/GAM-Assumption-Tests-tp4681670p4681857.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

[R] Problem with Barplots on Map

2013-12-09 Thread Indrajit Sengupta
I am trying to plot vertical bar plots over a map. I went through examples online but somehow not being able to. My data is currently in this format: University| Count | Category | lat | long Here is the code that I am trying execute:

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

2013-12-09 Thread Walter Anderson
Petr, Thank you for your assistance; however, your code does not produce the correct results in the following two cases; ID,Q1,Q2,Q3 17,Option 1, Option 3, Option 2 24,Option 2, Option 3, Option 1 In both cases it chooses a preference of Option 1, when the correct answer is None # The data

Re: [R] growth curve estimation

2013-12-09 Thread Robert Rigby
Dear Daniel, There are several papers which use gamlss for centile estimation. See www.gamlss.org/ and click MORE ON GAMLSS, Books Articles. In particular Rigby and Stasinopoulos (2004, 2005, 2006, 2013) and Stasinopoulos and Rigby (2007). m3 - gamlss(BMI~age, family=BCT,

[R] Model selection exponential and gamma distribution using cross validation

2013-12-09 Thread Man Zhang
Dear All, I have fitted the exponential and gamma model to my univariate data and obtained the MLE estimates using the R package fitdistr, now I'm trying to do model selection based on leave-one-out cross validation, are there any readily avaliable R package to do this. Thanks!

Re: [R] combine glmnet and coxph (and survfit) with strata()

2013-12-09 Thread Jieyue Li
check this one http://stackoverflow.com/questions/16299891/estimating-many-interaction-terms-in-glmnet On Mon, Dec 9, 2013 at 5:39 AM, Aaron Mackey ajmac...@gmail.com wrote: I'm also curious how to use glmnet with survfit -- specifically, for use with interval regression (which, under the

[R] (no subject)

2013-12-09 Thread Elham Shaarbaf
Hello, I want to fit linear mixed model for non-normal observation. Which package is appropriate? Thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

[R] roxygen2 and install.packages()

2013-12-09 Thread François Lefebvre
Hi, I am unable to install roxygen2 on R3.0.2. Any idea why? install.packages(roxygen2) Installing package into ‘/home/lefebvr3/R/x86_64-unknown-linux-gnu-library/3.0’ (as ‘lib’ is unspecified) Warning message: package ‘roxygen2’ is not available (for R version 3.0.1) sessionInfo() R version

[R] How to use multiple test for trend in proportions?

2013-12-09 Thread celebrex
dataorder.csv http://r.789695.n4.nabble.com/file/n4681879/dataorder.csv I have a set of data as attached.Like (181,246,378).(180,228,378)And I want to use test for trend in proportions using (400,500,600) as denominator and get 119 p-valuesSo I use the code as

Re: [R] roxygen2 and install.packages()

2013-12-09 Thread Hadley Wickham
Unfortunately roxygen2 3.0.0 now requires R 3.0.2. See https://github.com/klutometis/roxygen/issues/163 for some discussion as to why. Hadley On Mon, Dec 9, 2013 at 12:28 PM, François Lefebvre lefeb...@gmail.com wrote: Hi, I am unable to install roxygen2 on R3.0.2. Any idea why?

Re: [R] (no subject)

2013-12-09 Thread Kevin Wright
A more complete description of non-normal would be helpful. You might start with lme4 and MCMCglmm. See: http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4newwindow=1q=mixed%20model%20nonnormalsa=Searchcof=FORID%3A11 Kevin On Mon, Dec 9, 2013 at 11:58 AM, Elham Shaarbaf

[R] Revolutions blog: November roundup

2013-12-09 Thread David Smith
Revolution Analytics staff write about R every weekday at the Revolutions blog: http://blog.revolutionanalytics.com and every month I post a summary of articles from the previous month of particular interest to readers of r-help. In case you missed them, here are some articles related to R from

Re: [R] roxygen2 and install.packages()

2013-12-09 Thread Jeff Newmiller
The package specifies it. Either because the package author has used some feature that is only available in that version, or he did not test it in any earlier version. You can contact the maintainer (?maintainer) or try modifying the package dependencies and finding out yourself if it is a real

[R] data frame question

2013-12-09 Thread Andras Farkas
Dear All please help with the following: I have: a -seq(0,10,by=1) b -c(10:20) d -cbind(a,b) f -16 I would like to select the value in column a based on a value in column b, where the value in column b is the 1st value that is smaller then f. Thus I should end up with the number 5 because

Re: [R] growth curve estimation

2013-12-09 Thread David Winsemius
On Dec 8, 2013, at 7:45 AM, Dániel Kehl wrote: Dear Community, I am struggling with a growth curve estimation problem. It is a classic BMI change with age calculation. I am not an expert of this field but have some statistical experience in other fields. Of course I started reading

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

2013-12-09 Thread Walter Anderson
Karen, Thank you for your reply. That approach makes the code for determining preference much clearer. Unfortunately, it appears I am still needing to use a for loop to process each row. For any who find these posts and may have similar questions, I am including my current code and sample

Re: [R] data frame question

2013-12-09 Thread Sarah Goslee
Thank you for providing a reproducible example. I tweaked it a little bit to make it actually a data frame problem. There are lots of ways to do this; here's one approach. On second thought, this looks a lot like homework, so perhaps instead I'll just suggest using subset() with more than one

Re: [R] How to perform clustering without removing rows where NA is present in R

2013-12-09 Thread Sarah Goslee
Though your second question, restating this, has already been answered, it might be worth you taking another look at your code in this one as well. In particular note that NA and NA are NOT the same thing. data(mtcars) str(mtcars) # from your code mtcars[2,2] - NA mtcars[6,7] - NA str(mtcars)

Re: [R] data frame question

2013-12-09 Thread Sarah Goslee
If it's not homework, then I'm happy to provide more help: a -seq(0,10,by=1) b -c(10:20) d -data.frame(a=a,b=b) f -16 subset(d, b f b == max(b[b f]))$a # I'd turn it into a function getVal - function(d, f) { subset(d, b f b == max(b[b f]))$a } Sarah On Mon, Dec 9, 2013 at 3:50

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

2013-12-09 Thread andrewH
I have a humongous csv file containing census data, far too big to read into RAM. I have been trying to extract individual columns from this file using the colbycol package. This works for certain subsets of the columns, but not for others. I have not yet been able to precisely identify the

Re: [R] How to use multiple test for trend in proportions?

2013-12-09 Thread David Winsemius
On Dec 9, 2013, at 9:46 AM, celebrex wrote: dataorder.csv http://r.789695.n4.nabble.com/file/n4681879/dataorder.csv I have a set of data as attached.Like (181,246,378).(180,228,378). And I want to use test for trend in proportions using (400,500,600) as denominator and get 119

Re: [R] multiple bar for barchart

2013-12-09 Thread Richard M. Heiberger
The etiquette of this email list is to stay on the list. I am returning this email to the entire list. The line I sent earlier prints one Figure, with a different set of 4 bars in each panel. Here are three more options (and I repeat the first as well). Basic documentation for barchart is in

[R] Problem with R colors

2013-12-09 Thread Katharine Miller
Hello, I am having difficulty obtaining the correct colors in my R charts. colors()[c(552, 254, 26)] [1] red green blue But, if I specify col=552 in my barplot, I get gray bars. Likewise, col=254 gives bright pink, and col=26 is a red-orange. I get accurate results when I spell out the

[R] lattice: superposed boxplots with same colors for rectanglesand umbrellas and filled boxes

2013-12-09 Thread Gerrit Eichner
Dear R-list, I've been trying to produce a sort of an interaction plot wherein colored stripplots and boxplots are superposed. In particular, I want the colors of the (transparently) filled boxes to be the same as the colors of the box borders (rectangle) and their whiskers (umbrella). Below

Re: [R] Problem with R colors

2013-12-09 Thread Sarah Goslee
Hi, col=552 isn't the same as colors()[552] - I think the former is drawn from your current palette, with recycling of indices. The default color palette has only eight colors. You need instead col=colors()[552] It's very difficult to get 20-30 readily distinguishable colors. You might try the

[R] Plot mortality data and show trend

2013-12-09 Thread Norbi Gurracho
I have a mortality data over many years and I wish to plot the data and also add some smoother to clearly highlight the trend. How could I do that in R with base graphics or ggplot? I have the following sample data: require(lubridate) mdate-seq(ymd('2000-01-01'),ymd('2010-12-31'), by = '1

[R] How to coerce an object name to character vector?

2013-12-09 Thread Антон Морковин
For example, I have a numeric vector named d (without any attributes) and I want to coerce it to character vector d. Is there any such functions? I need it to make a function which applies other functions to objects, something like this: do-function(x,fun, ...) {

Re: [R] data frame question

2013-12-09 Thread Toth, Denes
Hi Andras, here is an other solution which also works if b contains missing values: a -seq(0,10,by=1) b -c(NA, 11:20) f -16 # a[which.max(b[bf])] # However, your question seems a bit artificial. Maybe you converted your original question to a suboptimal problem. HTH, Denes If it's not

[R] Chart colors

2013-12-09 Thread Katharine Miller - NOAA Federal
Hello, I am having difficulty obtaining the correct colors in my R charts. colors()[c(552, 254, 26)] [1] red green blue But, if I specify col=552 in my barplot, I get gray bars. Likewise, col=254 gives bright pink, and col=26 is a red-orange. I get accurate results when I spell out the

Re: [R] How do I print predicted effect sizes in forest plot?

2013-12-09 Thread Alma Wilflinger
Thank you very much Wolfgang and Michael for your help and information. Now I know how to get the predicted values. For information, my mean is the effect size for the one-sample-case. Obviously I used misleading labels, but I calculated the same with CMA and getting the same results, so it

Re: [R] Problem with R colors

2013-12-09 Thread David Carlson
The full details on the col= argument can be found in the section titled Color Specification on the help page for par - ?par. Basically, col= accepts color names, hexadecimal RGB, or an integer designating a position on the current palette. You can get the current palette using palette() [1]

Re: [R] lattice: superposed boxplots with same colors for rectanglesand umbrellas and filled boxes

2013-12-09 Thread Richard M. Heiberger
Gerrit, Thank you for the opportunity to illustrate this. I solved this problem last week and it will be included in the next version of the HH package (about a month away). panel.bwplot.constantColor - function(..., col, fill, cex, pch) { ## to be included in next version of the HH package

Re: [R] Chart colors

2013-12-09 Thread Michael Sumner
Those numbers that you pass to col = ... correspond to the current sessions palette, not to the names of colors() that R knows about. You can either set up your own palette: ## see current palette palette() [1] black red green3 bluecyanmagenta yellow [8] gray ## set up new

Re: [R] Chart colors

2013-12-09 Thread Peter Langfelder
On Mon, Dec 9, 2013 at 2:08 PM, Katharine Miller - NOAA Federal katharine.mil...@noaa.gov wrote: Hello, I am having difficulty obtaining the correct colors in my R charts. colors()[c(552, 254, 26)] [1] red green blue But, if I specify col=552 in my barplot, I get gray bars. Likewise,

Re: [R] Problem with R colors

2013-12-09 Thread Katharine Miller
Thanks everyone! You've been a big help. I've only ever worked with a few colors before, so this is something new! On Mon, Dec 9, 2013 at 1:46 PM, David Carlson dcarl...@tamu.edu wrote: The full details on the col= argument can be found in the section titled Color Specification on the help

Re: [R] Chart colors

2013-12-09 Thread Jeff Newmiller
Not reading the documentation for color specification? Integers do not specify offsets in the colors() table. ?par If you do want offsets into the colors table, perhaps you should do just that? ..., col=colors()[ c( 552, 254, 26 )], ...

Re: [R] multiple bar for barchart

2013-12-09 Thread Jim Lemon
On 12/10/2013 01:19 AM, Adel ESSAFI wrote: Hello list, I have the following data on dm table dm Group.1 V1 V2 V3V4 V5 V6 V7 V8 1 C/L NA 15.5 732179 875270.6 -143091.46 1107270 1088300 18964.40 2 C/S NA 15.5 803926 850352.1

Re: [R] How to coerce an object name to character vector?

2013-12-09 Thread MacQueen, Don
Not tested, but I think you may want this: do - function(x,fun, ...) { fun - match.fun(fun) obj.name - deparse(substitute(x)) assign(obj.name,fun(x, ...)) } -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On

Re: [R] Plot mortality data and show trend

2013-12-09 Thread Jim Lemon
On 12/10/2013 07:53 AM, Norbi Gurracho wrote: I have a mortality data over many years and I wish to plot the data and also add some smoother to clearly highlight the trend. How could I do that in R with base graphics or ggplot? I have the following sample data: require(lubridate)

[R] adding tables

2013-12-09 Thread Ross Boylan
Can anyone recommend a good way to add tables? Ideally I would like t1 - table(x1) t2 - table(x2) t1+t2 It t1 and t2 have the same levels this works fine, but I need something that will work even if they differ, e.g., t1 1 2 4 5 2 1 1 1 t2 - table(c(10, 11, 12, 13)) t1+t2 # apparently

Re: [R] adding tables [partial solution]

2013-12-09 Thread Ross Boylan
Answering myself... On Mon, 2013-12-09 at 15:59 -0800, Ross Boylan wrote: Can anyone recommend a good way to add tables? For count data, which were my main concern, it looks as if tabulate with nbins will work. I'm not sure how this works with a cross-classifying factor, which I will also need.

Re: [R] adding tables [partial solution]

2013-12-09 Thread Roy Mendelssohn
Is this what you are after? http://www.statmethods.net/management/merging.html -Roy On Dec 9, 2013, at 4:09 PM, Ross Boylan r...@biostat.ucsf.edu wrote: Answering myself... On Mon, 2013-12-09 at 15:59 -0800, Ross Boylan wrote: Can anyone recommend a good way to add tables? For count data,

Re: [R] adding tables [partial solution]

2013-12-09 Thread Ross Boylan
On Mon, 2013-12-09 at 16:20 -0800, Roy Mendelssohn wrote: Is this what you are after? http://www.statmethods.net/management/merging.html Not directly. Something could probably be fashioned using it and as.data.frame on the result of table(), but merge doesn't sum values. Ross -Roy On Dec

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

2013-12-09 Thread Patricia Costa
Dear R users, I'm using the ineq package to calculate the values ​​of Gini and Lorenz coefficients and to and plot Lorenz graph. I want to plot on the same diagram, curves from two different populations, that have different n. How can I do this?   Best regards,   Patricia

Re: [R] How to coerce an object name to character vector?

2013-12-09 Thread Bert Gunter
Don: I defer to your judgment as to whether this was what the OP wanted, but I think you would agree that the idiom of assign()ing to the global workspace from within a function is almost always a bad idea in R. Unfortunately, a better alternative, which frequently involves building up a list

Re: [R] adding tables

2013-12-09 Thread David Winsemius
On Dec 9, 2013, at 3:59 PM, Ross Boylan wrote: Can anyone recommend a good way to add tables? Ideally I would like t1 - table(x1) t2 - table(x2) t1+t2 It t1 and t2 have the same levels this works fine, but I need something that will work even if they differ, e.g., t1 1 2 4 5 2 1 1

Re: [R] adding tables [solution]

2013-12-09 Thread Ross Boylan
On Mon, 2013-12-09 at 16:09 -0800, Ross Boylan wrote: Answering myself... On Mon, 2013-12-09 at 15:59 -0800, Ross Boylan wrote: Can anyone recommend a good way to add tables? For count data, which were my main concern, it looks as if tabulate with nbins will work. I'm not sure how this

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

2013-12-09 Thread Pascal Oettli
Hello, Please read: library(fortune) fortune('TFM') Then: ?plot.Lc HTH, Pascal On 10 December 2013 09:19, Patricia Costa patcost...@yahoo.com.br wrote: Dear R users, I'm using the ineq package to calculate the values of Gini and Lorenz coefficients and to and plot Lorenz graph. I

Re: [R] adding tables

2013-12-09 Thread arun
HI, May be this helps: t2 - table(c(10,11,12,13))  t1 -table(c(1,1,2,4,5)) t - c(t1,t2) tapply(t,sort(as.numeric(names(t))),sum) A.K. On Monday, December 9, 2013 7:01 PM, Ross Boylan r...@biostat.ucsf.edu wrote: Can anyone recommend a good way to add tables? Ideally I would like t1 -

[R] Splitting a vector

2013-12-09 Thread Long Vo
Hi, I am quite new to R so I know that this probably is very basic , but how can I split a sequence of number into multiple parts with equal length? For example I have a vector X=c(1:12) I simply need to split it into sub-vectors with the same length N . Say N=3 then I need the output to be like

Re: [R] Splitting a vector

2013-12-09 Thread arun
Hi, Try: split(X,as.numeric(gl(length(X),3,length(X A.K. Hi, I am quite new to R so I know that this probably is very basic , but how can I split a sequence of number into multiple parts with equal length? For example I have a vector X=c(1:12) I simply need to split it into sub-vectors

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

2013-12-09 Thread Enrico Schumann
On Mon, 09 Dec 2013, andrewH ahoer...@rprogress.org writes: I have a humongous csv file containing census data, far too big to read into RAM. I have been trying to extract individual columns from this file using the colbycol package. This works for certain subsets of the columns, but not for