Re: [R] Loop Help

2012-06-17 Thread Jim Lemon
On 06/17/2012 08:50 AM, @ngel wrote: Hello again and thank you all so much for the help. Well, I tried and did it myself, here's what I wrote: library(tnet) net<- read.table("data.txt") net<- as.tnet(net, type="longitudinal tnet") loop<- range(net[,1]) net.static<- vector(length=as.integer(loop

Re: [R] how to convert a vector to an upper matrix

2012-06-17 Thread Berend Hasselman
ozzi wrote > > Dear Berend, > > the coding is not working for more than 6. Try to plug 10 or other number. > Would you please correct ? > My mistake. mkupper <- function(A) { n <- length(A) m <- (1+sqrt(1+8*n))/2 stopifnot(m==as.integer(m)) print(m) L <- matrix(0,nrow=m,nc

Re: [R] noob requesting help

2012-06-17 Thread Rui Barradas
Hello, It's stringsAsFactors = FALSE, just one '='. Your data structure, a list, seems to have elements, vectors, of the same lengths, all of them are of length 34773. You can check it with sapply(dat, length) It should return 4 times the value 34773. If so, there's no reason for David's su

[R] visualize correlation matrix

2012-06-17 Thread Christof Kluß
Hi is there a easy way to get something like http://addictedtor.free.fr/graphiques/graphcode.php?graph=137 pairs(USJudgeRatings[,c(2:3,6,1,7)], lower.panel=panel.smooth, upper.panel=panel.cor) but without the "lower.panel" (and without numbers and ticks at the border.) thx Christof _

Re: [R] visualize correlation matrix

2012-06-17 Thread Rui Barradas
Hello, The answer is yes, there is an easy way of getting that graphic without the lower.panel and axis tickmarks. op <- par(xaxt="n", yaxt="n") pairs(USJudgeRatings[,c(2:3,6,1,7)], upper.panel=panel.cor) par(op) where panel.cor() is the function in the link. Hope this helps, Rui Barra

Re: [R] How to specify "newdata" in a Cox-Modell with a time dependent interaction term?

2012-06-17 Thread Jürgen Biedermann
Dear John, Thank you very much for your help! It was very important for getting along further. I found out some additional things which I want to give back to you as feedback (maybe other persons will have the same problems). It's also possible to leave away the individual=T argument. Instead

Re: [R] count data without NA in certain time intervals and plot it

2012-06-17 Thread Tagmarie
Thank you Arun for your time! Your idea is maybe only the first step to what I want but it was nevertheless a new tool for me and interessing to learn. I added a "week"-column to your data set: dattrial<-data.frame(a=c(1,NA,rnorm(4,10)), Week=c(3,3,3,4,4,4)) I am looking for a way to count the

Re: [R] count data without NA in certain time intervals and plot it

2012-06-17 Thread Rui Barradas
Hello, I've seen your reply to arun's reply and gave it a try. Since arun's code included more than one column, I've added another in one of the examples. # Example 1 dattrial1 <- data.frame(a=c(1,NA,rnorm(4,10)), Week=c(3,3,3,4,4,4)) d1 <- split(dattrial1, dattrial1$Week) count <- sapply(d1,

Re: [R] how to convert a vector to an upper matrix

2012-06-17 Thread ozzi
Dear Berend, the coding is not working for more than 6. Try to plug 10 or other number. Would you please correct ? -- View this message in context: http://r.789695.n4.nabble.com/how-to-convert-a-vector-to-an-upper-matrix-tp3587715p4633628.html Sent from the R help mailing list archive at Nabble.

Re: [R] count data without NA in certain time intervals and plot it

2012-06-17 Thread Tagmarie
Great! That works! Thank you Rui! I would have spent days (which I don't have left before handing my report in) getting there by myself! Have a great rest-weekend! -- View this message in context: http://r.789695.n4.nabble.com/count-data-without-NA-in-certain-time-intervals-and-plot-it-tp46336

Re: [R] Temporal disaggregation

2012-06-17 Thread stef salvez
you are right Jeff and sorry for this I will try to explain what I want. I have the following dataset dat <- data.frame("country" = c(rep(1,4)), "date" = c("23/11/08","28/12/08","25/01/09","22/02/09"), "price" = c(2,3,4,5)) Normally, prices are observed every 4

Re: [R] noob requesting help

2012-06-17 Thread capital_P
Rui Barradas wrote > > It's stringsAsFactors = FALSE, just one '='. > > sapply(dat, length) > > It should return 4 times the value 34773. > > use dput() > it worked! > dat2 <- data.frame(dat, stringsAsFactors = FALSE) > sapply(dat2, length) device_info_serial hour

Re: [R] Temporal disaggregation

2012-06-17 Thread stef salvez
or put differently, I want to change the data frequency of the time series to monthly thanks On 6/17/12, stef salvez wrote: > you are right Jeff and sorry for this > > I will try to explain what I want. > > I have the following dataset > > dat <- data.frame("country" = c(rep(1,4)), >

[R] How to save my result with Loops

2012-06-17 Thread Cassie
Hi everyone, i'm not very good with R, and i know that my question is quite simple. I generated this vector for a sample of 100 and i want to know how to save these as ez1, ez1, ez3...ez100. I guess i have to do it by "for", but i didn't succeed.. i put here my output ezt [1] -0.05470228 -1.76

Re: [R] How to save my result with Loops

2012-06-17 Thread R. Michael Weylandt
Short answer: don't. R is built around vectors and lists. Trying to put individual variates in their own "scalar" variables is almost always a bad idea. Long answer: you can do it with assign() but I won't tell you how in light of my short answer. Michael On Sun, Jun 17, 2012 at 8:30 AM, Cassie

Re: [R] How to save my result with Loops

2012-06-17 Thread John Kane
It is not clear exactly what you want. Are you saying that you want to create an object out of each number in that vector or do you just want to name each element in the vector? It is best to supply the code that you used so that readers can see what you are doing. Also when you are providi

Re: [R] How to save my result with Loops

2012-06-17 Thread Bert Gunter
On Sun, Jun 17, 2012 at 6:30 AM, Cassie wrote: > Hi everyone, i'm not very good with R, and i know that my question is quite > simple. > So make an effort to educate yourself instead of badgering this list. Please read "An Intro to R" -- which ships with R (help.start() or Help Menu --> Manuals

Re: [R] FW: Multivariate Normal and loops

2012-06-17 Thread R. Michael Weylandt
It's requested to cc the list on our back-and-forths so that i) you can get help faster (I was moving all yesterday and it's a Hallmark holiday in the US today) since others may respond; ii) others can benefit by reading the archives. On Sun, Jun 17, 2012 at 4:34 AM, Giulia Motta wrote: > > > t

Re: [R] strang behaviour of mice package

2012-06-17 Thread Weidong Gu
Hi, In my case, that was due to the existence of highly correlated variables. see loggedEvents in the help file of mice. Weidong Gu On Sat, Jun 16, 2012 at 3:33 PM, b04877054 wrote: > I have the same problem. How did you end up solving yours? > > -- > View this message in context: > http://r.7

[R] Multi-threads in R

2012-06-17 Thread Gary Dong
Dear R users, I'm wonder if there is a easy way to make R use multi-CPUs on my computer. My computer has four CPUs but R uses only one. Thanks. Gary [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch

Re: [R] noob requesting help

2012-06-17 Thread Rui Barradas
Hello, Try names(departures) <- NULL dep <- data.frame(departures[ !sapply(departures, is.null) ]) You now have data.frame 'dep'. Rui Barradas Em 17-06-2012 12:19, capital_P escreveu: Rui Barradas wrote It's stringsAsFactors = FALSE, just one '='. sapply(dat, length) It should return 4

Re: [R] Multi-threads in R

2012-06-17 Thread R. Michael Weylandt
Take a look at the parallel package which ships with all current versions of R. Michael On Jun 17, 2012, at 11:39 AM, Gary Dong wrote: > Dear R users, > > I'm wonder if there is a easy way to make R use multi-CPUs on my computer. > My computer has four CPUs but R uses only one. Thanks. > > G

Re: [R] Multi-threads in R

2012-06-17 Thread Uwe Ligges
On 17.06.2012 19:04, R. Michael Weylandt wrote: Take a look at the parallel package which ships with all current versions of R. which is the right answer for the body of the message. For the subject line: Take a look at multi-threaded BLAS which can be used with R. Uwe Ligges Michael O

Re: [R] Efficient distance calculation on big matrix

2012-06-17 Thread Stefan Evert
> I'm working on analyzing a large data set, lets asume that > dim(Data)=c(1000,8700). I want to calculate the canberra distance > between the columns of this matrix, and using a toy example ('test' is > a matrix filled with random numbers 0-1): > >> system.time(d<-as.matrix(dist(t(test), method

Re: [R] noob requesting help

2012-06-17 Thread David Winsemius
On Jun 17, 2012, at 7:19 AM, capital_P wrote: Rui Barradas wrote It's stringsAsFactors = FALSE, just one '='. sapply(dat, length) It should return 4 times the value 34773. use dput() it worked! dat2 <- data.frame(dat, stringsAsFactors = FALSE) sapply(dat2, length) device_info_ser

Re: [R] how to delete a matrix column

2012-06-17 Thread 李红旺
> a<-c(1,4) > a [1] 1 4 > b<-a*5 > b [1] 5 20 a is a very long vector , how can i get c(1:5,4:20)? i do not want to use a loop. thanks very much! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posti

Re: [R] how to delete a matrix column

2012-06-17 Thread Jeff Newmiller
"a" looks pretty short to me, just two elements. You should spend some (more) time reading the "Introduction to R" document that is supplied with the software... particularly the parts on indexing. --- Jeff Newmiller

Re: [R] how to delete a matrix column

2012-06-17 Thread Petr Savicky
On Mon, Jun 18, 2012 at 01:24:21AM +0800, 李红旺 wrote: > > a<-c(1,4) > > a > [1] 1 4 > > b<-a*5 > > b > [1] 5 20 > > a is a very long vector , how can i get c(1:5,4:20)? i do not want to > use a loop. Hi. How large are the numbers in a? If max(a) is not too large, try the following. a <- c(1, 4

[R] time-series classification with k-nn

2012-06-17 Thread Pierre Antoine DuBoDeNa
Hello, i am trying to apply k-nn classification for my time-series, however the euclidean distance is not the best choice as the features i use are not all normalized (others have values form 0-1 others are negative etc.) and also it doesn't do any feature evaluation and give different weights to

Re: [R] Multi-threads in R

2012-06-17 Thread Gary Dong
Thanks for all replied. I read the introduction of R parallel. Is it for loops only? Gary On Sun, Jun 17, 2012 at 10:04 AM, R. Michael Weylandt < michael.weyla...@gmail.com> wrote: > Take a look at the parallel package which ships with all current versions > of R. > > Michael > > On Jun 17, 2

Re: [R] how to delete a matrix column

2012-06-17 Thread Ted Harding
On 17-Jun-2012 17:24:21 ÀîºìÍú wrote: >> a<-c(1,4) >> a > [1] 1 4 >> b<-a*5 >> b > [1] 5 20 > > a is a very long vector , how can i get c(1:5,4:20)? > i do not want to use a loop. > > thanks very much! Your question is not quite clear, but I think you mean: a is a very long vector, and you wa

Re: [R] count data without NA in certain time intervals and plot it

2012-06-17 Thread arun
Hi, Sorry, I didn't understand your question in the first post.  I saw Rui's reply and your reply that it is solved. I have another solution if it helps you. dattrial<-data.frame(a=c(1,NA,rnorm(4,10)), Week=c(3,3,3,4,4,4)) dattrial_wk3<-subset(dattrial,Week==3) dattrial_wk4<-subset(dattrial,We

Re: [R] visualize correlation matrix

2012-06-17 Thread Kevin Wright
You can also try the corrgram package. Kevin On Sun, Jun 17, 2012 at 4:06 AM, Christof Kluß wrote: > Hi > > is there a easy way to get something like > http://addictedtor.free.fr/graphiques/graphcode.php?graph=137 > > pairs(USJudgeRatings[,c(2:3,6,1,7)], >  lower.panel=panel.smooth, upper.panel

Re: [R] Multi-threads in R

2012-06-17 Thread R. Michael Weylandt
I would argue (somewhat emphatically) that the parallel facilities you are looking at are absolutely not for `for` loops. `for` loops are a control structure native to imperative programming and, as such, are inherently stateful. This provides many advantages, but easy parallelization is absolutely

Re: [R] Multi-threads in R

2012-06-17 Thread Fabrice Tourre
I think multicore is one of answer if you can write your function in to lapply. On Mon, Jun 18, 2012 at 12:14 PM, R. Michael Weylandt wrote: > I would argue (somewhat emphatically) that the parallel facilities you > are looking at are absolutely not for `for` loops. `for` loops are a > control st

Re: [R] Cholesky decomposition error

2012-06-17 Thread nataraj
Thanks Kjetil for your detailed code for log-Cholesky but my situation is like optimization of the variables inside the matrix. Let me change your own example matrix to explain the problem. A martrix is [,1] [,2][,3] [1,]3*Vs+Vn1*Vs 1*Vs