[R] Fw: Averaging without NAs

2017-03-02 Thread ch.elahe via R-help
The question seems easy but I could not find an answer for it. I have the following column in my data frame and I want to take average of the column excluding the number of NAs. $X2016.Q1 : int 47 53 75 97 NA NA 23 NA 43 NA Does anyone know how to do that? Thanks for any help Elahe

[R] Averaging without NAs

2017-03-02 Thread ch.elahe via R-help
Hi all, The question seems easy but I could not find an answer for it. I have the following column in my data frame and I want to take average of the column excluding the number of NAs. $X2016.Q1 : int 47 53 75 97 NA NA 23 NA 43 NA Does anyone know how to do that? Thanks for any help

[R] make a right subset!

2016-07-07 Thread ch.elahe via R-help
Hi all, I have 2 data frames like the following: the first one df1: 'data.frame': 141obs. of 1 variable: $SerialNum: int 41006 41013 41044 41046 41067 41166 41202 41262 41274 41290 and the second one df2: 'data.frame': 194 obs. of 2 variables: $Serial: int 41006 41013 41018

[R] a new df with one combined column

2016-06-29 Thread ch.elahe via R-help
Hi all, I have this column as a part of df: $License : Factor W/384 levels "41005","41006","41034","41097","41200",... and I have other column which is a part of other df lets say df2: $Diff: int 41166 41202 41290 41353 41503 41507 41548 these two columns df$License and df$Diff

Re: [R] R intersect()

2016-06-28 Thread ch.elahe via R-help
Yes, found it. Thanks On Tuesday, June 28, 2016 4:57 PM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote: On 28/06/2016 10:48 AM, ch.elahe via R-help wrote: > Hi all, > I have the following df: > > > licenseY :int 41006 41013 41044 41046 41067 41166 41202

[R] R intersect()

2016-06-28 Thread ch.elahe via R-help
Hi all, I have the following df: licenseY :int 41006 41013 41044 41046 41067 41166 41202 41262 41274 41290 licenseZ :int 41006 41013 41018 41044 41046 41067 4 41200 41262 41272 I needed the common values in both license columns so I used :

Re: [R] Y in Kohonen xyf function

2016-06-22 Thread ch.elahe via R-help
Dear Kimmo, I already used df$speed[training] in df.xyf but I get this error: Error in xyf(Xtraining,factor(df$speed[training]),grid=somgrid(5, : NA/NaN/Inf in foreign function call (arg 1) On Wednesday, June 22, 2016 3:48 AM, K. Elo wrote: Hi again! 21.06.2016,

Re: [R] Y in Kohonen xyf function

2016-06-21 Thread ch.elahe via R-help
xyf > > > On Thursday, June 16, 2016 2:29 PM, K. Elo <mailli...@pp.inet.fi> wrote: > Hi! > > Some sample data could help us to help you... > > But have you read '?xyf' in order to ensure that your 'Y' is what 'xyf' > expects it to be? > > What kind of error messages

[R] duplicate labels in Bar chart geom_text()

2016-06-21 Thread ch.elahe via R-help
Hi all, how should I avoid duplicate labels in geom_text for bar chart? in the bar chart below I have name of one country repeated several times on my bars, I only want COUNTRY to be shown above each bar:

[R] How to visualize this df

2016-06-20 Thread ch.elahe via R-help
Hi all, I have a question about how to visualize my df! here is my df I need to visualize: 'data.frame': 455 obs. of 128 variables: $Protocol :Factor w/132 levels "_unknown","PD FS SAG","T1 SAG FS","T2 FS OR",... $NRuns : int 45 45 156 75 89 69 .. $Speed

[R] merging df with world map

2016-06-17 Thread ch.elahe via R-help
Hi all, I want to use world map in ggplot2 and show my data on world map. my df is: $ COUNTRY : chr "DE" "DE" "FR" "FR" .. $ ContrastColor : int 9 9 9 9 13 9 9 9 9 .. $ quant : Factor w/ 4 levels "FAST","SLOW",..I need to merge my df with world_map data

Re: [R] Y in Kohonen xyf function

2016-06-16 Thread ch.elahe via R-help
Some sample data could help us to help you... But have you read '?xyf' in order to ensure that your 'Y' is what 'xyf' expects it to be? What kind of error messages do you get? Regards, Kimmo 16.06.2016, 15:13, ch.elahe via R-help wrote: > Is there any answer? > > > Hi all, I have a df

[R] Y in Kohonen xyf function

2016-06-16 Thread ch.elahe via R-help
Is there any answer? Hi all, I have a df and I want to use supervised Self Organizing Map to do classification. I should use Kohonen library and xyf function from it. As you know the xyf function looks like this and I have problem defining my Y:

[R] Y in Kohonen xyf function

2016-06-15 Thread ch.elahe via R-help
Hi all, I have a df and I want to use supervised Self Organizing Map to do classification. I should use Kohonen library and xyf function from it. As you know the xyf function looks like this and I have problem defining my Y: xyf(data,Y,grid=somgrid(),rlen=100,alpha=c(0.05,0.01)) I want to

[R] Factor levels in training set

2016-06-14 Thread ch.elahe via R-help
Hi all, I want to use Supervised Self organizing Maps from Kohonen package for my data. I need to divide my df into training set and test set, but a part of my df contains column with factor levels and I don't know how to bring them into my training set. Currently I use the following command

[R] Factor levels in training set

2016-06-14 Thread ch.elahe via R-help
Hi all, I want to use Supervised Self organizing Maps from Kohonen package for my data. I need to divide my df into training set and test set, but a part of my df contains column with factor levels and I don't know how to bring them into my training set. Currently I use the following command

[R] save rgl.sphere plot

2016-06-10 Thread ch.elahe via R-help
Hi all I have generated a 3D interactive rgl.sphere but I don't know how to save it to be viewed also interactive(being able to rotate it and do zoom-in and out). Does anyone know how should I save it? Thanks for any help! Elahe __

Re: [R] Training set in Self organizing Map

2016-06-05 Thread ch.elahe via R-help
t make sense to ask it to scale character or factor data? Could you perhaps exclude some of the columns that don't belong in the scaled data? -- Sent from my phone. Please excuse my brevity. On June 1, 2016 7:39:30 AM PDT, "ch.elahe via R-help" <r-help@r-project.org>

[R] Training set in Self organizing Map

2016-06-01 Thread ch.elahe via R-help
Hi all, I want to use Self Organizing Map in R for my data. I want my training set to be the following subset of my data: subdf=subset(df,Country%in%c("US","FR")) next I should change this subset to a matrix but I get the following error: data_train_matrix=as.matrix(scale(subdf))

Re: [R] add value to Bar chart ggplot2

2016-05-27 Thread ch.elahe via R-help
maybe this will help: http://stackoverflow.com/questions/6455088/how-to-put-labels-over-geom-bar-in-r-with-ggplot2 or this: http://stackoverflow.com/questions/12018499/how-to-put-labels-over-geom-bar-for-each-bar-in-r-with-ggplot2 Best, Ulrik On Fri, 27 May 2016 at 15:12 ch.elahe via R-help &

[R] add value to Bar chart ggplot2

2016-05-27 Thread ch.elahe via R-help
Hi all , I have the following bar chart and I want to add SLC variable values to the charts but I don't know how to use geom_text: ggplot(df,(Protocol,fill=quant))+geom_bar()+coord_flip() Thanks for any help! Elahe __ R-help@r-project.org

[R] subset data right

2016-05-26 Thread ch.elahe via R-help
Hi all, I have the following df and I want to know which Protocols are VeryFast, which are FAST, which are SLOW and also which ones are VerySLOW : $ Protocol : Factor w/ 48 levels "DP FS QTSE SAG",..: 5 5 28 5 5 5 7 7 47 5 ... $ quant : Factor w/ 4 levels

[R] Factor Variable frequency

2016-05-24 Thread ch.elahe via R-help
Hi all, I have the following df: $ Protocol : Factor w/ 48 levels "DP FS QTSE SAG",..: 2 3 43 42 31 36 37 30 28 5 ... $ Speed : chr "SLOW" "SLOW" "SLOW" "VerySLOW" ... How can I get the most frequent Protocol when Speed is "SLOW"? Thanks for any help! Elahe

[R] An averaged model based on Quartile and Mean of Quartiles

2016-05-21 Thread ch.elahe via R-help
Hi all, Here is my df and I want to make an averaged model of my variables based on Time like the following: $ Protocol : Factor w/ 48 levels "DP FS QTSE SAG",..: 2 3 43 42 $ Time : num 182 185 189 234 186 ... $ Systemtype : Factor w/ 2 levels "Aera XJ","AERA XQ": 1

[R] 3D plots in R.3.2.3

2016-05-18 Thread ch.elahe via R-help
Hi all, I am using R version 3.2.3 and I want to plot 3D histogram or 3D scatterplot. Does anyone know which packages can be used for this version for 3D plots? I tried plot3d but it's not working for this version. Thanks for any help. Elahe __

Re: [R] mean for every quartile

2016-05-16 Thread ch.elahe via R-help
, Michael Dewey <li...@dewey.myzen.co.uk> wrote: Dear Elahe In line On 16/05/2016 13:31, ch.elahe via R-help wrote: > Hi all, > I have a column in my df and I want to get quartiles for this column and then > calculate mean for each and every quartile, here is my column: > The quar

[R] mean for every quartile

2016-05-16 Thread ch.elahe via R-help
Hi all, I have a column in my df and I want to get quartiles for this column and then calculate mean for each and every quartile, here is my column: df$BR [1] 384 384 384 384 512 384 384 320 320 320 320 320 320 320 320 320 320 384 [19] 384 384 320 320 320 320 384 384 256 320 320

Re: [R] changing factor to numbers without getting NAs

2016-05-13 Thread ch.elahe via R-help
6 7:56 AM, ch.elahe via R-help wrote: > Hi all, > I have a df which a part of this is: > > TSTMax :int 213 228 227 281 > TSTMin :int 149 167 158 176 > TSTMean:Factor w/94 levels "100,2" , "104,3" , ... > I want to change the

[R] changing factor to numbers without getting NAs

2016-05-13 Thread ch.elahe via R-help
Hi all, I have a df which a part of this is: TSTMax :int 213 228 227 281 TSTMin :int 149 167 158 176 TSTMean:Factor w/94 levels "100,2" , "104,3" , ... I want to change the TSTMean into numeric but by using as.numeric(as.character(df$TSTMean)) I get too many NAs. Is there

[R] factor variables in logistic regression

2016-05-11 Thread ch.elahe via R-help
Hi all, I have a plot for TSTMean vs. SNRMean and both of these variables are factors. How can I use Logistic Regression for factor variables? Currently I use model=lm(TSTMean~SNRMean,data=df) but when I check summary(model) I get this error: r error in quartile.default (resid) factors are not

[R] undefined columns selected!

2016-05-04 Thread ch.elahe via R-help
Hi all, I know it seems simple but I am trying to copy a code and I don't know what is the problem with this command! msubsub=msub[,cn] the error I get is : error in '[.data.frame '(msub, ,cn) : undefined columns selected Thanks for any help, Elahe

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
men_t2 > > > >On Mon, May 2, 2016 at 7:42 AM, <chalabi.el...@yahoo.de> wrote: > >Thanks Peter, you were right, the exact grepl is >grepl("(.*t2.*pd.*)|(.*pd.*t2.*)",df$Command), but it does not change anything >in Command, when I check the size of it by >sum(

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
uot;(.*t2.*pd.*)|(.*pd.*t2.*)",df$Command), but it does not change anything in Command, when I check the size of it by sum(grepl("(.*t2.*pd.*)|(.*pd.*t2.*)",df$Command)) the result is 0, but I am sure that the size is not 0. It seems that this AND does not work. > > > >

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
e is not 0. It seems that this AND does not work. On Monday, May 2, 2016 5:05 AM, peter dalgaard <pda...@gmail.com> wrote: On 02 May 2016, at 12:43 , ch.elahe via R-help <r-help@r-project.org> wrote: > Thanks for your reply tom. After using > Subset(df,grepl("(.*t2.*pd.*)|(

Re: [R] how to use AND in grepl

2016-05-02 Thread ch.elahe via R-help
(.* t2.*pd.* )|(.* pd.* t2.*)",df$Command) On Sat, Apr 30, 2016, 7:07 PM Tom Wright <t...@maladmin.com> wrote: subset(df,grepl("t2|pd",x$Command)) > > > > >On Sat, Apr 30, 2016 at 2:38 PM, ch.elahe via R-help <r-help@r-project.org> >wrote: > >

[R] how to use AND in grepl

2016-04-30 Thread ch.elahe via R-help
Hi all, I have one factor variable in my df and I want to extract the names from it which contain both "t2" and "pd": 'data.frame': 36919 obs. of 162 variables $TE:int 38,41,11,52,48,75,. $TR:int 100,210,548,546,. $Command :factor

Re: [R] assign color to subsets

2016-04-24 Thread ch.elahe via R-help
ey' as the >colour option for ggplot. > > > > >Jim Holtman >Data Munger Guru > >What is the problem that you are trying to solve? >Tell me what you want to do, not how you want to do it. > >On Sat, Apr 23, 2016 at 4:16 PM, ch.elahe via R-help <r-help@r-project.org&g

Re: [R] assign color to subsets

2016-04-24 Thread ch.elahe via R-help
't1', 't2'))) This will give you a subset with just t1/t2 and you can use 'key' as the colour option for ggplot. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Sat, Apr 23, 2016 at 4:16 PM, ch.elah

[R] assign color to subsets

2016-04-23 Thread ch.elahe via R-help
Hi I have the following df and I created two subsets but I don't know how to use these subsets as the colors of my plot. data.frame': 36919 obs. of 162 variables $TE :int 38,41,11,52,48,75,. $TR :int 100,210,548,546,. $Command :factor W/2229

Re: [R] subset by multiple letters condition

2016-04-23 Thread ch.elahe via R-help
E) hast2 <- grepl("t2", Command, fixed=TRUE) > Command[hast1] [1] "_localize_t1_seq" "_localize_PD_t1" > Command[hasPD] [1] "_localize_PD""_localize_PD_t1" > Command[hast1 & hasPD] [1] "_localize_PD_t1" J

[R] subset by multiple letters condition

2016-04-22 Thread ch.elahe via R-help
Hi all, I have a data frame df and I want to do subset based on several conditions of letters of the names in Command.1)if the names contain PD 2)if the names contain t1 3)if the names contain t2 4)if the names contain t1 and PD 5)if the names contain t2 and PD 6)otherwise the names would be

[R] overlay two facet_grid

2016-04-20 Thread ch.elahe via R-help
Hi all, Does anyone know how to overlay two facet_grids? I have two facet grids as following: ggplot(data=df,aes(x=TE,y=TR,color="orange"))+geom_point()+facet_grid(FS+TRJ~OR+INV,labeller=label_both)+xlim(0,200)+ylim(0,1)

Re: [R] a replace for subset

2016-04-16 Thread ch.elahe via R-help
han...@gmail.com> wrote: Would facet_wrap or facet_grid give you what you want? On Sat, Apr 16, 2016 at 8:45 AM, ch.elahe via R-help <r-help@r-project.org> wrote: Hi, >I have a data set (mydata), which a part of this is like the following: > > >'data.frame': 36190 obs

[R] a replace for subset

2016-04-16 Thread ch.elahe via R-help
Hi, I have a data set (mydata), which a part of this is like the following: 'data.frame': 36190 obs. of 16 variables: $ RE: int 38 41 11 67 30 18 38 41 41 30 ... $ LU : int 4200 3330 530 4500 3000 1790 4700 3400 3640 4000 ... $ COUNTRY:

[R] a replace for subset

2016-04-14 Thread ch.elahe via R-help
Hi,I have a data set (mydata), which a part of this is like the following:   'data.frame':   36190 obs. of 16 variables:$ RE                    : int  38 41 11 67 30 18 38 41 41 30 ...$ LU                     : int  4200 3330 530 4500 3000 1790 4700 3400 3640 4000 ...$ COUNTRY        : Factor w/