Re: [R] count by value

2013-04-10 Thread Jim Lemon
On 04/10/2013 04:45 AM, catalin roibu wrote: Hello all! I have a big problem now. I want a data frame like this: dput(head(test,100)) ... Now I want to group rownames (in this case year) in 10 years classes and I want to count for each 10 years classe (decade) the number of major and minor

[R] Optimization problem

2013-04-10 Thread nntx
As a simple example, I want to find minimum value for x^2, but it can't be obtained by: f-function(x)x^2 optimize(f,lower=-1,upper=1) What are other methods to deal with this? I tried DEoptim, still doesn't work. Any suggustions will be extremely helpful! THanks! Shelly -- View this message

Re: [R] problem quitting

2013-04-10 Thread Julian Wells
Many thanks to Peter and Brian for their help; it was indeed a permissions problem; thanks also to Josh Paulson of the RStudio team for pointing me to instructions for making the necessary changes. But at the risk of seeming not only ungrateful and pedantic, but also off-topic, can I point out

Re: [R] Dengrogram Help (Custom Make)

2013-04-10 Thread gunturus
Hi Lets say I made dendrogram using this matrix A B C D E A 143 2 7 B 4 1 73 9 C 3 7192 D 2 3 915 E 7 9251 I want a value to next each leaf. The value is represented using a heatcolor square. So for each leave

Re: [R] Dengrogram Help (Custom Make)

2013-04-10 Thread gunturus
But how would I get the coordinates of the leaves to draw a rectangle. And what about determining the size of the rectangle. I will have about 1000 leaves, so it will hard to determine the size of the rectangle. -- View this message in context:

Re: [R] Error when using fitdist function in R

2013-04-10 Thread PIKAL Petr
Hi where is function fitdist from? Do you by chance mean fitdistr from MASS package? What is result of str(k)? Without these questions answered you hardly get any useful answer. Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-

Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-10 Thread jpm miao
Hi David, Many thanks. I try to follow your example and code as follows: xyplot( avg_cost_2012 ~ asset_2012, panel=function(x,y) { panel.xyplot(x,y, type=p) panel.lines(x2, y1, col=red)},scales=list(x=list(log=10))) However, I do see the points p of

Re: [R] Error when using fitdist function in R

2013-04-10 Thread Prof Brian Ripley
On 10/04/2013 08:29, PIKAL Petr wrote: Hi where is function fitdist from? Do you by chance mean fitdistr from MASS package? No, from the output. More likely fitdistrplus::fitdist Fit of univariate distributions to non-censored data What is result of str(k)?

Re: [R] Question on Stopword Removal from a Cyrillic (Bulgarian)Text

2013-04-10 Thread Ventseslav Kozarev, MPP
Hi, Thanks for taking the time. Here is a more reproducible example of the entire process: # Creating a vector source - stupid text in the Bulgarian language bg-c('Днес е хубав и слънчев ден, в който всички искат да бъдат навън.','Утре ще бъде още по-хубав ден.') # Converting strings from

Re: [R] sorting the VAR model output according to variable names??

2013-04-10 Thread Pfaff, Bernhard Dr.
Dear LondonPhd, assuming that you have assigned 'mod' to your VAR() call, you can run the following: lapply(coef(mod), function(x) x[sort(rownames(x)), ]) In general, the coef-method will retrieve the estimated coefficients and you can then do the reordering to your liking. Best, Bernhard

Re: [R] problem quitting

2013-04-10 Thread peter dalgaard
On Apr 10, 2013, at 07:19 , Julian Wells wrote: Many thanks to Peter and Brian for their help; it was indeed a permissions problem; thanks also to Josh Paulson of the RStudio team for pointing me to instructions for making the necessary changes. But at the risk of seeming not only

Re: [R] Optimization problem

2013-04-10 Thread peter dalgaard
On Apr 10, 2013, at 03:24 , nntx wrote: As a simple example, I want to find minimum value for x^2, but it can't be obtained by: f-function(x)x^2 optimize(f,lower=-1,upper=1) Works fine for me. What did you expect it to do? f-function(x)x^2 optimize(f,lower=-1,upper=1) $minimum [1]

[R] Levels and labels in factor

2013-04-10 Thread chong shiauyun
Hi R users, I have a imputed dataset of undefinedundefined cycles which I generated using StAta version undefinedundefined. Then I imported my data from Stata into R and I used a loop to run Mclust package in R. My observation starts with ID=2 (ID=1 has been excluded from the sample) and ends

Re: [R] Question on Stopword Removal from a Cyrillic (Bulgarian)Text

2013-04-10 Thread Milan Bouchet-Valat
Le mercredi 10 avril 2013 à 10:50 +0300, Ventseslav Kozarev, MPP a écrit : Hi, Thanks for taking the time. Here is a more reproducible example of the entire process: # Creating a vector source - stupid text in the Bulgarian language bg-c('Днес е хубав и слънчев ден, в който всички искат

Re: [R] Question on Stopword Removal from a Cyrillic (Bulgarian)Text

2013-04-10 Thread Ventseslav Kozarev, MPP
Thank you so much! You made it look (almost) so easy. I greatly appreciate it! On 10.4.2013 г. 11:29 ч., Milan Bouchet-Valat wrote: Le mercredi 10 avril 2013 à 10:50 +0300, Ventseslav Kozarev, MPP a écrit : Hi, Thanks for taking the time. Here is a more reproducible example of the entire

Re: [R] R crash

2013-04-10 Thread ONKELINX, Thierry
Have a look at the warning in ?geepack::geeglm It should be mentioned in ?geepack::geese as well. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070

Re: [R] Levels and labels in factor

2013-04-10 Thread Blaser Nello
Perhaps write.dta(..., convert.factors=string) might help. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of chong shiauyun Sent: Mittwoch, 10. April 2013 10:01 To: r-help@r-project.org Subject: [R] Levels and labels in factor Hi R

[R] non linear equation

2013-04-10 Thread catalin roibu
Hello all! I have a problem with a double exponential equation. this are my data's structure(list(proc = c(1870.52067384719, 766.789388745793, 358.701545859122, 237.113777545511, 43.2726259059654, 148.985133316262, 92.6242882655781, 88.4521557193262, 56.6404686159112, 27.0374477259404,

Re: [R] Boxplot Labels OK

2013-04-10 Thread Jose Iparraguirre
Beatriz, In this case, use the car package and run the following: bp - Boxplot(DATA$ave, data= DATA, main= Average Size, labels=DATA$num, Id.method=c(y)) This will print out the labels 211 225 beside the outlier points. As you can see, the instruction assigns the values in the num column

Re: [R] non linear equation

2013-04-10 Thread Jorge I Velez
Dear Catalin, You can look at ?nls. Alternatively, you could also consider a linear model as follows, where d is your data: # plot your data with(d, plot(cls, proc, las = 1)) # linear model fit - lm(proc ~ I(1/cls) + I((1/cls)^2), data = d) summary(fit) # plotting with(d, plot(cls, proc, las

Re: [R] checkUsage from codetools shows errors when function uses functions from loaded packages

2013-04-10 Thread Jannis
Well, its mentioned in the function itself by library(xxx) or require(xxx). Well, most probably codetools is more aimed towards checking packages in whcih case such information is in the depends section of the package declaration. Best Jannis On 08.04.2013 21:03, Duncan Murdoch wrote: On

Re: [R] non linear equation

2013-04-10 Thread Jorge I Velez
Please do not forget to CC the list to increase your chances of getting help. --JIV On Wed, Apr 10, 2013 at 9:31 PM, catalin roibu catalinro...@gmail.comwrote: Hello! I try to compute the double exponential function this code: f-function(cls,a,b,c,d)a*exp(cls*b)+c*exp(cls*d)

Re: [R] Dengrogram Help (Custom Make)

2013-04-10 Thread mlell08
Hi, this is how far I have come without practicel knowledge of dendrograms. _ # This dendrogram is from the demo of 'dendrogram', obtained by dput()! d3 - structure(list(structure(list(structure(8L, members = 1L, height =

Re: [R] Error when using fitdist function in R

2013-04-10 Thread Paul Bernal
Dear PIKAL, Thank you for your kind reply. The function fitdist comes from package fitdistrplus. I am attaching a .csv document that contains the data I want to fit a distribution to, so you can have a good idea of what kind of data I am dealing with. Basically what str(k) contains is the

Re: [R] Error when using fitdist function in R

2013-04-10 Thread Paul Bernal
Dear Dr. Brian, Hope you are doing well. The thing is that my data does not have any 0s in it. Furthermore, I also tried fitting other distributions (i.e. weibull) and still did not work. I will show you the results of str(k) so you have an idea of the tipe of data I am dealing with: int

[R] log x-axis lables on a histogram

2013-04-10 Thread Shane Carey
Hi, If you have the following lets say: hist(log10(rnorm(0:1000))) How do you show the labels on the x-axis as log vaules? so lets say: 0.01, 0.1,0,1,10,100 and so on. Thanks -- Shane [[alternative HTML version deleted]] __

Re: [R] How to replace zero with the character value- need help

2013-04-10 Thread arun
Hi,   Thank You, Arun Kirshna , for your efforts and time. I also found an equivalent code:  library(zoo) dat[] - lapply(dat, function(x){replace(x, x == 0, NA)}) dat -na.locf(dat) No problem. If you have equal replications, you could also use: dat- structure(list(val = c(-1.11106874013409,

Re: [R] log x-axis lables on a histogram

2013-04-10 Thread Rui Barradas
Hello, Try h - hist(log10(rnorm(0:1000)), xaxt = n) axis(1, at = pretty(h$breaks), labels = 10^pretty(h$breaks)) Hope this helps, Rui Barradas Em 10-04-2013 14:25, Shane Carey escreveu: Hi, If you have the following lets say: hist(log10(rnorm(0:1000))) How do you show the labels on the

Re: [R] log x-axis lables on a histogram

2013-04-10 Thread Shane Carey
Yup, that worked. Thats great. Thanks On Wed, Apr 10, 2013 at 3:34 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, Try h - hist(log10(rnorm(0:1000)), xaxt = n) axis(1, at = pretty(h$breaks), labels = 10^pretty(h$breaks)) Hope this helps, Rui Barradas Em 10-04-2013 14:25, Shane

Re: [R] non linear equation

2013-04-10 Thread Blaser Nello
I would suggest to try different starting values. The following works for instance: n2-nls(proc~f(cls,a,b,c,d),data=bline,start=list(a=1000,b=-1,c=4,d=1),t race=TRUE) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jorge I Velez

Re: [R] Converting matrix to data frame without losing an assigned dimname

2013-04-10 Thread David L Carlson
Other options (possibly counting as ugly): # Preserving States as rownames for labeling data.frame(State=rownames(tableData), tableData, stringsAsFactors=FALSE) State Frost Population Area Connecticut Connecticut 139 3100 4862 Pennsylvania Pennsylvania

Re: [R] Converting matrix to data frame without losing an assigned dimname

2013-04-10 Thread Paul Miller
Hi David, Gabor, Arun, and Rolf,   Thanks for your replies to my question. Very interesting and very helpful. I particularly liked the one-line solutions proposed by David and Gabor. I had a suspicion that this conversion could be done using only a minimal amount of code.   For what I'm doing, 

[R] Please Help FDR BH correction of pvalues

2013-04-10 Thread David Lyon
I have a matrix of p values below. Column1 are the analytes and the other columns are p values comparing time points. How do I convert this table of pvalues into adjust p values for FDR/BH This is wrong does anyone know how to fix this code a-read.table(file, header=T, sep\t)

[R] Table with n(%) formatting: A better way to do this?

2013-04-10 Thread Paul Miller
Hello All, Am learning to create tables with n(%) formatting using R. Below is a working example. I think this is not bad but wondered if there are better ways of doing it. Although it can be quite humbling, seeing good code helps me assess my progress as an R programmer. Ultimately want to

[R] Stringr Package

2013-04-10 Thread Sudip Chatterjee
Hi Group, I have a question on Stringr package I have a table like this X Y absu - di acpi - tu adtu - tu I want output like this XY ab su ab di ac pi ac tu ad tu ad tu I am wondering if this operation can be

Re: [R] checkUsage from codetools shows errors when function uses functions from loaded packages

2013-04-10 Thread R. Michael Weylandt
On Wed, Apr 10, 2013 at 4:47 AM, Jannis bt_jan...@yahoo.de wrote: Well, its mentioned in the function itself by library(xxx) or require(xxx). Well, most probably codetools is more aimed towards checking packages in whcih case such information is in the depends section of the package

Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-10 Thread David Winsemius
On Apr 10, 2013, at 12:44 AM, jpm miao wrote: Hi David, Many thanks. I try to follow your example and code as follows: xyplot( avg_cost_2012 ~ asset_2012, panel=function(x,y) { panel.xyplot(x,y, type=p) panel.lines(x2, y1,

Re: [R] Remove data 3 standard deviatons from the mean using R?

2013-04-10 Thread Greg Snow
To further David's comment, just think what the world would be like if Alexander Fleming had discarded an obvious outlier in 1928 ( http://en.wikipedia.org/wiki/Penicillin#Discovery). On Tue, Apr 9, 2013 at 7:46 AM, David Winsemius dwinsem...@comcast.netwrote: On Apr 9, 2013, at 4:12 AM,

Re: [R] Table with n(%) formatting: A better way to do this?

2013-04-10 Thread Duncan Murdoch
On 10/04/2013 11:59 AM, Paul Miller wrote: Hello All, Am learning to create tables with n(%) formatting using R. Below is a working example. I think this is not bad but wondered if there are better ways of doing it. Although it can be quite humbling, seeing good code helps me assess my

Re: [R] count by value

2013-04-10 Thread David Winsemius
On Apr 9, 2013, at 11:45 AM, catalin roibu wrote: Hello all! I have a big problem now. I want a data frame like this: dput(head(test,100)) structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,

Re: [R] Stringr Package

2013-04-10 Thread arun
Hi, Assuming that this is a data.frame. dat1-read.table(text= X,Y ab,su-di ac,pi-tu ad,tu-tu ,sep=,,header=TRUE,stringsAsFactors=FALSE) library(stringr) dat2-data.frame(X=rep(dat1$X,each=2),Y= unlist(str_split(dat1$Y,-)),stringsAsFactors=FALSE)  dat2 #   X  Y #1 ab su #2 ab di #3 ac pi #4 ac tu

Re: [R] Stringr Package

2013-04-10 Thread Ista Zahn
On Wed, Apr 10, 2013 at 12:25 PM, Sudip Chatterjee sudipanal...@gmail.com wrote: Hi Group, I have a question on Stringr package I have a table like this X Y absu - di acpi - tu adtu - tu I want output like this XY ab su ab di ac

Re: [R] Stringr Package

2013-04-10 Thread arun
Hi, Just noticed that there is space before and after the - dat1 - read.table(text = ' X    Y ab    su - di ac    pi - tu ad    tu - tu', header=TRUE,stringsAsFactors=FALSE) library(stringr)   Y-str_trim(unlist(str_split(dat$Y,-)),side=both)  

Re: [R] Solving tridiagonal matrix in R

2013-04-10 Thread S Ellison
I am trying to solve a tridiagonal matrix in R. I am wondering if there is an inbuilt R function or package to solve that. I tried looking on google but couldn't find something that would help directly. Any help is highly appreciated. You must be searching a different Google. I found

[R] Using PLYR to apply a custom function to a data frame

2013-04-10 Thread ramoss
Hello, I am still struggling w/ the PLYR syntax. I am trying to build a customized function to detect outliers in a data frame based on the interquantile method. My data frame is called ALL I am trying to create two new variables in my data frame: upper=q3+ 1.5*(q3-q1)

Re: [R] Question on Stopword Removal from a Cyrillic (Bulgarian)Text

2013-04-10 Thread Milan Bouchet-Valat
Le mercredi 10 avril 2013 à 13:17 +0200, Ingo Feinerer a écrit : On Wed, Apr 10, 2013 at 10:29:27AM +0200, Milan Bouchet-Valat wrote: Thanks for the reproducible example. Indeed, it does not work here either (Linux with UTF-8 locale). The problem seems to be in the call to gsub() in

Re: [R] Using PLYR to apply a custom function to a data frame

2013-04-10 Thread arun
Hi, You could try ?within() set.seed(25) ALL- data.frame(q3=sample(15:30,10,replace=TRUE), q1=sample(1:14,10,replace=TRUE)) res-within(ALL,{lower-q1- 1.5*(q3-q1);upper-q3+1.5*(q3-q1)})  res #   q3 q1 upper lower #1  21  5  45.0 -19.0 #2  26  6  56.0 -24.0 #3  17 14  21.5   9.5 #4  29  9  59.0

Re: [R] Using PLYR to apply a custom function to a data frame

2013-04-10 Thread ramoss
Thanks everyone. The mutate function worked great: all2- mutate(all1,upper=p75+1.5*(p75-p25),lower=p25-1.5*(p75-p25)) -- View this message in context: http://r.789695.n4.nabble.com/Using-PLYR-to-apply-a-custom-function-to-a-data-frame-tp4663897p4663902.html Sent from the R help mailing list

[R] grup function

2013-04-10 Thread Dominic Roye
Hello, How can i mattch blanks within words, when i have more phrases? c(Shangh i, Hello here i am,h llo) gsub( ,a,c(Shangh i, Hello here i am,h llo)) [1] ShanghaiHelloahereaiaam hallo I would like to have [1] Shanghai Hello here i am hallo I hope someone can help me. Thanks,

[R] Fit the data with an inverse quardratic function?

2013-04-10 Thread Jing Tang
Hi, I have a data y~x which looks like an inverse quardratic function, i.e. y=+/- sqrt(x). So for each x there are two y values due to the +/- operation. Do you know it is possible to fit a linear model on the data to fit such a model? How do I write the formula for this case? Thanks for the

[R] mle function

2013-04-10 Thread roger . campana
Hallo, I'm working with the mle function and I would like to ask you a couple of questions. My goal is to construct the historical value of v1(t), v2(t) and v3(t) using the maximum likelihood estimation. So, I need to optimize the following log-likelihood: sum(E1_f[t,]*(v1*teta1[] +

[R] Replace NAs in a data frame with elements randomly generated from the beta distribution

2013-04-10 Thread Sibusiso Ndzukuma
Hi there! Please help me, I am trying to replace all NAs in a data frame with numbers randomly generated from the beta(0.1,1) distribution. Firstly I tried looping: MAT -

Re: [R] count by value

2013-04-10 Thread Rui Barradas
Hello, Any of the two lapply intructions will give what you want. The difference is in the definition of decade. In the first case, it's ten years starting 1592. So the first decade are the 10 years 1592, 1593, ..., 1601, the second decade are the 10 years 1602, ..., 1611, etc. In the second

[R] means in tables

2013-04-10 Thread Silvano Cesar da Costa
Hi. I have 2 tables, with same dimensions (8000 x 5). Something like: tab1: V1 V2 V3 V4 V5 14.23 1.71 2.43 15.6 127 13.20 1.78 2.14 11.2 100 13.16 2.36 2.67 18.6 101 14.37 1.95 2.50 16.8 113 13.24 2.59 2.87 21.0 118 tab2: V1 V2 V3 V4 V5 1.23 1.1 2.3 1.6 17 1.20 1.8 2.4 1.2 10

Re: [R] Optimization problem

2013-04-10 Thread nntx
Thank you professor. I think the minimum value of x^2 between -1 and 1 should be x=0, y=0. but the result is not that. I am thinking is any wrong with my thought? Thanks for helping me out! -- View this message in context:

[R] bnlearn: how to compute boot strength with mmhc and a blacklist

2013-04-10 Thread Leonore Wigger
Dear R-help list: I have two related questions regarding the functions boot.strength and custom.strength in bnlearn. 1) I am using the following commands (on a set of continuous data, the example here run on fake data): myblacklist-data.frame(from=c(x1, x1, x1, x2, x2, x2)) , to=c(x2,

[R] how to calculate average of each column

2013-04-10 Thread Ye Lin
Hey All, I have a large dataset and I want to calculate the average of each column then return a new dataset. Here is my question: I dont know if there is a function that can allow me to calculate the average every 60 records of data in the whole dataset, and return a new data frame. Not sure if

Re: [R] Stringr Package

2013-04-10 Thread Hadley Wickham
with(dat, data.frame(X=rep(X, each=2), Y=unlist(strsplit(Y, split= - str_split_fixed would be a bit safer here. Hadley -- Chief Scientist, RStudio http://had.co.nz/ __ R-help@r-project.org mailing list

Re: [R] grup function

2013-04-10 Thread Bert Gunter
Below. On Wed, Apr 10, 2013 at 3:58 AM, Dominic Roye dominic.r...@gmail.com wrote: Hello, How can i mattch blanks within words, when i have more phrases? c(Shangh i, Hello here i am,h llo) gsub( ,a,c(Shangh i, Hello here i am,h llo)) [1] ShanghaiHelloahereaiaam hallo I would

Re: [R] means in tables

2013-04-10 Thread Marc Schwartz
On Apr 10, 2013, at 11:07 AM, Silvano Cesar da Costa silv...@uel.br wrote: Hi. I have 2 tables, with same dimensions (8000 x 5). Something like: tab1: V1 V2 V3 V4 V5 14.23 1.71 2.43 15.6 127 13.20 1.78 2.14 11.2 100 13.16 2.36 2.67 18.6 101 14.37 1.95 2.50 16.8 113 13.24

Re: [R] how to calculate average of each column

2013-04-10 Thread arun
Hi, TRy this: set.seed(52) dat1- as.data.frame(matrix(sample(1:40,100*60,replace=TRUE), nrow=600)) lapply(split(dat1,((seq_len(nrow(dat1))-1)%/% 60)+1),nrow) #$`1` #[1] 60 #$`2` #[1] 60 #$`3` #[1] 60 res-lapply(split(dat1,((seq_len(nrow(dat1))-1)%/% 60)+1),colMeans)  res[1:2] #$`1` #  V1   

Re: [R] Question on Stopword Removal from a Cyrillic (Bulgarian)Text

2013-04-10 Thread Ventseslav Kozarev
I just wanted to confirm that Milan's suggestion about adding (*UCP) like in the example below: gsub(sprintf((*UCP)\\b(%s)\\b, който), , който, perl=TRUE) solved all problems (under openSuse Linux 12.3 64-bit, R 2.15.2). I reencoded input files and stop word list in UTF-8, and now stop words

Re: [R] means in tables

2013-04-10 Thread arun
Hi, This could be done in different ways: tab1-read.table(text= V1  V2  V3  V4  V5 14.23 1.71 2.43 15.6 127 13.20 1.78 2.14 11.2 100 13.16 2.36 2.67 18.6 101 14.37 1.95 2.50 16.8 113 13.24 2.59 2.87 21.0 118 ,sep=,header=TRUE) tab2-read.table(text= V1  V2  V3  V4  V5 1.23 1.1 2.3 1.6 17 1.20 1.8

Re: [R] Replace NAs in a data frame with elements randomly generated from the beta distribution

2013-04-10 Thread arun
Hi, Try this: which(MAT==0)  #[1] 10 19 22 27 28 34 40 46 51 52 MAT[MAT==0]-sapply(seq_along(MAT[MAT==0]),function(x)rbeta(1,0.1,1)) MAT #    X1   X2  X3  X4   X5   X6 #1 0.68 9.731207e-14  0.03005021 0.003249449 1.36e+00 1.180602e-03 #2 9.86

Re: [R] how to calculate average of each column

2013-04-10 Thread Ye Lin
Thanks so much! it works fine! But when I convert the result to a data frame, it mess up. so i have: res - data.frame(res) then i get: X1 X2 X3 X4 X5 X6 V1 20.95000 22.16667 21.9 21.1 20.35000 19.36667 V2 20.5 19.85000 20.15000 17.5 19.3

Re: [R] how to calculate average of each column

2013-04-10 Thread Rui Barradas
Hello, You should provide us with a data example, like the posting guide asks you to. Without one, you could adapt the following example to your case # Make up some data dat - data.frame(X = rnorm(200), Y = rnorm(200)) # Divide into subsets of 60 rows each and compute the col means grp -

Re: [R] how to calculate average of each column

2013-04-10 Thread Ye Lin
That is very helpful Rui, thanks so much! On Wed, Apr 10, 2013 at 1:54 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, You should provide us with a data example, like the posting guide asks you to. Without one, you could adapt the following example to your case # Make up some data

Re: [R] Optimization problem

2013-04-10 Thread Rui Barradas
Hello, Your thoght is mathematically right but numerically wrong. The result given by optimize is so close to the real minimum that numerical accuracy comes in and it becomes indistinguishable from the value you're expecting. You get the minimum up to a certain accuracy, not more. Hope this

Re: [R] how to calculate average of each column

2013-04-10 Thread arun
Hi, Is this what you need? as.data.frame(do.call(rbind,res)) # V1   V2   V3   V4   V5   V6   V7   V8 #1  20.95000 20.5 20.55000 21.1 20.1 18.3 21.1 20.5 #2  22.16667 19.85000 19.7 22.26667 18.8 19.9 18.85000 20.46667 #3 

Re: [R] Replace NAs in a data frame with elements randomly generated from the beta distribution

2013-04-10 Thread peter dalgaard
On Apr 10, 2013, at 13:09 , Sibusiso Ndzukuma wrote: Hi there! Please help me, I am trying to replace all NAs in a data frame with numbers randomly generated from the beta(0.1,1) distribution. Firstly I tried looping: MAT -

Re: [R] grup function

2013-04-10 Thread arun
Hi, The pattern is not clear.  In this particular case, library(stringr) word1-c(Shangh i, Hello here i am,h llo)  word1[str_count(word1, )==1]-gsub( ,a,word1[str_count(word1, )==1])  word1 #[1] Shanghai    Hello here i am hallo But, this will  not work here: word2-c(Shangh i, B lanced

[R] Boxplot Labels solved

2013-04-10 Thread Beatriz González Domínguez
Hi Jose, Thanks a lot for your email! I was told a good solution to label outliers of a boxplot with identifying variable values of the data frame (instead of the row names). An example can be seen below: ## R CODE #DATA num - as.numeric(200:225) ave - c(0.5, 1, 1.6, 2, 2, 2.3, 2.5, 2.4, 3,

Re: [R] how to calculate average of each column

2013-04-10 Thread arun
Hi, Try this: set.seed(52) dat1- as.data.frame(matrix(sample(c(1:40,NA),100*60,replace=TRUE), nrow=600))   res1-as.data.frame(do.call(rbind,lapply(split(dat1,((seq_len(nrow(dat1))-1)%/% 60)+1),function(x) colMeans(x,na.rm=TRUE  res1 # V1   V2   V3   V4   V5   V6

Re: [R] means in tables

2013-04-10 Thread arun
Hi,  YOu can load all the datasets directly from the directory in a list. set.seed(25)  lst1-lapply(1:100,function(i) as.data.frame(matrix(sample(1:40,25,replace=TRUE),ncol=5)))  length(lst1) #[1] 100 library(abind) apply(abind(lst1,along=3),c(1,2),mean) #    V1    V2    V3    V4    V5

Re: [R] means in tables

2013-04-10 Thread arun
Hi, For loading number of datasets, you can use list.files() Example: list.files(pattern=.txt) #[1] file1.txt file2.txt file3.txt  lst2-lapply(list.files(pattern=.txt),function(x) read.table(x,sep=,header=TRUE)) lst2[[1]] #  col1 col2 #1    1  0.5 #2    2  0.2 #3    3  0.3 #4    4  0.3 #5    5 

Re: [R] Applying bagging in classifiers

2013-04-10 Thread Nicolás Sánchez
Any help? Thanks! 2013/4/8 Nicolás Sánchez eni...@gmail.com Hello! Does anyone know how to apply bagging for SVM? ( for example) I am using adabag package to execute bagging but this method, bagging, works with classification trees. I would like to apply my bagging to other classifiers

Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-10 Thread jpm miao
Thanks for your comments, David avg_cost_2012 and asset_2012 are numeric vectors of length 39 while x2 and y1 are longer vectors whose range is about the same as (avg_cost_2012, asset_2012) I also present the data by dput below. Is it clear? Thanks, Miao asset_2012 avg_cost_2012 1 3973730.0

Re: [R] means in tables

2013-04-10 Thread arun
HI Silvano, I tried with example set to see whether size is a problem. set.seed(25)  lst1-lapply(1:100,function(i) as.data.frame(matrix(sample(1:100,8000*3,replace=TRUE),ncol=3)))  length(lst1) system.time(res-apply(abind(lst1,along=3),c(1,2),mean)) #   user  system elapsed #  0.360   0.012  

Re: [R] means in tables

2013-04-10 Thread arun
HI Silvano, No problem. Just wanted to make sure that it worked. Regards, A.K. - Original Message - From: Silvano Cesar da Costa silv...@uel.br To: arun smartpink...@yahoo.com Cc: Sent: Wednesday, April 10, 2013 10:34 PM Subject: Re: [R] means in tables Arun, this code work very

[R] Generating equation problem

2013-04-10 Thread nntx
I am wondering if there is any function or command that could generate a equation automatically from the fitted results? For example, x-seq(1:20) y-rnorm(20) z-lm(y~poly(x,4)) z Call: lm(formula = y ~ poly(x, 4)) Coefficients: (Intercept) poly(x, 4)1 poly(x, 4)2 poly(x, 4)3 poly(x,

Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-10 Thread David Winsemius
On Apr 10, 2013, at 6:11 PM, jpm miao wrote: Thanks for your comments, David avg_cost_2012 and asset_2012 are numeric vectors of length 39 while x2 and y1 are longer vectors whose range is about the same as (avg_cost_2012, asset_2012) I also present the data by dput below. Is it clear?

[R] Installing gym package error

2013-04-10 Thread Gary
Dear R help Don't really understand if there is graph or should be graph. library(ggm) Loading required package: graph Error: package ‘graph’ could not be loaded In addition: Warning messages: 1: package ‘ggm’ was built under R version 2.15.3 2: In library(pkg, character.only = TRUE,

Re: [R] Question on Stopword Removal from a Cyrillic (Bulgarian)Text

2013-04-10 Thread Ventseslav Kozarev
I just wanted to confirm that Milan's suggestion about adding (*UCP) like in the example below: gsub(sprintf((*UCP)\\b(%s)\\b, който), , който, perl=TRUE) solved all problems (under openSuse Linux 12.3 64-bit, R 2.15.2). I reencoded input files and stop word list in UTF-8, and now stop words

Re: [R] Optimization problem

2013-04-10 Thread nntx
Rui, thanks for your reply. You meant that it is the issue of accuracy? So if I change the numerical accuracy, my results can be output? Thanks a lot! -- View this message in context: http://r.789695.n4.nabble.com/Optimization-problem-tp4663821p4663928.html Sent from the R help mailing list

Re: [R] Plot two separate curves in R Graphics and R Lattice package

2013-04-10 Thread jpm miao
Hi David, Thanks. How can I make the graph in log scale? Thanks Miao 2013/4/11 David Winsemius dwinsem...@comcast.net On Apr 10, 2013, at 6:11 PM, jpm miao wrote: Thanks for your comments, David avg_cost_2012 and asset_2012 are numeric vectors of length 39 while x2 and y1 are

Re: [R] Installing gym package error

2013-04-10 Thread Pascal Oettli
Hello, The package 'ggm' depends on graph, igraph and RGBL packages. The error message is clear: there is no package called ‘graph’ Regards, Pascal On 04/11/2013 05:02 AM, Gary wrote: Dear R help Don't really understand if there is graph or should be graph. library(ggm) Loading

Re: [R] means in tables

2013-04-10 Thread arun
Hi Silvano, Just to add: If you need to use the first option: set.seed(25)  lst1-lapply(1:100,function(i) as.data.frame(matrix(sample(1:100,8000*3,replace=TRUE),ncol=3))) system.time(res1-eval(parse(text=paste(paste(lst1,[[,seq_along(lst1),]],sep=),collapse=+)))/length(lst1)) # user  system

[R] Calculating std errors of marginal effects in interactions

2013-04-10 Thread Richard Asturia
Hi! I've been looking for a way to calculate std errors of marginal effects when I use interaction terms, but with no success. I pretty much have two cases: continuous variable * continuous variable, and continuous variable * binary variable. In both cases, I know how to calculate the marginal