Re: [R] Object oriented programming in R.
I think you should have a look at the 'proto' package on CRAN. Yvonnick Noel University of Brittany, Rennes France __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Pesky homemade function code
Hi all- this seems to be simple to figure out but since im new to writing functions I dont know what is happening. Here is my code along with the error I am receiving: semivario=function(data,ids,times,resids){ id=unique(data$ids) index=combinations(length(data$times[data$ids==id[1]]),2) time=gamma=numeric(dim(index)[1]) for (j in 1:dim(index)[1]){ time[j]=abs(data$times[data$ids==id[1]][index[j,1]]-data$times[data$ids==id[1]][index[j,2]]) gamma[j]=.5*(data$resids[data$ids==id[1]][index[j,1]]-data$resids[data$ids==id[1]][index[j,2]])^2 } for (i in id[-1]){ index=combinations(length(data$times[data$ids==i]),2) time1=gamma1=numeric(dim(index)[1]) for (j in 1:dim(index)[1]){ time1[j]=abs(data$times[data$ids==i][index[j,1]]-data$times[data$ids==i][index[j,2]]) gamma1[j]=.5*(data$resids[data$ids==i][index[j,1]]-data$resids[data$ids==i][index[j,2]])^2 } time=c(time,time1) gamma=c(gamma,gamma1) } value=list(time=time,gamma=gamma) return(value) } and I would run it as semivario(data=hope,ids=id,times=sctime,resids=scResid) What I want to do is everywhere we see the words data,ids,times,resids to be replaced with, for example, hope,id,sctime,scResid. Think of macros in SAS where we use the before every macro input variable name. Im not sure if this is how R handles function inputs. Here is my error: Error in combinations(length(data$times[data$ids == id[1]]), 2) : bad value of n Thanks -- View this message in context: http://r.789695.n4.nabble.com/Pesky-homemade-function-code-tp2541597p2541597.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plotting time series using ggplots
Hi, I would like to plot a bunch of tree ring width data (time series) using ggplots, but I'm having trouble figuring out how to do it. My data is in a data.frame, with years as rownames and a distinct tree ring series in each column. So, something like this: rwl-matrix(rnorm(800), nrow = 100) colnames(rwl) - paste('V', 1:8, sep = '') rownames(rwl)-c(1900:1999) rwl-as.data.frame(rwl)) I have 2 specific things I'd like to do: 1) use stat_summary(), geom_line(), and either geom_smooth() or geom_ribbon() to plot the mean of the timeseries (e.g. V1:V8) and error bands or confidence limits around the mean for each year. I cannot figure out how to do this except for this really clunky way: rwl$year-as.numeric(rownames(rwl)) h-ggplot(rwl, aes(x=year)) h+ geom_line(aes(y=V1)) #plots one of the timeseries ymax=as.data.frame( t(apply(rwl[1:8], 1, summary,na.rm=TRUE )) )[,4] ymin=as.data.frame( t(apply(rwl[1:8], 1, summary,na.rm=TRUE )) )[,2] h + geom_ribbon(aes(ymin=ymin, ymax=ymax)) +geom_line(aes(y=rowMeans(rwl[1:8]))) 2) I'd like to be able to plot all of the timeseries together, or plot them grouped by another variable (for example site), but I can't figure out how to get ggplot to plot all of the columns as Y data, without specifying each separate timeseries with a distinct +geom_line(aes(y=columnname). Any suggestions on either problem would be greatly appreciated! ~Ali Alison Macalady Ph.D. Candidate University of Arizona School of Geography and Development Laboratory of Tree Ring Research __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] The permutation of one vector into another
Dear R-help-list I have two character vectors a - c(A, B, C) b - c(A, C, B) Then sapply(a, function(i) grep(i, b)) computes the permutation of the entries in 'b' needed to bring 'b' into the same order as 'a'. I have searched around, but haven't been able to find any existing function that compute this permutation. Is there such a function doing this -- perhaps more efficiently than the above? For those interested, I need the permutation to bring the rows of a data frame into the same order as the levels of a factor. Thanks, Niels -- Niels Richard Hansen Web: www.math.ku.dk/~richard Associate Professor Email: niels.r.han...@math.ku.dk Department of Mathematical Sciences nielsrichardhan...@gmail.com University of Copenhagen Skype: nielsrichardhansen.dk Universitetsparken 5 Phone: +45 353 20783 (office) 2100 Copenhagen Ø +45 2859 0765 (mobile) Denmark __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating publication-quality plots for use in Microsoft Word
On Wed, 2010-09-15 at 08:25 -0700, dadrivr wrote: Thanks for your help, guys. I'm looking to produce a high-quality plot (no jagged lines or other distortions) with a filetype that is accepted by Microsoft Word on a PC and that most journals will accept. That's why I'd prefer to stick with JPEG, TIFF, PNG, or the like. I'm not sure EPS would fly. From my experience, most (all of the ones I have personal experience with) of the large publishers of scientific journals accept EPS as a file format. I have used it [EPS] routinely for providing figures to Windows-bound colleagues to insert into Word. EPS is perfectly acceptable in Word on a PC. The only proviso is that, as has been mentioned, Word will only *display* a low resolution bitmap preview of EPS image *in* the document on screen whilst editing. When printed to a postscript printer or converted to PDF via something like Distiller or via publishers' online submission tools, the figure will be in the best possible quality. TIFF is the only bitmap format I am aware of that journals routinely accept. So, IMHO, EPS or TIFF are the only two viable options if you factor in wide journal acceptance. I tried inserting the PDF directly into Word, but I am on a PC and there is a loss of quality in the transfer. I'm not sure I know how to use the approach that Marc suggested in reference to saving a new PDF for use in Word. I haven't used the recent version of Word, but PDF was not accepted as an picture format, on a PC (Macs may be different). I also tried Gabor's suggestion to save in Microsoft's metafile format (savePlot with type = wmf and emf), but the images contain lines that are as jagged as those created from the regular R plot output. On screen or when printed? I wouldn't expect them to be jagged when printed for the same reasons as EPS; they are a vector format. Is there a way to enable anti-aliasing on all regular R plot output to clean up the jaggies and then save it in another format? Or should I try something else? Thanks again! Use EPS, or as Thomas Lumley (IIRC) suggested, a high resolution (300dpi or greater) TIFF. Also, make sure you are plotting on the device directly, e.g. postscript() plot() dev.off() rather than use the menu options to save plots/copy to clipboard features in the windows version of R. I've not used that version for some time, but you get far more control over the parameters of the produced plot (height, width, paper etc) by plotting directly on the device. HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting time series using ggplots
Dear Alison, Creating a dataset in long format instead of wide format makes things much easier with ggplot2. You also need a variable with Year. Rownames will not do. rwl - matrix(rnorm(800, 1, sd =0.5), nrow = 100) colnames(rwl) - paste('V', 1:8, sep = '') rwl - as.data.frame(rwl) rwl$Year - 1900:1999 library(ggplot2) molten - melt(rwl, id.vars = Year) ggplot(molten, aes(x = Year, y = value)) + geom_smooth() moltenCI - cast(Year ~ ., data = molten, fun = c(mean, sd, length)) moltenCI$Low - with(moltenCI, mean - sd / sqrt(length - 1)) moltenCI$High - with(moltenCI, mean + sd / sqrt(length - 1)) ggplot(moltenCI, aes(x = Year, y = mean, ymin = Low, ymax = High)) + geom_ribbon(alpha = 0.5) + geom_line() ggplot(molten, aes(x = Year, y = value, colour = variable)) + geom_line() ggplot(molten, aes(x = Year, y = value, colour = variable)) + geom_smooth() HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics Quality Assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Alison Macalady Verzonden: donderdag 16 september 2010 8:51 Aan: r-help@r-project.org Onderwerp: [R] plotting time series using ggplots Hi, I would like to plot a bunch of tree ring width data (time series) using ggplots, but I'm having trouble figuring out how to do it. My data is in a data.frame, with years as rownames and a distinct tree ring series in each column. So, something like this: rwl-matrix(rnorm(800), nrow = 100) colnames(rwl) - paste('V', 1:8, sep = '') rownames(rwl)-c(1900:1999) rwl-as.data.frame(rwl)) I have 2 specific things I'd like to do: 1) use stat_summary(), geom_line(), and either geom_smooth() or geom_ribbon() to plot the mean of the timeseries (e.g. V1:V8) and error bands or confidence limits around the mean for each year. I cannot figure out how to do this except for this really clunky way: rwl$year-as.numeric(rownames(rwl)) h-ggplot(rwl, aes(x=year)) h+ geom_line(aes(y=V1)) #plots one of the timeseries ymax=as.data.frame( t(apply(rwl[1:8], 1, summary,na.rm=TRUE )) )[,4] ymin=as.data.frame( t(apply(rwl[1:8], 1, summary,na.rm=TRUE )) )[,2] h + geom_ribbon(aes(ymin=ymin, ymax=ymax)) +geom_line(aes(y=rowMeans(rwl[1:8]))) 2) I'd like to be able to plot all of the timeseries together, or plot them grouped by another variable (for example site), but I can't figure out how to get ggplot to plot all of the columns as Y data, without specifying each separate timeseries with a distinct +geom_line(aes(y=columnname). Any suggestions on either problem would be greatly appreciated! ~Ali Alison Macalady Ph.D. Candidate University of Arizona School of Geography and Development Laboratory of Tree Ring Research __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Druk dit bericht a.u.b. niet onnodig af. Please do not print this message unnecessarily. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Asking Favor
Here's a way with less code... # assume original matrix is X u - unique( sort(X) ) ucdf - cumsum( tabulate(X)[u] ) Xcdf - matrix(ucdf[ match(X, u) ], 8) Michael On 16 September 2010 14:58, chuan zun liang chuan...@yahoo.com.my wrote: Hello Friend: Thanks a lot. I kindly told that Micheal already misunderstand what i want.But never mind.I also can share with you what I want. I got a set of matrix(image) as below: x-t(matrix(y,8)) x [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 52 55 61 66 70 61 64 73 [2,] 63 59 55 90 109 85 69 72 [3,] 62 59 68 113 144 104 66 73 [4,] 63 58 71 122 154 106 70 69 [5,] 67 61 68 104 126 88 68 70 [6,] 79 65 60 70 77 68 58 75 [7,] 85 71 64 59 55 61 65 83 [8,] 87 79 69 68 65 76 78 94 y just the matrix change to vector. y-c(52,55,61,66,70,61,64,73,63,59,55,90,109,85,69,72,62,59,68,113,144,104,66,73,63,58,71,122,154,106,70,69,67,61,68,104,126,88,68,70,79,65,60,70,77,68,58,75,85,71,64,59,55,61,65,83,87,79,69,68,65,76,78,94) Then, I want doing for histogram equalization for my image.What I want is I want to replace 52 by value of the cumulative distribution function. For example,frequency 52 is 1 and frequency for 55 is 3, so cumulative frequency for 55 is 4.So, I want replace 52 by 1 and 55 by 4 and so on until 94 replace 94. This is the script I get(just a part for histogram equalization): cdfv-function(p) {a-cumsum(unlist(lapply(split(p,f=p),length))) b-sort(unique(p)) for(i in c(1:37)) {x-replace(x,x==b[i],a[i])} c(x)} matrix(cdfv(y),8) Thank you. Chuan From: Michael Bedward michael.bedw...@gmail.com To: chuan zun liang chuan...@yahoo.com.my; Rhelp r-help@r-project.org Sent: Wednesday, 15 September 2010 16:08:20 Subject: Re: [R] Asking Favor Hello Chuan, If you just want a matrix with the numbers 1 to 64 arranged by row... m - matrix(1:64, ncol=8, byrow=TRUE) But perhaps I don't understand your question properly ? Michael On 16 September 2010 12:46, chuan zun liang chuan...@yahoo.com.my wrote: Dear Prof: My name is Chuan.I from Malaysia.I am a beginner for R.I need favor for Prof. This is my data: y-c(52,55,61,66,70,61,64,73,63,59,55,90,109,85,69,72,62,59,68,113,144,104,66,73,63,58,71,122,154,106,70,69,67,61,68,104,126,88,68,70,79,65,60,70,77,68,58,75,85,71,64,59,55,61,65,83,87,79,69,68,65,76,78,94) and I form it into matrix as below: [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 52 63 62 63 67 79 85 87 [2,] 55 59 59 58 61 65 71 79 [3,] 61 55 68 71 68 60 64 69 [4,] 66 90 113 122 104 70 59 68 [5,] 70 109 144 154 126 77 55 65 [6,] 61 85 104 106 88 68 61 76 [7,] 64 69 66 70 68 58 65 78 [8,] 73 72 73 69 70 75 83 94 But i want replace 52 by 1, 63 by 2, 63 by 5, 94 by 64. Is it possible I do it in R.Thank a lot. Chuan [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Pesky homemade function code
The calculation of semivraiogram is allready implemented is many R packages. So why do it yourself? library(sos) findFn(variogram) Gives you 190 hits! ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics Quality Assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens trekvana Verzonden: donderdag 16 september 2010 8:35 Aan: r-help@r-project.org Onderwerp: [R] Pesky homemade function code Hi all- this seems to be simple to figure out but since im new to writing functions I dont know what is happening. Here is my code along with the error I am receiving: semivario=function(data,ids,times,resids){ id=unique(data$ids) index=combinations(length(data$times[data$ids==id[1]]),2) time=gamma=numeric(dim(index)[1]) for (j in 1:dim(index)[1]){ time[j]=abs(data$times[data$ids==id[1]][index[j,1]]-data$times [data$ids==id[1]][index[j,2]]) gamma[j]=.5*(data$resids[data$ids==id[1]][index[j,1]]-data$res ids[data$ids==id[1]][index[j,2]])^2 } for (i in id[-1]){ index=combinations(length(data$times[data$ids==i]),2) time1=gamma1=numeric(dim(index)[1]) for (j in 1:dim(index)[1]){ time1[j]=abs(data$times[data$ids==i][index[j,1]]-data$times[da ta$ids==i][index[j,2]]) gamma1[j]=.5*(data$resids[data$ids==i][index[j,1]]-data$resids [data$ids==i][index[j,2]])^2 } time=c(time,time1) gamma=c(gamma,gamma1) } value=list(time=time,gamma=gamma) return(value) } and I would run it as semivario(data=hope,ids=id,times=sctime,resids=scResid) What I want to do is everywhere we see the words data,ids,times,resids to be replaced with, for example, hope,id,sctime,scResid. Think of macros in SAS where we use the before every macro input variable name. Im not sure if this is how R handles function inputs. Here is my error: Error in combinations(length(data$times[data$ids == id[1]]), 2) : bad value of n Thanks -- View this message in context: http://r.789695.n4.nabble.com/Pesky-homemade-function-code-tp2 541597p2541597.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Druk dit bericht a.u.b. niet onnodig af. Please do not print this message unnecessarily. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Pesky homemade function code
@Thierry- I am writing my own semivariogram code since I could not find a pre-made function that did what I need it do. The code in the function correctly works but I not sure how to get the function itself to work. In other words if I fill in the commands (hope,id,sctime,scResid) by hand then everything is ok -- but I dont want to do that. Plus this will help be better understand how to program functions in R. -- View this message in context: http://r.789695.n4.nabble.com/Pesky-homemade-function-code-tp2541597p2541696.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Splitting a matrix
Hi, I was trying to split the following matrix dat: set.seed(1) dat - matrix(rnorm(4*16), 4, 16) dat [,1] [,2] [,3][,4][,5][,6] [,7] [,8][,9] [,10] [,11] [1,] -0.6264538 0.3295078 0.5757814 -0.62124058 -0.01619026 0.91897737 0.61982575 -0.4781501 0.38767161 -0.3942900 -0.1645236 [2,] 0.1836433 -0.8204684 -0.3053884 -2.21469989 0.94383621 0.78213630 -0.05612874 0.4179416 -0.05380504 -0.0593134 -0.2533617 [3,] -0.8356286 0.4874291 1.5117812 1.12493092 0.82122120 0.07456498 -0.15579551 1.3586796 -1.37705956 1.1000254 0.6969634 [4,] 1.5952808 0.7383247 0.3898432 -0.04493361 0.59390132 -1.98935170 -1.47075238 -0.1027877 -0.41499456 0.7631757 0.5566632 [,12] [,13] [,14] [,15] [,16] [1,] -0.6887557 -0.1123462 0.3411197 -0.3672215 2.40161776 [2,] -0.7074952 0.8811077 -1.1293631 -1.0441346 -0.03924000 [3,] 0.3645820 0.3981059 1.4330237 0.5697196 0.68973936 [4,] 0.7685329 -0.6120264 1.9803999 -0.1350546 0.02800216 I want to split above one into 4 matrices (probably can be confined into a list) wherein 1st matrix consists of columns 1-4, 2nd matrix consists column 5-8 etc. Here I tried following: lapply(split(t(dat), c(4,8,12,16), drop=F), function(x) return(t(matrix(x, 4, 4 $`4` [,1][,2][,3] [,4] [1,] -0.6264538 -0.01619026 0.38767161 -0.1123462 [2,] 0.1836433 0.94383621 -0.05380504 0.8811077 [3,] -0.8356286 0.82122120 -1.37705956 0.3981059 [4,] 1.5952808 0.59390132 -0.41499456 -0.6120264 $`8` [,1][,2] [,3] [,4] [1,] 0.3295078 0.91897737 -0.3942900 0.3411197 [2,] -0.8204684 0.78213630 -0.0593134 -1.1293631 [3,] 0.4874291 0.07456498 1.1000254 1.4330237 [4,] 0.7383247 -1.98935170 0.7631757 1.9803999 $`12` [,1][,2] [,3] [,4] [1,] 0.5757814 0.61982575 -0.1645236 -0.3672215 [2,] -0.3053884 -0.05612874 -0.2533617 -1.0441346 [3,] 1.5117812 -0.15579551 0.6969634 0.5697196 [4,] 0.3898432 -1.47075238 0.5566632 -0.1350546 $`16` [,1] [,2] [,3][,4] [1,] -0.62124058 -0.4781501 -0.6887557 2.40161776 [2,] -2.21469989 0.4179416 -0.7074952 -0.03924000 [3,] 1.12493092 1.3586796 0.3645820 0.68973936 [4,] -0.04493361 -0.1027877 0.7685329 0.02800216 However this is not that which I wanted to get. Any idea on the proper code to doing that? Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problem reading Matlab file into R
Hi, I'm trying to read a .mat file into R (2.11.1) with medium success so far. The file I have is a MATLAB 5.0 MAT-file exported from RiverSurveyor LIVE software (http://www.sontek.com/software.php). I have R.matlab and Rcompression installed and readMat() starts reading the file, as can be seen in verbose mode (hence medium success), but then gives the following error: Error in dim(matrix) - dimensionsArray$dim : dims [product 1] do not match the length of object [0] I put the whole verbose output at the end of this email and an example file here: http://users.utu.fi/cjflen/files/riversurveyor.mat Can anyone give me some advice on what the problem might be, and how to solve it? This is the first time I'm using the R.matlab package and I have no access to or any experience with Matlab, so changing the mat file or saving it in a different format is not an option for me. Kind regards, Claude foo - readMat(riversurveyor.mat, verbose=TRUE) Trying to read MAT v5 file stream... List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 2848 $ padding : num 0 $ compressed: logi FALSE List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE int 1 List of 1 $ : int [1, 1] 1 List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE num 0 List of 1 $ : num [1, 1] 0 ..- attr(*, Csingle)= logi TRUE List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE num 0 List of 1 $ : num [1, 1] 0 ..- attr(*, Csingle)= logi TRUE List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE int 2 List of 1 $ : int [1, 1] 2 List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE int 3 List of 1 $ : int [1, 1] 3 List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE int 3 List of 1 $ : int [1, 1] 3 List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE int 0 List of 1 $ : int [1, 1] 0 List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE num 0 List of 1 $ : num [1, 1] 0 ..- attr(*, Csingle)= logi TRUE List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE num 0.1 List of 1 $ : num [1, 1] 0.1 ..- attr(*, Csingle)= logi TRUE List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE num 0 List of 1 $ : num [1, 1] 0 ..- attr(*, Csingle)= logi TRUE List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE num 2 List of 1 $ : num [1, 1] 2 ..- attr(*, Csingle)= logi TRUE List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0 $ what : num 0 $ nbrOfBytes: int 56 $ padding : num 0 $ compressed: logi FALSE num 0 List of 1 $ : num [1, 1] 0 ..- attr(*, Csingle)= logi TRUE List of 7 $ type : chr miMATRIX $ signed: logi NA $ sizeOf: int 0
Re: [R] Fwd: R install in Fedora
Actually I tried in both ways : yum install R and sudo yum install R , but the error is same. I have root privilege, means I used the command su - and enter the password. May be its problem from Fedora. Thanks for your valuable help. I will post this issue in R-SIG-Fedora list. Kind Regards Wesley -- Forwarded message -- From: Marc Schwartz marc_schwa...@me.com Date: Wed, Sep 15, 2010 at 2:02 PM Subject: Re: [R] R install in Fedora To: wesley mathew wesleycmat...@gmail.com Cc: r-help@r-project.org On Sep 15, 2010, at 5:14 AM, wesley mathew wrote: Dear All As you suggested I tried to install was trying to install R-2.11.1-3.fc13.1686 in Fedora-13-i386 but it also shows error. I wrote yum install R-2.11.1-3fc13.i686 Errors Cannot retrieve repository metadata (repond.xml) for repository: fedora. Please verify its path and try again. Could you please help me to solve this problem. . . . Note that the error reported by Fedora has nothing at all to do with the fact that you're trying to install R. Fedora has a (user-configurable) set of repositories -- places to look for software -- from which it will try to install packages. In Fedora 13 (the latest version) the repositories are listed in: /etc/yum.repos.d Fedora will check with every web site that appears in a stanza marked enabled=1 in the files in that directory when you do a yum install, yum update, etc. My guess is that you've got a network problem and/or there's an error in the file: /etc/yum.repos.d/fedora Often such problems just magically disappear as intermediate routers get rebooted, etc. As a minor aside, note that if you have sudo set up on your computer, you do NOT need the root password to perform whatever tasks you're allowed to do by the sudo configuration. Of course, you do have to have root privileges to set up the sudo configuration in the first place. -- Mike __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Splitting a matrix
Here is one possibility: set.seed(1) dat - matrix(rnorm(4*16), 4, 16) dim(dat) - c(4,4,4) dat , , 1 [,1] [,2] [,3][,4] [1,] -0.6264538 0.3295078 0.5757814 -0.62124058 [2,] 0.1836433 -0.8204684 -0.3053884 -2.21469989 [3,] -0.8356286 0.4874291 1.5117812 1.12493092 [4,] 1.5952808 0.7383247 0.3898432 -0.04493361 , , 2 [,1][,2][,3] [,4] [1,] -0.01619026 0.91897737 0.61982575 -0.4781501 [2,] 0.94383621 0.78213630 -0.05612874 0.4179416 [3,] 0.82122120 0.07456498 -0.15579551 1.3586796 [4,] 0.59390132 -1.98935170 -1.47075238 -0.1027877 , , 3 [,1] [,2] [,3] [,4] [1,] 0.38767161 -0.3942900 -0.1645236 -0.6887557 [2,] -0.05380504 -0.0593134 -0.2533617 -0.7074952 [3,] -1.37705956 1.1000254 0.6969634 0.3645820 [4,] -0.41499456 0.7631757 0.5566632 0.7685329 , , 4 [,1] [,2] [,3][,4] [1,] -0.1123462 0.3411197 -0.3672215 2.40161776 [2,] 0.8811077 -1.1293631 -1.0441346 -0.03924000 [3,] 0.3981059 1.4330237 0.5697196 0.68973936 [4,] -0.6120264 1.9803999 -0.1350546 0.02800216 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Megh Dal Sent: Thursday, 16 September 2010 5:43 PM To: r-h...@stat.math.ethz.ch Subject: [R] Splitting a matrix Hi, I was trying to split the following matrix dat: set.seed(1) dat - matrix(rnorm(4*16), 4, 16) dat [,1] [,2] [,3][,4][,5][,6] [,7] [,8][,9] [,10] [,11] [1,] -0.6264538 0.3295078 0.5757814 -0.62124058 -0.01619026 0.91897737 0.61982575 -0.4781501 0.38767161 -0.3942900 -0.1645236 [2,] 0.1836433 -0.8204684 -0.3053884 -2.21469989 0.94383621 0.78213630 -0.05612874 0.4179416 -0.05380504 -0.0593134 -0.2533617 [3,] -0.8356286 0.4874291 1.5117812 1.12493092 0.82122120 0.07456498 -0.15579551 1.3586796 -1.37705956 1.1000254 0.6969634 [4,] 1.5952808 0.7383247 0.3898432 -0.04493361 0.59390132 -1.98935170 -1.47075238 -0.1027877 -0.41499456 0.7631757 0.5566632 [,12] [,13] [,14] [,15] [,16] [1,] -0.6887557 -0.1123462 0.3411197 -0.3672215 2.40161776 [2,] -0.7074952 0.8811077 -1.1293631 -1.0441346 -0.03924000 [3,] 0.3645820 0.3981059 1.4330237 0.5697196 0.68973936 [4,] 0.7685329 -0.6120264 1.9803999 -0.1350546 0.02800216 I want to split above one into 4 matrices (probably can be confined into a list) wherein 1st matrix consists of columns 1-4, 2nd matrix consists column 5-8 etc. Here I tried following: lapply(split(t(dat), c(4,8,12,16), drop=F), function(x) return(t(matrix(x, 4, 4 $`4` [,1][,2][,3] [,4] [1,] -0.6264538 -0.01619026 0.38767161 -0.1123462 [2,] 0.1836433 0.94383621 -0.05380504 0.8811077 [3,] -0.8356286 0.82122120 -1.37705956 0.3981059 [4,] 1.5952808 0.59390132 -0.41499456 -0.6120264 $`8` [,1][,2] [,3] [,4] [1,] 0.3295078 0.91897737 -0.3942900 0.3411197 [2,] -0.8204684 0.78213630 -0.0593134 -1.1293631 [3,] 0.4874291 0.07456498 1.1000254 1.4330237 [4,] 0.7383247 -1.98935170 0.7631757 1.9803999 $`12` [,1][,2] [,3] [,4] [1,] 0.5757814 0.61982575 -0.1645236 -0.3672215 [2,] -0.3053884 -0.05612874 -0.2533617 -1.0441346 [3,] 1.5117812 -0.15579551 0.6969634 0.5697196 [4,] 0.3898432 -1.47075238 0.5566632 -0.1350546 $`16` [,1] [,2] [,3][,4] [1,] -0.62124058 -0.4781501 -0.6887557 2.40161776 [2,] -2.21469989 0.4179416 -0.7074952 -0.03924000 [3,] 1.12493092 1.3586796 0.3645820 0.68973936 [4,] -0.04493361 -0.1027877 0.7685329 0.02800216 However this is not that which I wanted to get. Any idea on the proper code to doing that? Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The permutation of one vector into another
match(b, a) ? Michael On 16 September 2010 17:13, Niels Richard Hansen niels.r.hansen+li...@math.ku.dk wrote: Dear R-help-list I have two character vectors a - c(A, B, C) b - c(A, C, B) Then sapply(a, function(i) grep(i, b)) computes the permutation of the entries in 'b' needed to bring 'b' into the same order as 'a'. I have searched around, but haven't been able to find any existing function that compute this permutation. Is there such a function doing this -- perhaps more efficiently than the above? For those interested, I need the permutation to bring the rows of a data frame into the same order as the levels of a factor. Thanks, Niels -- Niels Richard Hansen Web: www.math.ku.dk/~richard Associate Professor Email: niels.r.han...@math.ku.dk Department of Mathematical Sciences nielsrichardhan...@gmail.com University of Copenhagen Skype: nielsrichardhansen.dk Universitetsparken 5 Phone: +45 353 20783 (office) 2100 Copenhagen Ø +45 2859 0765 (mobile) Denmark __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using feather.plot to try and generate a stick plot of current velocity data (and having issues)
Hi all, After a bit of offlist correspondence, the problem with feather.plot was found to be with the input data format (lists) and the particular data revealed a bug in the function. A fix for the bug and a warning about lists as input will be in the next version of plotrix (3.0-1). Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The permutation of one vector into another
match(b, a) ? Michael Right! Thanks, Michael. On 16 September 2010 17:13, Niels Richard Hansen niels.r.hansen+li...@math.ku.dk wrote: Dear R-help-list I have two character vectors a - c(A, B, C) b - c(A, C, B) Then sapply(a, function(i) grep(i, b)) computes the permutation of the entries in 'b' needed to bring 'b' into the same order as 'a'. I have searched around, but haven't been able to find any existing function that compute this permutation. Is there such a function doing this -- perhaps more efficiently than the above? For those interested, I need the permutation to bring the rows of a data frame into the same order as the levels of a factor. Thanks, Niels -- Niels Richard Hansen Web: www.math.ku.dk/~richard Associate Professor Email: niels.r.han...@math.ku.dk Department of Mathematical Sciences nielsrichardhan...@gmail.com University of Copenhagen Skype: nielsrichardhansen.dk Universitetsparken 5 Phone: +45 353 20783 (office) 2100 Copenhagen Ø +45 2859 0765 (mobile) Denmark __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] use same breaks and colors, but the displayed scale are different-image.plot()
On 09/16/2010 12:05 PM, rusers.sh wrote: Hi all, I want to put several figures in a one figure for easy comparison, so i need to use the same methods to plot these figures. The following is an example. I also list my method, but it does not work. #Example data x- 1:10; y- 1:10; z- outer( x,y,+);z2- outer( x,y,-) #Quick view them image.plot(x,y,z) #relatively larger value image.plot(x,y,z2) #relatively small value #define the same breaks and colors brks-quantile(c(as.vector(z),as.vector(z2)),na.rm=TRUE) colsn-length(brks)-1 cols-gray((colsn:1)/colsn) #I expect they use the same breaks and colors par(mfrow=c(1,2)) image.plot(x,y,z,breaks=brks,col=cols) image.plot(x,y,z2,breaks=brks,col=cols) par(mfrow=c(1,1)) I think they really use the same breaks and colors, but you can see the color legends are still different. One is 20-15-10-5, another is 5-0--5. I hope they not only use the same breaks and colors, but also display the same color legends. How can i do it? Hi Jane, The color.legend function in the plotrix package will do this - see the examples, especially those for the barp function. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to combine matrix and vector
Dear fellows, I am a novice in R. I would like to combine a matrix and a vector. Assume that we have the matrix a and the vector b with same length of column. a-matrix(seq(1:10),nrow=2,ncol=5,byrow=TRUE) a= 12345 6789 10 b-t(c(11,12,13,14,15)) b= 11 12 13 14 15 Then, I want to combine a and b as follows. c= 12345 6789 10 11 12 13 14 15 If you teach me to easily combine the matrix and the vector, I will greatly appreciate you. Thank you. Regards, Wonsang - -- Wonsang You Special Lab Non-Invasive Brain Imaging Leibniz Institute for Neurobiology http://www.ifn-magdeburg.de -- View this message in context: http://r.789695.n4.nabble.com/How-to-combine-matrix-and-vector-tp2541797p2541797.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to combine matrix and vector
Hi! Take a look at rbind() Btw, I don't think you have to transpose b. HTH, Ivan Le 9/16/2010 11:09, Wonsang You a écrit : Dear fellows, I am a novice in R. I would like to combine a matrix and a vector. Assume that we have the matrix a and the vector b with same length of column. a-matrix(seq(1:10),nrow=2,ncol=5,byrow=TRUE) a= 12345 6789 10 b-t(c(11,12,13,14,15)) b= 11 12 13 14 15 Then, I want to combine a and b as follows. c= 12345 6789 10 11 12 13 14 15 If you teach me to easily combine the matrix and the vector, I will greatly appreciate you. Thank you. Regards, Wonsang - -- Wonsang You Special Lab Non-Invasive Brain Imaging Leibniz Institute for Neurobiology http://www.ifn-magdeburg.de -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to uncompress a gz file in R
Dear Henrik and Steven, Thank you for your kind help and guidance even though it is a basic question. I misunderstood that gunzip is a part of not R.utils but utils. I could find out the function in R.utils. Then, it was successful to decompress any gz file as follows. library(R.utils) gunzip(foo.gz) Best Regards, Wonsang [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] standard error of difference for mixed effects
Dear Tony, A mixed models is not a good idea if you have only two levels for sites and two times two for phase. The first problem is a mathematical problems. You are estimating variances based on only two and four values. Which is very small, hence you will not get reliable estimates of the variance. The second problem is more conceptual. Your question indicates that you are interested in the effect of specific levels of your random effects. The philosophy of mixed models is that you only care about the variability due to the random effects, and not in specific effects. IMHO een simple linear model will do. lm(log(Salinity) ~ log(flow)*sites/phase) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics Quality Assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Meissner, Tony (DFW) Verzonden: donderdag 16 september 2010 2:58 Aan: r-help@r-project.org Onderwerp: [R] standard error of difference for mixed effects I have a dataset relating the effects of engineering works on the level of salinity in a river before and after the works. I have modelled this using linear mixed effects models to determine if the significance and level of the response to the works. I am wanting to calculate the se of difference at several points. I am not sure of how to calculate the difference and which estimate of se I should be using e.g. is it the random effects or the fixed effects estimates and what formula to use e.g. the one for calculating se using linear models? To assist here is one of the models I have formulated log(Salinity) ~ log(flow), random=~log(flow)|sites/phase where sites is a factor with levels upstream downstream, and phase is a factor with two levels before and after. Any help would be appreciated. Tschüß Tony Meissner Principal Scientist - Monitoring Department for Water | Level 3 28 Vaughan Terrace Berri SA 5343 T 8595 2209 | M 0401 124 971 E tony.meiss...@sa.gov.aumailto:tony.meiss...@sa.gov.au Mon | Tue | Wed | Thurs | Fri www.waterforgood.sa.gov.auhttp://www.waterforgood.sa.gov.au/ | www.sa.gov.auhttp://www.sa.gov.au/ The information in this e-mail may be confidential and/o...{{dropped:13}} Druk dit bericht a.u.b. niet onnodig af. Please do not print this message unnecessarily. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to uncompress a gz file in R
you are welcome. Henrik's package is an great piece of work. It is worth the time to read through the whole thing and see how you can improve your programs by using other features as well. On Thu, Sep 16, 2010 at 2:16 AM, Wonsang You y...@ifn-magdeburg.de wrote: Dear Henrik and Steven, Thank you for your kind help and guidance even though it is a basic question. I misunderstood that gunzip is a part of not R.utils but utils. I could find out the function in R.utils. Then, it was successful to decompress any gz file as follows. library(R.utils) gunzip(foo.gz) Best Regards, Wonsang [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Pesky homemade function code
Hello, why you don't use the last 3 arguments? semivario=function(data,ids,times,resids){ id=unique(data$ids) ... It seems data be a list. In that case the last 3 arguments are useless. Could you please send us a runable code example. That means some example data and your all neede functions (e.g. combinations, because there is the error you looking for.) Error in combinations(length(data$times[data$ids == id[1]]), 2) : bad value of n Kind regards, Sebastian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error compiling R 2.10.1 on AIX
Hello, I am also facing exactly same problem like Mike while compiling R on AIX 5.3 Error in read.dcf(file = descfile) : Line starting 'Package: tools ...' is malformed! Calls: makeLazyLoading ... code2LazyLoadDB - loadNamespace - parseNamespaceFile - read.dcf Execution halted My Environment is : CC='xlc_r -q64' CFLAGS='-O -qstrict' CPPFLAGS='-I/opt/freeware/include -I/usr/lpp/X11/include/X11' CXX='xlC_r -q64' CXXFLAGS='-O -qstrict' AR='ar -X64' F77='xlf_r -q64' LDFLAGS='-L/opt/freeware/lib -L/usr/lib -L/usr/X11R6/lib' LIBICONV=/opt/freeware OBJECT_MODE=64 Any suggestions/solutions? I am compiling on AIX 5.3 same problem occurs for 2.10.1 and 2.11.1 -Balkrishna Ketkar --- I'm trying to compile R 2.10.1 on AIX 5.3, and am getting the following error: Error in read.dcf(file = descfile) : Line starting 'Package: tools ...' is malformed! Calls: makeLazyLoading ... code2LazyLoadDB - loadNamespace - parseNamespaceFile - read.dcf Execution halted make[3]: *** [all] Error 1 make[3]: Leaving directory `/afs/.isis.unc.edu/pkg/r-2.10.1/.build/rs_aix53/R-patched/src/library/tools ' My environment and configure settings are as follows: export PATH=/usr/local/bin:/opt/freeware/bin:$PATH export OBJECT_MODE=64 export LIBICONV=/opt/freeware export CC=xlc_r -q64 export CFLAGS=-O -qstrict export CXX=xlC_r -q64 export CXXFLAGS=-O -qstrict export AR=ar -X64 export F77=xlf_r -q64 export CPPFLAGS=-I/afs/isis/pkg/libpng/include -I/usr/local/include -I$LIBICONV/include -I/usr/lpp/X11/include/X11 export LDFLAGS=-L/usr/local/lib -L$LIBICONV/lib -L/usr/lib -L/usr/X11R6/lib export CAIRO_CFLAGS=-I/opt/freeware/include/cairo -I/opt/freeware/include/freetype2 export CAIRO_LIBS=-L/opt/freeware/lib -lcairo export JAVA_HOME=/usr/java14_64 export JAVA_CPPFLAGS=-I/usr/java14_64/include export LDR_CNTRL=USERREGS ./configure --prefix=/afs/.isis/pkg/r-2.10.1 --with-tcltk=/usr/local/lib --with-tcl-config=/usr/local/lib/tclConfig.sh --with-tk-config=/usr/local/lib/tkConfig.sh Mike Waldron -- View this message in context: http://r.789695.n4.nabble.com/Error-compiling-R-2-10-1-on-AIX-tp1017862p2541849.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] multiple cores/building fails
On 15.09.2010 17:40, Gregory Ryslik wrote: Hi, That seems to be the case. Is there a way that I can put an object in some global place where all the workers can access it? Doing the following at the start (before I make multiple workers) does not work: Assign('global.control', control, globalenv()) Well, you need to go via the NetWorkSpaces if using the Ffaemwork, I believe, hence use nwsDeclare(). I never used nws myself, hence just a guess. But all these parallelizing framworks work more or less the way that you need to make objects available to clients since it would be ineffeicent to transfer the whole (maybe huge) workspace of the master to each client. Best, Uwe Ligges Thanks for your help! Kind regards, Greg Sent via BlackBerry by ATT -Original Message- From: Uwe Liggeslig...@statistik.tu-dortmund.de Date: Wed, 15 Sep 2010 10:56:54 To: Gregory Ryslikrsa...@comcast.net Cc:r-h...@stat.math.ethz.ch Subject: Re: [R] multiple cores/building fails On 14.09.2010 21:50, Gregory Ryslik wrote: Hi Everyone, I have written debugged and tested my code and it works (yay!). I recently tried to parallelize it (1 core/per tree) and when I run the code I get an error saying the object control was not found. I do have an object control in my code but it always works fine as long as I am not running it on multiple cores (which I am doing via the help of sleigh and the 'nws' package). Think that this could be an error in my source statements, I tried to build my package (with the hope of replace source with library()) and I get the following (where XXX is my package name that I've removed for privacy reasons): * creating vignettes ... ERROR Error: processing vignette '.Rnw' failed with diagnostics: chunk 4 Error : object control not found Again it gives me that this control object is not found. Does anyone have an idea how I can isolate what's going on. It's slightly tough to do because it all works fine in the single processor case! Perhaps you forgot to populate the object to the client nodes? Hard to say without any reproducible example code. Uwe Ligges Thanks! Kind regards, Greg __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] approxfun returning value higher than I would expect
stephen sefick wrote: I will get R-dev tomorrow, and give it a try. Where do I check out the svn? https://svn.r-project.org/R/trunk The fixed files are in .../src/library/stats/R and are approx.R, spline.R and splinefun.R. The only one that affects your report is approx.R. Duncan Murdoch thanks, Stephen On Wed, Sep 15, 2010 at 10:00 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: I think this is fixed now. There were actually two bugs: I fixed an old one a few days ago, but my fix didn't handle the case of unsorted x properly. (I haven't checked whether the old code handled that properly; I'd guess not, but it might have.) Now I've fixed my new bug. *Please* test R-devel to see if I got it right this time. (I think I did, but I thought I did last time, too.) If you don't build your own copies, look for a build based on revision r52916 or newer. Windows builds should appear late tomorrow, I don't know about other platforms. Duncan Murdoch On 15/09/2010 4:32 PM, stephen sefick wrote: x - c(-0.48,-0.48,-0.42,-0.26,0.58,0.48,0.47,0.54,0.5,0.52,0.52,0.56,0.58,0.61,0.68) y - c(0,0.2,0.4,0.6,0.8,1,1.2,1.4,1.6,1.8,2,2.2,2.4,2.6,2.8) s - approxfun(x[4:5], y[4:5], ties=mean) s(0) #This is the value that I want. The first zero crossing in the order of y. #In other words in between 0.6 and 0.8. #The data is a channel cross-section, and should really be visualized plot(x~y, ylim=c(1,-1)) #this is half of a cross-section #The bankfull depth is where x is equal to 0 On Wed, Sep 15, 2010 at 3:12 PM, stephen sefick ssef...@gmail.com wrote: Thanks and I'll strip the code down even more in future posts. Stephen On Wed, Sep 15, 2010 at 3:05 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 15/09/2010 3:48 PM, stephen sefick wrote: Below is the code that I am using in a much larger function. I would expect a bankfull measure at zero to be between 0.6 and 0.8 approxfun is returning 0.8136986. I am sure that I am missing something. measure_bkf- (structure(list(measurment_num = c(0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.2, 3.4), bankfull_depths_m = c(-0.48, -0.48, -0.42, -0.26, 0.58, 0.48, 0.47, 0.54, 0.5, 0.52, 0.52, 0.56, 0.58, 0.61, 0.68, 0.62, 0.67, 0.66)), .Names = c(measurment_num, bankfull_depths_m), row.names = c(6124, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628), class = data.frame)) measure_bkf_not_zero- subset(measure_bkf, measure_bkf$bankfull_depths_m!=0) bkf_min- which.max(measure_bkf_not_zero[,bankfull_depths_m]0) bkf_max- which.max(measure_bkf_not_zero[,bankfull_depths_m]) #bkf_min- ifelse(length(bkf_min)1, bkf_min[1], bkf_min) #bkf_max- ifelse(length(bkf_max)1, bkf_max[1], bkf_max) #s- with(measure_bkf_not_zero, approx(measurment_num, bankfull_depths_m, xout=seq(measure_bkf_not_zero[bkf_min,measurment_num], measure_bkf_not_zero[bkf_max,measurment_num], length=2000))) #int_bkf- with(s, x[which.min(y[y0])]) s- with(measure_bkf_not_zero[bkf_min:bkf_max,], approxfun(bankfull_depths_m, measurment_num), ties=mean) int_bkf- s(0) It is easier to see the problem if you don't leave all the complications in the beginning. Just define some variables and show the interpolation on a plot: x - c(-0.48,-0.48,-0.42,-0.26,0.58,0.48,0.47,0.54,0.5,0.52,0.52,0.56,0.58,0.61,0.68) y - c(0,0.2,0.4,0.6,0.8,1,1.2,1.4,1.6,1.8,2,2.2,2.4,2.6,2.8) plot(x, y) s - approxfun(x, y, ties=mean) curve(s, add=TRUE) On my system, this looks okay in 2.11.1, but not in R-patched or R-devel (soon to be 2.12.0). It is fixed if the x values are ordered, but it's not supposed to need that. I'll take a look. Duncan Murdoch -- Stephen Sefick | Auburn University | | Department of Biological Sciences | | 331 Funchess Hall | | Auburn, Alabama | | 36849| |___| | sas0...@auburn.edu | | http://www.auburn.edu/~sas0025 | |___| Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis A big computer, a complex algorithm and a long time does not equal science. -Robert Gentleman __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help me understand how things work.
Hello I have some strange output from R and I try to understand how R works. Could you please help me with that? temp - rbind (c(10,1),c(99,98)) temp [,1] [,2] [1,] 101 [2,] 99 98 dist(temp) 1 2 131.6435 sqrt(dist(temp)) 1 2 11.47360 so far so good. until the nex line: when I try to do what i did before but adding the 1/(what I did before). I was expecting a number as a result of the division but unfortunately I took the following: 1/sqrt(dist(temp)) [1] 0.08715662 attr(,Size) [1] 2 attr(,Diag) [1] FALSE attr(,Upper) [1] FALSE attr(,method) [1] euclidean attr(,call) dist(x = temp) attr(,class) [1] dist Could you please help me understand what is this about? I would like to thank you in advance for your help Best REgards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Pesky homemade function code
Checking on the function 'combinations' in gplot i find this: if (mode(n) != numeric || length(n) != 1 || n 1 || (n%%1) != 0) stop(bad value of n) So essentially, the argument 'length(data$times[data$ids == id[1]])' in the line 'combinations(length(data$times[data$ids == id[1]]), 2)' does not meet one of those four conditions. That's as much as i can tell you without some kind of reproducible code. 2010/9/16 trekvana trekv...@aol.com Hi all- this seems to be simple to figure out but since im new to writing functions I dont know what is happening. Here is my code along with the error I am receiving: semivario=function(data,ids,times,resids){ id=unique(data$ids) index=combinations(length(data$times[data$ids==id[1]]),2) time=gamma=numeric(dim(index)[1]) for (j in 1:dim(index)[1]){ time[j]=abs(data$times[data$ids==id[1]][index[j,1]]-data$times[data$ids==id[1]][index[j,2]]) gamma[j]=.5*(data$resids[data$ids==id[1]][index[j,1]]-data$resids[data$ids==id[1]][index[j,2]])^2 } for (i in id[-1]){ index=combinations(length(data$times[data$ids==i]),2) time1=gamma1=numeric(dim(index)[1]) for (j in 1:dim(index)[1]){ time1[j]=abs(data$times[data$ids==i][index[j,1]]-data$times[data$ids==i][index[j,2]]) gamma1[j]=.5*(data$resids[data$ids==i][index[j,1]]-data$resids[data$ids==i][index[j,2]])^2 } time=c(time,time1) gamma=c(gamma,gamma1) } value=list(time=time,gamma=gamma) return(value) } and I would run it as semivario(data=hope,ids=id,times=sctime,resids=scResid) What I want to do is everywhere we see the words data,ids,times,resids to be replaced with, for example, hope,id,sctime,scResid. Think of macros in SAS where we use the before every macro input variable name. Im not sure if this is how R handles function inputs. Here is my error: Error in combinations(length(data$times[data$ids == id[1]]), 2) : bad value of n Thanks -- View this message in context: http://r.789695.n4.nabble.com/Pesky-homemade-function-code-tp2541597p2541597.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error compiling R 2.10.1 on AIX
Hi, This is a bug of tre-regex(AIX 64bit only). following patches help you. https://r-forge.r-project.org/scm/viewvc.php/patches/aix_R210_tre.patch?view=markuproot=aix 2010/9/16 Balkrishna Ketkar bket...@gmail.com: Hello, I am also facing exactly same problem like Mike while compiling R on AIX 5.3 Error in read.dcf(file = descfile) : Line starting 'Package: tools ...' is malformed! Calls: makeLazyLoading ... code2LazyLoadDB - loadNamespace - parseNamespaceFile - read.dcf Execution halted My Environment is : CC='xlc_r -q64' CFLAGS='-O -qstrict' CPPFLAGS='-I/opt/freeware/include -I/usr/lpp/X11/include/X11' CXX='xlC_r -q64' CXXFLAGS='-O -qstrict' AR='ar -X64' F77='xlf_r -q64' LDFLAGS='-L/opt/freeware/lib -L/usr/lib -L/usr/X11R6/lib' LIBICONV=/opt/freeware OBJECT_MODE=64 Any suggestions/solutions? I am compiling on AIX 5.3 same problem occurs for 2.10.1 and 2.11.1 -Balkrishna Ketkar --- I'm trying to compile R 2.10.1 on AIX 5.3, and am getting the following error: Error in read.dcf(file = descfile) : Line starting 'Package: tools ...' is malformed! Calls: makeLazyLoading ... code2LazyLoadDB - loadNamespace - parseNamespaceFile - read.dcf Execution halted make[3]: *** [all] Error 1 make[3]: Leaving directory `/afs/.isis.unc.edu/pkg/r-2.10.1/.build/rs_aix53/R-patched/src/library/tools ' My environment and configure settings are as follows: export PATH=/usr/local/bin:/opt/freeware/bin:$PATH export OBJECT_MODE=64 export LIBICONV=/opt/freeware export CC=xlc_r -q64 export CFLAGS=-O -qstrict export CXX=xlC_r -q64 export CXXFLAGS=-O -qstrict export AR=ar -X64 export F77=xlf_r -q64 export CPPFLAGS=-I/afs/isis/pkg/libpng/include -I/usr/local/include -I$LIBICONV/include -I/usr/lpp/X11/include/X11 export LDFLAGS=-L/usr/local/lib -L$LIBICONV/lib -L/usr/lib -L/usr/X11R6/lib export CAIRO_CFLAGS=-I/opt/freeware/include/cairo -I/opt/freeware/include/freetype2 export CAIRO_LIBS=-L/opt/freeware/lib -lcairo export JAVA_HOME=/usr/java14_64 export JAVA_CPPFLAGS=-I/usr/java14_64/include export LDR_CNTRL=USERREGS ./configure --prefix=/afs/.isis/pkg/r-2.10.1 --with-tcltk=/usr/local/lib --with-tcl-config=/usr/local/lib/tclConfig.sh --with-tk-config=/usr/local/lib/tkConfig.sh Mike Waldron -- View this message in context: http://r.789695.n4.nabble.com/Error-compiling-R-2-10-1-on-AIX-tp1017862p2541849.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- EI-JI Nakama nakama (a) ki.rim.or.jp \u4e2d\u9593\u6804\u6cbb nakama (a) ki.rim.or.jp __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help me understand how things work.
Hello Alex, Look at the help page for the dist function. You'll see it doesn't return a simple vector or matrix, rather a dist class object which is why you got a surprise when you tried to treat it like a simple value. The function is not really intended for spatial point distance calculations, but rather for multivariate analysis. Your example would work if you did it like this... d dist( temp )[1] dd - 1 / sqrt( d ) But if you want to have more than just two points in your matrix it will get ugly trying to work out the indices for the distances (although the dist help page gives you a formula). You'd be better for using a simple function... getdist - function(p1, p2) sqrt( (p1[1] - p2[1])^2 + (p1[2] - p2[2])^2 ) Or if you are going to do more complex point pattern analyses look at one of the many spatial packages for R such as spatstat. Hope this helps, Michael On 16 September 2010 20:02, Alaios ala...@yahoo.com wrote: Hello I have some strange output from R and I try to understand how R works. Could you please help me with that? temp - rbind (c(10,1),c(99,98)) temp [,1] [,2] [1,] 10 1 [2,] 99 98 dist(temp) 1 2 131.6435 sqrt(dist(temp)) 1 2 11.47360 so far so good. until the nex line: when I try to do what i did before but adding the 1/(what I did before). I was expecting a number as a result of the division but unfortunately I took the following: 1/sqrt(dist(temp)) [1] 0.08715662 attr(,Size) [1] 2 attr(,Diag) [1] FALSE attr(,Upper) [1] FALSE attr(,method) [1] euclidean attr(,call) dist(x = temp) attr(,class) [1] dist Could you please help me understand what is this about? I would like to thank you in advance for your help Best REgards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help me understand how things work.
Hi Alex, What is happening is that the ´dist´function calculates a distance matrix, and returns an object of the ´dist´ class. temp - rbind (c(10,1),c(99,98)) x=dist(temp) x 1 2 131.6435 class(x) [1] dist You can see a description of the ´dist´class at the end of the function´s help file. Do this: ?dist So when you do dist(temp) you do not just get a number. You get an object that has the distance between the points, plus additional information (i.e. the method used to calculate the distance, if the matrix contains only the lower triangle or also the upper triangle and the diagonal, etc.). If you do sqrt() or 1/ over this object it is still of the ´dist´ class: x=dist(temp) x=sqrt(x) class(x) [1] dist x=1/x class(x) [1] dist Notice that you still the right answer (0.08715662). For some reason R prints the attributes of the object when you do the inverse but not when you do the square root (I´m curious about why...If anyone has an answer please pitch in). If you only want to get a number, do this: x=as.numeric(dist(temp)) class(x) [1] numeric 1/sqrt(as.numeric(dist(temp))) [1] 0.08715662 All the best, Julián Julian Mariano Burgos Hafrannsóknastofnunin/Marine Research Institute Skúlagata 4, 121 Reykjavík, Iceland Sími/Telephone : +354-5752037 Bréfsími/Telefax: +354-5752001 Netfang/Email: jul...@hafro.is, jmbur...@uw.edu On Thu, Sep 16, 2010 at 10:02 AM, Alaios ala...@yahoo.com wrote: Hello I have some strange output from R and I try to understand how R works. Could you please help me with that? temp - rbind (c(10,1),c(99,98)) temp [,1] [,2] [1,] 101 [2,] 99 98 dist(temp) 1 2 131.6435 sqrt(dist(temp)) 1 2 11.47360 so far so good. until the nex line: when I try to do what i did before but adding the 1/(what I did before). I was expecting a number as a result of the division but unfortunately I took the following: 1/sqrt(dist(temp)) [1] 0.08715662 attr(,Size) [1] 2 attr(,Diag) [1] FALSE attr(,Upper) [1] FALSE attr(,method) [1] euclidean attr(,call) dist(x = temp) attr(,class) [1] dist Could you please help me understand what is this about? I would like to thank you in advance for your help Best REgards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help me understand how things work.
I fixed by adding this: k - sqrt(dist(temp)) k returns sort of a list. So I need to select the first item which is the result. a - k[1] Can someone explain me why k[1] is needed for that? Best Regards Alex From: Mario Valle mva...@cscs.ch Sent: Thu, September 16, 2010 1:28:31 PM Subject: Re: [R] help me understand how things work. ?dist BTW, to me this does not happens. x - matrix(rnorm(100), nrow=5) d - dist(x) 1/sqrt(d) 1/sqrt(dist(x)) Hope it helps mario On 16-Sep-10 12:02, Alaios wrote: Hello I have some strange output from R and I try to understand how R works. Could you please help me with that? temp- rbind (c(10,1),c(99,98)) temp [,1] [,2] [1,] 101 [2,] 99 98 dist(temp) 1 2 131.6435 sqrt(dist(temp)) 1 2 11.47360 so far so good. until the nex line: when I try to do what i did before but adding the 1/(what I did before). I was expecting a number as a result of the division but unfortunately I took the following: 1/sqrt(dist(temp)) [1] 0.08715662 attr(,Size) [1] 2 attr(,Diag) [1] FALSE attr(,Upper) [1] FALSE attr(,method) [1] euclidean attr(,call) dist(x = temp) attr(,class) [1] dist Could you please help me understand what is this about? I would like to thank you in advance for your help Best REgards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with cat() == A related question
The question is wehter cat() can print out a matrix as it is. For example, Let's assume that we have matrices A, B, D(= A+B), if it is possible that cat(\n, A, +,B,=, D, some control arguments , \n) prints out matrix A + matrix B = matrix D where matrices A, B, D (= A+B) should be in the form of their actual matrices. -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-cat-tp2538811p2542098.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help me understand how things work.
print(k) and you see a lower triangular distance matrix. k[1] selects distances between 1 and 2 k[2] selects distances between 1 and 3 and so on. you have a distance matrix, not a single distance value, so you have to select which distance you need. Ciao! mario On 16-Sep-10 14:38, Alaios wrote: I fixed by adding this: k - sqrt(dist(temp)) k returns sort of a list. So I need to select the first item which is the result. a - k[1] Can someone explain me why k[1] is needed for that? Best Regards Alex *From:* Mario Valle mva...@cscs.ch *To:* Alaios ala...@yahoo.com *Sent:* Thu, September 16, 2010 1:28:31 PM *Subject:* Re: [R] help me understand how things work. ?dist BTW, to me this does not happens. x - matrix(rnorm(100), nrow=5) d - dist(x) 1/sqrt(d) 1/sqrt(dist(x)) Hope it helps mario On 16-Sep-10 12:02, Alaios wrote: Hello I have some strange output from R and I try to understand how R works. Could you please help me with that? temp- rbind (c(10,1),c(99,98)) temp [,1] [,2] [1,] 101 [2,] 99 98 dist(temp) 1 2 131.6435 sqrt(dist(temp)) 1 2 11.47360 so far so good. until the nex line: when I try to do what i did before but adding the 1/(what I did before). I was expecting a number as a result of the division but unfortunately I took the following: 1/sqrt(dist(temp)) [1] 0.08715662 attr(,Size) [1] 2 attr(,Diag) [1] FALSE attr(,Upper) [1] FALSE attr(,method) [1] euclidean attr(,call) dist(x = temp) attr(,class) [1] dist Could you please help me understand what is this about? I would like to thank you in advance for your help Best REgards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle http://www.cscs.ch/%7Emvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 -- Ing. Mario Valle Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help for an absolutely r-noob
Hello together, I am an absolute noob in R and therefore I need help urgently. I have received a script from my tutor with plot functions in it. However, I can' manage to adapt these plots. The hole script is as follows: setwd(E:/) # (1) Read data ### dat - read.table(Komfort_Tatsaechliche_ID_Versuchsreihe_1.txt, header=TRUE, sep=\t, dec=,) # tab-getrennte Textdatei names(dat) - c(id, resp, amp) dat$id - factor(dat$id) # kategoriale Variablen als Faktor definieren dat$amp - as.numeric(gsub(^([0-9]),([0-9]+) Nm$, \\1.\\2, dat$amp)) # (2) Explorative plots # library(lattice) xyplot(resp ~ amp|id, dat, type=c(g,p,smooth)) # (3) MIXED-EFFECTS REGRESSION MODELS # library(nlme) lme1 - lme(resp ~ amp, dat, ~1|id, method=ML) lme2 - lme(resp ~ amp + I(amp^2), dat, ~1|id, method=ML) lme2a - lme(resp ~ amp + I(amp^2), dat, ~amp|id, method=ML) lme3 - lme(resp ~ amp + I(amp^2) + I(amp^3), dat, ~1|id, method=ML) lme5 - lme(resp ~ factor(amp), dat, ~1|id, method=ML) anova(lme1, lme2) anova(lme2, lme3, lme5) summary(lme2) # (4) observed vs. predicted data # plot(augPred(lme2, ~amp, level=0:1)) xvar - seq(0, 0.4, len=50) plot(predict(lme2, data.frame(amp=xvar), level=0) ~ xvar, type=l) # points() # adding mean I marked the important plot with boldface. I would like to adapt the Y axis on a value of -2 to +2. Moreover, I want to add the means of the the responses (resp) of each amp-value. My tutor already add a line # points() for this but I'm not sure how to complement this line. And the last problem: How do I change the axis labels? I am glad about every constructive input. Please apologize my bad english. Strampe -- View this message in context: http://r.789695.n4.nabble.com/Help-for-an-absolutely-r-noob-tp2542119p2542119.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The permutation of one vector into another
On Sep 16, 2010, at 4:23 AM, Michael Bedward wrote: match(b, a) ? Or just order(.) : b[order(a)] [1] A C B -- David Michael On 16 September 2010 17:13, Niels Richard Hansen niels.r.hansen+li...@math.ku.dk wrote: Dear R-help-list I have two character vectors a - c(A, B, C) b - c(A, C, B) Then sapply(a, function(i) grep(i, b)) computes the permutation of the entries in 'b' needed to bring 'b' into the same order as 'a'. I have searched around, but haven't been able to find any existing function that compute this permutation. Is there such a function doing this -- perhaps more efficiently than the above? For those interested, I need the permutation to bring the rows of a data frame into the same order as the levels of a factor. Thanks, Niels -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How do I create a plotable zoo object based on weekly data?
Dear readers, The problem is simple: I have weekly time series data with a maximum week number of (52,53,52,52) in (2008,2009,2010,2011) respectively. That means I have a dataset looking like this: 2008-01 value 2008-02 value . . 2011-52 value And I would like to turn that data into a plotable zoo object. Now a simple example containing 4 data points, each being on the December 28th, would be: x - zoo(rnorm(4), as.Date(2008-12-28)+0:3*365) plot(x) This works fine, but y - zoo(rnorm(4), format(as.Date(2008-12-28)+0:3*365, %Y-%U)) plot(y) gives me the following warning message: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf Anyone knows how to solve this? Best regards, Michael Green __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help for an absolutely r-noob
Hi, Take a look at ?par, all the arguments for the plot() function are described there. Check in particular ylim, xlab and ylab HTH, Ivan Le 9/16/2010 14:45, strampe a écrit : Hello together, I am an absolute noob in R and therefore I need help urgently. I have received a script from my tutor with plot functions in it. However, I can' manage to adapt these plots. The hole script is as follows: setwd(E:/) # (1) Read data ### dat- read.table(Komfort_Tatsaechliche_ID_Versuchsreihe_1.txt, header=TRUE, sep=\t, dec=,) # tab-getrennte Textdatei names(dat)- c(id, resp, amp) dat$id- factor(dat$id) # kategoriale Variablen als Faktor definieren dat$amp- as.numeric(gsub(^([0-9]),([0-9]+) Nm$, \\1.\\2, dat$amp)) # (2) Explorative plots # library(lattice) xyplot(resp ~ amp|id, dat, type=c(g,p,smooth)) # (3) MIXED-EFFECTS REGRESSION MODELS # library(nlme) lme1- lme(resp ~ amp, dat, ~1|id, method=ML) lme2- lme(resp ~ amp + I(amp^2), dat, ~1|id, method=ML) lme2a- lme(resp ~ amp + I(amp^2), dat, ~amp|id, method=ML) lme3- lme(resp ~ amp + I(amp^2) + I(amp^3), dat, ~1|id, method=ML) lme5- lme(resp ~ factor(amp), dat, ~1|id, method=ML) anova(lme1, lme2) anova(lme2, lme3, lme5) summary(lme2) # (4) observed vs. predicted data # plot(augPred(lme2, ~amp, level=0:1)) xvar- seq(0, 0.4, len=50) plot(predict(lme2, data.frame(amp=xvar), level=0) ~ xvar, type=l) # points() # adding mean I marked the important plot with boldface. I would like to adapt the Y axis on a value of -2 to +2. Moreover, I want to add the means of the the responses (resp) of each amp-value. My tutor already add a line # points() for this but I'm not sure how to complement this line. And the last problem: How do I change the axis labels? I am glad about every constructive input. Please apologize my bad english. Strampe -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshape matrix entities to columns
Thanks for the help I have tried the one that uses xtab() and the answer is correct because when I was using the rbind() still getting the same error message⦠Now I have some more questions ⦠I am trying to be able to adapt this for any kind of data of the same structure so now im thinking about few points 1. what is there is no row name : (center1,center2) assuming the rows automatically present that 2. what if I donât have the column names: considering that there is no rows names as well: assuming odd columns are age and even ones are numbers of ppl. 3. And Time? How to automatically match this ⦠I have tried with ncol() but because now I have name of the rows there its giving me a number like 5.5 which is not helpful thanks again From: David Winsemius dwinsem...@comcast.net Cc: Dennis Murphy djmu...@gmail.com; r-help@r-project.org Sent: Tue, 14 September, 2010 2:24:19 Subject: Re: [R] reshape matrix entities to columns On Sep 13, 2010, at 8:51 PM, Natasha Asar wrote: I am trying this as you mentioned and getting an error which i cant fix do you know where is the problem? df2[is.na(df2)] - 0 df2 X age no. age.1 no..1 age.2 no..2 age.3 no..3 age.4 no..4 1 center1 3 9 6 4 9 110 1 0 0 2 center2 5 3 9 2 0 0 0 0 0 0 3 center3 2 2 5 8 7 3 0 0 0 0 4 center4 1 12 4 7 8 3 9 1 0 0 5 center5 6 9 8 5 0 0 0 0 0 0 6 center6 4 8 0 0 0 0 0 0 0 0 7 center7 9 5 0 0 0 0 0 0 0 0 8 center8 4 7 6 3 7 1 8 1 9 2 9 center9 7 3 9 110 2 0 0 0 0 10 center10 10 5 0 0 0 0 0 0 0 0 df3 - rbind(df2, data.frame(center=1,time=1, age=1:max(df2$age), n=0)) Error in rbind(deparse.level, ...) : numbers of columns of arguments do not match I was doing the rbind on df2 after it was reshaped to long structure and before it was xtab()-ed to back wide structure df2 - reshape(df, idvar = 'center', varying = list(c(paste('age', 1:5, sep = '')), c(paste('n', 1:5, sep = ''))), v.names = c('age', 'n'), times = 1:5, direction = 'long') df2 center time age n 1.1 11 6 10 2.1 21 7 12 3.1 31 5 6 1.2 12 8 13 2.2 22 8 14 3.2 32 8 NA 1.3 13 10 9 2.3 23 10 NA 3.3 33 9 10 1.4 14 12 7 2.4 24 11 16 3.4 34 11 12 1.5 15 14 10 2.5 25 14 13 3.5 35 13 9 Then do the rbind so while the columns match up. xtabs then puts zeros back in for each empty cell with a level. -- David Natatsha From: Dennis Murphy djmu...@gmail.com To: David Winsemius dwinsem...@comcast.net Cc: r-help@r-project.org Sent: Sun, 12 September, 2010 23:16:47 Subject: Re: [R] reshape matrix entities to columns Thanks, David; I overlooked that part. Dennis On Sun, Sep 12, 2010 at 1:18 PM, David Winsemius dwinsem...@comcast.netwrote: On Sep 12, 2010, at 3:34 PM, Dennis Murphy wrote: Hi: Natasha said: I changed it so i hope it will look better now the matrix is like this: AgeNo. Age No. AgeNo. Center152 8 7 Center210 7209 4 10 column name = sequence of age-no. But what I want the data to look like is this Age 1 2 3 4 5 6 7 8 910 20 Center1 27 Center2 107 9 column name= age of ppl entries = number of ppl with that age in on center * It's a continuation of the reshape problem, but we have to change the NAs in the reshaped data frame to zeros first: df2[is.na(df2)] - 0 xtabs(n ~ center + age, data = df2) age center 5 6 7 8 9 10 11 12 13 14 1 0 10 0 13 0 9 0 7 0 10 2 0 0 12 14 0 0 16 0 0 13 3 6 0 0 0 10 0 12 0 9 0 How's that? You've done all the hard work, but the OP wanted the full range of age values from 1:max and that pretty easy to do with one further step that adds entries fo the missing age levels: df3 - rbind(df2, data.frame(center=1,time=1, age=1:max(df2$age), n=0)) xtabs(n ~ center + age, data = df3) age center 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 0 0 0 0 0 10 0 13 0 9 0 7 0 10 2 0 0 0 0 0 0 12 14 0 0 16 0 0 13 3 0 0 0 0 6 0 0 0 10 0 12 0 9 0 -- David. Dennis On Sun, Sep 12, 2010 at 9:46 AM, Dennis Murphy djmu...@gmail.com wrote: Hi: Here's a made up example using the reshape function: Input data: df
[R] R Founding
A few days ago Tal Galili posted a message about some controversies concerning the future of R. Having read the discussions, especially those following Ross Ihaka's post, I have come to the conclusion, that, as usual, the problem is money. I doubt there would be discussions about dropping R in its present form if the R-Foundation were properly funded and could hire computer scientists, programmers and statisticians. If a commercial company is able to provide big-database and multicore solutions, then so would a properly founded R-Foundation. In my opinion the main reason for the lack of funding is that the Foundation does not want to accept it from users and waits for the likes of Google to bring them a sack of money. I have already posted about this, but this seems to be the time and place to repeat it: it is very difficult to donate anything to the R-Foundation. First you have to find the appropriate link at the r-project page, then you have to fill out a form and send or fax it to the Foundation. I am not comfortable sending my details over snail-mail or fax. I would GLADLY donate 30-50$ each year just to see R develop, but there needs to be a way for me to do it in a civilized manner. If the userbase of R is over 2 million there will surely be 100,000 users who, like myself, will happily fork out 40$ a year - would that help? you can do the calculation yourselves. Set up a donation page in which I will be able to pay by credit card or PayPal and you will start getting donations from individual users. Advertise this at the startup message of the program: say something like support us at www.suppoRtR.com and the money will start coming. I am sure there would be enough to employ some foundation members full-time, pay external CSs and even protect the system in court from those who make money off of somebody else's work and do not give back to the community (you know who I am talking about). R and the Foundation have helped a lot of us to do our research and make real money. Now give us a chance to help you! Regards Jaroslaw Piskorski __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How do I create a plotable zoo object based on weekly data?
Dear readers, The problem is simple: I have weekly time series data with a maximum week number of (52,53,52,52) in (2008,2009,2010,2011) respectively. That means I have a dataset looking like this: 2008-01 value 2008-02 value . . 2011-52 value And I would like to turn that data into a plotable zoo object. Now a simple example containing 4 data points, each being on the December 28th, would be: x - zoo(rnorm(4), as.Date(2008-12-28)+0:3*365) plot(x) This works fine, but y - zoo(rnorm(4), format(as.Date(2008-12-28)+0:3*365, %Y-%U)) plot(y) gives me the following warning message: Error in plot.window(...) : need finite 'xlim' values In addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf Anyone knows how to solve this? Best regards, Michael Green __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Odp: Programming: loop versus vector oriented
Hello Petr, If you want to get results of your function for a vector of reynolds and dk you can use function outer and probably get rid of for cycle in the function. outer(c(100, 530,2410), c(10, 150,200),lambda_wall) [,1] [,2] [,3] [1,] 0.640 0.6400 0.6400 [2,] 0.1207547 0.12075472 0.12075472 [3,] 0.1081338 0.04515774 0.04515774 that gives me an array as an answer (and does more calculations than necessary, in this case 9 instead of 3). The result should be a vector. The function should work on the nth elements of the two input vectors and put the result into the nth element of the output vector. So it would work like c - a + b, only instead of '+' there are more complex calculations. Best regards, Jan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Package build and install under Windows
On 15.09.2010 17:06, Tao wrote: Thanks. It seems that both Rtools210.exe and Rtools211.exe support R 1.10.x, which one is better for R 2.10.1. You can use both, but you may want to choose the newer one. Uwe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Founding
I am a poor student, and would gladly donate 20ish bucks if it would help. R continues to make me more productive. Thanks for all of the good work! On Thu, Sep 16, 2010 at 5:49 AM, jaropis jaro...@zg.home.pl wrote: A few days ago Tal Galili posted a message about some controversies concerning the future of R. Having read the discussions, especially those following Ross Ihaka's post, I have come to the conclusion, that, as usual, the problem is money. I doubt there would be discussions about dropping R in its present form if the R-Foundation were properly funded and could hire computer scientists, programmers and statisticians. If a commercial company is able to provide big-database and multicore solutions, then so would a properly founded R-Foundation. In my opinion the main reason for the lack of funding is that the Foundation does not want to accept it from users and waits for the likes of Google to bring them a sack of money. I have already posted about this, but this seems to be the time and place to repeat it: it is very difficult to donate anything to the R-Foundation. First you have to find the appropriate link at the r-project page, then you have to fill out a form and send or fax it to the Foundation. I am not comfortable sending my details over snail-mail or fax. I would GLADLY donate 30-50$ each year just to see R develop, but there needs to be a way for me to do it in a civilized manner. If the userbase of R is over 2 million there will surely be 100,000 users who, like myself, will happily fork out 40$ a year - would that help? you can do the calculation yourselves. Set up a donation page in which I will be able to pay by credit card or PayPal and you will start getting donations from individual users. Advertise this at the startup message of the program: say something like support us at www.suppoRtR.com and the money will start coming. I am sure there would be enough to employ some foundation members full-time, pay external CSs and even protect the system in court from those who make money off of somebody else's work and do not give back to the community (you know who I am talking about). R and the Foundation have helped a lot of us to do our research and make real money. Now give us a chance to help you! Regards Jaroslaw Piskorski __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Stephen Sefick | Auburn University | | Department of Biological Sciences | | 331 Funchess Hall | | Auburn, Alabama | | 36849 | |___| | sas0...@auburn.edu | | http://www.auburn.edu/~sas0025 | |___| Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis A big computer, a complex algorithm and a long time does not equal science. -Robert Gentleman __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Founding
On 16/09/2010 6:49 AM, jaropis wrote: A few days ago Tal Galili posted a message about some controversies concerning the future of R. Having read the discussions, especially those following Ross Ihaka's post, I have come to the conclusion, that, as usual, the problem is money. I doubt there would be discussions about dropping R in its present form if the R-Foundation were properly funded and could hire computer scientists, programmers and statisticians. If a commercial company is able to provide big-database and multicore solutions, then so would a properly founded R-Foundation. In my opinion the main reason for the lack of funding is that the Foundation does not want to accept it from users and waits for the likes of Google to bring them a sack of money. I have already posted about this, but this seems to be the time and place to repeat it: it is very difficult to donate anything to the R-Foundation. First you have to find the appropriate link at the r-project page, then you have to fill out a form and send or fax it to the Foundation. I am not comfortable sending my details over snail-mail or fax. I would GLADLY donate 30-50$ each year just to see R develop, but there needs to be a way for me to do it in a civilized manner. If the userbase of R is over 2 million there will surely be 100,000 users who, like myself, will happily fork out 40$ a year - would that help? you can do the calculation yourselves. Set up a donation page in which I will be able to pay by credit card or PayPal and you will start getting donations from individual users. Advertise this at the startup message of the program: say something like support us at www.suppoRtR.com and the money will start coming. I am sure there would be enough to employ some foundation members full-time, pay external CSs and even protect the system in court from those who make money off of somebody else's work and do not give back to the community (you know who I am talking about). R and the Foundation have helped a lot of us to do our research and make real money. Now give us a chance to help you! Sure, I'd love to have $4M, but writing this to the R-help list isn't going to bring it in. You should convince the executive of the R Foundation. The co-Presidents are Ross Ihaka and Robert Gentleman. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] IP address
Hi, We have some tight controls in our systems and I am having difficulty downloading/upgrading R packages. The IT department will configure our system to let me download packages from two or three R depositories. How do I find out what the IP address of the R depositories are so that I can select a few? The IT department needs to know the IP addresses. Thanks, Jorge Nieves [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Founding
I mailed a check for an R Foundation membership almost a year ago, along with the form. In US dollars, corrected by the then-current Euro exchange rate. It has never been cashed. Christopher W. Ryan, MD SUNY Upstate Medical University Clinical Campus at Binghamton 425 Robinson Street, Binghamton, NY 13904 cryanatbinghamtondotedu Observation is a more powerful force than you could possibly reckon. The invisible, the overlooked, and the unobserved are the most in danger of reaching the end of the spectrum. They lose the last of their light. From there, anything can happen . . . [God, in Joan of Arcadia, episode entitled, The Uncertainty Principle.] stephen sefick wrote: I am a poor student, and would gladly donate 20ish bucks if it would help. R continues to make me more productive. Thanks for all of the good work! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] problems trying to reproduce structural equation model using the sem package
Hello, I've been unsuccessfully trying to reproduce a sem from Grace et al. (2010) published in Ecological Monographs: http://www.esajournals.org/doi/pdf/10.1890/09-0464.1 The model in question is presented in Figure 8, page 81. The errors that I've been getting are: 1. Using a correlation matrix: res.grace - sem(grace.model, S = grace, N = 190) Warning message: In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names = vars, : Could not compute QR decomposition of Hessian. Optimization probably did not converge. 2. Using a variances/covariances matrix: res.grace - sem(grace.model, S = grace.cov, N = 190) Error in solve.default(C) : Lapack routine dgesv: system is exactly singular In addition: Warning messages: 1: In log(det(C)) : NaNs produced 2: In sem.default(ram = ram, S = S, N = N, param.names = pars, var.names = vars, : singular Hessian: model is probably underidentified. (...) So far I've tried: 1. Fixing the variances of the latent variables 2. Allowing the exogenous indicators to covary (fixed.x parameter in sem()) 3. Manually inserting the published parameter estimates during model specification (specify.model()) to see if the starting parameters passed to nlm were the problem 4. Extensively looking for typing mistakes Anyway, there seems to be a problem either with the way I specified the model or with the model itself as it has been published. I can see that the number of degrees of freedom in the model that I've specified is 21, as in the published model. Any light you could shed on this would be greatly appreciated. The code to reproduce all steps is presented below. Thank you very much, Gustavo. ## library(sem) grace - matrix(ncol = 10, nrow = 10) variables - c(lightlog, light, dstb, species_count, masslog, soil_carbon, soil_organic, soil_low_flooding, soil_high_flooding, soil_salinity) rownames(grace) - colnames(grace) - variables diag(grace) - 1 ## Coefficients from the paper. grace.coefficients - c(0.858, 0.667, -0.251, -0.699, 0.06, 0.012, 0.552, 0.547, 0.327, 0.776, -0.404, -0.794, 0.157, 0.120, 0.439, 0.462, 0.321, -0.228, -0.686, 0.218, 0.186, 0.249, 0.290, 0.216, 0.291, 0.119, 0.132, -0.374, -0.406, -0.292, -0.096, -0.071, -0.426, -0.466, -0.138, 0.973, -0.170, -0.150, 0.249, -0.211, -0.188, 0.244, 0.959, 0.073, 0.052) grace.sds - c(1.11, 0.285, 3.29, 3.33, 1.44, 0.605, 1.23, 1.33, 1.27, 1.68) grace[lower.tri(grace, diag = F)] - grace.coefficients grace[upper.tri(grace, diag = F)] - t(grace)[upper.tri(grace, diag = F)] ## Covariances matrix grace.cov - outer(grace.sds, grace.sds) * grace ## Specifying the model grace.model - specify.model() salinity - soil_salinity, NA, 1 flooding - soil_high_flooding, NA, 1 flooding - soil_low_flooding, flooding_low_flooding, NA infertility - soil_organic, NA, -1 infertility - soil_carbon, inf_carbon, NA disturbance - dstb, NA, 1 biomass - masslog, NA, 1 light - light_effect, NA, 1 lightlog - light_effect, lightlog_light_effect, NA richness - species_count, NA, 1 salinity - richness, salinity_richness, NA salinity - light, salinity_light, NA flooding - richness, flooding_richness, NA flooding - biomass, flooding_biomass, NA infertility - richness, infertility_richness, NA disturbance - biomass, disturbance_biomass, NA disturbance - light, disturbance_light, NA biomass - light, biomass_light, NA light_effect - richness, light_effect_richness, NA salinity - flooding, salinity_flooding, NA salinity - infertility, salinity_infertility, NA salinity - disturbance, salinity_disturbance, NA flooding - infertility, flooding_infertility, NA flooding - disturbance, flooding_disturbance, NA infertility - disturbance, infertility_disturbance, NA biomass - biomass, biomass, NA masslog - masslog, masslog, NA light - lightlog, light_lightlog, NA light_effect - light_effect, NA, 0 richness - richness, richness, NA species_count - species_count, species_count, NA light - light, light, NA lightlog - lightlog, NA, 1 salinity - salinity, salinity, NA disturbance - disturbance, disturbance, NA flooding - flooding, flooding, NA infertility - infertility, infertiliy, NA soil_salinity - soil_salinity, soil_salinity, NA soil_high_flooding - soil_high_flooding, soil_high, NA soil_low_flooding - soil_low_flooding, soil_low, NA soil_organic - soil_organic, soil_organic, NA soil_carbon - soil_carbon, soil_carbon, NA dstb - dstb, dstb, NA res.grace - sem(grace.model, S = grace.cov, N = 190) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with customizing a histogram figure
Hi all, Please consider the following code: require(plotrix) l - list(rnorm(50),rnorm(50,sd=2),rnorm(50,mean=3)) multhist(l) I have two things I need help with: (1) In the output, there are empty spaces on the x-axis. How would I eliminate these spaces? I want a nice, smooth, empty-spaceless x-axis. (2) How could I add tracing lines to each histogram? I am undoubtedly using the wrong terminology. What I want to do is something like this: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=55 Note that each histogram has a tracing line that summarizes the histogram. In summary, I'd like to modify the code above to (1) get rid of the dead spaces on the x-axis, and (2) add lines that traces to each of the histograms therein (all on the same graph). I am very bad at using R graphics at this point, so I need some pretty serious hand-holding. Exact code that gets the job done would be most useful for me. Thanks very much in advance! Sincerely, --- Josh Banta, Ph.D Center for Genomics and Systems Biology New York University 100 Washington Square East New York, NY 10003 Tel: (212) 998-8465 http://plantevolutionaryecology.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Founding
I cannot speak for the R Foundation, but you know, getting a US check into money is roughly 20$ fees (at least in Germany, don't know the typical Austrian conditions). I know from organizing a conference in Germany that the only really good way was and is ordinary money transfer via BIC and IBAN numbers. Unfortunately, this system is pretty unknown in the US. Europeans can easily use money transfer to the R foundation. Credit card bookings are already rather expensive and even more expensive if you go for online processing rather than manual Fax processing (I do not know why the credit card companies prefer Fax), checks less than several hundred euros do not make sense at all. Best wishes, Uwe Ligges On 16.09.2010 15:49, Christopher W. Ryan wrote: I mailed a check for an R Foundation membership almost a year ago, along with the form. In US dollars, corrected by the then-current Euro exchange rate. It has never been cashed. Christopher W. Ryan, MD SUNY Upstate Medical University Clinical Campus at Binghamton 425 Robinson Street, Binghamton, NY 13904 cryanatbinghamtondotedu Observation is a more powerful force than you could possibly reckon. The invisible, the overlooked, and the unobserved are the most in danger of reaching the end of the spectrum. They lose the last of their light. From there, anything can happen . . . [God, in Joan of Arcadia, episode entitled, The Uncertainty Principle.] stephen sefick wrote: I am a poor student, and would gladly donate 20ish bucks if it would help. R continues to make me more productive. Thanks for all of the good work! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error in 2.10: R include directory is empty prevents package installation
I hope to revive this topic. I have the same error message when I try to install any package. Many thanks upfront! -- View this message in context: http://r.789695.n4.nabble.com/error-in-2-10-R-include-directory-is-empty-prevents-package-installation-tp907110p2542306.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Nemenyi test as a post-hoc test to Kruskal Wallis
Dear all, I've discovered the possibility to do the Nemenyi-Damico-Wolfe-Dunn test in the library(coin); oneway_test() With the given example I am unfortunately not able to reproduce the test. What does trafo and contrMat mean? I have a dataframe with 176 elements in 7 classes. It may be a problem, that my model isn't balanced? In Class1 I happen to have 4 elements, while there are 90 in class2. Thank you for your help, Anne ___ GRATIS: Spider-Man 1-3 sowie 300 weitere Videos! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with customizing a histogram figure
Josh- The link you included with your post provides the code for the example plot. Simply click on the icon in the Download Source Code section. I think you'll be able to learn a lot by playing with that source code. -tgs On Thu, Sep 16, 2010 at 9:40 AM, Josh B josh...@yahoo.com wrote: Hi all, Please consider the following code: require(plotrix) l - list(rnorm(50),rnorm(50,sd=2),rnorm(50,mean=3)) multhist(l) I have two things I need help with: (1) In the output, there are empty spaces on the x-axis. How would I eliminate these spaces? I want a nice, smooth, empty-spaceless x-axis. (2) How could I add tracing lines to each histogram? I am undoubtedly using the wrong terminology. What I want to do is something like this: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=55 Note that each histogram has a tracing line that summarizes the histogram. In summary, I'd like to modify the code above to (1) get rid of the dead spaces on the x-axis, and (2) add lines that traces to each of the histograms therein (all on the same graph). I am very bad at using R graphics at this point, so I need some pretty serious hand-holding. Exact code that gets the job done would be most useful for me. Thanks very much in advance! Sincerely, --- Josh Banta, Ph.D Center for Genomics and Systems Biology New York University 100 Washington Square East New York, NY 10003 Tel: (212) 998-8465 http://plantevolutionaryecology.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] IP address
Jorge Nieves jorge.nieves at moorecap.com writes: Hi, We have some tight controls in our systems and I am having difficulty downloading/upgrading R packages. The IT department will configure our system to let me download packages from two or three R depositories. How do I find out what the IP address of the R depositories are so that I can select a few? The IT department needs to know the IP addresses. Thanks, Jorge Nieves This works for me. Substitute your closest mirror(s). (I believe 'ping' should be available on Windows, MacOS, or Linux in a command window.) ping probability.ca PING probability.ca (128.100.73.51) 56(84) bytes of data. 64 bytes from markov.utstat.toronto.edu (128.100.73.51): icmp_seq=2 ttl=52 time=125 ms 64 bytes from markov.utstat.toronto.edu (128.100.73.51): icmp_seq=3 ttl=52 time=152 ms ping cran.r-project.org PING cran.wu-wien.ac.at (137.208.57.37) 56(84) bytes of data. 64 bytes from cran.wu-wien.ac.at (137.208.57.37): icmp_seq=1 ttl=44 time=123 ms 64 bytes from cran.wu-wien.ac.at (137.208.57.37): icmp_seq=2 ttl=44 time=122 ms ^C ping r-forge.r-project.org PING r-forge.wu-wien.ac.at (137.208.57.38) 56(84) bytes of data. 64 bytes from r-forge.wu-wien.ac.at (137.208.57.38): icmp_seq=1 ttl=44 time=123 ms 64 bytes from r-forge.wu-wien.ac.at (137.208.57.38): icmp_seq=2 ttl=44 time=122 ms ^C __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with customizing a histogram figure
Hi Josh, You can go to http://addictedtor.free.fr/graphiques/sources/source_55.R and see the source code there. Now, if you want to run the example directly from the R console, something along the lines of source('http://addictedtor.free.fr/graphiques/sources/source_55.R') might work. HTH, Jorge On Thu, Sep 16, 2010 at 9:40 AM, Josh B wrote: Hi all, Please consider the following code: require(plotrix) l - list(rnorm(50),rnorm(50,sd=2),rnorm(50,mean=3)) multhist(l) I have two things I need help with: (1) In the output, there are empty spaces on the x-axis. How would I eliminate these spaces? I want a nice, smooth, empty-spaceless x-axis. (2) How could I add tracing lines to each histogram? I am undoubtedly using the wrong terminology. What I want to do is something like this: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=55 Note that each histogram has a tracing line that summarizes the histogram. In summary, I'd like to modify the code above to (1) get rid of the dead spaces on the x-axis, and (2) add lines that traces to each of the histograms therein (all on the same graph). I am very bad at using R graphics at this point, so I need some pretty serious hand-holding. Exact code that gets the job done would be most useful for me. Thanks very much in advance! Sincerely, --- Josh Banta, Ph.D Center for Genomics and Systems Biology New York University 100 Washington Square East New York, NY 10003 Tel: (212) 998-8465 http://plantevolutionaryecology.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] FTP Download
Hi, I have problems downloading complete folders via ftp with R. Single files work fine. I tried Rcurl, but it does not work. This is my code: url = ftp://disc2.nascom.nasa.gov/data/TRMM/Gridded/Derived_Products/3B42_V6/Daily/2009/; filenames = getURL(url, ftp.use.epsv = FALSE, ftplistonly = TRUE, crlf = TRUE) filenames = paste(url, strsplit(filenames, \r*\n)[[1]], sep = ) no problems until here, I get a list with the files I want. But then, when I use: download.file(filenames, destfile=) I don't know how to tell R to use the same names for the destfiles als the filenames. If i use: con = getCurlHandle( ftp.use.epsv = FALSE) contents = sapply(filenames[1:5], getURL, curl = con) names(contents) = filenames[1:length(contents)] I get an error in curlPerform. I know, it's easy to download ftp folders with appropriate programs, but i want to manage to get it work in R greets Martin -- View this message in context: http://r.789695.n4.nabble.com/FTP-Download-tp2542359p2542359.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to combine matrix and vector
Thank you so much for your help. It was successful to combine matrix and vector by using rbind as follows. a-matrix(seq(1:10),nrow=2,ncol=5,byrow=TRUE) a [,1] [,2] [,3] [,4] [,5] [1,]12345 [2,]6789 10 b-t(c(11,12,13,14,15)) b [,1] [,2] [,3] [,4] [,5] [1,] 11 12 13 14 15 rbind(a,b) [,1] [,2] [,3] [,4] [,5] [1,]12345 [2,]6789 10 [3,] 11 12 13 14 15 - -- Wonsang You Special Lab Non-Invasive Brain Imaging Leibniz Institute for Neurobiology http://www.ifn-magdeburg.de -- View this message in context: http://r.789695.n4.nabble.com/How-to-combine-matrix-and-vector-tp2541797p2542362.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] FTP Download
Try this: mapply(download.file, filenames, basename(filenames)) On Thu, Sep 16, 2010 at 11:56 AM, Martin mar...@bier-mail.de wrote: Hi, I have problems downloading complete folders via ftp with R. Single files work fine. I tried Rcurl, but it does not work. This is my code: url = ftp://disc2.nascom.nasa.gov/data/TRMM/Gridded/Derived_Products/3B42_V6/Daily/2009/ filenames = getURL(url, ftp.use.epsv = FALSE, ftplistonly = TRUE, crlf = TRUE) filenames = paste(url, strsplit(filenames, \r*\n)[[1]], sep = ) no problems until here, I get a list with the files I want. But then, when I use: download.file(filenames, destfile=) I don't know how to tell R to use the same names for the destfiles als the filenames. If i use: con = getCurlHandle( ftp.use.epsv = FALSE) contents = sapply(filenames[1:5], getURL, curl = con) names(contents) = filenames[1:length(contents)] I get an error in curlPerform. I know, it's easy to download ftp folders with appropriate programs, but i want to manage to get it work in R greets Martin -- View this message in context: http://r.789695.n4.nabble.com/FTP-Download-tp2542359p2542359.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] FTP Download
works, thanks a lot! -- View this message in context: http://r.789695.n4.nabble.com/FTP-Download-tp2542359p2542380.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Nemenyi test as a post-hoc test to Kruskal Wallis
On 2010-09-16 8:31, Anne-Christine Mupepele wrote: Dear all, I've discovered the possibility to do the Nemenyi-Damico-Wolfe-Dunn test in the library(coin); oneway_test() With the given example I am unfortunately not able to reproduce the test. What does trafo and contrMat mean? I have a dataframe with 176 elements in 7 classes. It may be a problem, that my model isn't balanced? In Class1 I happen to have 4 elements, while there are 90 in class2. Thank you for your help, Anne I don't quite understand your question; do you mean that you can't run the example in pkg:coin? Works fine for me. As to trafo and contrMat, try this: ?trafo ## in pkg:coin ?contrMat ## in pkg:multcomp -Peter Ehlers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] question about changing color scale in plot.fmri
Hello everybody, I am using plot.fmri function to plot some stats on a functional image, but for some reasons the only collor I get on the image is gray. Here is the function I am using:plot.fmridata(t1,type=slice,col.o=heat.colors(256)) It is the first time I am using this package, so I might be doing something completely wrong. Any advice would be great ! Dana [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odd graphics output problem
Hi all, I'm having trouble saving graphics output from within a loop, and I can't figure out a solution. I'd like to produce and save lots of individual plots for inspection, so I set up the following script: library( lattice ) wd = ~/Documents/PPM/ ppm = read.table( paste( wd, ppm_summary.txt, sep = ), sep = \t, header = TRUE ) ppm$Trial = as.factor( ppm$Trial ) for ( ID in levels( ppm$Patient ) ){ patient_data = ppm[ ppm$Patient == ID, ] dir.create( paste( wd, ID, sep = ) ) for ( trial in ( levels( ppm[ ppm$Patient == ID, ]$Trial ) ) ){ trial_data = patient_data[ patient_data$Trial == trial, ] trial_str = sprintf( %03d, as.integer( trial ) ) path = paste( wd, ID, /, trial_str, .png, sep = ) cat( path, \n ) png( path ) xyplot( PupilArea ~ Offset, data = trial_data ) dev.off() } } Everything runs, the cat() command displays output to the console, but no files are created. However, if I interrupt the script with control-C and execute the png(), xyplot(), and dev.off() commands manually, the appropriate plot image files are written based on the correct data. That is, everything from data subsetting to plotting works fine except when the loop is actually running. I've tried swapping png() for bitmap(), Sys.sleep()ing R at various stages, and some other things with no success. What am I missing? Thanks in advance, Dave -- Post-doctoral Fellow Neurology Department University of Iowa Hospitals and Clinics davideugenewar...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Can I save my console contents automatically?
Hello David and Greg, Thank you for your suggestions. These really help me. I'm curious about txtStart function of TeachingDemos library. It looks exactly what I need. So I installed TeachingDemos library and tried following. - library(TeachingDemos) setwd(/Users/NOBU/Documents/R_data/) txtStart(logtest.txt, commands = TRUE, results = TRUE, append = FALSE) #Top of commands date() #End of commands txtStop() --- Then I got following outputs on my console window, but I only got a null file named logtest.txt. I tried several times by trial and error, but I couldn't find the solution to log outputs on the logtest.txt. --- library(TeachingDemos) setwd(/Users/NOBU/Documents/R_data/) txtStart(logtest.txt, commands = TRUE, results = TRUE, append = FALSE) Output being copied to text file, use txtStop to end txt txt #Top of commands txt date() [1] Thu Sep 16 07:16:29 2010 txt #End of commands txt txt txtStop() Thank you for your help! Nobu 2010/9/14 Nobuaki Michihata gha10...@gmail.com: Dear All, I found a following solution from http://r.789695.n4.nabble.com/;. However this command can save only the result. Is there any good solution to save both commands themselves and the results. Thank you for your help. sink(Filename_here.log, type=c(output,message), split=TRUE) # Put commands here # However this method save only the results. sink() Nobu Message: 33 Date: Fri, 10 Sep 2010 07:07:37 -0700 From: Nobuaki Michihata gha10...@gmail.com To: r-help@r-project.org, r-help@r-project.org Subject: [R] Can I save my console contents automatically? Message-ID: aanlktimez-igqk6gzeyqerzatg7m+chjbgjmagmel...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Dear All, I'm using R for Mac OS X Cocoa GUI R version 2.11.1. I can save contents of my console window by using command + s, but I would like to do same thing using R commands. My question is can I save the contents automatically by using R editor with some R commands. Thank you. Nobu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] question about converting a matrix to a dataframe
First I have a matrix called stocks1: class(stocks1) [1] matrix Here are the first 5 rows of the last 4 columns: stocks1[1:5,2:5] [,1] [,2] [,3] [,4] [1,] 80.73 31.95 25.4 25.69 [2,] 83.66 31.95 27.12 25.2 [3,] 83.27 32.93 28.74 26.29 [4,] 83.9 34.07 29.77 26.6 [5,] 82.74 35.18 30.24 27.41 Now, why can't I convert this into a dataframe? It automatically converts the columns into 1 long row?? newdata.df-data.frame(stocks1[1:5,2:5]) newdata.df X1.1 X1.2 X1.3 X1.4 X1.5 X1.6 X1.7 X1.8 X1.9 X1.10 X1.11 X1.12 1 80.73 83.66 83.27 83.9 82.74 31.95 31.95 32.93 34.07 35.18 25.4 27.12 X1.13 X1.14 X1.15 X1.16 X1.17 X1.18 X1.19 X1.20 1 28.74 29.77 30.24 25.69 25.2 26.29 26.6 27.41 Regards, Leigh [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Odd graphics output problem
See the FAQ 7.22 Why do lattice/trellis graphics not work? The most likely reason is that you forgot to tell R to display the graph. Lattice functions such as xyplot() create a graph object, but do not display it (the same is true of *ggplot2*http://cran.r-project.org/package=ggplot2graphics, and Trellis graphics in S-Plus). The print() method for the graph object produces the actual display. When you use these functions interactively at the command line, the result is automatically printed, but in source() or inside your own functions you will need an explicit print() statement. On Thu, Sep 16, 2010 at 10:34 AM, David Warren davideugenewar...@gmail.comwrote: Hi all, I'm having trouble saving graphics output from within a loop, and I can't figure out a solution. I'd like to produce and save lots of individual plots for inspection, so I set up the following script: [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Instal R on OS X Server
Hi, I was trying to install R in my home directory on a Mac OS X Server running Darwin. How do I go about installing it? How can I install from the binary provided (R-2.11.1.pkg) from command line? Is there any other information that I can provide? thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question about converting a matrix to a dataframe
Use as.data.frame instead. It does what you want it to do. newdata.df-as.data.frame(stocks1[1:5,2:5]) Cheers, Michael -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Leigh E. Lommen Sent: 16. september 2010 17:18 To: r-help@r-project.org Subject: [R] question about converting a matrix to a dataframe First I have a matrix called stocks1: class(stocks1) [1] matrix Here are the first 5 rows of the last 4 columns: stocks1[1:5,2:5] [,1] [,2] [,3] [,4] [1,] 80.73 31.95 25.4 25.69 [2,] 83.66 31.95 27.12 25.2 [3,] 83.27 32.93 28.74 26.29 [4,] 83.9 34.07 29.77 26.6 [5,] 82.74 35.18 30.24 27.41 Now, why can't I convert this into a dataframe? It automatically converts the columns into 1 long row?? newdata.df-data.frame(stocks1[1:5,2:5]) newdata.df X1.1 X1.2 X1.3 X1.4 X1.5 X1.6 X1.7 X1.8 X1.9 X1.10 X1.11 X1.12 1 80.73 83.66 83.27 83.9 82.74 31.95 31.95 32.93 34.07 35.18 25.4 27.12 X1.13 X1.14 X1.15 X1.16 X1.17 X1.18 X1.19 X1.20 1 28.74 29.77 30.24 25.69 25.2 26.29 26.6 27.41 Regards, Leigh [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question about converting a matrix to a dataframe
Hi, Well, it works for me: x - matrix(1:20, nrow=5, ncol=4) data.frame(x[1:5,2:4]) X1 X2 X3 1 6 11 16 2 7 12 17 3 8 13 18 4 9 14 19 5 10 15 20 Maybe with as.data.frame(), or set the drop argument to FALSE: data.frame(x[1:5,2:4,drop=FALSE]) Not sure why it doesn't work for you. Check the output of str(stocks1) HTH, Ivan Le 9/16/2010 17:18, Leigh E. Lommen a écrit : First I have a matrix called stocks1: class(stocks1) [1] matrix Here are the first 5 rows of the last 4 columns: stocks1[1:5,2:5] [,1] [,2] [,3] [,4] [1,] 80.73 31.95 25.4 25.69 [2,] 83.66 31.95 27.12 25.2 [3,] 83.27 32.93 28.74 26.29 [4,] 83.9 34.07 29.77 26.6 [5,] 82.74 35.18 30.24 27.41 Now, why can't I convert this into a dataframe? It automatically converts the columns into 1 long row?? newdata.df-data.frame(stocks1[1:5,2:5]) newdata.df X1.1 X1.2 X1.3 X1.4 X1.5 X1.6 X1.7 X1.8 X1.9 X1.10 X1.11 X1.12 1 80.73 83.66 83.27 83.9 82.74 31.95 31.95 32.93 34.07 35.18 25.4 27.12 X1.13 X1.14 X1.15 X1.16 X1.17 X1.18 X1.19 X1.20 1 28.74 29.77 30.24 25.69 25.2 26.29 26.6 27.41 Regards, Leigh [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Odd graphics output problem
Got it, thanks! On Thu, Sep 16, 2010 at 10:22 AM, RICHARD M. HEIBERGER r...@temple.eduwrote: See the FAQ 7.22 Why do lattice/trellis graphics not work? The most likely reason is that you forgot to tell R to display the graph. Lattice functions such as xyplot() create a graph object, but do not display it (the same is true of *ggplot2*http://cran.r-project.org/package=ggplot2graphics, and Trellis graphics in S-Plus). The print() method for the graph object produces the actual display. When you use these functions interactively at the command line, the result is automatically printed, but in source() or inside your own functions you will need an explicit print() statement. On Thu, Sep 16, 2010 at 10:34 AM, David Warren davideugenewar...@gmail.com wrote: Hi all, I'm having trouble saving graphics output from within a loop, and I can't figure out a solution. I'd like to produce and save lots of individual plots for inspection, so I set up the following script: -- Post-doctoral Fellow Neurology Department University of Iowa Hospitals and Clinics davideugenewar...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Local Variable
Dear All, I have a function: gen - function(m){for(i in 1:m){assign(paste(x,i, sep=), (7*get(paste(x,i-1,sep=)))%%13); print(get(paste(x, i, sep=)))}} my question is, I do gen(20), then the function prints out 20 values, however when I do objects(), I can't see x1,x2,x3,,x20 as objects. Why? Are they local variables? R doesn't show local variables as objects? Thanks, Harun -- View this message in context: http://r.789695.n4.nabble.com/Local-Variable-tp2542441p2542441.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] get top n rows group by a column from a dataframe
Hi, is there an R function like sql's TOP key word? I have a dataframe that has 3 columns: company, person, salary How do I get top 5 highest paid person for each company, and if I have fewer than 5 people for a company, just return all of them? Thanks, Richard [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ANOVA - more sophisticated contrasts
dear list, i am using a multifactorial design with two treatments (factor A: drugs, three levels; factor B: theraphy, two levels) and a time factor (three levels, different timepoint). hypothetically, i measured the same subjects for all treatements and timepoints, so its a repeated measurement design. now i ran an anova in R and also some Tukey post-hoc tests using glht. but what i am actually interested in is to perform conditional contrasts, f.i. A1 for the 1st timepoint vs. A1 for the 2nd time (to put it in words: an evaluation of whether this particular type of drug exerts an effect over time). so far, i couldnt find any function doing this. i also queried the r help list archive but without success. any help on that would be appreciated. kind regards j [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Local Variable
Leaving aside the question of whether this is a good thing to do, you can accomplish what you want by changing the pos argument, which by default does not save the variable to the global environment. Reading the details section of ?assign and also ?environment may help. I'd offer an example, but your function doesn't work as-is because I don't have any idea what the get statements are supposed to be getting. Sarah On Thu, Sep 16, 2010 at 11:36 AM, harunpirim harunpi...@gmail.com wrote: Dear All, I have a function: gen - function(m){for(i in 1:m){assign(paste(x,i, sep=), (7*get(paste(x,i-1,sep=)))%%13); print(get(paste(x, i, sep=)))}} my question is, I do gen(20), then the function prints out 20 values, however when I do objects(), I can't see x1,x2,x3,,x20 as objects. Why? Are they local variables? R doesn't show local variables as objects? Thanks, Harun -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] using variable from for loop in naming new variables
Simple one here ... but can't get it to work ... for (i in 1:4){ paste(stuff,[i]),sep=) - 3 + i } ls() rm(list=ls()) I just want it to create 4 new variables called stuff1, stuff2, stuff3, stuff4 with the corresponding assignments. I realise that there are more elegant functions but this is just a model of a bigger situation. Thanks Jim === Dr. Jim Maas University of East Anglia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Local Variable
Sarah Goslee wrote: Leaving aside the question of whether this is a good thing to do, Let's not leave that aside. Surely there is a much more straight-forward way to accomplish what you want. Why not store all the X's in a vector, and then you can avoid this for/assign/get hack. you can accomplish what you want by changing the pos argument, which by default does not save the variable to the global environment. Reading the details section of ?assign and also ?environment may help. I'd offer an example, but your function doesn't work as-is because I don't have any idea what the get statements are supposed to be getting. Sarah On Thu, Sep 16, 2010 at 11:36 AM, harunpirim harunpi...@gmail.com wrote: Dear All, I have a function: gen - function(m){for(i in 1:m){assign(paste(x,i, sep=), (7*get(paste(x,i-1,sep=)))%%13); print(get(paste(x, i, sep=)))}} my question is, I do gen(20), then the function prints out 20 values, however when I do objects(), I can't see x1,x2,x3,,x20 as objects. Why? Are they local variables? R doesn't show local variables as objects? Thanks, Harun __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Founding
On Thu, Sep 16, 2010 at 3:49 AM, jaropis jaro...@zg.home.pl wrote: A few days ago Tal Galili posted a message about some controversies concerning the future of R. Having read the discussions, especially those following Ross Ihaka's post, I have come to the conclusion, that, as usual, the problem is money. I doubt there would be discussions about dropping R in its present form if the R-Foundation were properly funded and could hire computer scientists, programmers and statisticians. If a commercial company is able to provide big-database and multicore solutions, then so would a properly founded R-Foundation. In my opinion the main reason for the lack of funding is that the Foundation does not want to accept it from users and waits for the likes of Google to bring them a sack of money. I have already posted about this, but this seems to be the time and place to repeat it: it is very difficult to donate anything to the R-Foundation. First you have to find the appropriate link at the r-project page, then you have to fill out a form and send or fax it to the Foundation. I am not comfortable sending my details over snail-mail or fax. I would GLADLY donate 30-50$ each year just to see R develop, but there needs to be a way for me to do it in a civilized manner. If the userbase of R is over 2 million there will surely be 100,000 users who, like myself, will happily fork out 40$ a year - would that help? you can do the calculation yourselves. Set up a donation page in which I will be able to pay by credit card or PayPal and you will start getting donations from individual users. Advertise this at the startup message of the program: say something like support us at www.suppoRtR.com and the money will start This is a nice idea, and I agree that the current donation system is cumbersome (even for direct bank transfers, a letter must be mailed requesting the relevant information). However, it takes time and effort to create a website and provide convenient ways to donate. Further, since this would be money and going to the R Foundation, members from that would have to be involved---these are people whose time is already heavily taxed (no pun intended). Generally, before people will put effort into something, they want some degree of confidence that it will be worth it, *If* the userbase of R is over 2 million *there will surely be* 100,000 [emphasis mine] may not provide it. I also suspect there would be some logistical issues that could be rather dicey (e.g., Who do you pay? How do you pay them? How much do you pay? and all the hurt feelings that can ensue if one or more individuals feel slighted in some way). I imagine the process would go something like: 1) Get a rough plan of how this all might work 2) Drum up users and support 3) Create a proposal detailing current estimates of support and providing several options for receiving it 4) Take said proposal to powers that be at R Foundation 5) Repeat 2 3 until everyone who needs to be convinced, is convinced. 6) Enact plan 7) Follow up 8) Duncan (and the rest of R Core / R Foundation) get their $4M For the record, you could count me in for #2. Josh coming. I am sure there would be enough to employ some foundation members full-time, pay external CSs and even protect the system in court from those who make money off of somebody else's work and do not give back to the community (you know who I am talking about). R and the Foundation have helped a lot of us to do our research and make real money. Now give us a chance to help you! Regards Jaroslaw Piskorski __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] More accurate ODE solver?
Dear All, I was using rk4 and lsoda to solve a ODE system. However, both of them gave bad accurate solutions, especially compared with Matlab solver ODE45. For example, ODE45 gave solutions that can go to a stable level (about 1.6) when time goes to infinity, however, the solutions from lsoda are decreasing to very very small (about 1e-130) numbers. Does R have more accurate ODE solvers as ODE45 in Matlab? Thank you, Jane __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] aggregate, by, *apply
Thanks everyone for the responses. They were all helpful! On Sep 15, 2010, at 5:22 PM, Abhijit Dasgupta, PhD wrote: I would approach this slightly differently. I would make func a function of x and y. func - function(x,y){ m - median(x) return(m 2 m y) } Now generate tmp just as you have. then: require(plyr) res - daply(tmp, .(z), summarise, res=func(x,y)) I believe this does the trick Abhijit On 9/15/10 5:45 PM, Mark Ebbert wrote: Dear R gurus, I regularly come across a situation where I would like to apply a function to a subset of data in a dataframe, but I have not found an R function to facilitate exactly what I need. More specifically, I'd like my function to have a context of where the data it's analyzing came from. Here is an example: ### BEGIN ### func-function(x){ m-median(x$x) if(m 2 m x$y){ return(T) } return(F) } tmp-data.frame(x=1:10,y=c(rep(34,3),rep(35,3),rep(34,4)),z=c(rep(a,3),rep(b,3),rep(c,4))) res-aggregate(tmp,list(z),func) ### END ### The values in the example are trivial, but the problem is that only one column is passed to my function at a time, so I can't determine how 'm' relates to 'x$y'. Any tips/guidance is appreciated. Mark T. W. Ebbert __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Abhijit Dasgupta, PhD Director and Principal Statistician ARAASTAT Ph: 301.385.3067 E: adasgu...@araastat.com W: http://www.araastat.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] get top n rows group by a column from a dataframe
tmp - data.frame(matrix(rnorm(30), 10, 3, dimnames=list(letters[1:10], c(company, person, salary tmp company person salary a -1.04590176 -0.7841855 1.07150503 b -1.06643101 0.6545647 0.43920454 c 0.72894531 -1.3812867 0.41313659 d -0.39265263 -0.3871271 0.69404325 e 0.54028124 0.7124772 0.66630904 f -1.46931714 -0.3823353 0.03069797 g -0.33283666 -0.6351862 0.37920017 h -0.79977129 0.2605315 0.92373900 i 0.80614119 0.3727227 -1.16560563 j 0.03165012 0.4690400 -0.81966285 order(tmp$person, decreasing=TRUE)[1:min(5, length(tmp$person))] [1] 5 2 10 9 8 tmp[order(tmp$person, decreasing=TRUE)[1:min(5, length(tmp$person))],] companyperson salary e 0.54028124 0.7124772 0.6663090 b -1.06643101 0.6545647 0.4392045 j 0.03165012 0.4690400 -0.8196628 i 0.80614119 0.3727227 -1.1656056 h -0.79977129 0.2605315 0.9237390 You can easily write a function for that. top - function(DF, varname, howmany) {} On Thu, Sep 16, 2010 at 11:39 AM, Tan, Richard r...@panagora.com wrote: Hi, is there an R function like sql's TOP key word? I have a dataframe that has 3 columns: company, person, salary How do I get top 5 highest paid person for each company, and if I have fewer than 5 people for a company, just return all of them? Thanks, Richard [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with graphic margin
Hi everyone. I would like to make a graphic with 2 subplots (lets say A and B). For instance, I use : par(mfcol = c(2,1)); The 2 subplots use the same X axis. So I provide no tics labels and no xlab for the top plot. I would like the second plot to be right bellow the first one (small margin). So my question is how I can keep a small gap between the 2 plots while having enough space under the second plot to insert xtics-labels + xlab. Hope I have been clear enough! With regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/Help-with-graphic-margin-tp2542469p2542469.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] KMedians clustering in R
Hi R, Is there a package in R to perform KMedian clustering? Thanks. Shubha This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] More accurate ODE solver?
Dear All, I was using rk4 and lsoda to solve a ODE system. However, both of them gave bad accurate solutions, especially compared with Matlab solver ODE45. For example, ODE45 gave solutions that can go to a stable level (about 1.6) when time goes to infinity, however, the solutions from lsoda are decreasing to very very small (about 1e-130) numbers. Does R have more accurate ODE solvers as ODE45 in Matlab? Thank you, Jane __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Instal R on OS X Server
On Sep 16, 2010, at 11:25 AM, James Nead wrote: Hi, I was trying to install R in my home directory on a Mac OS X Server running Darwin. How do I go about installing it? How can I install from the binary provided (R-2.11.1.pkg) from command line? It's not really an rhelp question, is it? More of a Google question in my opinion. I cannot say for sure that MacOSX Server is the same as regular MacOSX but if it isn't, then there are not too many people on rhelp who will know. The first hit deals with a somewhat more complex operation and you probably only need the lines that deal with you local box: http://codesnippets.joyent.com/posts/show/322 See if this answer adds anything useful, since it appears to be regarding OSX-Server: http://hints.macworld.com/article.php?story=20030614230204397 Is there any other information that I can provide? I suggest you read the Posting Guide. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ANOVA - more sophisticated contrasts
Jake, You can easily use glht for that. See ?MMC in the HH package for examples. You may need install.packages(HH) ## if you don't already have HH. Specifically, look at the examples showing the use of focus.lmat On Thu, Sep 16, 2010 at 11:43 AM, Jake Kami jakejk...@gmail.com wrote: dear list, i am using a multifactorial design with two treatments (factor A: drugs, three levels; factor B: theraphy, two levels) and a time factor (three levels, different timepoint). hypothetically, i measured the same subjects for all treatements and timepoints, so its a repeated measurement design. now i ran an anova in R and also some Tukey post-hoc tests using glht. but what i am actually interested in is to perform conditional contrasts, f.i. A1 for the 1st timepoint vs. A1 for the 2nd time (to put it in words: an evaluation of whether this particular type of drug exerts an effect over time). so far, i couldnt find any function doing this. i also queried the r help list archive but without success. any help on that would be appreciated. kind regards j [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] KMedians clustering in R
pam/clara in package cluster are probably as close to it as you can be. There is no unique definition of a multivariate median and therefore there is no unique definition of k-medians, but pam/clara is one possible version of it. (Of course if you think of k-medians as defined in a specific paper, it may still be something slightly different.) Christian On Thu, 16 Sep 2010, Shubha Vishwanath Karanth wrote: Hi R, Is there a package in R to perform KMedian clustering? Thanks. Shubha This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using variable from for loop in naming new variables
Hi! assign() should do the job. But using a list, and filling each element iteratively (with a for loop or with *apply() ) might be better, up to you. Btw, why do you remove your objects? HTH, Ivan Le 9/16/2010 17:44, Maas James Dr (MED) a écrit : Simple one here ... but can't get it to work ... for (i in 1:4){ paste(stuff,[i]),sep=)- 3 + i } ls() rm(list=ls()) I just want it to create 4 new variables called stuff1, stuff2, stuff3, stuff4 with the corresponding assignments. I realise that there are more elegant functions but this is just a model of a bigger situation. Thanks Jim === Dr. Jim Maas University of East Anglia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with cat() == A related question
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng, C Sent: Thursday, September 16, 2010 5:39 AM To: r-help@r-project.org Subject: Re: [R] Problem with cat() == A related question The question is wehter cat() can print out a matrix as it is. For example, Let's assume that we have matrices A, B, D(= A+B), if it is possible that cat(\n, A, +,B,=, D, some control arguments , \n) prints out matrix A + matrix B = matrix D where matrices A, B, D (= A+B) should be in the form of their actual matrices. cat() will not do that. I use a function, SideBySide(x,y) to print two objects next to each other. It does it by capturing the printed output of each as character vectors, then cbinding them together into a 2 column character matrix which the standard print routine will print nicely. Typical usage is A-matrix(1:12,nrow=3) B-matrix(100,nrow=3,ncol=4) sideBySide(A,A+B) AA + B [,1] [,2] [,3] [,4] [,1] [,2] [,3] [,4] [1,]147 10 [1,] 101 104 107 110 [2,]258 11 [2,] 102 105 108 111 [3,]369 12 [3,] 103 106 109 112 Perhaps you can adapt it to your needs by letting it take more than two arguments and adding some separators. sideBySide - function (a, b, argNames) { oldWidth - options(width = getOption(width)/2 - 4) on.exit(options(oldWidth)) if (missing(argNames)) { argNames - c(deparse(substitute(a))[1], deparse(substitute(b))[1]) } pa - capture.output(print(a)) pb - capture.output(print(b)) nlines - max(length(pa), length(pb)) length(pa) - nlines length(pb) - nlines pb[is.na(pb)] - pa[is.na(pa)] - retval - cbind(pa, pb, deparse.level = 0) dimnames(retval) - list(rep(, nrow(retval)), argNames) noquote(retval) } Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-cat-tp2538811p2542098.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using variable from for loop in naming new variables
On Sep 16, 2010, at 11:44 AM, Maas James Dr (MED) wrote: Simple one here ... but can't get it to work ... for (i in 1:4){ paste(stuff,[i]),sep=) - 3 + i } ls() rm(list=ls()) for (i in 1:4){ +paste(stuff,[i]),sep=) - 3 + i Error: unexpected '[' in: for (i in 1:4){ paste(stuff,[ So the first error pointed you to a problem } Error: unexpected '}' in } Fixing that error points you to another: for (i in 1:4){ +paste(stuff, i),sep=) - 3 + i Error: unexpected ',' in: for (i in 1:4){ paste(stuff, i), And when the syntax gets unsnarled you find that you are trying not using the correct semantics for assignment: for (i in 1:4){ +paste(stuff,i,sep=) - 3 + i + } Error in paste(stuff, i, sep = ) - 3 + i : target of assignment expands to non-language object You are currently attempting to assign a numeric value to a character vector. (That is, once stop throwing an error because putting the square brackets around i ... and you lose the right- paren before the sep argument.) Try looking at the help page for assign (and working more basic examples): ?assign. I just want it to create 4 new variables called stuff1, stuff2, stuff3, stuff4 with the corresponding assignments. I realise that there are more elegant functions but this is just a model of a bigger situation. Thanks Jim === Dr. Jim Maas University of East Anglia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Survival Analysis Daily Time-Varying Covariate but Event Time Unknown
Help! I am unsure if I can analyze data from the following experiment. Fish were placed in a tank at (t=0) Measurements of Carbon Dioxide were taken each day for 120 days (t=0,...120) A few fish were then randomly pulled out of the tank at different days, killed and examined for the presence of a disease T= time of examination in days from start (i.e. 85th day), E = 0/1 for nonevent/event My problem has been linking all the Carbon Dioxide measurements up to the day of examination and trying to create a survival object. I have considered interval censoring with right censored for fish without disease and then left censored for fish with the disease, but i really cannot structure the data or intuitively figure out how to incorporate the daily Carbon Dioxide values up until day of examination. The end goal to to predict an event based on Carbon Dioxide levels Thank you for help or redirection. -- View this message in context: http://r.789695.n4.nabble.com/Survival-Analysis-Daily-Time-Varying-Covariate-but-Event-Time-Unknown-tp2542533p2542533.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reshape matrix entities to columns
Hi: Could you please devise a reproducible example that illustrates the problem? As far as points (1) and (2) are concerned, if you lack row or column names, they can always be defined and added to the object. Dennis On Thu, Sep 16, 2010 at 4:26 AM, Natasha Asar natasha.asa...@yahoo.comwrote: Thanks for the help I have tried the one that uses xtab() and the answer is correct because when I was using the rbind() still getting the same error message Now I have some more questions I am trying to be able to adapt this for any kind of data of the same structure so now im thinking about few points 1. what is there is no row name : (center1,center2) assuming the rows automatically present that 2. what if I dont have the column names: considering that there is no rows names as well: assuming odd columns are age and even ones are numbers of ppl. 3. And Time? How to automatically match this I have tried with ncol() but because now I have name of the rows there its giving me a number like 5.5 which is not helpful thanks again -- *From:* David Winsemius dwinsem...@comcast.net *To:* Natasha Asar natasha.asa...@yahoo.com *Cc:* Dennis Murphy djmu...@gmail.com; r-help@r-project.org *Sent:* Tue, 14 September, 2010 2:24:19 *Subject:* Re: [R] reshape matrix entities to columns On Sep 13, 2010, at 8:51 PM, Natasha Asar wrote: I am trying this as you mentioned and getting an error which i cant fix do you know where is the problem? df2[is.na(df2)] - 0 df2 X age no. age.1 no..1 age.2 no..2 age.3 no..3 age.4 no..4 1 center1 3 9 6 4 9 110 1 0 0 2 center2 5 3 9 2 0 0 0 0 0 0 3 center3 2 2 5 8 7 3 0 0 0 0 4 center4 1 12 4 7 8 3 9 1 0 0 5 center5 6 9 8 5 0 0 0 0 0 0 6 center6 4 8 0 0 0 0 0 0 0 0 7 center7 9 5 0 0 0 0 0 0 0 0 8 center8 4 7 6 3 7 1 8 1 9 2 9 center9 7 3 9 110 2 0 0 0 0 10 center10 10 5 0 0 0 0 0 0 0 0 df3 - rbind(df2, data.frame(center=1,time=1, age=1:max(df2$age), n=0)) Error in rbind(deparse.level, ...) : numbers of columns of arguments do not match I was doing the rbind on df2 after it was reshaped to long structure and before it was xtab()-ed to back wide structure df2 - reshape(df, idvar = 'center', varying = list(c(paste('age', 1:5, sep = '')), c(paste('n', 1:5, sep = ''))), v.names = c('age', 'n'), times = 1:5, direction = 'long') df2 center time age n 1.1 11 6 10 2.1 21 7 12 3.1 31 5 6 1.2 12 8 13 2.2 22 8 14 3.2 32 8 NA 1.3 13 10 9 2.3 23 10 NA 3.3 33 9 10 1.4 14 12 7 2.4 24 11 16 3.4 34 11 12 1.5 15 14 10 2.5 25 14 13 3.5 35 13 9 Then do the rbind so while the columns match up. xtabs then puts zeros back in for each empty cell with a level. -- David Natatsha -- *From:* Dennis Murphy djmu...@gmail.com *To:* David Winsemius dwinsem...@comcast.net *Cc:* r-help@r-project.org *Sent:* Sun, 12 September, 2010 23:16:47 *Subject:* Re: [R] reshape matrix entities to columns Thanks, David; I overlooked that part. Dennis On Sun, Sep 12, 2010 at 1:18 PM, David Winsemius dwinsem...@comcast.net wrote: On Sep 12, 2010, at 3:34 PM, Dennis Murphy wrote: Hi: Natasha said: I changed it so i hope it will look better now the matrix is like this: AgeNo. Age No. AgeNo. Center152 8 7 Center210 7209 4 10 column name = sequence of age-no. But what I want the data to look like is this Age 1 2 3 4 5 6 7 8 910 20 Center1 27 Center2 107 9 column name= age of ppl entries = number of ppl with that age in on center * It's a continuation of the reshape problem, but we have to change the NAs in the reshaped data frame to zeros first: df2[is.na(df2)] - 0 xtabs(n ~ center + age, data = df2) age center 5 6 7 8 9 10 11 12 13 14 1 0 10 0 13 0 9 0 7 0 10 2 0 0 12 14 0 0 16 0 0 13 3 6 0 0 0 10 0 12 0 9 0 How's that? You've done all the hard work, but the OP wanted the full range of age values from 1:max and that pretty easy to do with one further step that adds entries fo the missing age levels: df3 - rbind(df2,
[R] RODBC Access/Excel driver location for 64 bit Win7
Apologies, but after a fair amount of digging, I still only have a foggy understanding of the cause of this problem, due to my own ignorance. I hope to use RODBC package to connect to an Access DB when running 64 bit Win7 (R version 2.11.1, 64 bit). I have successfully done this before on a winXP machine. Currently I am unable to establish a connection using odbcConnect() (I am able to establish a MySQL connection just fine), which I suspect may be a result of the driver setup location varying for 64 bit Win7 and 32 bit Win7. That is, to create a ODBC connection when running 64 bit Win7 the default executable file appears to NOT be the correct c:\windows\sysWOW64\odbcad32.exe but rather is c:\windows\system32\odbcad32.exe. odbcConnect returns a Microsoft error of specified DSN contains an architecture mismatch between the Driver and Application I am guessing wildly here, but I wonder if odbcConnect is looking in the wrong directory for my MS Access driver, as Microsoft hasn't even managed to make the default location one is directed to to manage ODBC connections via the control panel to be correct? I also suspect that if I installed a 32 bit version of R, odbcConnect might correctly find the location of my MS Access driver. Clearly I'm a pretty confused about this, but I hope one of you old pros on RODBC that is knowledgeable of the peculiarities of 64 bit Win 7 can give me some guidance. Thanks in advance - Peter [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] a reliable way to check the latest version of R on CRAN?
Hi all, We know old.packages() can check for updates of add-on packages, but is there a way to check updates of R itself? go to R homepage is a way, of course, but I hope this can be done by R. I'm not sure about the reliable place to check; here is a simple example to check from one of the CRAN webpages (kind of nasty approach...): x = readLines(http://cran.r-project.org/sources.html;) # the version number is in the next line of 'The latest release' rls = x[grep(latest release, x) + 1L] newver = gsub((.*R-|\\.tar\\.gz.*), , rls) oldver = paste(getRversion(), collapse = .) # new version available? compareVersion(newver, oldver) == 1L Thanks! Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problems creating a Panel
Hello, I am trying to create a panel with the attached data frame. using the following code: PanelRio = DataRiopaila[which(duplicated(DataRiopaila$SEC_STE)==T),] PanelRio=plm.data(PanelRio,index=c(SEC_STE,FechaSiembra)) series Pluv3Meses,PluvMes4al10,Pluv2UltimosMeses,Rad3Meses,RadMes4al10,Rad2UltimosMeses are NA and have been removed It tells me it removes couple of series because they are NA, and I don't understand why because if I do: PanelRio = DataRiopaila[which(duplicated(DataRiopaila$SEC_STE)==T),] length(which(is.na(PanelRio[,Pluv3Meses])==T)) [1] 474 nrow(PanelRio) [1] 4129 which means there are still around 3500 entries which aren't NA. Does anybody what can be going on? Thank you Felipe Parra __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating publication-quality plots for use in Microsoft Word
Thanks for all the suggestions, guys. It looks like TIFF may be the easiest solution, as I wouldn't have to worry about printing to a postscript printer or converting to PDF (when using EPS). That way, I could send the Word file as is to all coauthors (important for collaboration - i.e., track changes) and submit the same file to journals without the need for any secondary conversion. Thanks, everyone. -- View this message in context: http://r.789695.n4.nabble.com/Creating-publication-quality-plots-for-use-in-Microsoft-Word-tp2540676p2542603.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] parallel computation with plyr 1.2.1
Hi, I have been trying to use the new .parallel argument with the most recent version of plyr [1] to speed up some tasks. I can run the example in the NEWS file [1], and it seems to be working correctly. However, R will only use a single core when I try to apply this same approach with ddply(). 1. http://cran.r-project.org/web/packages/plyr/NEWS Watching my CPUs I see that in both cases only a single core is used, and they take about the same amount of time. Is there a limitation with how ddply() dispatches parallel jobs, or is this task not suitable for parallel computing? Cheers, Dylan Here is an example: library(plyr) library(doMC) registerDoMC(cores=2) # example data d - data.frame(y=rnorm(1000), id=rep(letters[1:4], each=500)) # function that wastes some time f - function(x) { m - vector(length=1) for(i in 1:1) { m[i] - mean(sample(x$y, 100)) } mean(m) } system.time(ddply(d, .(id), .fun=f, .parallel=FALSE)) # user system elapsed # 2.740 0.016 2.766 system.time(ddply(d, .(id), .fun=f, .parallel=TRUE)) # user system elapsed # 2.720 0.000 2.726 -- Dylan Beaudette Soil Resource Laboratory http://casoilresource.lawr.ucdavis.edu/ University of California at Davis 530.754.7341 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] shuffling of data
I have a file that reads like this: Species,Year,Julian_day Alnus_glutinosa, 1873, 123 Sorbus_aucuparia, 1873, 122 (more species...) Alnus_glutinosa, 1874, 134 Sorbus_aucuparia, 1874, 143 (more species and years) Is there a way to plot this as julian day over years so that each species get a different color? Also is it possible to convert this data into the format: Alnus_glutinosa, Sorbus_aucuparia,(more species) 123 122 134 143 ...(more years) Then I could attatch a time series to the data. -- View this message in context: http://r.789695.n4.nabble.com/shuffling-of-data-tp2542615p2542615.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] shuffling of data
Something like this? library(ggplot2) qplot(Year, Julian_day, data=a, colour=Species) On Thu, Sep 16, 2010 at 12:14 PM, fugelpitch jo...@runtimerecords.net wrote: I have a file that reads like this: Species,Year,Julian_day Alnus_glutinosa, 1873, 123 Sorbus_aucuparia, 1873, 122 (more species...) Alnus_glutinosa, 1874, 134 Sorbus_aucuparia, 1874, 143 (more species and years) Is there a way to plot this as julian day over years so that each species get a different color? Also is it possible to convert this data into the format: Alnus_glutinosa, Sorbus_aucuparia,(more species) 123 122 134 143 ...(more years) Then I could attatch a time series to the data. -- View this message in context: http://r.789695.n4.nabble.com/shuffling-of-data-tp2542615p2542615.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Stephen Sefick | Auburn University | | Department of Biological Sciences | | 331 Funchess Hall | | Auburn, Alabama | | 36849 | |___| | sas0...@auburn.edu | | http://www.auburn.edu/~sas0025 | |___| Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis A big computer, a complex algorithm and a long time does not equal science. -Robert Gentleman __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] get top n rows group by a column from a dataframe
Hi Richard Thanks for the suggestion, but I want top 5 salary for each company, not the whole list. I don't see how your way can work? Thanks, Richard From: RICHARD M. HEIBERGER [mailto:r...@temple.edu] Sent: Thursday, September 16, 2010 11:53 AM To: Tan, Richard Cc: r-help@r-project.org Subject: Re: [R] get top n rows group by a column from a dataframe tmp - data.frame(matrix(rnorm(30), 10, 3, dimnames=list(letters[1:10], c(company, person, salary tmp company person salary a -1.04590176 -0.7841855 1.07150503 b -1.06643101 0.6545647 0.43920454 c 0.72894531 -1.3812867 0.41313659 d -0.39265263 -0.3871271 0.69404325 e 0.54028124 0.7124772 0.66630904 f -1.46931714 -0.3823353 0.03069797 g -0.33283666 -0.6351862 0.37920017 h -0.79977129 0.2605315 0.92373900 i 0.80614119 0.3727227 -1.16560563 j 0.03165012 0.4690400 -0.81966285 order(tmp$person, decreasing=TRUE)[1:min(5, length(tmp$person))] [1] 5 2 10 9 8 tmp[order(tmp$person, decreasing=TRUE)[1:min(5, length(tmp$person))],] companyperson salary e 0.54028124 0.7124772 0.6663090 b -1.06643101 0.6545647 0.4392045 j 0.03165012 0.4690400 -0.8196628 i 0.80614119 0.3727227 -1.1656056 h -0.79977129 0.2605315 0.9237390 You can easily write a function for that. top - function(DF, varname, howmany) {} On Thu, Sep 16, 2010 at 11:39 AM, Tan, Richard r...@panagora.com wrote: Hi, is there an R function like sql's TOP key word? I have a dataframe that has 3 columns: company, person, salary How do I get top 5 highest paid person for each company, and if I have fewer than 5 people for a company, just return all of them? Thanks, Richard [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] shuffling of data
On Sep 16, 2010, at 1:14 PM, fugelpitch wrote: I have a file that reads like this: How much R do you know? Are you still at the stage where you need basic help reading a file into a session? Species,Year,Julian_day Alnus_glutinosa, 1873, 123 Sorbus_aucuparia, 1873, 122 (more species...) Alnus_glutinosa, 1874, 134 Sorbus_aucuparia, 1874, 143 (more species and years) Is there a way to plot this as julian day over years so that each species get a different color? If (as is quite likely) that species variable is (or will be) actually a factor, you could use as.numeric(Species) as a vector for the color argument. with(dfname, plot(Julian_day, Year, col=as.numeric(Species))) Also is it possible to convert this data into the format: Alnus_glutinosa, Sorbus_aucuparia,(more species) 123 122 134 143 ...(more years) ?reshape package::reshape2 (and possibly other tabulating, time-series, and recoding options, depending on all those devilish details you have unfortunately omitted.) Then I could attatch a time series to the data. -- View this message in context: http://r.789695.n4.nabble.com/shuffling-of-data-tp2542615p2542615.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] test to see if a s4 property is assigned?
On 09/15/2010 12:03 PM, darckeen wrote: Class(person,representation(age=numeric,weight=numeric)) [1] person bob - new(person,age=30) is.null(b...@weight) [1] FALSE b...@weight numeric(0) b...@weight == numeric(0) logical(0) Hi darckeen -- use the prototype argument to setClass to assign a default value, and test for that. Martin How can i test to see if a s4 property is assigned? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.