[R] Easy cut paste from Excel to R?
Hi! Is it possible to easily cut paste data from an Excel spreadsheet to an R edit( ) grid or to variable? It seems that R cannot handle the cell delimiters Excel hands over. Regards, Werner __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Easy cut paste from Excel to R?
Werner Wernersen wrote: Hi! Is it possible to easily cut paste data from an Excel spreadsheet to an R edit( ) grid or to variable? It seems that R cannot handle the cell delimiters Excel hands over. Regards, Werner __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html copy in Excel and say in R: read.table(file(clipboard)) Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] real and complex vectors
The following caught me off-guard: R z - 1i + 1:10 R z - Re(z) R z [1] 1 2 3 4 5 6 7 8 9 10 as expected. But look: R z - 1i + 1:10 R make.real - abs(z) 1000 R z[make.real] - Re(z[make.real]) R z [1] 1+0i 2+0i 3+0i 4+0i 5+0i 6+0i 7+0i 8+0i 9+0i 10+0i R didn't make z a real vector, which is what I wanted. ?[- says If one of these expressions appears on the left side of an assignment then that part of 'x' is set to the value of the right hand side of the assignment. so the behaviour is as documented: class(z) is unchanged in the second session. Would modifying [- to add a test for all elements of an object being replaced (and if this is the case to change the class of z appropriately), be a bad idea? -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: Off topic -- large data sets. Was RE: [R] 64 Bit R Background Question
In message [EMAIL PROTECTED], Prof Brian Ripley [EMAIL PROTECTED] writes But Bert's caveats apply: you have 200 problems of size 20,000 since in QDA each class's distribution is estimated separately, and a single pass will give you the sufficient statistics however large the dataset is. I think we've interpreted Bert's question differently. I am not saying I need to have vast amounts of data in RAM, or in a single data structure, or anything like that, and I am not saying I need a 64-bit version of R. What I am saying is that if I had 40 million cases for a problem like the one I described, I'd want to use all of them when designing a classifier. Patrick Burns, if you're reading: OCR = optical character recognition. -- Graham Jones, author of SharpEye Music Reader http://www.visiv.co.uk 21e Balnakeil, Durness, Lairg, Sutherland, IV27 4PT, Scotland, UK __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] real and complex vectors
On Wed, 16 Feb 2005, Robin Hankin wrote: The following caught me off-guard: R z - 1i + 1:10 R z - Re(z) R z [1] 1 2 3 4 5 6 7 8 9 10 as expected. But look: R z - 1i + 1:10 R make.real - abs(z) 1000 R z[make.real] - Re(z[make.real]) R z [1] 1+0i 2+0i 3+0i 4+0i 5+0i 6+0i 7+0i 8+0i 9+0i 10+0i R didn't make z a real vector, which is what I wanted. ?[- says If one of these expressions appears on the left side of an assignment then that part of 'x' is set to the value of the right hand side of the assignment. so the behaviour is as documented: class(z) is unchanged in the second session. Would modifying [- to add a test for all elements of an object being replaced (and if this is the case to change the class of z appropriately), be a bad idea? Yes. Don't expect your interpreter to mind-read. Changing basic things like this is likely to break lots of existing code. R-help is not really the place for programming design questions (R-devel is). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Easy cut paste from Excel to R?
Uwe Ligges [EMAIL PROTECTED] writes: Werner Wernersen wrote: Hi! Is it possible to easily cut paste data from an Excel spreadsheet to an R edit( ) grid or to variable? It seems that R cannot handle the cell delimiters Excel hands over. Regards, Werner __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html copy in Excel and say in R: read.table(file(clipboard)) Er, doesn't that want to be read.delim (or read.delim2 in comma-locales)? Plain read.table() could cause some grief if there are empty cells. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] real and complex vectors
Robin Hankin wrote: The following caught me off-guard: R z - 1i + 1:10 R z - Re(z) R z [1] 1 2 3 4 5 6 7 8 9 10 as expected. But look: R z - 1i + 1:10 R make.real - abs(z) 1000 R z[make.real] - Re(z[make.real]) R z [1] 1+0i 2+0i 3+0i 4+0i 5+0i 6+0i 7+0i 8+0i 9+0i 10+0i R didn't make z a real vector, which is what I wanted. ?[- says If one of these expressions appears on the left side of an assignment then that part of 'x' is set to the value of the right hand side of the assignment. so the behaviour is as documented: class(z) is unchanged in the second session. Would modifying [- to add a test for all elements of an object being replaced (and if this is the case to change the class of z appropriately), be a bad idea? Sorry, but yes, a bad idea. If you use z[someIndex] - someValues you expect that z only changes its class if required to represent someValues, but never vice versa. That's in particular TRUE for the case of explicitly indexing all elements as in: z - 1i + 1:10 z[] - 1:10 And why should R do different things in the following two cases, comparing z[1:5] - 1:5 and z[1:10] - 1:10 ? Uwe Ligges -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] some help interpreting ANOVA results, please?
Dear RenE, Can you explain a bit more how you derive your T.SPart? That´s what I think is the tricky part of your analysis. I would suggest you should try to end up with something like this: model1-aov(SR~WasSick*Time+Error(Subject/Time) model2-aov(SR~SC*Time+Error(Subject/Time) This way it would be like a repeated measures ANOVA, where WasSick (or SC) are the primary covariates, and Time is nested within Subject. I think the correct specification of time is crucial for the whole analysis. It´s like in a split-plot ANOVA, where finding the appropriate codings for plots of different sizes can sometimes take a very long time. Regards, Christoph 0) Subject, the subject identifier 1) physiological recordings, say SR (skin resistance): time series 2) a SessionPart variable (parts R1 and R2, separated in time by a pause) 3) time, T.SPart: normalised per subject and per SessionPart, so twice 0..1 4) a subjective sickness estimate (SC): time series 5) a per-subject classification: WasSick or not (available as a time series, but constant in time of course) RenE J.V. Bertin wrote: On Sun, 10 Oct 2004 19:55:41 +0200, RenE J.V. Bertin [EMAIL PROTECTED] wrote regarding Re: [R] some help interpreting ANOVA results, please? I'm would like to come back to a question I posted quite a while ago, concerning the analysis of data of an ongoing experiment. I have, for a given number of subjects: 0) Subject, the subject identifier 1) physiological recordings, say SR (skin resistance): time series 2) a SessionPart variable (parts R1 and R2, separated in time by a pause) 3) time, T.SPart: normalised per subject and per SessionPart, so twice 0..1 4) a subjective sickness estimate (SC): time series 5) a per-subject classification: WasSick or not (available as a time series, but constant in time of course) I would like to make statements on whether or not sickness (measured by 4 or 5) can be deduced from the physiological recordings, e.g. something like aov( SR ~ WasSick * T.SPart ) expecting a significant effect of time (sickness building up), of WasSick, and a significant interaction showing that the effect is stronger (or only significant) in the WasSick=TRUE subjects. A simple t.test(SR~WasSick) gives a significant difference, as well as t.test( SR~ (T.SPart=0.5) ) . The problem I'm having is that WasSick (and SC) are not independent variables properly speaking. So I cannot do aov( SR ~ WasSick * T.SPart + Error(Subject/WasSick*T.SPart) ) R would remove WasSick from the Error term, and do the analysis without it, giving a significant T.SPart effect and WasSick:T.SPart interaction (?), both listed under Error: Subject:T.SPart : Error: Subject:T.SPart Df Sum Sq Mean Sq F value Pr(F) T.SPart 5 318.263.6 8.336 7.46e-07 *** WasSick:T.SPart 5 125.525.1 3.289 0.0079 ** Residuals 129 984.9 7.6 There is no trace of a WasSick effect other than in that interaction (of which I'm not sure it is truly one). I have 2 questions at this point: A) I think one could assimilate WasSick to a grouping variable (like in a clinical stdudy), forgetting it is actually an observation on the subjects. In that case, I could do aov( SR ~ WasSick * T.SPart ) which gives me the expected two significant main effects and the significant interaction (which agrees with visual inspection of the data). Is this an acceptable approach/model? B) Should I contine putting the Subject id in an Error term, e.g. aov( SR ~ WasSick + Error(Subject) ) WithOUT this error term, that anova gives a significant effect, confirming the t.test mentioned above. If I include the error term, the effect is no longer significant. Is that because the model does not make sense, rather because my data are so non-normal that a t.test cannot be used? (?Error has a similar model, and calls it not particularly sensible statistically.) I would really appreciate some more constructive comments! Thanks, RenE Bertin PS: I must add that it has been suggested to try lme. I went over what docs I have (help and MASS 4), but these are far to specialistic for me, so I haven't gotten anywhere in that direction :( __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Easy cut paste from Excel to R?
Peter Dalgaard wrote: Uwe Ligges [EMAIL PROTECTED] writes: Werner Wernersen wrote: Hi! Is it possible to easily cut paste data from an Excel spreadsheet to an R edit( ) grid or to variable? It seems that R cannot handle the cell delimiters Excel hands over. Regards, Werner __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html copy in Excel and say in R: read.table(file(clipboard)) Er, doesn't that want to be read.delim (or read.delim2 in comma-locales)? Plain read.table() could cause some grief if there are empty cells. Well, yes, some arguments twisting might be required as for my german locales / german version of Excel the following works even for empty cells and real valued entries: read.table(file(clipboard), sep=\t, dec=,) V1 V2 V3 1 1.2 NA 2.3 2 3.4 4.5 5.6 Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Easy cut paste from Excel to R?
Uwe Ligges [EMAIL PROTECTED] writes: Well, yes, some arguments twisting might be required as for my german locales / german version of Excel the following works even for empty cells and real valued entries: read.table(file(clipboard), sep=\t, dec=,) V1 V2 V3 1 1.2 NA 2.3 2 3.4 4.5 5.6 ...which is of course the same as read.delim2(file(clipboard), header=FALSE) except for possible variations in the fill and quote settings. (What happens if you have empty cells in the last columns, or cells with the text Don't do this?) -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] real and complex vectors
On Wed, 16 Feb 2005 10:00:01 +, Robin Hankin [EMAIL PROTECTED] wrote : The following caught me off-guard: R z - 1i + 1:10 R z - Re(z) R z [1] 1 2 3 4 5 6 7 8 9 10 as expected. But look: R z - 1i + 1:10 R make.real - abs(z) 1000 R z[make.real] - Re(z[make.real]) R z [1] 1+0i 2+0i 3+0i 4+0i 5+0i 6+0i 7+0i 8+0i 9+0i 10+0i R didn't make z a real vector, which is what I wanted. ?[- says If one of these expressions appears on the left side of an assignment then that part of 'x' is set to the value of the right hand side of the assignment. so the behaviour is as documented: class(z) is unchanged in the second session. Would modifying [- to add a test for all elements of an object being replaced (and if this is the case to change the class of z appropriately), be a bad idea? I think it might be. Think of a situation where make.real is almost never all true. Then z would almost always remain complex after z[make.real] - Re(z[make.real]) but on rare occasions would switch to being real. If some poor programmer assumed that z was always complex, it would likely pass tests, but on rare occasions would give garbage. (Off the top of my head I can't think of any cases where R code that expects a complex vector would fail if passed a real one, but it's certainly easy to construct cases in external code.) I think it's safer to make the conversion explicitly if you happen to know that all(make.real) is true. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Easy cut paste from Excel to R?
Peter Dalgaard wrote: Uwe Ligges [EMAIL PROTECTED] writes: Well, yes, some arguments twisting might be required as for my german locales / german version of Excel the following works even for empty cells and real valued entries: read.table(file(clipboard), sep=\t, dec=,) V1 V2 V3 1 1.2 NA 2.3 2 3.4 4.5 5.6 ...which is of course the same as read.delim2(file(clipboard), header=FALSE) except for possible variations in the fill and quote settings. (What happens if you have empty cells in the last columns, or cells with the text Don't do this?) Yes, you are right, thanks! Uwe __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R: ridge regression
hi all a technical question for those bright statisticians. my question involves ridge regression. definition: n=sample size of a data set X is the matrix of data with , say p variables Y is the y matrix i.e the response variable Z(i,j) = ( X(i,j)- xbar(j) / [ (n-1)^0.5* std(x(j))] Y_new(i)=( Y(i)- ybar(j) ) / [ (n-1)^0.5* std(Y(i))](note that i have scaled the Y matrix as well) k is the ridge constant the ridge estimate for the betas is = inverse(Z'Z+kI)*Z'Y_new=W*Z'Y_new the associated variance covariance matrix sigma*W*(Z'Z)*W where sigma is the residual variance based on the transformed variables if we transform the variables back to the original variables the beta estimates are now: beta(j)= std(y)*betaridge(j)/std(x(j)) but what is the covariance matrix of these estimates??? i know that this might not be the correct forum for this question, but since i know that many users are statisticians i know that i will get an informed response.__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Repeating grey scale in graph?
Dear R users, Could somebody tell me why the grey color ramp is repeated in this graph, eventhough the ramp values go from 0 to 1? I must be missing something obvious, but I can not see it! z - c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.259835539,0.284571226, 0.038507288,0.094184749,0.140959431,0.180803984,0.215159105,0.245096084,0.271412845, 0.00775022,0.066198255,0.115433207,0.157494219,0.193836765,0.225569076,0.253518629, -0.02820814,0.032958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392, -0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.170630435,0.201956395, -0.117878701,-0.050461393,0.005991829,0.054672666,0.097103088,0.134398711,0.167423957) x - c(0,1,2,3,4,5) y - c(50, 100, 150, 200, 250, 300, 350) z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE) #persp(x, y, z, theta = 30, phi = 30, expand = 0.5, # box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) hgt - (z - min(z))/ (max(z) - min(z)) z hgt cols - grey(hgt) persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5, box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) Thanks, Sander. version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R -- - Dr. Sander P. Oom Animal, Plant and Environmental Sciences University of the Witwatersrand Private Bag 3 Wits 2050 South Africa Tel (work) +27 (0)11 717 64 04 Tel (home) +27 (0)18 297 44 51 Fax +27 (0)18 299 24 64 Email [EMAIL PROTECTED] Web www.oomvanlieshout.net/sander __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] curve(x,y)?
HI, i search for a function what plot a curve but my function f(x) have two variables, exist a funcion curve(x,y) in R. Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] R: ridge regression
If I'm not mistaken, you only need to know that if V is the covariance matrix of a random vector X, then the covariance of the linear transformation AX + b is AVA'. Substitute betahat for X, and figure out what A is and you're set. (b is 0 in your case.) Andy From: Clark Allan hi all a technical question for those bright statisticians. my question involves ridge regression. definition: n=sample size of a data set X is the matrix of data with , say p variables Y is the y matrix i.e the response variable Z(i,j) = ( X(i,j)- xbar(j) / [ (n-1)^0.5* std(x(j))] Y_new(i)=( Y(i)- ybar(j) ) / [ (n-1)^0.5* std(Y(i))] (note that i have scaled the Y matrix as well) k is the ridge constant the ridge estimate for the betas is = inverse(Z'Z+kI)*Z'Y_new=W*Z'Y_new the associated variance covariance matrix sigma*W*(Z'Z)*W where sigma is the residual variance based on the transformed variables if we transform the variables back to the original variables the beta estimates are now: beta(j)= std(y)*betaridge(j)/std(x(j)) but what is the covariance matrix of these estimates??? i know that this might not be the correct forum for this question, but since i know that many users are statisticians i know that i will get an informed response. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] phi correlation
Hello my big problem is, i can´t find the phi-correlation instruction in the R - programm. (correlation method= spearman, pearson, kendall, I have found) I also cant find the transform instruction which I can transform rational vector into nominal vectors (binary) Transforming into ordinaI I have found with the rank instruction, but I have no found into nominal dates. Please help me . I need it for an examination !!! Thank you Adolf Pessernig [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Setting log(0) to 0
Hi, I'm trying to do a regression like this: wage.r = lm( log(WAGE) ~ log(EXPER) where EXPER is an integer that goes from 0 to about 50. EXPER contains some zeros, so you can't take its log, and the above regression therefore fails. I would like to make R accept log(0) as 0, is that possible? Or do I have first have to turn the 0's into 1's to be able to do the above regression? Regards T Petersen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Lattice --reference line in panels does not come up
R-help, I am quite new to lattice. I am plotting something in which I want some reference lines. I do the foolowing : library ( lattice ) reference.line - trellis.par.get ( reference.line ) reference.line$lty - 2## not working with any of the reference.line components # reference.line$col - red trellis.par.set(reference.line, reference.line) xyplot ( number ~ cm | year , data = lgda., type = l, col = black , ylab = Number, xlab = Length (cm) ) ## the actual plot The result is without reference lines. What am I doing wrong? Thanks in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Repeating grey scale in graph?
Sander Oom wrote: Dear R users, Could somebody tell me why the grey color ramp is repeated in this graph, eventhough the ramp values go from 0 to 1? I must be missing something obvious, but I can not see it! You missed to read the ehlp page ?persp: col: the color(s) of the surface facets. Transparent colours are ignored. This is recycled to the (nx-1)(ny-1) facets. Attention: (nx-1)x(ny-1) facets, but not nx x ny Uwe Ligges z - c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.259835539,0.284571226, 0.038507288,0.094184749,0.140959431,0.180803984,0.215159105,0.245096084,0.271412845, 0.00775022,0.066198255,0.115433207,0.157494219,0.193836765,0.225569076,0.253518629, -0.02820814,0.032958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392, -0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.170630435,0.201956395, -0.117878701,-0.050461393,0.005991829,0.054672666,0.097103088,0.134398711,0.167423957) x - c(0,1,2,3,4,5) y - c(50, 100, 150, 200, 250, 300, 350) z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE) #persp(x, y, z, theta = 30, phi = 30, expand = 0.5, # box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) hgt - (z - min(z))/ (max(z) - min(z)) z hgt cols - grey(hgt) persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5, box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) Thanks, Sander. version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Repeating grey scale in graph?
Sander Oom [EMAIL PROTECTED] writes: Dear R users, Could somebody tell me why the grey color ramp is repeated in this graph, eventhough the ramp values go from 0 to 1? I must be missing something obvious, but I can not see it! z - c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.259835539,0.284571226, 0.038507288,0.094184749,0.140959431,0.180803984,0.215159105,0.245096084,0.271412845, 0.00775022,0.066198255,0.115433207,0.157494219,0.193836765,0.225569076,0.253518629, -0.02820814,0.032958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392, -0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.170630435,0.201956395, -0.117878701,-0.050461393,0.005991829,0.054672666,0.097103088,0.134398711,0.167423957) x - c(0,1,2,3,4,5) y - c(50, 100, 150, 200, 250, 300, 350) z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE) #persp(x, y, z, theta = 30, phi = 30, expand = 0.5, # box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) hgt - (z - min(z))/ (max(z) - min(z)) z hgt cols - grey(hgt) persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5, box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) You have 30 facets and 42 colour values. Try it with cols - grey(hgt[-1,-1]) -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] curve(x,y)?
[EMAIL PROTECTED] wrote: HI, i search for a function what plot a curve but my function f(x) have two variables, exist a funcion curve(x,y) in R. Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Not exactly, but quite easy to do it yourself, example: f - function(x, y) x+y x - 1:10 y - 1:10 z - outer(x, y, f) persp(x, y, z) Uwe Ligges __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R: ridge regression
hi Andy and other r users i never gave the full picture. beta(j)= std(y)*betaridge(j)/std(x(j)) for j=1,2,...p but beta(0) = ybar- sum( i= 1 to p, betaridge(i)*xbar(j) ) note that ybar and the xbars are estimated parameters. we can split the covariance matrix into three sections namely: 1. var(beta(0)) 2. covar(beta(0), other betas) and 3. covar(other betas) , (this is your answer, which was correct) but now i need var(beta(0)) and covar(beta(0), other betas) any suggestions! Liaw, Andy wrote: If I'm not mistaken, you only need to know that if V is the covariance matrix of a random vector X, then the covariance of the linear transformation AX + b is AVA'. Substitute betahat for X, and figure out what A is and you're set. (b is 0 in your case.) Andy From: Clark Allan hi all a technical question for those bright statisticians. my question involves ridge regression. definition: n=sample size of a data set X is the matrix of data with , say p variables Y is the y matrix i.e the response variable Z(i,j) = ( X(i,j)- xbar(j) / [ (n-1)^0.5* std(x(j))] Y_new(i)=( Y(i)- ybar(j) ) / [ (n-1)^0.5* std(Y(i))] (note that i have scaled the Y matrix as well) k is the ridge constant the ridge estimate for the betas is = inverse(Z'Z+kI)*Z'Y_new=W*Z'Y_new the associated variance covariance matrix sigma*W*(Z'Z)*W where sigma is the residual variance based on the transformed variables if we transform the variables back to the original variables the beta estimates are now: beta(j)= std(y)*betaridge(j)/std(x(j)) but what is the covariance matrix of these estimates??? i know that this might not be the correct forum for this question, but since i know that many users are statisticians i know that i will get an informed response. -- Notice: This e-mail message, together with any attachment...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] phi correlation
On 16 Feb 2005 at 12:54, Nicole wrote: Hello my big problem is, i can´t find the phi-correlation instruction in the R - programm. (correlation method= spearman, pearson, kendall, I have found) See package vcd, command assoc.stats. I also cant find the transform instruction which I can transform rational vector into nominal vectors (binary) What about using as.factor? # little example... x-c(0,1,0,0,0,1,1) y-as.factor(x) y assoc.stats(table(y,y)) HTH, Bernd __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] phi correlation
Nicole wrote: Hello my big problem is, i cant find the phi-correlation instruction in the R - programm. (correlation method= spearman, pearson, kendall, I have found) I also cant find the transform instruction which I can transform rational vector into nominal vectors (binary) Transforming into ordinaI I have found with the rank instruction, but I have no found into nominal dates. Please help me . I need it for an examination !!! So what? Time to do your homework, isn't it? phi: it is the same as pearson for a 2x2 table of dichotomous/binary data. Should be written in any basic textbook on descriptive statsitics. Do your homework!!! I really dislike these triple exclamation marks. nominal: Well, try factor() or as.character(), or whatever depends on your aims Who are you? Adolf Pessernig, or nicole.raschun??? Uwe Ligges Thank you Adolf Pessernig [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Easy cut paste from Excel to R?
I've had good luck with the scan() function when I want to get a few numbers from Excel into R quickly to use it as a calculator. CAVEAT: you have to have the numbers you want to copy in a column not a row in Excel. For example: In Excel your data are in a column as follows: Col A 1 2 3 Then copy the 3 cells (e.g. 1, 2,3) in Excel and open R and type in: data - scan() Then Paste using Ctrl-V. Hit the Enter key. You know have an object called data that you can use and manipulate in R. I've taken this even further by creating an R function that will take a column of numbers from Excel and then scan() them into R, create a matrix, and then perform a Chi-square test. Let me know if you'd like to know more. I'm a beginner and if I can do so can you!! ~Nick __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] histogram and boxplot in a same postscript
Hi, all. I need plot a boxplot under a histogram like below, but some configs are troubled: - the boxplot contours the plot, even if I put bty=n, modifying the histogram plot; - I changed the configs of axis to do a 3x3 inches plot, but the result is 2 different axis. For example, the code below ilustrates this... scores-c(2.0, 0.0, 5.0, 5.0, 5.0, 2.0, 0.0, 5.0, 2.5, 4.0, 5.0, 0.0, 5.0, 0.0, 2.0, 5.0, 5.0, 2.0, 3.0, 3.0) postscript(test.ps, width=3, height=3, horizontal=FALSE, family=Times, paper=special) gra-hist(scores, breaks=((0:11)/2-.2), xlim=c(-1,6), plot=FALSE, cex.axis=.5, cex.main=.5, cex.sub=.5, cex.lab=.5, mgp=c(1.5,.5,0)) yy-ceiling(max(gra$counts)/10)*10 hist(scores, breaks=((0:11)/2-.2), xlim=c(-1,6), ylim=c(0,yy), main=scores, ylab=Freq, xlab=math, cex.axis=.5, cex.main=.5, cex.sub=.5, cex.lab=.5, mgp=c(1.5,.5,0)) boxplot(scores, horizontal=1, add=1, at=-yy/50, boxwex=yy/20, bty=n, cex.axis=.5, cex.main=.5, cex.sub=.5, cex.lab=.5, ann=FALSE) points(q[4], -yy/50, col=1, pch=x, cex=.2) dev.off() Thanks, C. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice --reference line in panels does not come up
Luis Ridao Cruz wrote: R-help, I am quite new to lattice. I am plotting something in which I want some reference lines. I do the foolowing : library ( lattice ) reference.line - trellis.par.get ( reference.line ) reference.line$lty - 2## not working with any of the reference.line components # reference.line$col - red trellis.par.set(reference.line, reference.line) xyplot ( number ~ cm | year , data = lgda., type = l, col = black , ylab = Number, xlab = Length (cm) ) ## the actual plot The result is without reference lines. What am I doing wrong? You have forgotten to specify panel.grid() in your call, which is the only function accepting reference line settings, AFAIK. The following should do the trick: xyplot(., panel = function(x, y, ...){ panel.xyplot(x, y, ...) panel.grid() } ) Uwe Ligges Thanks in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] RE: Off topic -- large data sets. Experiences using R on clusters/Grids
Thanks for all the input. Now to go further off topic.. Does anyone have any comments regarding running 64 BIT R on cluster/grid systems? Given an (almost) unlimited amount of memory, can R hypotheticaly handle Very Large Datasets? I'm finding that even small sub sets of this data come in at 1 GB (1-5 million rows), which no R 32 BIT workstation (at least in this lab) can handle. This type of stuff is done effortlessly in genomic research, mapping DNA, etc Tom Colson Center for Earth Observation North Carolina State University Raleigh, NC 27695 (919) 515 3434 (919) 673 8023 [EMAIL PROTECTED] Online Calendar: http://www4.ncsu.edu/~tpcolson -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Graham Jones Sent: Wednesday, February 16, 2005 5:08 AM To: Prof Brian Ripley Cc: r-help@stat.math.ethz.ch Subject: Re: Off topic -- large data sets. Was RE: [R] 64 Bit R BackgroundQuestion In message [EMAIL PROTECTED], Prof Brian Ripley [EMAIL PROTECTED] writes But Bert's caveats apply: you have 200 problems of size 20,000 since in QDA each class's distribution is estimated separately, and a single pass will give you the sufficient statistics however large the dataset is. I think we've interpreted Bert's question differently. I am not saying I need to have vast amounts of data in RAM, or in a single data structure, or anything like that, and I am not saying I need a 64-bit version of R. What I am saying is that if I had 40 million cases for a problem like the one I described, I'd want to use all of them when designing a classifier. Patrick Burns, if you're reading: OCR = optical character recognition. -- Graham Jones, author of SharpEye Music Reader http://www.visiv.co.uk 21e Balnakeil, Durness, Lairg, Sutherland, IV27 4PT, Scotland, UK __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice --reference line in panels does not come up
Thank you Uwe, It worked ! Luis Uwe Ligges [EMAIL PROTECTED] 16/02/2005 13:21:27 Luis Ridao Cruz wrote: R-help, I am quite new to lattice. I am plotting something in which I want some reference lines. I do the foolowing : library ( lattice ) reference.line - trellis.par.get ( reference.line ) reference.line$lty - 2## not working with any of the reference.line components # reference.line$col - red trellis.par.set(reference.line, reference.line) xyplot ( number ~ cm | year , data = lgda., type = l, col = black , ylab = Number, xlab = Length (cm) ) ## the actual plot The result is without reference lines. What am I doing wrong? You have forgotten to specify panel.grid() in your call, which is the only function accepting reference line settings, AFAIK. The following should do the trick: xyplot(., panel = function(x, y, ...){ panel.xyplot(x, y, ...) panel.grid() } ) Uwe Ligges Thanks in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Setting log(0) to 0
On 16-Feb-05 Terji Petersen wrote: Hi, I'm trying to do a regression like this: wage.r = lm( log(WAGE) ~ log(EXPER) where EXPER is an integer that goes from 0 to about 50. EXPER contains some zeros, so you can't take its log, and the above regression therefore fails. I would like to make R accept log(0) as 0, is that possible? Or do I have first have to turn the 0's into 1's to be able to do the above regression? If treating log(0) as 0 would do your business, then a preliminary pass to turn 0 into 1 would be the simplest method. It only takes 1 line. This is a bit of a Catch-22. It looks like you're trying to fit a power law WAGE = A*(EXPER^B) (where I guess EXPER means experience) and you've got some cases with no experience. Whether your work-round is appropriate depends in part on the unit of experience. If it's in years, then a case with 3 months experience would have log(EXPER) = -1.39, thereby weighing in with a lesser value than someone with zero experience, on your proposal. On the other hand, if it's in days, then log(EXPER) = log(91) = 4.51 and even someone with only a week has log(EXPER) = 1.95 But your log(0) = 0 data would be sitting there all the time, whatever the scale of EXPER, and so would have an influence on your regression which depended on this scale. You might have to consider using log(0) -- const where the const is such as to give reasonable results, given what comes out of the rest of the data (where EXPER0). The fundamental problem is that your power law predicts zero wage for zero experience, which is rarely the case. You might do better to try a non-linear fit WAGE = W0 + A*(EXPER^B) for which sort of thing there are several resources in R, perhaps the simplest being 'nls'. For what you have in your installed packages, try a help.search(nonlinear) Once you open this door, you can try perhaps more realistic non-linear models, including what can be found amongst the SS. (Self-Starting) models in nls -- have a look at what's listed by library(help=nls) as well as what is allowed according to ?nls. Such models would allow an initial (zero-experience) wage, perhaps not changing much for some time, then rising more rapidly once an experience threshold is passed, then flattening out to a lower slope over a longer time (something which many of us have experience of). And even ultimately ending to decrease ... Hoping this helps, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 16-Feb-05 Time: 13:26:53 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Repeating grey scale in graph?
Thanks Peter! Of course I only have (nx-1)(ny-1) facets in a x*y plot! The help page line: ... col the color(s) of the surface facets. Transparent colours are ignored. This is recycled to the (nx-1)(ny-1) facets. ... just did not ring a bell. In fact, it is still not clear to me why it recycles the ramp even though it has a surplus of colours (grey levels)! Why not just ignore the surplus colours? Anyway it works, Sander. Peter Dalgaard wrote: Sander Oom [EMAIL PROTECTED] writes: Dear R users, Could somebody tell me why the grey color ramp is repeated in this graph, eventhough the ramp values go from 0 to 1? I must be missing something obvious, but I can not see it! z - c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.259835539,0.284571226, 0.038507288,0.094184749,0.140959431,0.180803984,0.215159105,0.245096084,0.271412845, 0.00775022,0.066198255,0.115433207,0.157494219,0.193836765,0.225569076,0.253518629, -0.02820814,0.032958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392, -0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.170630435,0.201956395, -0.117878701,-0.050461393,0.005991829,0.054672666,0.097103088,0.134398711,0.167423957) x - c(0,1,2,3,4,5) y - c(50, 100, 150, 200, 250, 300, 350) z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE) #persp(x, y, z, theta = 30, phi = 30, expand = 0.5, # box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) hgt - (z - min(z))/ (max(z) - min(z)) z hgt cols - grey(hgt) persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5, box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) You have 30 facets and 42 colour values. Try it with cols - grey(hgt[-1,-1]) -- - Dr. Sander P. Oom Animal, Plant and Environmental Sciences University of the Witwatersrand Private Bag 3 Wits 2050 South Africa Tel (work) +27 (0)11 717 64 04 Tel (home) +27 (0)18 297 44 51 Fax +27 (0)18 299 24 64 Email [EMAIL PROTECTED] Web www.oomvanlieshout.net/sander __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Profiling R code and C code (Rprof and gprof)
Hi, I have searched R mail list archive and couldn't find my answers. The R extension describes how to make use of Rprof to profile R code. gprof can be also used for the same purpose for the C codes when the C codes are written independently and provided with a main() function. I'm currently writing R codes meshed with C Codes, and use .Call as the interface between the two parts. Rprof reports details of each R functions, but does not report the details of the C functions. I'm wondering if there is a way such that Rprof can report the detials of each C functions as did in gprof. One may suggest I can compile all of the C codes and write a main function, and then use the gprof. That's definitely true before I moved from .C to .Call. Since now the R codes and C codes are meshed in the same program, it does not seem a trivial job to separate the two parts neatly. We can use R -d gdb to debug C codes meshed with R codes. If we can also profile the C functions called by the R codes, then it will much be productive to write useful C codes. Any suggestions how to use Rprof and gprof to help me to spot a C function which I can work on to speed up my program will be much appreciated. Thanks, Yongchao __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Passing colnames to graphics title
Hi, Just a quick query - if I'm creating a function to produce a number of histograms per page of output (one per column from a matrix), how can I pass the column name of the matrix into the title (or indeed to form part of the x-axis label)? TIA, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Lattice --reference line in panels does not come up
Uwe Ligges wrote: Luis Ridao Cruz wrote: R-help, I am quite new to lattice. I am plotting something in which I want some reference lines. I do the foolowing : library ( lattice ) reference.line - trellis.par.get ( reference.line ) reference.line$lty - 2## not working with any of the reference.line components # reference.line$col - red trellis.par.set(reference.line, reference.line) xyplot ( number ~ cm | year , data = lgda., type = l, col = black , ylab = Number, xlab = Length (cm) ) ## the actual plot The result is without reference lines. What am I doing wrong? You have forgotten to specify panel.grid() in your call, which is the only function accepting reference line settings, AFAIK. The following should do the trick: xyplot(., panel = function(x, y, ...){ panel.xyplot(x, y, ...) panel.grid() } ) Or, in recent versions of the lattice package, xyplot(..., type = c(g, p)) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] (no subject)
R-people I wonder if one could change a list of table with number of the form 1,200.44 , to 1200.44 Regards JG -- This e-mail and any attachment may be confidential and may also be privileged. If you are not the intended recipient, please notify us immediately and then delete this e-mail and any attachment without retaining copies or disclosing the contents thereof to any other person. Thank you. -- [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Informix from Mac
I am using R 2.0.1 on Max OS X. The database is Informix. There is no Informix ODBC client for Mac, as far as I know, so I can't use RODBC. Other than going with SJava/JDBC, is there a way for me to connect to the database? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Repeating grey scale in graph?
On Wed, 16 Feb 2005 15:44:00 +0200 Sander Oom wrote: Thanks Peter! Of course I only have (nx-1)(ny-1) facets in a x*y plot! The help page line: ... col the color(s) of the surface facets. Transparent colours are ignored. This is recycled to the (nx-1)(ny-1) facets. ... just did not ring a bell. In fact, it is still not clear to me why it recycles the ramp even though it has a surplus of colours (grey levels)! Why not just ignore the surplus colours? It does! cols is a vector of length 42 and only the first 30 are used. Try to use your persp call below with col = cols and col = cols[1:30]. Z Anyway it works, Sander. Peter Dalgaard wrote: Sander Oom [EMAIL PROTECTED] writes: Dear R users, Could somebody tell me why the grey color ramp is repeated in this graph, eventhough the ramp values go from 0 to 1? I must be missing something obvious, but I can not see it! z - c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.2598 35539,0.284571226,0.038507288,0.094184749,0.140959431,0.180803984,0 .215159105,0.245096084,0.271412845,0.00775022,0.066198255,0.1154332 07,0.157494219,0.193836765,0.225569076,0.253518629,-0.02820814,0.03 2958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392, -0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.1706 30435,0.201956395,-0.117878701,-0.050461393,0.005991829,0.054672666 ,0.097103088,0.134398711,0.167423957) x - c(0,1,2,3,4,5) y - c(50, 100, 150, 200, 250, 300, 350) z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE) #persp(x, y, z, theta = 30, phi = 30, expand = 0.5, # box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) hgt - (z - min(z))/ (max(z) - min(z)) z hgt cols - grey(hgt) persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5, box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) You have 30 facets and 42 colour values. Try it with cols - grey(hgt[-1,-1]) -- - Dr. Sander P. Oom Animal, Plant and Environmental Sciences University of the Witwatersrand Private Bag 3 Wits 2050 South Africa Tel (work) +27 (0)11 717 64 04 Tel (home) +27 (0)18 297 44 51 Fax +27 (0)18 299 24 64 Email [EMAIL PROTECTED] Web www.oomvanlieshout.net/sander __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Repeating grey scale in graph?
Sander Oom wrote: Thanks Peter! Of course I only have (nx-1)(ny-1) facets in a x*y plot! The help page line: ... col the color(s) of the surface facets. Transparent colours are ignored. This is recycled to the (nx-1)(ny-1) facets. ... just did not ring a bell. In fact, it is still not clear to me why it recycles the ramp even though it has a surplus of colours (grey levels)! Why not just ignore the surplus colours? Indeed, it ignores them in your case, but since each row of your matrix there is one too much this one is moved to the next row, 2 from row two to three, 3 from three to four, and the last nx+ny-1 are omitted. Uwe Ligges Anyway it works, Sander. Peter Dalgaard wrote: Sander Oom [EMAIL PROTECTED] writes: Dear R users, Could somebody tell me why the grey color ramp is repeated in this graph, eventhough the ramp values go from 0 to 1? I must be missing something obvious, but I can not see it! z - c(0.064329041,0.117243316,0.161565116,0.19923015,0.231642175,0.259835539,0.284571226, 0.038507288,0.094184749,0.140959431,0.180803984,0.215159105,0.245096084,0.271412845, 0.00775022,0.066198255,0.115433207,0.157494219,0.193836765,0.225569076,0.253518629, -0.02820814,0.032958752,0.084661362,0.128946221,0.167320522,0.200892494,0.230504392, -0.07003273,-0.005814512,0.048304039,0.094805358,0.135196637,0.170630435,0.201956395, -0.117878701,-0.050461393,0.005991829,0.054672666,0.097103088,0.134398711,0.167423957) x - c(0,1,2,3,4,5) y - c(50, 100, 150, 200, 250, 300, 350) z - matrix(z, nrow=length(x), ncol=length(y), byrow=TRUE) #persp(x, y, z, theta = 30, phi = 30, expand = 0.5, # box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) hgt - (z - min(z))/ (max(z) - min(z)) z hgt cols - grey(hgt) persp(x, y, z, col = cols, theta = 30, phi = 30, expand = 0.5, box= TRUE, axes= TRUE, ticktype = detailed, main=Title of plot) You have 30 facets and 42 colour values. Try it with cols - grey(hgt[-1,-1]) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Repeating grey scale in graph?
Achim Zeileis [EMAIL PROTECTED] writes: In fact, it is still not clear to me why it recycles the ramp even though it has a surplus of colours (grey levels)! Why not just ignore the surplus colours? It does! cols is a vector of length 42 and only the first 30 are used. Try to use your persp call below with col = cols and col = cols[1:30]. Z Just to rub it in, consider M [,1] [,2] [,3] [,4] [,5] [1,]23456 [2,]34567 [3,]45678 [4,]56789 [5,]6789 10 M2 - matrix(M[1:16],4,4) M2 [,1] [,2] [,3] [,4] [1,]2666 [2,]3377 [3,]4448 [4,]5555 -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Passing colnames to graphics title
Laura Quinn wrote: Hi, Just a quick query - if I'm creating a function to produce a number of histograms per page of output (one per column from a matrix), how can I pass the column name of the matrix into the title (or indeed to form part of the x-axis label)? By extracting them using colnames()? Uwe Ligges TIA, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Passing colnames to graphics title
a simple thing to do is: mat - matrix(...) # your matrix nams - dimnames(mat)[[2]] for(j in 1:ncol(mat)) hist(mat[,j], main=nams[j]) # or hist(mat[,j], xlab=paste(..., nams[j], ...)) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Laura Quinn [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Wednesday, February 16, 2005 2:56 PM Subject: [R] Passing colnames to graphics title Hi, Just a quick query - if I'm creating a function to produce a number of histograms per page of output (one per column from a matrix), how can I pass the column name of the matrix into the title (or indeed to form part of the x-axis label)? TIA, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Passing colnames to graphics title
Obviously I have been trying to use the colnames() function! However, when I try to subscript ie: for(i in 1:20){ main=paste(Site:,colnames(i),sep=) } this doesn't work! I thought that as.character(colnames(i)) or substitute(colnames(i)) might work, but to no avail... Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] On Wed, 16 Feb 2005, Uwe Ligges wrote: Laura Quinn wrote: Hi, Just a quick query - if I'm creating a function to produce a number of histograms per page of output (one per column from a matrix), how can I pass the column name of the matrix into the title (or indeed to form part of the x-axis label)? By extracting them using colnames()? Uwe Ligges TIA, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] histogram and boxplot in a same postscript
Cézar Freitas wrote: Hi, all. I need plot a boxplot under a histogram like below, but some configs are troubled: - the boxplot contours the plot, even if I put bty=n, modifying the histogram plot; You want to set axes = FALSE in boxplot() BTW: What is q[4] in your call to points()? Uwe Ligges - I changed the configs of axis to do a 3x3 inches plot, but the result is 2 different axis. For example, the code below ilustrates this... scores-c(2.0, 0.0, 5.0, 5.0, 5.0, 2.0, 0.0, 5.0, 2.5, 4.0, 5.0, 0.0, 5.0, 0.0, 2.0, 5.0, 5.0, 2.0, 3.0, 3.0) postscript(test.ps, width=3, height=3, horizontal=FALSE, family=Times, paper=special) gra-hist(scores, breaks=((0:11)/2-.2), xlim=c(-1,6), plot=FALSE, cex.axis=.5, cex.main=.5, cex.sub=.5, cex.lab=.5, mgp=c(1.5,.5,0)) yy-ceiling(max(gra$counts)/10)*10 hist(scores, breaks=((0:11)/2-.2), xlim=c(-1,6), ylim=c(0,yy), main=scores, ylab=Freq, xlab=math, cex.axis=.5, cex.main=.5, cex.sub=.5, cex.lab=.5, mgp=c(1.5,.5,0)) boxplot(scores, horizontal=1, add=1, at=-yy/50, boxwex=yy/20, bty=n, cex.axis=.5, cex.main=.5, cex.sub=.5, cex.lab=.5, ann=FALSE) points(q[4], -yy/50, col=1, pch=x, cex=.2) dev.off() Thanks, C. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Easy cut paste from Excel to R?
Peter Dalgaard p.dalgaard at biostat.ku.dk writes: : : Uwe Ligges ligges at statistik.uni-dortmund.de writes: : : Well, yes, some arguments twisting might be required as for my german : locales / german version of Excel the following works even for empty : cells and real valued entries: : : read.table(file(clipboard), sep=\t, dec=,) : : V1 V2 V3 : 1 1.2 NA 2.3 : 2 3.4 4.5 5.6 : : ...which is of course the same as : : read.delim2(file(clipboard), header=FALSE) which is the same as read.delim2(clipboard, header = FALSE) : : except for possible variations in the fill and quote settings. (What : happens if you have empty cells in the last columns, or cells with : the text Don't do this?) : __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Passing colnames to graphics title
Wonderful, thank you very much! Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] On Wed, 16 Feb 2005, Dimitris Rizopoulos wrote: a simple thing to do is: mat - matrix(...) # your matrix nams - dimnames(mat)[[2]] for(j in 1:ncol(mat)) hist(mat[,j], main=nams[j]) # or hist(mat[,j], xlab=paste(..., nams[j], ...)) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Laura Quinn [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Wednesday, February 16, 2005 2:56 PM Subject: [R] Passing colnames to graphics title Hi, Just a quick query - if I'm creating a function to produce a number of histograms per page of output (one per column from a matrix), how can I pass the column name of the matrix into the title (or indeed to form part of the x-axis label)? TIA, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] (no subject)
Hi Jim I'm not sure if I understand your problem correctly. Is this a solution? (li - list(a=1,b=200.44)) as.numeric(paste(unlist(li), collapse = )) Best regards, Christoph Buser -- Christoph Buser [EMAIL PROTECTED] Seminar fuer Statistik, LEO C11 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-5414 fax: 632-1228 http://stat.ethz.ch/~buser/ -- Jim Gustafsson writes: R-people I wonder if one could change a list of table with number of the form 1,200.44 , to 1200.44 Regards JG -- This e-mail and any attachment may be confidential and may also be privileged. If you are not the intended recipient, please notify us immediately and then delete this e-mail and any attachment without retaining copies or disclosing the contents thereof to any other person. Thank you. -- [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] splitting items into groups according to correlations
hi, i'm looking for a smart way of distributing items to different groups according to their correlation(s). the correlation of items within one group should be minimal, whereas (canonical) correlation between the blocks should be maximal. example: you have 20 items, which are to be split into 4 blocks with 5 items in each block. (of course, the numbers are to be interchangable). so far, 2 (problematic) solutions were thought of: 1) try all different combinations of blocks of items and look for the maximum canonical correlation between the blocks. problems are, that the correlation of items within one block are only regarded implicitely and, more sadly, this approach is very time-consuming as the number of items increases. 2) an approximation could be to use the results of a factor analysis to distribute items from one factor to different blocks. however, this is a rather quick and dirty solution. has anybody else encountered a similar problem before or can think of an approach to handle this? any help is more than welcome. best regards andreas [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Repeating grey scale in graph?
On Wed, 16 Feb 2005 15:44:00 +0200, Sander Oom [EMAIL PROTECTED] wrote : Thanks Peter! Of course I only have (nx-1)(ny-1) facets in a x*y plot! The help page line: ... colthe color(s) of the surface facets. Transparent colours are ignored. This is recycled to the (nx-1)(ny-1) facets. ... just did not ring a bell. In fact, it is still not clear to me why it recycles the ramp even though it has a surplus of colours (grey levels)! Why not just ignore the surplus colours? Your z array is 6 by 7. Your cols will be mapped to a 5 by 6 array. They don't look like an array, because the grey() function stripped off the dimension attribute. The problem is that if you pass the entries from a 6 by 7 array to something that expects the entries from a 5 by 6 array, you get things in the wrong order. You see the same effect here: rownum - as.vector(row(matrix(NA, 6, 7))) matrix(rownum, 6, 7) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,]1111111 [2,]2222222 [3,]3333333 [4,]4444444 [5,]5555555 [6,]6666666 matrix(rownum, 5, 6) [,1] [,2] [,3] [,4] [,5] [,6] [1,]165432 [2,]216543 [3,]321654 [4,]432165 [5,]543216 Warning message: data length [42] is not a sub-multiple or multiple of the number of rows [5] in matrix except that in this case you get a warning about the wrong length; persp doesn't give you the warning. Maybe it should? Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] glmm with negative binomial
Hello, At present, can generalized linear mixed models with negative binomial distribution and estimating the shape parameter be fit using R? I am aware of glm.nb but am wondering about incorporation of mixed effects. Thanks in advance, Brian Aukema __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] (no subject)
Hi Jim Something like x-1,200.44 as.numeric(sub(,, , x)) [1] 1200.44 Petr On 16 Feb 2005 at 15:08, Jim Gustafsson wrote: R-people I wonder if one could change a list of table with number of the form 1,200.44 , to 1200.44 Regards JG -- This e-mail and any attachment may be confidential and may also be privileged. If you are not the intended recipient, please notify us immediately and then delete this e-mail and any attachment without retaining copies or disclosing the contents thereof to any other person. Thank you. -- [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] (no subject)
Jim Gustafsson [EMAIL PROTECTED] writes: R-people I wonder if one could change a list of table with number of the form 1,200.44 , to 1200.44 Regards JG On input, I assume? Read as character variable, get rid of the comma(s) using (g)sub, then use as.numeric. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Passing colnames to graphics title
Laura Quinn wrote: Obviously I have been trying to use the colnames() function! However, when I try to subscript ie: for(i in 1:20){ main=paste(Site:,colnames(i),sep=) } Example (which you should have provided): # Generate an example-matrix: X - matrix(1:9, 3) colnames(X) - letters[1:3] # now try to get histograms of columns using a loop: par(mfrow = c(3, 1)) cnames - colnames(X) for(i in 1:ncol(X)){ hist(X[,i], main = paste(Site:, cnames[i], sep=)) } Uwe Ligges this doesn't work! I thought that as.character(colnames(i)) or substitute(colnames(i)) might work, but to no avail... Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] On Wed, 16 Feb 2005, Uwe Ligges wrote: Laura Quinn wrote: Hi, Just a quick query - if I'm creating a function to produce a number of histograms per page of output (one per column from a matrix), how can I pass the column name of the matrix into the title (or indeed to form part of the x-axis label)? By extracting them using colnames()? Uwe Ligges TIA, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Passing colnames to graphics title
Uwe Ligges wrote: Laura Quinn wrote: Obviously I have been trying to use the colnames() function! However, when I try to subscript ie: for(i in 1:20){ main=paste(Site:,colnames(i),sep=) } BTW: colnames(i) is the same as colnames(1) in the first iteration of your loop. What do you expect colnames(1) to be? Uwe Ligges Example (which you should have provided): # Generate an example-matrix: X - matrix(1:9, 3) colnames(X) - letters[1:3] # now try to get histograms of columns using a loop: par(mfrow = c(3, 1)) cnames - colnames(X) for(i in 1:ncol(X)){ hist(X[,i], main = paste(Site:, cnames[i], sep=)) } Uwe Ligges this doesn't work! I thought that as.character(colnames(i)) or substitute(colnames(i)) might work, but to no avail... Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] On Wed, 16 Feb 2005, Uwe Ligges wrote: Laura Quinn wrote: Hi, Just a quick query - if I'm creating a function to produce a number of histograms per page of output (one per column from a matrix), how can I pass the column name of the matrix into the title (or indeed to form part of the x-axis label)? By extracting them using colnames()? Uwe Ligges TIA, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Rmpi - cluster with no name
Hello everybody, thanks for help. I'm having this problem using the package Rmpi. I run R with mpi and then I load the library 'Rmpi' and 'snow'. But when I try to create the cluster: mycluster - makeCluster(2) I get this error Error in makeMPIcluster(spec, ...) : a cluster already exists 1 The first time I did this was ok, but I didn't link the created cluster to any object, to see if it worked I just tiped: makeCluster(name) So, now, I think I have this cluster. But since it has no name I cannot communicate with it. I can't even remove it or just link it to an object I can handle with. I checked all the documentations but I couldn't find anything useful. -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Passing colnames to graphics title
Laura Quinn wrote: Obviously I have been trying to use the colnames() function! However, when I try to subscript ie: for(i in 1:20){ main=paste(Site:,colnames(i),sep=) } this doesn't work! I thought that as.character(colnames(i)) or substitute(colnames(i)) might work, but to no avail... Laura, You should (re)read ?colnames. It takes a matrix as it's argument, not an integer as you have supplied. I think you want: for(i in 1:20){ main=paste(Site:,colnames(mat)[i],sep=) } --sundar Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] On Wed, 16 Feb 2005, Uwe Ligges wrote: Laura Quinn wrote: Hi, Just a quick query - if I'm creating a function to produce a number of histograms per page of output (one per column from a matrix), how can I pass the column name of the matrix into the title (or indeed to form part of the x-axis label)? By extracting them using colnames()? Uwe Ligges TIA, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Passing colnames to graphics title
On Wed, Feb 16, 2005 at 02:46:51PM +, Laura Quinn wrote: Obviously I have been trying to use the colnames() function! However, when I try to subscript ie: for(i in 1:20){ main=paste(Site:,colnames(i),sep=) ^^^ it looks to me that this should be something like colnames(foo)[i] where foo is the matrix or data.frame you use. Best regards, Jan -- +- Jan T. Kim ---+ |*NEW*email: [EMAIL PROTECTED] | |*NEW*WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Multiple instances of R shell in Mac OS X 10.3?
Wondering if there's a way to do this. I'm not referring to running Rterm from OSX terminal, but actually running multiple instances of the R command shell within the OS X GUI... I have R v2.0.1, OS X 10.3.8. Thanks in advance, Ken __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Passing colnames to graphics title
If i is 1:20, there are no column names. Make sure you are indexing the names from your your dataframe. xx - data.frame(a=c(1:10), b = letters[1:10]) colnames(xx) [1] a b for(i in 1:2) print(colnames(xx)[i]) [1] a [1] b for(i in colnames(xx)) print(i) [1] a [1] b Matt Austin Statistician Amgen One Amgen Center Drive M/S 24-2-C Thousand Oaks CA 93021 (805) 447 - 7431 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Laura Quinn Sent: Wednesday, February 16, 2005 6:47 AM To: Uwe Ligges Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Passing colnames to graphics title Obviously I have been trying to use the colnames() function! However, when I try to subscript ie: for(i in 1:20){ main=paste(Site:,colnames(i),sep=) } this doesn't work! I thought that as.character(colnames(i)) or substitute(colnames(i)) might work, but to no avail... Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] On Wed, 16 Feb 2005, Uwe Ligges wrote: Laura Quinn wrote: Hi, Just a quick query - if I'm creating a function to produce a number of histograms per page of output (one per column from a matrix), how can I pass the column name of the matrix into the title (or indeed to form part of the x-axis label)? By extracting them using colnames()? Uwe Ligges TIA, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Repeating grey scale in graph?
Aaaah...the inner workings of R! Now I also see why the colours are not only repeated, but also 'wrongly' allocated to the facets! Very clear example! Indeed a warning or error would have been more helpful! Cheers, Sander. PS: I hope that after all this, I can still convince the creator of the original data that it is a good idea to plot his graphs in R instead of excel. ;-) Duncan Murdoch wrote: On Wed, 16 Feb 2005 15:44:00 +0200, Sander Oom [EMAIL PROTECTED] wrote : Thanks Peter! Of course I only have (nx-1)(ny-1) facets in a x*y plot! The help page line: ... col the color(s) of the surface facets. Transparent colours are ignored. This is recycled to the (nx-1)(ny-1) facets. ... just did not ring a bell. In fact, it is still not clear to me why it recycles the ramp even though it has a surplus of colours (grey levels)! Why not just ignore the surplus colours? Your z array is 6 by 7. Your cols will be mapped to a 5 by 6 array. They don't look like an array, because the grey() function stripped off the dimension attribute. The problem is that if you pass the entries from a 6 by 7 array to something that expects the entries from a 5 by 6 array, you get things in the wrong order. You see the same effect here: rownum - as.vector(row(matrix(NA, 6, 7))) matrix(rownum, 6, 7) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,]1111111 [2,]2222222 [3,]3333333 [4,]4444444 [5,]5555555 [6,]6666666 matrix(rownum, 5, 6) [,1] [,2] [,3] [,4] [,5] [,6] [1,]165432 [2,]216543 [3,]321654 [4,]432165 [5,]543216 Warning message: data length [42] is not a sub-multiple or multiple of the number of rows [5] in matrix except that in this case you get a warning about the wrong length; persp doesn't give you the warning. Maybe it should? Duncan Murdoch -- - Dr. Sander P. Oom Animal, Plant and Environmental Sciences University of the Witwatersrand Private Bag 3 Wits 2050 South Africa Tel (work) +27 (0)11 717 64 04 Tel (home) +27 (0)18 297 44 51 Fax +27 (0)18 299 24 64 Email [EMAIL PROTECTED] Web www.oomvanlieshout.net/sander __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] (no subject)
use 'gsub' x - c('1,200.44', '23,345.66') gsub(',','',x) [1] 1200.44 23345.66 as.numeric(gsub(',','',x)) [1] 1200.44 23345.66 __ James HoltmanWhat is the problem you are trying to solve? Executive Technical Consultant -- Office of Technology, Convergys [EMAIL PROTECTED] +1 (513) 723-2929 Jim Gustafsson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent by: cc: [EMAIL PROTECTED]Subject: [R] (no subject) ath.ethz.ch 02/16/2005 09:08 R-people I wonder if one could change a list of table with number of the form 1,200.44 , to 1200.44 Regards JG -- This e-mail and any attachment may be confidential and may also be privileged. If you are not the intended recipient, please notify us immediately and then delete this e-mail and any attachment without retaining copies or disclosing the contents thereof to any other person. Thank you. -- [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Passing colnames to graphics title
Dear Laura, It doesn't make sense to call colnames() with the loop index; you could do something like (for the matrix or data frame X): par(mfrow=c(1, ncol(X))) names - colnames(X) for (i in seq(along=names)) hist(X[,i], main=, xlab=paste(Site:, names[i])) I hope this helps, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Laura Quinn Sent: Wednesday, February 16, 2005 9:47 AM To: Uwe Ligges Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Passing colnames to graphics title Obviously I have been trying to use the colnames() function! However, when I try to subscript ie: for(i in 1:20){ main=paste(Site:,colnames(i),sep=) } this doesn't work! I thought that as.character(colnames(i)) or substitute(colnames(i)) might work, but to no avail... Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] On Wed, 16 Feb 2005, Uwe Ligges wrote: Laura Quinn wrote: Hi, Just a quick query - if I'm creating a function to produce a number of histograms per page of output (one per column from a matrix), how can I pass the column name of the matrix into the title (or indeed to form part of the x-axis label)? By extracting them using colnames()? Uwe Ligges TIA, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Sampling given a table of percentages?
I have a vector V. sum(V) = 100, i.e. it's percentages. length(V) is large. I wish to generate samples (with replacement is fine), integers, in the range 1:length(V) who's distribution is driven by the distribution implied by the percentages in V.V is unsorted, but that could change. I'd rather not be too specific about the distribution of V.I can certainly solve the problem intersecting my thin knowledge of R with my skills in programming, but I suspect this is trivial to somebody fluent in R. Suggestions? Thanks! - ben http://enthusiasm.cozy.org/ -- blog tel:+1-781-240-2221 -- mobile, et.al. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] problem with da.mix
Hello, We use the mix package and we have a problem with the DA function. We aren't sure, but it's maybbe a memory problem. We have done: Ent--read.table(C:/.../File.txt) attach(Ent) Ent V1 V2 V3 V4 ... V16 V17 11 1 2 6 18 18 21 1 1 NA 14 17 31 1 2 1 16 14 199 2 1 NA 7 19 18 200 2 1 3 2 14 17 EntPrelim-prelim.mix(as.matrix(Ent),9) EntEM-em.mix(EntPrelim,maxits=500) rngseed(1234567) EntDA-da.mix(EntPrelim, EntEM, steps=100, showits=TRUE) Steps of data Augmentation: 1... Error in da.mix(EntPrelim, EntEM, steps=100; showits=TRUE): Improper posterior--empty cells If you know what is the matter, please help us. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] panel/prepanel for polar plots ala xYplot
First a bit of background: After doing a search for a flexible polar plot function and coming up empty, I have begun writing one myself. Since I am new to writing mid-level graphics routines, this has required some learning about lattice, grid and related things. I am to the point where I have a workable proof of concept, but still need to make some improvements. My goal is to have something akin to a polar version of xYplot. Although the particular plot I need requires some customization of that idea, the use of Cbind() has made that fairly easy. Now some questions: 1) What are the best sources of documentation for lattice/grid? I have found a few things by googling, but mostly I have been reverse engineering code and experimenting to figure out how things work. 2) What is the best way to generate axis and labels for them? Currently my radplot is a wrapper for xyplot that (a) turns off the axes and labels, and (b) calls xyplot with panel.radplot, prepanel.radplot, and radplot.superpose replacing the obvious things. I am generating the axes (concentric circles and peripheral labels) in panel.radplot, but this means that they are redrawn for each group when there is superposition. Furthermore, there seems to be some jittering, so besides inefficiency, the result is not crisp. How are axes generated in xyplot? To do this correctly will I have to go deeper and make a new version of trellis.skeleton or make a new call to it? If I put the code into prepanel.radplot will it be executed once per panel or once per group in each panel? 3) I'd be happy to receive any other suggestions for how to approach the design of a robust, formula-based (including xYplot-like options) radial/polar plot. I'd also be happy to hear of any packages that include something heading in this direction, if they exist and I just didn't locate them. Thanks in advance for any assistance. ---rjp PS. For the curioius, the plot I am designing has a function call like radplot(Cbind(y,ratio)~x|g, groups=h, ...) where y is numeric and x may be numeric or a factor. The resulting plot has spokes for each value of x with length y, the last 1 - min(ratio, 1/ratio) fraction of the spoke rendered differently. This is similar to adding error bars to a plot in xYplot -- only in polar coordinates. == Randall Pruim Dept. of Biostatistics, University of Michigan email: [EMAIL PROTECTED] phone: 734.615.9825 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Easy cut paste from Excel to R?
Thank you all very much for the answers! The read.table / read.delim2 commands are exactly what I was looking for to get a couple of numbers or a little matrix quickly into R without creating an extra text file every time. And it works the other way around as well: write.table(x, file(clipboard), sep=\t) Fantastic! Thanks again, Werner Nick Drew wrote: I've had good luck with the scan() function when I want to get a few numbers from Excel into R quickly to use it as a calculator. CAVEAT: you have to have the numbers you want to copy in a column not a row in Excel. For example: In Excel your data are in a column as follows: Col A 1 2 3 Then copy the 3 cells (e.g. 1, 2,3) in Excel and open R and type in: data - scan() Then Paste using Ctrl-V. Hit the Enter key. You know have an object called data that you can use and manipulate in R. I've taken this even further by creating an R function that will take a column of numbers from Excel and then scan() them into R, create a matrix, and then perform a Chi-square test. Let me know if you'd like to know more. I'm a beginner and if I can do so can you!! ~Nick __ Do you Yahoo!? http://promotions.yahoo.com/new_mail __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] about library(boot)
Dear Sir/Madam: I try to use the library boot to bootstrap the median of a data set. Can anybody tell me why this doesn't work? Thanks. library(boot) x=rnorm(100) boot(x,median,999) I know I can write a simple code for bootstrapping myself. but I am so curious to know why the above code does not work. F. Xuan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] glmm with negative binomial
On Wed, 16 Feb 2005, Brian Aukema wrote: At present, can generalized linear mixed models with negative binomial distribution and estimating the shape parameter be fit using R? I am aware of glm.nb but am wondering about incorporation of mixed effects. I am not aware of anyone who knows how to do that reasonably robustly. If the model were simple enough you might be able to do numerical integration well enough to get a likelihood to maximize, but we usually have enough trouble with a Poisson model (and our experiments seem to show that other people's software has much more trouble). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] (no subject)
Please remove me from the mailing list! __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Setting log(0) to 0
Thank you both of you, Kenneth and Ted:-). Log1p(x) is not what I asked for, but it is better:-D And Ted, thanks for your thoughts on funcional form. I'm just starting out with R, and feel like I've barely scratched the surface of the program. I have never in my life done a non-linear regression, but that will soon change:-) (Ted Harding) wrote: On 16-Feb-05 Terji Petersen wrote: Hi, I'm trying to do a regression like this: wage.r = lm( log(WAGE) ~ log(EXPER) where EXPER is an integer that goes from 0 to about 50. EXPER contains some zeros, so you can't take its log, and the above regression therefore fails. I would like to make R accept log(0) as 0, is that possible? Or do I have first have to turn the 0's into 1's to be able to do the above regression? If treating log(0) as 0 would do your business, then a preliminary pass to turn 0 into 1 would be the simplest method. It only takes 1 line. This is a bit of a Catch-22. It looks like you're trying to fit a power law WAGE = A*(EXPER^B) (where I guess EXPER means experience) and you've got some cases with no experience. Whether your work-round is appropriate depends in part on the unit of experience. If it's in years, then a case with 3 months experience would have log(EXPER) = -1.39, thereby weighing in with a lesser value than someone with zero experience, on your proposal. On the other hand, if it's in days, then log(EXPER) = log(91) = 4.51 and even someone with only a week has log(EXPER) = 1.95 But your log(0) = 0 data would be sitting there all the time, whatever the scale of EXPER, and so would have an influence on your regression which depended on this scale. You might have to consider using log(0) -- const where the const is such as to give reasonable results, given what comes out of the rest of the data (where EXPER0). The fundamental problem is that your power law predicts zero wage for zero experience, which is rarely the case. You might do better to try a non-linear fit WAGE = W0 + A*(EXPER^B) for which sort of thing there are several resources in R, perhaps the simplest being 'nls'. For what you have in your installed packages, try a help.search(nonlinear) Once you open this door, you can try perhaps more realistic non-linear models, including what can be found amongst the SS. (Self-Starting) models in nls -- have a look at what's listed by library(help=nls) as well as what is allowed according to ?nls. Such models would allow an initial (zero-experience) wage, perhaps not changing much for some time, then rising more rapidly once an experience threshold is passed, then flattening out to a lower slope over a longer time (something which many of us have experience of). And even ultimately ending to decrease ... Hoping this helps, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 16-Feb-05 Time: 13:26:53 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Passing colnames to graphics title
Either set the 'main' or 'xlab' in the hist(). See help(par) for more information on graphical arguments or help(hist). mat - matrix( rnorm(1000), nc=5 ) colnames(mat) - LETTERS[1:ncol(mat)] for( i in 1:ncol(mat) ){ hist( mat[ ,i], main=paste( Histogram of data from column , colnames(mat)[i] ), xlab= ) } On Wed, 2005-02-16 at 13:56 +, Laura Quinn wrote: Hi, Just a quick query - if I'm creating a function to produce a number of histograms per page of output (one per column from a matrix), how can I pass the column name of the matrix into the title (or indeed to form part of the x-axis label)? TIA, Laura Laura Quinn Institute of Atmospheric Science School of Earth and Environment University of Leeds Leeds LS2 9JT tel: +44 113 343 1596 fax: +44 113 343 6716 mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Re: histogram ... postscript - width of lines / plot margins
Thanks. You answer works well. But this time I get 2 problems: - because the region of plot is shorter then the default, the width of lines of plots is larger (see the two attached pictures .ps) and the lwd command don't deals with it; - the plot region contains big margins (the picture has 3x3 inches, but the plot uses only 2x2) The code: par(fin=c(3,3)) scores-c(2.0, 0.0, 5.0, 5.0, 5.0, 2.0, 0.0, 5.0, 2.5, 4.0, 5.0, 0.0, 5.0, 0.0, 2.0, 5.0, 5.0, 2.0, 3.0, 3.0) q-summary(scores) gra-hist(scores, breaks=((0:11)/2-.2), plot=FALSE) yy-ceiling(max(gra$counts)/10)*10 yz-yy/12 postscript(test.ps, width=3, height=3, horizontal=FALSE, family=Times, paper=special) hist(scores, breaks=((0:11)/2-.2), xlim=c(-1,6), ylim=c(-yz,yy), main=scores, ylab=Freq, xlab=math, cex.axis=.3, cex.main=.3, cex.sub=.3, cex.lab=.3, mgp=c(1.5,.5,0)) boxplot(scores, horizontal=1, add=1, at=-2*yz/3, boxwex=1.5*yz, bty=n, axes=FALSE) points(q[4], -2*yz/3, col=1, pch=+, cex=.5) dev.off() --- Uwe Ligges [EMAIL PROTECTED] escreveu: Cézar Freitas wrote: Hi, all. I need plot a boxplot under a histogram like below, but some configs are troubled: - the boxplot contours the plot, even if I put bty=n, modifying the histogram plot; You want to set axes = FALSE in boxplot() BTW: What is q[4] in your call to points()? Uwe Ligges - I changed the configs of axis to do a 3x3 inches plot, but the result is 2 different axis. For example, the code below ilustrates this... scores-c(2.0, 0.0, 5.0, 5.0, 5.0, 2.0, 0.0, 5.0, 2.5, 4.0, 5.0, 0.0, 5.0, 0.0, 2.0, 5.0, 5.0, 2.0, 3.0, 3.0) postscript(test.ps, width=3, height=3, horizontal=FALSE, family=Times, paper=special) gra-hist(scores, breaks=((0:11)/2-.2), xlim=c(-1,6), plot=FALSE, cex.axis=.5, cex.main=.5, cex.sub=.5, cex.lab=.5, mgp=c(1.5,.5,0)) yy-ceiling(max(gra$counts)/10)*10 hist(scores, breaks=((0:11)/2-.2), xlim=c(-1,6), ylim=c(0,yy), main=scores, ylab=Freq, xlab=math, cex.axis=.5, cex.main=.5, cex.sub=.5, cex.lab=.5, mgp=c(1.5,.5,0)) boxplot(scores, horizontal=1, add=1, at=-yy/50, boxwex=yy/20, bty=n, cex.axis=.5, cex.main=.5, cex.sub=.5, cex.lab=.5, ann=FALSE) points(q[4], -yy/50, col=1, pch=x, cex=.2) dev.off() Thanks, C. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html ___ via_postscript.ps Description: via_postscript.ps via_R.ps Description: via_R.ps __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Sampling given a table of percentages?
Wouldn't sample(length(V), prob=V) do? Andy From: Ben Hyde I have a vector V. sum(V) = 100, i.e. it's percentages. length(V) is large. I wish to generate samples (with replacement is fine), integers, in the range 1:length(V) who's distribution is driven by the distribution implied by the percentages in V.V is unsorted, but that could change. I'd rather not be too specific about the distribution of V.I can certainly solve the problem intersecting my thin knowledge of R with my skills in programming, but I suspect this is trivial to somebody fluent in R. Suggestions? Thanks! - ben http://enthusiasm.cozy.org/ -- blog tel:+1-781-240-2221 -- mobile, et.al. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] problem with se.contrast()
I am having trouble getting standard errors for contrasts using se.contrast() in what appears to be a simple case to me. The following test example illustrates my problem: Lab - factor(rep(c(1,2,3),each=12)) Material - factor(rep(c(A,B,C,D),each=3,times=3)) Measurement - c(12.20,12.28,12.16,15.51,15.02,15.29,18.14,18.08,18.21,18.54,18.36 ,18.45,12.59,12.30,12.67,14.98,15.46,15.22,18.54,18.31,18.60,19.21,18.77 ,18.69,12.72,12.78,12.66,15.33,15.19,15.24,18.00,18.15,17.93,18.88,18.12,18.03) testdata - data.frame(Lab,Material,Measurement) rm(list=c(Lab,Material,Measurement)) test.aov - with(testdata,aov(Measurement ~ Material + Error(Lab/Material))) This gives me the desired ANOVA table. I next want to get the standard errors for certain contrasts and following the help page for se.contrast() I tried the following but I get an error: se.contrast(test.aov,list(Material==A,Material==B,Material==C,Material==D),coef=c(1,1,-1,-1),data=testdata) Error in matrix(0, length(asgn), ncol(effects), dimnames = list(nm[1 + : length of dimnames [1] not equal to array extent I have tested this on R 2.0.1 on Windows XP and Solaris and get the same error on both systems. I am unsure as to what I am doing wrong here. Thanks for any help. Jamie Jarabek __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] running out of memory
Hi I am trying to do a large glm and running into this message. Error: cannot allocate vector of size 3725426 Kb In addition: Warning message: Reached total allocation of 494Mb: see help(memory.size) Am I simply out of memory (I only have .5 gig)? Is there something I can do? Stephen [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] panel/prepanel for polar plots ala xYplot
On Wednesday 16 February 2005 11:11, Randall Pruim wrote: First a bit of background: After doing a search for a flexible polar plot function and coming up empty, I have begun writing one myself. Since I am new to writing mid-level graphics routines, this has required some learning about lattice, grid and related things. I am to the point where I have a workable proof of concept, but still need to make some improvements. My goal is to have something akin to a polar version of xYplot. Although the particular plot I need requires some customization of that idea, the use of Cbind() has made that fairly easy. Now some questions: 1) What are the best sources of documentation for lattice/grid? I have found a few things by googling, but mostly I have been reverse engineering code and experimenting to figure out how things work. Why is the package documentation insufficient? There are some grid articles on Paul's website, and S-PLUS Trellis documentation mostly applies to lattice. 2) What is the best way to generate axis and labels for them? Currently my radplot is a wrapper for xyplot that (a) turns off the axes and labels, and (b) calls xyplot with panel.radplot, prepanel.radplot, and radplot.superpose replacing the obvious things. I am generating the axes (concentric circles and peripheral labels) in panel.radplot, but this means that they are redrawn for each group when there is superposition. Furthermore, there seems to be some jittering, so besides inefficiency, the result is not crisp. If you want something that's to be done once per panel and something else that's to be done once per group within panel, I would suggest you separate out the per-group part in a function and call that multiple times from your panel function. An example of this is panel.dotplot, which essentially looks like: function (x, y, levels.fos = unique(y), groups = NULL, ...) { panel.abline(h = levels.fos) if (is.null(groups)) panel.xyplot(x = x, y = y, ...) else panel.superpose(x = x, y = y, groups = groups, panel.groups = panel.xyplot, ...) } This ensures that the reference lines are drawn only once per panel (and not once per group, which would have overwritten the dots from earlier groups). How are axes generated in xyplot? In xyplot, the axes are generated separately from the panel function, because they are outside the panels (and the same axes are associated with multiple panels). It sounds like you want something similar to cloud, where the axes are part of each panel. In that case, your panel function needs to be responsible for drawing the axes. To do this correctly will I have to go deeper and make a new version of trellis.skeleton or make a new call to it? I don't see why. If I put the code into prepanel.radplot will it be executed once per panel or once per group in each panel? The prepanel function should absolutely not do any plotting. 3) I'd be happy to receive any other suggestions for how to approach the design of a robust, formula-based (including xYplot-like options) radial/polar plot. I'd also be happy to hear of any packages that include something heading in this direction, if they exist and I just didn't locate them. Thanks in advance for any assistance. ---rjp PS. For the curioius, the plot I am designing has a function call like radplot(Cbind(y,ratio)~x|g, groups=h, ...) where y is numeric and x may be numeric or a factor. The resulting plot has spokes for each value of x with length y, the last 1 - min(ratio, 1/ratio) fraction of the spoke rendered differently. This is similar to adding error bars to a plot in xYplot -- only in polar coordinates. == Randall Pruim Dept. of Biostatistics, University of Michigan email: [EMAIL PROTECTED] phone: 734.615.9825 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] intersection or == of date vectors
I have a vector of unique dates v1, and a vector of unique dates v2 (the vectors are of different lengths). How do I find out the count of elements that matches between the two vectors? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] problem with da.mix
On 16-Feb-05 [EMAIL PROTECTED] wrote: We use the mix package and we have a problem with the DA function. We aren't sure, but it's maybbe a memory problem. We have done: Ent--read.table(C:/.../File.txt) attach(Ent) Ent V1 V2 V3 V4 ... V16 V17 11 1 2 6 18 18 21 1 1 NA 14 17 31 1 2 1 16 14 199 2 1 NA 7 19 18 200 2 1 3 2 14 17 EntPrelim-prelim.mix(as.matrix(Ent),9) EntEM-em.mix(EntPrelim,maxits=500) rngseed(1234567) EntDA-da.mix(EntPrelim, EntEM, steps=100, showits=TRUE) Steps of data Augmentation: 1... Error in da.mix(EntPrelim, EntEM, steps=100; showits=TRUE): Improper posterior--empty cells Dear Stéphanie, This problem is closely related to the problem reported yesterday by Delphine Gille from your same institution: From: [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] memory problem with package mix Date: Tue, 15 Feb 2005 15:23:08 +0100 Hello, I think we have a memory problem with em.mix. We have done: library(mix) Manq - read.table(C:/.../file.txt) attach(Manq) Manq V1 V2 V3 V4 .V27 1 1 1 1 1... 2 1 NA 3 6 3 1 2 6 2 ... ... 300 2 NA 6 2... Essaimanq -prelim.mix(as.matrix(Manq),5) test - em.mix(Essaimanq) error cannot allocated vector of size 535808 KB in addition : warning message reached total allocation of 509MB The reason is almost certainly the same fact that I pointed out in my reply to Delphine: you have 9 categorical variables, each necessarily at at least 2 levels (and in your case at least one has =3 levels and at least one has =6 levels) so you have at least (2^7)*3*6 = 2304 cells (possibly many more, depending on the numbers of levels in the variables) in your unrestricted model for the categorical variables (as implied by your usage of em.mix and da.mix). With only 200 rows of data, there will (even if it is only 2304 cells) be at least 2104 of them empty (i.e. with no data falling in them). Therefore, given the improper Dirichlet prior which da.mix uses by default, you will almost certainly end up with an improper posterior distribution as a result of your many empty cells, which is just what your error message is telling you. With so few data, you need to severely restrict the level of interaction allowed for the categorical variables (and use ecm.mix instead of em.mix, dabipf.mix instead of da.mix). In the best possible case (7 variables at 2 levels, one at 3, one at 6) implied by your data excerpt above, you need 7 + 2 + 5 = 14 parameters at a minimum (no-interaction or complete-independence model). If you admit the first-order (2-factor) interactions as well, you need 84 parameters (I hope I have calculated this right!). Going to 2nd-order (3-factor) will surely take you over your data size of 200 (I haven't worked this one out: maybe there's a snappy R function for this sort of thing!). But if your variables have more levels than the minimum I have assumed (based on your data excerpt) then the situation will rapidly get much worse. Another approach might be to consider using an informative (proper) prior distribution for the Dirichlet probabilities, but unless you are very careful you risk adopting something which is not realistic for your problem. You can do this with both da.mix with em.mix (provided em.mix works with your sparse data, which it didn't for Delphine) and da.bipf.mix with ecm.mix. See also the explanations in ?da.mix and ?dabipf.mix, section Details, which refer to just the kind of problem you are having. Hoping this helps, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 16-Feb-05 Time: 20:37:15 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Sampling given a table of percentages?
yes but add 'replace=TRUE' into that statement to sample with replacement. On Wed, 2005-02-16 at 14:00 -0500, Liaw, Andy wrote: Wouldn't sample(length(V), prob=V) do? Andy From: Ben Hyde I have a vector V. sum(V) = 100, i.e. it's percentages. length(V) is large. I wish to generate samples (with replacement is fine), integers, in the range 1:length(V) who's distribution is driven by the distribution implied by the percentages in V.V is unsorted, but that could change. I'd rather not be too specific about the distribution of V.I can certainly solve the problem intersecting my thin knowledge of R with my skills in programming, but I suspect this is trivial to somebody fluent in R. Suggestions? Thanks! - ben http://enthusiasm.cozy.org/ -- blog tel:+1-781-240-2221 -- mobile, et.al. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] (no subject)
Jeff Knoblett [EMAIL PROTECTED] writes: Please remove me from the mailing list! Well, the list manager *might* remove you, *when* he gets back from his holiday, *if* he notices it and is in a good mood. If you want a quicker reaction, please use the web interface as indicated in the footer: https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] intersection or == of date vectors
length(intersect(v1,v2)) -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Omar Lakkis Sent: Wednesday, February 16, 2005 12:27 PM To: r-help@stat.math.ethz.ch Subject: [R] intersection or == of date vectors I have a vector of unique dates v1, and a vector of unique dates v2 (the vectors are of different lengths). How do I find out the count of elements that matches between the two vectors? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Positive log-likelihood in lme
Kia ora I'm a using lme (from nlme package) with data similar to the Orthodont dataset and am getting positive log-likelihoods (100). This seems usual and I wondered if someone could offer a possible explanation. I can supply a sample dataset if requested, but I feel almost certain that this question has been asked and answered recently. However, I can find no trace of it in the mail archives (although I have spent several hours reading lots of other interesting things :-)). Thanks . Peter Alspach __ The contents of this e-mail are privileged and/or confidenti...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] scaling axes when plotting multiple data sets
1) When adding additional data sets to a plot using plot followed by lines, is there a way to automate the scaling of the axes to allow for all data sets to fit within the plot area? 2) I attempted to solve this by setting xlim=c(min(c(data1,data2,data3)),max(c(data1,data2,data3))) however, there are some NAs and Infs in these data sets, and min(data1) and max(data1) both return NA, as with data2 and data3. (These are time series). Thank you, Ben Osborne -- Botany Department University of Vermont 109 Carrigan Drive Burlington, VT 05405 [EMAIL PROTECTED] phone: 802-656-0297 fax: 802-656-0440 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] about library(boot)
Dear Francisca, On Wed, 16 Feb 2005 11:28:24 -0500 Francisca xuan [EMAIL PROTECTED] wrote: Dear Sir/Madam: I try to use the library boot to bootstrap the median of a data set. Can anybody tell me why this doesn't work? Thanks. library(boot) x=rnorm(100) boot(x,median,999) I know I can write a simple code for bootstrapping myself. but I am so curious to know why the above code does not work. Take a closer look at ?boot: The function that computes the statistic that you're bootstrapping (in a simple situation like this) should take two arguments -- the data and an index vector. Thus, boot.median - function(x, i) median(x[i]) result - boot(x, boot.median, 999) I hope this helps, John __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Positive log-likelihood in lme
The likelihood is the probability density function, which can be greater than 1 for continuous distributions with a fairly narrow spread. For discrete distributions, the density never exceeds 1, in which case the log(likelihood) would always be negative(*). hope this helps. spencer graves (*) If you are using measure-theoretic probability with some non-standard measure, it might be possible to get a discrete probability density greater than 1. One might want to use such as a class exercise, but I can't think of a real world application for such. Peter Alspach wrote: Kia ora I'm a using lme (from nlme package) with data similar to the Orthodont dataset and am getting positive log-likelihoods (100). This seems usual and I wondered if someone could offer a possible explanation. I can supply a sample dataset if requested, but I feel almost certain that this question has been asked and answered recently. However, I can find no trace of it in the mail archives (although I have spent several hours reading lots of other interesting things :-)). Thanks . Peter Alspach __ The contents of this e-mail are privileged and/or confidenti...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Positive log-likelihood in lme
Hi Peter, Why do you think positive log-likelihoods are unusual? consider: dnorm(1,1,0.1) [1] 3.989423 log(dnorm(1,1,0.1)) [1] 1.383647 Any log-likelihood would be a sum of such terms. Hth, ingmar On 2/16/05 11:02 PM, Peter Alspach [EMAIL PROTECTED] wrote: Kia ora I'm a using lme (from nlme package) with data similar to the Orthodont dataset and am getting positive log-likelihoods (100). This seems usual and I wondered if someone could offer a possible explanation. I can supply a sample dataset if requested, but I feel almost certain that this question has been asked and answered recently. However, I can find no trace of it in the mail archives (although I have spent several hours reading lots of other interesting things :-)). Thanks . Peter Alspach __ The contents of this e-mail are privileged and/or confidenti...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Ingmar Visser Roetersstraat 15 1018 WB Amsterdam The Netherlands [EMAIL PROTECTED] http://users.fmg.uva.nl/ivisser/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] scaling axes when plotting multiple data sets
Dear Ben, On Wed, 16 Feb 2005 17:04:13 -0500 Benjamin M. Osborne [EMAIL PROTECTED] wrote: 1) When adding additional data sets to a plot using plot followed by lines, is there a way to automate the scaling of the axes to allow for all data sets to fit within the plot area? Not, to my knowledge, after the fact. 2) I attempted to solve this by setting xlim=c(min(c(data1,data2,data3)),max(c(data1,data2,data3))) however, there are some NAs and Infs in these data sets, and min(data1) and max(data1) both return NA, as with data2 and data3. (These are time series). Specifying, e.g., min(data1, data2, data3, na.rm=TRUE) will get rid of the NAs, but it's not obvious that Infs should be removed, since if one is present, shouldn't max be Inf? If you want to get rid of the Infs, however, you could change them into NAs, as in data1[data1 == Inf] - NA, and proceed as above. I hope this helps, John Thank you, Ben Osborne -- Botany Department University of Vermont 109 Carrigan Drive Burlington, VT 05405 [EMAIL PROTECTED] phone: 802-656-0297 fax: 802-656-0440 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] scaling axes when plotting multiple data sets
I just did ?min and found an argument na.rm, which when TRUE causes min to ignore NAs. Also, See Also for ?min mentions range, which returns a 2-vector consisting of both min and max. The function range also accepts the na.rm argument. AND the documentation for range includes a simple example that seems to demonstrate exactly what you are requesting here. hope this helps. spencer graves Benjamin M. Osborne wrote: 1) When adding additional data sets to a plot using plot followed by lines, is there a way to automate the scaling of the axes to allow for all data sets to fit within the plot area? 2) I attempted to solve this by setting xlim=c(min(c(data1,data2,data3)),max(c(data1,data2,data3))) however, there are some NAs and Infs in these data sets, and min(data1) and max(data1) both return NA, as with data2 and data3. (These are time series). Thank you, Ben Osborne __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Unable to create histograms
Hi, could someone pelase help me with this? My data set's name is db1(say) and one of the variables is var1. I gave the command: hist(db1$var1). The values of Var1 are numbers. I got an error which says: 'x' must be numeric. Sometimes it works for other datasets and it's not working for this dataset. Also, does R let us import data from an excel spreadhsheet? Thanks, Radha __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Unable to create histograms
Are you sure it's numeric? Have you looked at the following: class(db1$var1) Do you mean hist(db1$Var1)? R is case sensitive. Importing data from an Excel spreadsheet was discussed earlier today on this list. My favorite, contributed by Gabor Grothendieck, was to select what you want in Excel, then Copy, then use the following in R: read.delim2(clipboard, header = FALSE) Werner Wernersen then reported that it works the other way around as well: write.table(x, file(clipboard), sep=\t) hope this helps. spencer graves Radha Chebolu wrote: Hi, could someone pelase help me with this? My data set's name is db1(say) and one of the variables is var1. I gave the command: hist(db1$var1). The values of Var1 are numbers. I got an error which says: 'x' must be numeric. Sometimes it works for other datasets and it's not working for this dataset. Also, does R let us import data from an excel spreadhsheet? Thanks, Radha __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] (no subject)
On 16-Feb-05 Peter Dalgaard wrote: Well, the list manager *might* remove you, *when* he gets back from his holiday, *if* he notices it and is in a good mood. If you want a quicker reaction, please use the web interface as indicated in the footer: Error: syntax error (: use *and* :) Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 16-Feb-05 Time: 22:06:58 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] scaling axes when plotting multiple data sets
Benjamin M. Osborne Benjamin.Osborne at uvm.edu writes: : : 1) When adding additional data sets to a plot using plot followed by lines, : is there a way to automate the scaling of the axes to allow for all data sets : to fit within the plot area? : : 2) I attempted to solve this by setting : xlim=c(min(c(data1,data2,data3)),max(c(data1,data2,data3))) : however, there are some NAs and Infs in these data sets, and min(data1) and : max(data1) both return NA, as with data2 and data3. (These are time series). Any of the following solutions would avoid having to calculate maximum and minimum in the first place: 1. You can first plot all the data together using type = n (no points are actually shown) and then add them one by one plot(c(x1,x2), c(y1,y2), type = n) lines(x1, y1) lines(x2, y2) 2. you may be able to use matplot. See ?matplot . 3. if these are 'ts' class time series you could plot them all at once using ts.plot even if they have different time bases. See ?ts.plot 4. the 'zoo' library's plot function has facilities for plotting multiple time series all at once even if they have different time bases. Seelibrary(zoo); ?plot.zoo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Multiple Fstats/breakpoints test using Panel data
Hi, I have recently use the strucchange package in R with a single time series observation. I found it extremely useful in the testing of change points. Now, I am thinking of using the strucchange package with panel data (about 500 firms, with 73 monthly time series observations each). For each firm, I have to conduct the Fstats and breakpoints tests. Based on the test of each firm, I have to output a table/histogram with the number of times each SupF test is significant and the frequency that a breakpoint is observed in each of the 73 months. In summary, I have to conduct the Fstats/breakpoint test 500 times and summarize the results. I have the 500 firms with 73 observations (approx 36,500 observations) stacked in one data file. Is there anyone who can help mw with this? Warm Regards, Yen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Adding new column to data frame and filling some rows of it - classes
Hello! Few days ago I was asking on a list about adding a column and filling it in some rows. I was satisfied, but one thing raised my attention. I will show itthrough an example: tmp - data.frame(y1=1:4, f1=factor(c(A, B, C, D))) f2 - factor(c(Z, Y)) # I would like to add f2 to tmp and I know that values in f2 fit to # first two values in tmp. I used tmp$f2 - NA tmp[1:2, f2] - f2 tmp y1 f1 f2 1 1 A 2 2 2 B 1 3 3 C NA 4 4 D NA # However tmp$f2 is not factor. How can I make it to be a factor? I tried # with class(tmp$f2) - factor # but I get this tmp y1 f1 f2 1 1 A NULL 2 2 B NA 3 3 C NA 4 4 D NA Warning message: corrupt data frame: columns will be truncated or padded with NAs in: format.data.frame(x, digits = digits) # I tried the other approach tmp - data.frame(y1=1:4, f1=factor(c(A, B, C, D))) f2 - factor(c(Z, Y)) tmp$f2 - f2 tmp[3:4, f2] - NA tmp y1 f1 f2 1 1 AZ 2 2 BY 3 3 C NA 4 4 D NA class(tmp$f2) [1] factor # And I have now the same class for tmp$f2 as in f2. Is this the # only way? -- Lep pozdrav / With regards, Gregor GORJANC --- University of Ljubljana Biotechnical Faculty URI: http://www.bfro.uni-lj.si Zootechnical Departmentemail: gregor.gorjanc at bfro.uni-lj.si Groblje 3 tel: +386 (0)1 72 17 861 SI-1230 Domzalefax: +386 (0)1 72 17 888 Slovenia __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Adding new column to data frame and filling some rows of it - classes
Gorjanc Gregor Gregor.Gorjanc at bfro.uni-lj.si writes: : Few days ago I was asking on a list about adding a column and filling : it in some rows. I was satisfied, but one thing raised my attention. I : will show itthrough an example: : : tmp - data.frame(y1=1:4, f1=factor(c(A, B, C, D))) : f2 - factor(c(Z, Y)) : : # I would like to add f2 to tmp and I know that values in f2 fit to : # first two values in tmp. I used : : tmp$f2 - NA : tmp[1:2, f2] - f2 : tmp : y1 f1 f2 : 1 1 A 2 : 2 2 B 1 : 3 3 C NA : 4 4 D NA : : # However tmp$f2 is not factor. How can I make it to be a factor? I tried : # with : class(tmp$f2) - factor : : # but I get this : tmp : y1 f1 f2 : 1 1 A NULL : 2 2 B NA : 3 3 C NA : 4 4 D NA : Warning message: : corrupt data frame: columns will be truncated or padded with NAs in: format.data.frame(x, digits = : digits) : : # I tried the other approach : tmp - data.frame(y1=1:4, f1=factor(c(A, B, C, D))) : f2 - factor(c(Z, Y)) : tmp$f2 - f2 : tmp[3:4, f2] - NA : tmp : y1 f1 f2 : 1 1 AZ : 2 2 BY : 3 3 C NA : 4 4 D NA : : class(tmp$f2) : [1] factor : : # And I have now the same class for tmp$f2 as in f2. Is this the : # only way? Here are a few possibilities: R # 1 R R tmp - data.frame(y1=1:4, f1=factor(c(A, B, C, D))) R f2 - factor(c(Z, Y)) R R length(f2) - nrow(tmp) R tmp$f2 - f2 R tmp y1 f1 f2 1 1 AZ 2 2 BY 3 3 C NA 4 4 D NA R R # 2 R R tmp - data.frame(y1=1:4, f1=factor(c(A, B, C, D))) R f2 - factor(c(Z, Y)) R R tmp$f2 - factor(NA, levels = levels(f2)) R tmp[seq(along = f2),f2] - f2 R tmp y1 f1 f2 1 1 AZ 2 2 BY 3 3 C NA 4 4 D NA R R # 3 R R tmp - data.frame(y1=1:4, f1=factor(c(A, B, C, D))) R f2 - factor(c(Z, Y)) R R merge(tmp, list(f2 = f2), by = 0, all.x = TRUE) Row.names y1 f1 f2 1 1 1 AZ 2 2 2 BY 3 3 3 C NA 4 4 4 D NA --- Here is just the input: # 1 tmp - data.frame(y1=1:4, f1=factor(c(A, B, C, D))) f2 - factor(c(Z, Y)) length(f2) - nrow(tmp) tmp$f2 - f2 tmp # 2 tmp - data.frame(y1=1:4, f1=factor(c(A, B, C, D))) f2 - factor(c(Z, Y)) tmp$f2 - factor(NA, levels = levels(f2)) tmp[seq(along = f2),f2] - f2 tmp # 3 tmp - data.frame(y1=1:4, f1=factor(c(A, B, C, D))) f2 - factor(c(Z, Y)) merge(tmp, list(f2 = f2), by = 0, all.x = TRUE) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] socket problems (maybe bugs?)
Dear R Gurus, for some purpose i have to use a socket connection, where i have to read and write both text and binary data (each binary data package will be preceeded by a header line). When experimenting, i encountered some problems (with R-2.0.1 under different Linuxes (SuSE and Gentoo)). Since the default mode for socket connections is non-blocking, i first tried socketSelect() in order to see whether the socket is ready for reading: # Server: s - socketConnection(port=, server=TRUE, open=w+b) writeLines(test, s) writeBin(1:10, s, size=4, endian=big) # Client, variation 1: s - socketConnection(port=, server=FALSE, open=w+b) socketSelect(list(s)) readLines(s, n=1) # works, test is read socketSelect(list(s)) # does never return, although the server wrote 1:10 (This seems to happen only, when i mix text and binary reads.) However, without socketSelect(), R may crash if i try to read from an empty socket: Server: s - socketConnection(port=, server=TRUE, open=w+b) writeLines(test, s) writeBin(1:10, s, size=4, endian=big) # Client, variation 2: s - socketConnection(port=, server=FALSE, open=w+b) readLines(s, n=1) # works, test is read readBin(s, int, size=4, n=10, endian=big) # works, 1:10 is read readBin(s, int, size=4, n=10, endian=big) # second read leads to # segmentation fault If i omit the endian=big option, the second read does not crash, but just gets 10 random numbers. On the first view, this does not seem to be a problem, since the data will be preeceded by a header, which contains the number of bytes in the binary block. However, due to race conditions, i cannot exclude this situation: timeserver client t0 sends header t1 reads header t2 tries to read binary, crashes t3 sends binary If i open the client socket in blocking mode, the second variation seems to work (the second read just blocks as desired). When using only one socket, i can do without socketSelect(), but i have the follwoing questions: 1. Can i be sure, the the blocking variation will also work for larger data sets, when e.g. the server starts writing before the client is reading? 2. How could i proceed, if i needed several sockets? Then i cannot use socketSelect due to the problem described in variation 1. I also cannot use blocking sockets, since reading from an empty socket would block the others. Without blocking and socketSelect(), i might run into the race condition described above. In any case, the readBin() crash with endian=big is a bug in my eyes. For non-blocking sockets, readBin() should just return numeric(0), if no data are written on the socket. I also stronlgy suspect that the socketSelect() behaviour as described in variation 1 is a bug. Christian :-( __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to upgrade library from R 1.9.1 to R 2.0.1
Dear All: I have a library for R 1.9.1, it is very easy to setup a library in R 1.9.1. For example: I want to setup a library test for R1.9.1. 1. Create a folder test in the direct X:\ R\ rw1091\ library \. 2. Create a file DESCRIPTION in the direct X:\ R\ rw1091\ library\ test\. 3. Modify the Package: and Title: item to test in the file DESCRIPTION . 4.Create a folder R in the direct X:\ R\ rw1091\ library\ test\ . 5.Create a file test in the direct X:\ R\ rw1091\ library\ test\ R\ . 6. Add all the function into the test file. Then I can call the test using command library (test) . I setup the library using the same way in R2.0.1, but the library can't work. The error message is Error in library(test) : 'test' is not a valid package -- installed 2.0.0? I search the help file and document but still can't upgrade the library. Who can tell me how to upgrade library from R 1.9.1 to R 2.0.1 or give me a sample, thanks. Best Regards YiYao Jiang Product Division/ Product Testing Department Semiconductor Manufacturing International Corporation 18 ZhangJiang Road, PuDong New Area, Shanghai ZIP: 201203 Tel:86-21-5080-2000 Ext. 15173 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to upgrade library from R 1.9.1 to R 2.0.1
YiYao_Jiang YiYao_Jiang at smics.com writes: : : Dear All: : : I have a library for R 1.9.1, it is very easy to setup a library in R 1.9.1. : For example: : I want to setup a library test for R1.9.1. : 1. Create a folder test in the direct X:\ R\ rw1091\ library \. : 2. Create a file DESCRIPTION in the direct X:\ R\ rw1091\ library\ test\. : 3. Modify the Package: and Title: item to test in the file DESCRIPTION . : 4.Create a folder R in the direct X:\ R\ rw1091\ library\ test\ . : 5.Create a file test in the direct X:\ R\ rw1091\ library\ test\ R\ . : 6. Add all the function into the test file. : Then I can call the test using command library (test) . : I setup the library using the same way in R2.0.1, but the library can't work. : The error message is Error in library(test) : 'test' is not a valid package -- installed 2.0.0? : I search the help file and document but still can't upgrade the library. : Who can tell me how to upgrade library from R 1.9.1 to R 2.0.1 or give me a sample, thanks. I assume you are referring to a package that you wrote and want to upgrade. I think there may be confusion here between the source and installed package. The source package is what you wrote and it should _not_ go into \R\rw2001\library\test.Lets say we put that in \Rpkgs\test . Then, assuming you just installed R 2.0.1, use the Rcmd.exe program to install the source package into your R tree. cd \Rpkgs \R\rw2001\bin\Rcmd install test to install it. Fix up any errors you get during the install and repeat until it installs. Now go into R and test it out. If it seems to work try running 'Rcmd check' on it: cd \Rpkgs \R\rw2001\bin\Rcmd check test and fix up any errors and repeat until it passes Rcmd check and reinstall. See the Writing Extensions Manual if the above is not sufficient. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Error in eval(expr, envir, enclos) : numeric envir arg not of length one
I am working with a largish dataset of 25k lines and I am now tying to use predict. pred = predict(cuDataGlmModel, length + meanPitch + minimumPitch + maximumPitch + meanF1 + meanF2 + meanF3 + meanF4 + meanF5 + ratioF1ToF2 + rationF3ToF1 + jitter + shimmer + percentUnvoicedFrames + numberOfVoiceBreaks + percentOfVoiceBreaks + meanIntensity + minimumIntensity + maximumIntensity + ratioIntensity + noSyllsIntensity + startSpeech + syllables) I keep on getting this error message Error in eval(expr, envir, enclos) : numeric envir arg not of length one To be quite frank I am at a bit of a loss to know where to start looking to solve the problem. Any help most welcome. Stephen [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] running out of memory
Stephen Choularton wrote: Hi I am trying to do a large glm and running into this message. Error: cannot allocate vector of size 3725426 Kb In addition: Warning message: Reached total allocation of 494Mb: see help(memory.size) Am I simply out of memory (I only have .5 gig)? Is there something I can do? You have to rethink whether the analyses you are doing is sensible this way, or whether you can respecify things. R claims to need almost 4Gb(!) for the next memory allocation step, so you will get in trouble even on huge machines Uwe Ligges Stephen [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html