Re: [R] Boxplot- input the median point and the median value
On 01/02/2010 12:53 PM, elaine kuo wrote: Dear, I am a newbie to R. Now I am learning to draw boxplot using graphics(). I want to highlight the median position with a round point and the value left (or on the top of)to the point. Hi Elaine, For your boxplot questions, I'll use the first example from the boxplot help page: boxplot(count ~ spray, data = InsectSprays, col = lightgray,yaxt=n) axis(2,c(2,8,14,20),c(2,8,14,20)) For the dotted to solid question: boxplot_info-boxplot(count ~ spray, data = InsectSprays,col = lightgray) segments(rep(1:6,each=2),boxplot_info$stats[c(1,4),], rep(1:6,each=2),boxplot_info$stats[c(2,5),]) And finally, for the median value question: boxplot_info-boxplot(count ~ spray, data = InsectSprays, col = lightgray) points(1:6,boxplot_info$stats[3,]) text(1:6,boxplot_info$stats[3,]+1,boxplot_info$stats[3,]) A bit messy, but you get the idea. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use read.table with Hebrew column names ?
Hi David, Thank you for responding, but it didn't work. I get the following error: [1] X. 0 rows (or 0-length row.names) Warning messages: 1: In read.table(http://www.talgalili.com/files/aa.txt;, header = T, : invalid input found on input connection ' http://www.talgalili.com/files/aa.txt' 2: In read.table(http://www.talgalili.com/files/aa.txt;, header = T, : incomplete final line found by readTableHeader on ' http://www.talgalili.com/files/aa.txt' My OS is: PC - windows XP SP2 My session info is: R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices datasets tcltk utils methods base other attached packages: [1] rcom_2.2-1 rscproxy_1.3-1 svSocket_0.9-43 svMisc_0.9-48 TinnR_1.0.3 R2HTML_1.59-1 [7] Hmisc_3.6-0 loaded via a namespace (and not attached): [1] cluster_1.12.0 grid_2.9.1 lattice_0.17-25 tools_2.9.1 I would like to emphasis that my question was posed to me by several R users here in Israel, so the solution to which is sought out here by more then just me :) Thanks all, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com/ (English) -- On Sat, Jan 2, 2010 at 12:49 AM, David Winsemius dwinsem...@comcast.netwrote: You might try: read.table(http://www.talgalili.com/files/aa.txt;, header = T, fileEncoding = UTF-8, sep = \t) -- David. On Jan 1, 2010, at 5:37 PM, Tal Galili wrote: Hi Jorge, Thank you for the answer, it is a lead. Though I am unsure as to what to do next with it :) Here is my session info: sessionInfo() R version 2.9.1 (2009-06-26) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices datasets tcltk utils methods [8] base other attached packages: [1] rcom_2.2-1 rscproxy_1.3-1 svSocket_0.9-43 svMisc_0.9-48 [5] TinnR_1.0.3 R2HTML_1.59-1 Hmisc_3.6-0 loaded via a namespace (and not attached): [1] cluster_1.12.0 grid_2.9.1 lattice_0.17-25 tools_2.9.1 Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com/ (English) -- On Sat, Jan 2, 2010 at 12:29 AM, Jorge Ivan Velez jorgeivanve...@gmail.comwrote: Hi Tal, I am not even sure what is going on, but I think it is OS specific. When I run your script on a Mac, I got the desired result: read.table(http://www.talgalili.com/files/aa.txt;, header = T, sep = \t) ××ת שת××× ×©××ש 1 12976 2 123 354 44 3 6 13 This is the sessionInfo(): R version 2.10.1 (2009-12-14) x86_64-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base When doing the same on a PC via virtual machines on the same Mac, I got: read.table(http://www.talgalili.com/files/aa.txt;, header = T, sep = \t, as.is = TRUE) X.ª X...ª.. X...Å 1 12 97 6 2 123 35444 3 6 1 3 Here is the sessionInfo(): R version 2.10.1 Patched (2009-12-21 r50814) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base HTH, Jorge On Fri, Jan 1, 2010 at 4:47 PM, Tal Galili wrote: Hello dear R help group, I am trying to read a .txt file, with Hebrew column names, while keeping the column names looking well in R - but without success. I uploaded an example file to: http://www.talgalili.com/files/aa.txt And am trying the command: read.table(http://www.talgalili.com/files/aa.txt;, header = T, sep = \t) This returns me with: X.ª X...ª.. X...Å 1 12 97 6 2 123 35444 3 6 1 3 Instead of: ××ת שת××× ×©××ש 12 97 6 123 354 44 6 1 3
[R] [Off-topic] problem with Tinn-R editor
This is not directly related with R however I would like to ask for a solution for my TINN-R editor because, I feel that lot many people perhaps use it as a reliable R editor and secondly I could not find any other forum only deals with TINN over net to discuss with. For quite sometime I have been using Tinn-R as an editor for R-code however for some days I am noticing a strange problem on that, I cannot edit anything after typing something there, specially 'back-space' is not working at all. I feel, perhaps I have changed some default setting unintentionally which creates that pinching. Would anyone guide me how to get rid from that? Your help will be highly appreciated. Thanks, -- View this message in context: http://n4.nabble.com/Off-topic-problem-with-Tinn-R-editor-tp997185p997185.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Run R in server web
Colleagues, I have a web server (appache Tomcat), and my web application (java-jsp..) run on it, how i can run R on server example, i want running R on server, and save output on server Thanks -- View this message in context: http://n4.nabble.com/Run-R-in-server-web-tp997126p997126.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using optim
On 01/01/2010 11:45 PM, Erin Hodgess wrote: Dear R People: I know that you can use optim for a function with several parameters. Is there an equivalent for 2 functions, please? Or should I put together a finite difference type of matrix, etc., please? What is the goal? optim optimizes a scalar value. If you have a length 2 vector to optimize, what does that mean? Duncan Murdoch Thanks, Happy New Year, Erin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] suppress output for meta in package tm
Can you wrap your call in capture.output(..., file=...)? -Peter Ehlers Amber Jaycocks wrote: Hello, I am using the tm package and wish to suppress the output for meta. I am defining another variable for one of the tags and don't want the value printed on the screen. Any help would be appreciated. Thanks. here is the commnad: n_corp_file - meta(corpa[[n]], URI) -Amber [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Ehlers University of Calgary 403.202.3921 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] to discriminate AUC of different models
Hello Elaine, Time to learn about search facilities: RSiteSearch(AUC, restrict=functions) #too many hits? RSiteSearch(DeLong, restrict=functions) -Peter Ehlers elaine kuo wrote: Dear, Regarding the methodology comparing the power of AUC generated by differernt models, please kindly suggest any R code available for the function. (similar to DeLong, DeLong, and Clarke-Pearson (1988) ) Thank you very much. Elaine [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Ehlers University of Calgary 403.202.3921 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using optim
Duncan Murdoch wrote: On 01/01/2010 11:45 PM, Erin Hodgess wrote: Dear R People: I know that you can use optim for a function with several parameters. Is there an equivalent for 2 functions, please? Or should I put together a finite difference type of matrix, etc., please? What is the goal? optim optimizes a scalar value. If you have a length 2 vector to optimize, what does that mean? Just a guess: If you want to optimize a 2 dim vector, you are probably doing some multi criterial optimization and you are looking for pareto optimality, right? In that case, you might be interested in package mco for Multi criteria optimization algorithms and related functions Best wishes, Uwe Duncan Murdoch Thanks, Happy New Year, Erin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Question on Reduce + rollmean
Hello useRs, I'd like to perform a moving average on the dataset, xx. I've tried combining the functions Reduce and rollmean but it didn't work. r - function(n) rollmean(n, 2) # where 2 = averaging interval output - Reduce(r, x) Error in f(init, x[[i]]) : unused argument(s) (x[[i]]) Is there anything wrong with the code in the first place? where x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 The moving average is to be performed on 1,4,7 = (1+4)/2 , (4+7)/2 2,5,8 = .. 3,6,9 = .. Thanks Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on Reduce + rollmean
Dear M.Rahiz, Unfortunatelly I can't reproduce your example. PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html bests milton On Sat, Jan 2, 2010 at 9:26 AM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk wrote: Hello useRs, I'd like to perform a moving average on the dataset, xx. I've tried combining the functions Reduce and rollmean but it didn't work. r - function(n) rollmean(n, 2) # where 2 = averaging interval output - Reduce(r, x) Error in f(init, x[[i]]) : unused argument(s) (x[[i]]) Is there anything wrong with the code in the first place? where x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 The moving average is to be performed on 1,4,7 = (1+4)/2 , (4+7)/2 2,5,8 = .. 3,6,9 = .. Thanks Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on Reduce + rollmean
Let me rephrase; Given x as x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 I'd like to calculate the moving average (interval = 2) i.e. ( x[[1]] + x[[2]] ) / 2 ( x[[2]] + x[[3]] ) / 2 ... and so on. The desired output will return 2.5 2.5 2.5 3.5 3.5 3.5 4.5 4.5 4.5 5.5 5.5 5.5 6.5 6.5 6.5 7.5 7.5 7.5 Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk milton ruser wrote: Dear M.Rahiz, Unfortunatelly I can't reproduce your example. PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html bests milton On Sat, Jan 2, 2010 at 9:26 AM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.ukmailto:muhammad.ra...@ouce.ox.ac.uk wrote: Hello useRs, I'd like to perform a moving average on the dataset, xx. I've tried combining the functions Reduce and rollmean but it didn't work. r - function(n) rollmean(n, 2) # where 2 = averaging interval output - Reduce(r, x) Error in f(init, x[[i]]) : unused argument(s) (x[[i]]) Is there anything wrong with the code in the first place? where x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 The moving average is to be performed on 1,4,7 = (1+4)/2 , (4+7)/2 2,5,8 = .. 3,6,9 = .. Thanks Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.ukmailto:muhammad.ra...@ouce.ox.ac.uk __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] scatterplot matrix question
I would like a scatterplot matrix and a correlation matrix for the following set-up. The data (dataframe d) are like this: angle resp -90 182 -60 137 -30 ...etc 0 30 60 90 ...etc I would like each cell in the matrix to be the scatterplot of the responses for each pair of angles ( -90 vs -60, -90 vs -30, etc). Same for the correlation matrix. Please tell me what to do. Thanks very much! Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Regexp: extract first occurrence of date in string
I would like to extract first date from a string: txt - first date is 05.12.2009. Second date is 06.12.2009. txt [1] first date is 05.12.2009. Second date is 06.12.2009. I tried: sub(^.*?\\s(\\d{1,2}\\.\\d{1,2}\\.\\d{4}), \\1, txt, extended=T, perl=T) [1] 05.12.2009. Second date is 06.12.2009. How to modify this? -J __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on Reduce + rollmean
Try apply: library(zoo) # rollmean # test data m - matrix(1:3, 3, 3) x - list(m, m+3, m+6) # convert to array a - array(unlist(x), c(3, 3, 3)); a # apply rollmean and permute to desired form aa - apply(a, 1:2, rollmean, k = 2) aperm(aa, c(2, 3, 1)) The last line outputs: aperm(aa, c(2, 3, 1)) , , 1 [,1] [,2] [,3] [1,] 2.5 2.5 2.5 [2,] 3.5 3.5 3.5 [3,] 4.5 4.5 4.5 , , 2 [,1] [,2] [,3] [1,] 5.5 5.5 5.5 [2,] 6.5 6.5 6.5 [3,] 7.5 7.5 7.5 On Sat, Jan 2, 2010 at 10:00 AM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.uk wrote: Let me rephrase; Given x as x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 I'd like to calculate the moving average (interval = 2) i.e. ( x[[1]] + x[[2]] ) / 2 ( x[[2]] + x[[3]] ) / 2 ... and so on. The desired output will return 2.5 2.5 2.5 3.5 3.5 3.5 4.5 4.5 4.5 5.5 5.5 5.5 6.5 6.5 6.5 7.5 7.5 7.5 Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.uk milton ruser wrote: Dear M.Rahiz, Unfortunatelly I can't reproduce your example. PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html bests milton On Sat, Jan 2, 2010 at 9:26 AM, Muhammad Rahiz muhammad.ra...@ouce.ox.ac.ukmailto:muhammad.ra...@ouce.ox.ac.uk wrote: Hello useRs, I'd like to perform a moving average on the dataset, xx. I've tried combining the functions Reduce and rollmean but it didn't work. r - function(n) rollmean(n, 2) # where 2 = averaging interval output - Reduce(r, x) Error in f(init, x[[i]]) : unused argument(s) (x[[i]]) Is there anything wrong with the code in the first place? where x [[1]] V1 V2 V3 [1,] 1 1 1 [2,] 2 2 2 [3,] 3 3 3 [[2]] V1 V2 V3 [1,] 4 4 4 [2,] 5 5 5 [3,] 6 6 6 [[3]] V1 V2 V3 [1,] 7 7 7 [2,] 8 8 8 [3,] 9 9 9 The moving average is to be performed on 1,4,7 = (1+4)/2 , (4+7)/2 2,5,8 = .. 3,6,9 = .. Thanks Muhammad -- Muhammad Rahiz | Doctoral Student in Regional Climate Modeling Climate Research Laboratory, School of Geography the Environment Oxford University Centre for the Environment, University of Oxford South Parks Road, Oxford, OX1 3QY, United Kingdom Tel: +44 (0)1865-285194 Mobile: +44 (0)7854-625974 Email: muhammad.ra...@ouce.ox.ac.ukmailto:muhammad.ra...@ouce.ox.ac.uk __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Regexp: extract first occurrence of date in string
Try this which uses a slightly simpler regexp: library(gsubfn) strapply(txt, (\\d{1,2}\\.\\d{1,2}\\.\\d{4}).*)[[1]] [1] 05.12.2009 or we could convert it to Date class at the same time where we have assumed month.day.year: strapply(txt, (\\d{1,2}\\.\\d{1,2}\\.\\d{4}).*, ~ as.Date(x, %m.%d.%Y))[[1]] [1] 2009-05-12 or this even simpler regexp extracting all the dates and then picking off the first: strapply(txt, \\d{1,2}\\.\\d{1,2}\\.\\d{4})[[1]][1] [1] 05.12.2009 On Sat, Jan 2, 2010 at 10:08 AM, johannes rara johannesr...@gmail.com wrote: I would like to extract first date from a string: txt - first date is 05.12.2009. Second date is 06.12.2009. txt [1] first date is 05.12.2009. Second date is 06.12.2009. I tried: sub(^.*?\\s(\\d{1,2}\\.\\d{1,2}\\.\\d{4}), \\1, txt, extended=T, perl=T) [1] 05.12.2009. Second date is 06.12.2009. How to modify this? -J __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Regexp: extract first occurrence of date in string
Thanks, is the same possible using basic gsub/sub/grep etc. functions? -J 2010/1/2 Gabor Grothendieck ggrothendi...@gmail.com: Try this which uses a slightly simpler regexp: library(gsubfn) strapply(txt, (\\d{1,2}\\.\\d{1,2}\\.\\d{4}).*)[[1]] [1] 05.12.2009 or we could convert it to Date class at the same time where we have assumed month.day.year: strapply(txt, (\\d{1,2}\\.\\d{1,2}\\.\\d{4}).*, ~ as.Date(x, %m.%d.%Y))[[1]] [1] 2009-05-12 or this even simpler regexp extracting all the dates and then picking off the first: strapply(txt, \\d{1,2}\\.\\d{1,2}\\.\\d{4})[[1]][1] [1] 05.12.2009 On Sat, Jan 2, 2010 at 10:08 AM, johannes rara johannesr...@gmail.com wrote: I would like to extract first date from a string: txt - first date is 05.12.2009. Second date is 06.12.2009. txt [1] first date is 05.12.2009. Second date is 06.12.2009. I tried: sub(^.*?\\s(\\d{1,2}\\.\\d{1,2}\\.\\d{4}), \\1, txt, extended=T, perl=T) [1] 05.12.2009. Second date is 06.12.2009. How to modify this? -J __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Regexp: extract first occurrence of date in string
Use regexpr to get the offset into the string and its length and then use substr to pick extract it. On Sat, Jan 2, 2010 at 10:43 AM, johannes rara johannesr...@gmail.com wrote: Thanks, is the same possible using basic gsub/sub/grep etc. functions? -J 2010/1/2 Gabor Grothendieck ggrothendi...@gmail.com: Try this which uses a slightly simpler regexp: library(gsubfn) strapply(txt, (\\d{1,2}\\.\\d{1,2}\\.\\d{4}).*)[[1]] [1] 05.12.2009 or we could convert it to Date class at the same time where we have assumed month.day.year: strapply(txt, (\\d{1,2}\\.\\d{1,2}\\.\\d{4}).*, ~ as.Date(x, %m.%d.%Y))[[1]] [1] 2009-05-12 or this even simpler regexp extracting all the dates and then picking off the first: strapply(txt, \\d{1,2}\\.\\d{1,2}\\.\\d{4})[[1]][1] [1] 05.12.2009 On Sat, Jan 2, 2010 at 10:08 AM, johannes rara johannesr...@gmail.com wrote: I would like to extract first date from a string: txt - first date is 05.12.2009. Second date is 06.12.2009. txt [1] first date is 05.12.2009. Second date is 06.12.2009. I tried: sub(^.*?\\s(\\d{1,2}\\.\\d{1,2}\\.\\d{4}), \\1, txt, extended=T, perl=T) [1] 05.12.2009. Second date is 06.12.2009. How to modify this? -J __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Regexp: extract first occurrence of date in string
Thanks for the hint, ie. something like this works in this case: txt - first date is 05.12.2009. Second date is 06.12.2009. txt [1] first date is 05.12.2009. Second date is 06.12.2009. l - regexpr(\\d{1,2}\\.\\d{1,2}\\.\\d{4}, txt, perl=T) substr(txt, l, l+9) [1] 05.12.2009 But your examples are more generic. I'll have to look gsubfn more closely. -J 2010/1/2 Gabor Grothendieck ggrothendi...@gmail.com: Use regexpr to get the offset into the string and its length and then use substr to pick extract it. On Sat, Jan 2, 2010 at 10:43 AM, johannes rara johannesr...@gmail.com wrote: Thanks, is the same possible using basic gsub/sub/grep etc. functions? -J 2010/1/2 Gabor Grothendieck ggrothendi...@gmail.com: Try this which uses a slightly simpler regexp: library(gsubfn) strapply(txt, (\\d{1,2}\\.\\d{1,2}\\.\\d{4}).*)[[1]] [1] 05.12.2009 or we could convert it to Date class at the same time where we have assumed month.day.year: strapply(txt, (\\d{1,2}\\.\\d{1,2}\\.\\d{4}).*, ~ as.Date(x, %m.%d.%Y))[[1]] [1] 2009-05-12 or this even simpler regexp extracting all the dates and then picking off the first: strapply(txt, \\d{1,2}\\.\\d{1,2}\\.\\d{4})[[1]][1] [1] 05.12.2009 On Sat, Jan 2, 2010 at 10:08 AM, johannes rara johannesr...@gmail.com wrote: I would like to extract first date from a string: txt - first date is 05.12.2009. Second date is 06.12.2009. txt [1] first date is 05.12.2009. Second date is 06.12.2009. I tried: sub(^.*?\\s(\\d{1,2}\\.\\d{1,2}\\.\\d{4}), \\1, txt, extended=T, perl=T) [1] 05.12.2009. Second date is 06.12.2009. How to modify this? -J __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] caculate the frequencies of the Amino Acids
Hi fadialnaji, Take a look at the Biostring package in Bioconductor [1] It might be an alternative to do what you want. HTH, Jorge [1] http://www.bioconductor.org/packages/release/bioc/html/Biostrings.html On Fri, Jan 1, 2010 at 11:59 PM, che wrote: may some one please help me to sort this out, i am trying to writ a R code for calculating the frequencies of the amino acids in 9 different sequences, i want the code to read the sequence from external text file, i used the following code to do so: x-read.table(sequence.txt,header=FALSE) then i defined an array for 20 amino acids as following: AA-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') i am using the following code to calculate the frequencies: frequency-function(X) { y-rep(0,20) for(j in 1:nchar(as.character(x$V1[i]))){ for(i in 1:9){ res-which(AA==substr(x$V1[i],j,j)) y[res]=y[res]+1 } } return(y) } but this code actually is not working, it reads only one sequence, i dont know why the loop is not working for the i, which suppose to read the nine rows of the file sequence.txt. the sequence.txt file is attached to this message. cheers http://n4.nabble.com/file/n997072/sequence.txt sequence.txt -- View this message in context: http://n4.nabble.com/caculate-the-frequencies-of-the-Amino-Acids-tp997072p997072.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building static HTML help pages in R 2.10.x on Windows
Steve Rowley wrote: Heinz Tuechler wrote: At 21:40 22.12.2009, Steve Rowley wrote: (a) how to build the static HTML help pages of all currently installed packages under Windows, [...] At least two ways: Way 1: reinstall all those packages from sources using R CMD INSTALL --html Way 2: go to the man directory of a source package and apply R CMD Rdconv --type=html *.Rd to all Rd files. Ok, thanks. That's starting along a helpful path. The first way sounds dicey on Windows, since some of the packages require tools that I probably have installed (e.g., as part of Cygwin), but have never thought about how to hook together. The second way sounds useful if I want to download the source for all the packages in addition to the binary installers that I already have. Is there any way to do this from the Windows binary .zip files, or from the installations generated thereby? After all, R generates the HTML on the fly somehow, so the information is present; IWBNI there were a way to use that to generate the static HTML. (Looking through the installation dirs doesn't show very many .Rd files.) Ah, sorry, I must have missed your reply. WEell, internally, you can do somewthing as R's help system does, but it is documented to be subject to change (As they are mainly intended for internal use, their interfaces are subject to change.), see ?Rd2HTML For package pkg in directory c:/dir on help topic foo you could ask Rd2HTML(tools:::fetchRdDB(c:/dir/pkg/help/pkg, foo)) in order to get a HTML representation. See ?Rd2HTML for details on how to control stuff. Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to calculate density function of Bivariate binomial distribution
Thanks milton, I checked some of them, and actually none is what I want. So instead, I wrote a small function for the density of bivariate binomial. Thanks, nykee milton ruser wrote: Hi Nykee, I checked out ??bivariate on my R installed libraries, and found about a hundred of occurrences of bivariate. If nobody reply you with a streigth answer, give a look at: VGAM; splancs; sm; prada; geoR; fUtilities; fBasics; akima; adehabitat; vegan; ade4 and spatstat packages. bests milton On Fri, Jan 1, 2010 at 5:36 PM, nykee rairai...@hotmail.com wrote: Am trying to do some study on bivariate binomial distribution. Anyone knows if there is package in R that I can use to calculate the density function of bivariate binomial distribution and to generate random samples of it. Thanks, -- View this message in context: http://n4.nabble.com/How-to-calculate-density-function-of-Bivariate-binomial-distribution-tp992002p992002.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://n4.nabble.com/How-to-calculate-density-function-of-Bivariate-binomial-distribution-tp992002p997292.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Query: sampling from a multivariate normal distribution using the singular value decomposition
Dear R-list users, this question is not strictly related to R, but hopefully somebody will be able to answer. In a schematic way, which is the algorithm to sample from a multivariate normal distribution using the singular value decomposition? thank you for your help Stefano AVVISO IMPORTANTE: Questo messaggio di posta elettronica pu? contenere informazioni confidenziali, pertanto ? destinato solo a persone autorizzate alla ricezione. I messaggi di posta elettronica per i client di Regione Marche possono contenere informazioni confidenziali e con privilegi legali. Se non si ? il destinatario specificato, non leggere, copiare, inoltrare o archiviare questo messaggio. Se si ? ricevuto questo messaggio per errore, inoltrarlo al mittente ed eliminarlo completamente dal sistema del proprio computer. Ai sensi dell'art. 6 della DGR n. 1394/2008 si segnala che, in caso di necessit? ed urgenza, la risposta al presente messaggio di posta elettronica pu? essere visionata da persone estranee al destinatario. IMPORTANT NOTICE: This e-mail message is intended to be received only by persons entitled to receive the confidential information it may contain. E-mail messages to clients of Regione Marche may contain information that is confidential and legally privileged. Please do not read, copy, forward, or store this message unless you are an intended recipient of it. If you have received this message in error, please forward it to the sender and delete it completely from your computer system. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scatterplot matrix question
On Sat, 2 Jan 2010, William Simpson wrote: I would like a scatterplot matrix and a correlation matrix for the following set-up. The data (dataframe d) are like this: angle resp -90 182 -60 137 -30 ...etc 0 30 60 90 ...etc I would like each cell in the matrix to be the scatterplot of the responses for each pair of angles ( -90 vs -60, -90 vs -30, etc). Same for the correlation matrix. Please tell me what to do. Thanks very much! 1) You need to provide commented, minimal, self-contained, reproducible code. 2) You need to fill in some missing info: Either you have only one response for each angle, or you need a third variable to pair up the corresponding responses for one angle with those of another. Chuck Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. NOTE:.^ Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] filehash - multiple indices via '[' not allowed when using RDS format
Hi, I have been using filehash for a while. It has performed very well. However, recently I found filehash gives an error when I need to do something like db[c(a, b)] when the db is in RDS format. Does any one know a way to get around that? The code below reproduces the error thanks Jeff filehashOption(defaultType = DB1) dbCreate(mydb3, type = DB1) db = dbInit(mydb3) db$a = rnorm(100, 1) db$b = rnorm(100, 1) with(db, c(a = mean(a), b = mean(b))) sapply(db[c(a, b)], mean) # works. filehashOption(defaultType = RDS) dbCreate(mydb4, type = RDS) db = dbInit(mydb4) db$a = rnorm(100, 1) db$b = rnorm(100, 1) with(db, c(a = mean(a), b = mean(b))) sapply(db[c(a, b)], mean) # not work Error in .local(x, i, j, ..., drop) : multiple indices via '[' not allowed Calls: sapply - lapply - is.vector - [ - [ - .local [1] 7: stop(\multiple indices via '[' not allowed\) [1] 6: .local(x, i, j, ..., drop) [1] 5: db[c(\a\, \b\)] [1] 4: db[c(\a\, \b\)] [1] 3: is.vector(X) [1] 2: lapply(X, FUN, ...) [1] 1: sapply(db[c(\a\, \b\)], mean) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scatterplot matrix question
On Sat, Jan 2, 2010 at 4:55 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote: On Sat, 2 Jan 2010, William Simpson wrote: I would like a scatterplot matrix and a correlation matrix for the following set-up. The data (dataframe d) are like this: angle resp -90 182 -60 137 -30 ...etc 0 30 60 90 ...etc I would like each cell in the matrix to be the scatterplot of the responses for each pair of angles ( -90 vs -60, -90 vs -30, etc). Same for the correlation matrix. Please tell me what to do. Thanks very much! 1) You need to provide commented, minimal, self-contained, reproducible code. d-read.table(rstuff/data.dat,header=TRUE) Now what? :-) certainly it's not pairs(d) 2) You need to fill in some missing info: Either you have only one response for each angle, or you need a third variable to pair up the corresponding responses for one angle with those of another. contents of rstuff/data.dat: angle resp ID -90 182 1 -60 137 1 -30 123 1 067 1 30 32 1 60 12 1 9013 1 -90 178 2 -60 111 2 -30 137 2 094 2 30 59 2 60 1 2 9019 2 I actually have a lot more than 2 experimental units (ID)... Thanks for any help Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with for loop
If I understand the query, z - outer(x,x,-) z[lower.tri(z)] ## is what you want. ?outer and ?lower.tri will tell you how to interpret what you get. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of jim holtman Sent: Friday, January 01, 2010 5:25 PM To: Rafael Moral Cc: r-help Subject: Re: [R] help with for loop Look at your function; it is returning exactly what you are asking for: x.dif - c(diff(my.vec), diff(my.vec, lag=i)) # the first and last values You probably want something like this: dif - function(my.vec) { x.diff - diff(my.vec) for(i in 2:(length(my.vec)-1)) { x.dif - c(x.diff, diff(my.vec, lag=i)) } return(x.dif) } You might also want to check if the length of the vector is 2, or less, since your 'for' will not work. On Fri, Jan 1, 2010 at 8:16 PM, Rafael Moral rafa_moral2...@yahoo.com.brwrote: Dear useRs, I want to write a function that generates all the possible combinations of diff(). Example: If my vector has length 5, I need the diff() until lag=4 - c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3), diff(my.vec, lag=4)) If it has length 4, I need until lag=3 - c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3)) So, it must be until lag=(length(my.vec)-1). The function I've written is: dif - function(my.vec) { for(i in 2:(length(my.vec)-1)) { x.dif - c(diff(my.vec), diff(my.vec, lag=i)) } return(x.dif) } But it only returns the first diff() (lag=1) and the last one ( diff(my.vec, lag=(length(my.vec)-1) ) Example: my.vec = c(1,2,3,2) dif(my.vec) [1] 1 1 -1 1 What I wanted to get was: c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3)) [1] 1 1 -1 2 0 1 Is there a way of computing it so R understands what I want? Thanks in advance, happy new year for everyone! Kind regards, Rafael. [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting -guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scatterplot matrix question
William Simpson wrote: On Sat, Jan 2, 2010 at 4:55 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote: On Sat, 2 Jan 2010, William Simpson wrote: I would like a scatterplot matrix and a correlation matrix for the following set-up. The data (dataframe d) are like this: angle resp -90 182 -60 137 -30 ...etc 0 30 60 90 ...etc I would like each cell in the matrix to be the scatterplot of the responses for each pair of angles ( -90 vs -60, -90 vs -30, etc). Same for the correlation matrix. Please tell me what to do. Thanks very much! 1) You need to provide commented, minimal, self-contained, reproducible code. d-read.table(rstuff/data.dat,header=TRUE) Now what? :-) certainly it's not pairs(d) Now that we are able to help with some more detailed view of your data (although you could have helped helping by making it easier for us to import your data into R), the answer is: Almost, after reshaping: dwide - reshape(d, v.names=resp, idvar=ID, timevar=angle, direction=wide) pairs(dwide[,-1]) Best, Uwe Ligges 2) You need to fill in some missing info: Either you have only one response for each angle, or you need a third variable to pair up the corresponding responses for one angle with those of another. contents of rstuff/data.dat: angle resp ID -90 182 1 -60 137 1 -30 123 1 067 1 30 32 1 60 12 1 9013 1 -90 178 2 -60 111 2 -30 137 2 094 2 30 59 2 60 1 2 9019 2 I actually have a lot more than 2 experimental units (ID)... Thanks for any help Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] suppress output for meta in package tm
Hi, Peter. Thanks. This works but is not ideal to have an external file. The main reason I want to suppress the output is to speed up the processing time, which capture.output does indeed do. It is a great work around for now. I am using the output to match items in a corpa to a file that contains metadata and then attaching the fields in the meta data file as metadata to each item in the corpa. If you have any other suggestions to increase processing speed please let me know. Many Thanks. for (n in 1:length(corpa)) { n_corp_file - capture.output(meta(corpa[[n]], URI),file=log.txt) #want just file not dir and file n_char - nchar(n_corp_file[2]) #nchar[1] is file=4 and nchar[2] is dir + filename amd nchar[3] is UTF-8 = 5 n_char_dir - nchar(corpa_dir) corp_file - substr(n_corp_file, n_char_dir + 2, n_char) corp_file - corp_file[2] #match corpa file with meta data file match_index - match(corp_file,(meta_data$file)) if (!is.na(match_index)) { #attach all rows of meta_data meta_cols - colnames(meta_data) for (col in 1:length(meta_cols)) { meta(corpa[[n]], meta_cols[col]) - meta_data[match_index,meta_cols[col]] } } #if } #for n corpa On Sat, Jan 2, 2010 at 6:03 AM, Peter Ehlers ehl...@ucalgary.ca wrote: Can you wrap your call in capture.output(..., file=...)? -Peter Ehlers Amber Jaycocks wrote: Hello, I am using the tm package and wish to suppress the output for meta. I am defining another variable for one of the tags and don't want the value printed on the screen. Any help would be appreciated. Thanks. here is the commnad: n_corp_file - meta(corpa[[n]], URI) -Amber [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Ehlers University of Calgary 403.202.3921 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scatterplot matrix question
Now that we are able to help with some more detailed view of your data (although you could have helped helping by making it easier for us to import your data into R), the answer is: I am preparing for the data analysis, writing the code (knowing I may have to modify it later) while the data are still being collected. That's why I used the artificial data when asked for some. I will be pressed for time when the data arrive. Almost, after reshaping: dwide - reshape(d, v.names=resp, idvar=ID, timevar=angle, direction=wide) pairs(dwide[,-1]) Thanks very much, Uwe. I will try this (on artificial data). I think reshape() requires a library [reshape?]. Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] suppress output for meta in package tm
I don't know anything about pkg:tm, but I'll make a couple of comments below. Amber Jaycocks wrote: Hi, Peter. Thanks. This works but is not ideal to have an external file. The main reason I want to suppress the output is to speed up the processing time, which capture.output does indeed do. It is a great work around for now. I am using the output to match items in a corpa to a file that contains metadata and then attaching the fields in the meta data file as metadata to each item in the corpa. If you have any other suggestions to increase processing speed please let me know. Many Thanks. for (n in 1:length(corpa)) { or: for(n in seq_along(corpa)){ n_corp_file - capture.output(meta(corpa[[n]], URI),file=log.txt) here, I think, you want: capture.output(n_corp_file - meta(corpa[[n]], URI), file=log.txt) and I would use (on Windows): file=clipboard #want just file not dir and file n_char - nchar(n_corp_file[2]) #nchar[1] is file=4 and nchar[2] is dir + filename amd nchar[3] is UTF-8 = 5 n_char_dir - nchar(corpa_dir) corp_file - substr(n_corp_file, n_char_dir + 2, n_char) corp_file - corp_file[2] #match corpa file with meta data file match_index - match(corp_file,(meta_data$file)) if (!is.na(match_index)) { #attach all rows of meta_data meta_cols - colnames(meta_data) for (col in 1:length(meta_cols)) { meta(corpa[[n]], meta_cols[col]) - meta_data[match_index,meta_cols[col]] } } #if } #for n corpa You might also find sink() to be more to your taste than capture.output(). -Peter On Sat, Jan 2, 2010 at 6:03 AM, Peter Ehlers ehl...@ucalgary.ca wrote: Can you wrap your call in capture.output(..., file=...)? -Peter Ehlers Amber Jaycocks wrote: Hello, I am using the tm package and wish to suppress the output for meta. I am defining another variable for one of the tags and don't want the value printed on the screen. Any help would be appreciated. Thanks. here is the commnad: n_corp_file - meta(corpa[[n]], URI) -Amber [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Ehlers University of Calgary 403.202.3921 -- Peter Ehlers University of Calgary 403.202.3921 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scatterplot matrix question
On Jan 2, 2010, at 1:49 PM, William Simpson wrote: Now that we are able to help with some more detailed view of your data (although you could have helped helping by making it easier for us to import your data into R), the answer is: I am preparing for the data analysis, writing the code (knowing I may have to modify it later) while the data are still being collected. That's why I used the artificial data when asked for some. I will be pressed for time when the data arrive. Almost, after reshaping: dwide - reshape(d, v.names=resp, idvar=ID, timevar=angle, direction=wide) pairs(dwide[,-1]) Thanks very much, Uwe. I will try this (on artificial data). I think reshape() requires a library [reshape?]. No. In fact, the reshape package does not have a reshape function. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scatterplot matrix question
OK thanks David Thanks very much, Uwe. I will try this (on artificial data). I think reshape() requires a library [reshape?]. No. In fact, the reshape package does not have a reshape function. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] suppress output for meta in package tm
Actually if you just use 'capture.output' without specifying a 'file' it will return a character vector with the output which you can just ignore. On Sat, Jan 2, 2010 at 1:51 PM, Peter Ehlers ehl...@ucalgary.ca wrote: I don't know anything about pkg:tm, but I'll make a couple of comments below. Amber Jaycocks wrote: Hi, Peter. Thanks. This works but is not ideal to have an external file. The main reason I want to suppress the output is to speed up the processing time, which capture.output does indeed do. It is a great work around for now. I am using the output to match items in a corpa to a file that contains metadata and then attaching the fields in the meta data file as metadata to each item in the corpa. If you have any other suggestions to increase processing speed please let me know. Many Thanks. for (n in 1:length(corpa)) { or: for(n in seq_along(corpa)){ n_corp_file - capture.output(meta(corpa[[n]], URI),file=log.txt) here, I think, you want: capture.output(n_corp_file - meta(corpa[[n]], URI), file=log.txt) and I would use (on Windows): file=clipboard #want just file not dir and file n_char - nchar(n_corp_file[2]) #nchar[1] is file=4 and nchar[2] is dir + filename amd nchar[3] is UTF-8 = 5 n_char_dir - nchar(corpa_dir) corp_file - substr(n_corp_file, n_char_dir + 2, n_char) corp_file - corp_file[2] #match corpa file with meta data file match_index - match(corp_file,(meta_data$file)) if (!is.na(match_index)) { #attach all rows of meta_data meta_cols - colnames(meta_data) for (col in 1:length(meta_cols)) { meta(corpa[[n]], meta_cols[col]) - meta_data[match_index,meta_cols[col]] } } #if } #for n corpa You might also find sink() to be more to your taste than capture.output(). -Peter On Sat, Jan 2, 2010 at 6:03 AM, Peter Ehlers ehl...@ucalgary.ca wrote: Can you wrap your call in capture.output(..., file=...)? -Peter Ehlers Amber Jaycocks wrote: Hello, I am using the tm package and wish to suppress the output for meta. I am defining another variable for one of the tags and don't want the value printed on the screen. Any help would be appreciated. Thanks. here is the commnad: n_corp_file - meta(corpa[[n]], URI) -Amber [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Ehlers University of Calgary 403.202.3921 -- Peter Ehlers University of Calgary 403.202.3921 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Please help me!!!! Error in `[.data.frame`(x, , retained, drop = FALSE) : undefined columns selected
Your data set has 217 predictors and 166 samples. If you read the vignette on feature selection for this package, you'll see that the default ranking mechanism that it uses for linear models requires a linear model fit. The note that: prediction from a rank-deficient fit may be misleading should tell you something. If it doesn't: the model fit is over determined and there is no unique solution, so many of the parameter estimates are NA. Either create a modified version of lmFuncs that suits your needs or remove variables prior to modeling (or try some other method that doesn't require more samples than predictors, such as the lasso or elasticnet). Max On Fri, Jan 1, 2010 at 10:14 PM, bbslover dlu...@yeah.net wrote: I am learning the package caret, after I do the rfe function, I get the error ,as follows: Error in `[.data.frame`(x, , retained, drop = FALSE) : undefined columns selected In addition: Warning message: In predict.lm(object, x) : prediction from a rank-deficient fit may be misleading I try to that manual example, that is good, my data is wrong. I do not know what reanson? my code is : subsets-c(1:5,10,15,20,25) ctrl-rfeControl(functions=lmFuncs, method = cv, verbose=FALSE,returnResamp=final) lmProfile-rfe(trainDescr,trainY,sizes=subsets,rfeControl=ctrl) before it, I have do some pre-process and my data is in the attachment. Please help me. thank you! kevin http://n4.nabble.com/file/n996068/trainDescr.txt trainDescr.txt http://n4.nabble.com/file/n996068/trainY.txt trainY.txt -- View this message in context: http://n4.nabble.com/Please-help-me-Error-in-data-frame-x-retained-drop-FALSE-undefined-columns-selected-tp996068p996068.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Ordering variables in a parallel coordinates plot
Hello all, I am searching for a way in R to re-order variables before presenting them in a parallel coordinates plot. So far I didn't find anything within a R related context on how to do this. I did find some texts talking about how it should be done in general, here is such example: http://tinyurl.com/ycnsjpe Is there a package or an example of the variable ordering (for parallel coordinate plot) in R ? Thanks, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com/ (English) -- [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Rscript: how to suppress all output
How can I suppress ALL output when running Rscript in Terminal? ~/DocumentsRscript test.r I tried options --slave, --vanilla with no success. I get these Loading required package: methods ..etc.. and other output as well. -J sessionInfo() R version 2.9.2 (2009-08-24) i386-apple-darwin8.11.1 locale: fi_FI.UTF-8/fi_FI.UTF-8/C/C/fi_FI.UTF-8/fi_FI.UTF-8 attached base packages: [1] grid splines stats graphics grDevices utils datasets methods base other attached packages: [1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9 proto_0.3-8 Hmisc_3.7-0 survival_2.35-7 loaded via a namespace (and not attached): [1] cluster_1.12.1 lattice_0.17-26 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] suppress output for meta in package tm
Thanks Jim and Peter. Ignoring the filename worked. The process is still slow but a bit improved. I had to slightly modify the substring to match across the two objects. n_corp_file - capture.output(meta(corpa[[n]], URI),file=) n_char - nchar(n_corp_file[1]) n_char_dir - nchar(corpa_dir) # want to start at file(\ = 6 + directory + 2 corp_file -substr(n_corp_file, 6+ n_char_dir +2, n_char-3) corp_file - corp_file[1] ##this doesnt suppress, but works too #n_corp_file - meta(corpa[[n]], URI) ##want just file not dir and file #n_char - nchar(n_corp_file[2]) ##nchar[1] is file=4 and nchar[2] is dir + filename amd nchar[3] is UTF-8 = 5 #n_char_dir - nchar(corpa_dir) #corp_file - substr(n_corp_file, n_char_dir + 2, n_char) #corp_file - corp_file[2] #END of nonsupressed On Sat, Jan 2, 2010 at 11:19 AM, jim holtman jholt...@gmail.com wrote: Actually if you just use 'capture.output' without specifying a 'file' it will return a character vector with the output which you can just ignore. On Sat, Jan 2, 2010 at 1:51 PM, Peter Ehlers ehl...@ucalgary.ca wrote: I don't know anything about pkg:tm, but I'll make a couple of comments below. Amber Jaycocks wrote: Hi, Peter. Thanks. This works but is not ideal to have an external file. The main reason I want to suppress the output is to speed up the processing time, which capture.output does indeed do. It is a great work around for now. I am using the output to match items in a corpa to a file that contains metadata and then attaching the fields in the meta data file as metadata to each item in the corpa. If you have any other suggestions to increase processing speed please let me know. Many Thanks. for (n in 1:length(corpa)) { or: for(n in seq_along(corpa)){ n_corp_file - capture.output(meta(corpa[[n]], URI),file=log.txt) here, I think, you want: capture.output(n_corp_file - meta(corpa[[n]], URI), file=log.txt) and I would use (on Windows): file=clipboard #want just file not dir and file n_char - nchar(n_corp_file[2]) #nchar[1] is file=4 and nchar[2] is dir + filename amd nchar[3] is UTF-8 = 5 n_char_dir - nchar(corpa_dir) corp_file - substr(n_corp_file, n_char_dir + 2, n_char) corp_file - corp_file[2] #match corpa file with meta data file match_index - match(corp_file,(meta_data$file)) if (!is.na(match_index)) { #attach all rows of meta_data meta_cols - colnames(meta_data) for (col in 1:length(meta_cols)) { meta(corpa[[n]], meta_cols[col]) - meta_data[match_index,meta_cols[col]] } } #if } #for n corpa You might also find sink() to be more to your taste than capture.output(). -Peter On Sat, Jan 2, 2010 at 6:03 AM, Peter Ehlers ehl...@ucalgary.ca wrote: Can you wrap your call in capture.output(..., file=...)? -Peter Ehlers Amber Jaycocks wrote: Hello, I am using the tm package and wish to suppress the output for meta. I am defining another variable for one of the tags and don't want the value printed on the screen. Any help would be appreciated. Thanks. here is the commnad: n_corp_file - meta(corpa[[n]], URI) -Amber [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Ehlers University of Calgary 403.202.3921 -- Peter Ehlers University of Calgary 403.202.3921 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rscript: how to suppress all output
Try this on Windows: Rscript test.r 1NUL 2NUL On Sat, Jan 2, 2010 at 3:27 PM, johannes rara johannesr...@gmail.com wrote: How can I suppress ALL output when running Rscript in Terminal? ~/DocumentsRscript test.r I tried options --slave, --vanilla with no success. I get these Loading required package: methods ..etc.. and other output as well. -J sessionInfo() R version 2.9.2 (2009-08-24) i386-apple-darwin8.11.1 locale: fi_FI.UTF-8/fi_FI.UTF-8/C/C/fi_FI.UTF-8/fi_FI.UTF-8 attached base packages: [1] grid splines stats graphics grDevices utils datasets methods base other attached packages: [1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9 proto_0.3-8 Hmisc_3.7-0 survival_2.35-7 loaded via a namespace (and not attached): [1] cluster_1.12.1 lattice_0.17-26 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Questions bout SVM
Hi, On Fri, Jan 1, 2010 at 1:03 PM, Nancy Adam nancyada...@hotmail.com wrote: Hi everyone, Can someone please help me in these questions?: 1)if I use crossvalidation with svm, do I have to use this equation to calculate RMSE?: mymodel - svm(myformula,data=mydata,cross=10) sqrt(mean(mymodel$MSE)) No, I don't think so. W/o looking at the C code, I'm guessing that MSE is a vector of length 10 that represents the mean squared error from each fold ... but what are you trying to do? Trying to get the average of the RMSE over all folds? Wouldn't that then be: mean(sqrt(mymodel$MSE))? But if I don’t use crossvalidation, I have to use the following to calculate RMSE: mymodel - svm(myformula,data=mydata) mytest - predict(mymodel, mytestdata) error - mytest - mytestdata[,1] sqrt(mean(error**2)) OK 2)if I don’t set the parameters of SVM, like in the above, how the program knows them? Or it is a must to determine them when I invoke svm? What parameters are you talking about? Your two `svm` function calls look the same with the exception of not including a value for `cross` in your 2nd. What parameters of the SVM do you think are different? 3)can you please tell me why we use this equation: mymodel - svm(myformula,data=mydata)instead of mymodel - svm(myformula, mydata) Since the data argument is the 2nd argument in the function definition of svm.formula, those two invocations are actually the same. and why use this: error - mytest - mytestdata[,1] instead of error - mytest – mytestdata It depends on what type of variable 'mytestdata' is, and its shape, eg. those two calls might be doing the same thing if mytestdata is just a 1d matrix. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xyplot: several plots in one creates y-scale problem
Hello, I've been looking for a solution to this problem for some time now but I seem unable to solve it.. so this is the case: I want to plot 4 time series in the same graph using xyplot(). When I do this with xyplot(mydata[,2]+mydata[,3]+mydata[,4]+mydata[,5] ~ mydata[,1], data = mydata, type = l, auto.key = list(space=right, lines = T, points = F), par.settings = simpleTheme(lty = c(1,2,3,4)) ) I get a graph where all lines are maximized to cover the entire y- scale width. I.e., they are use their own scale independent of each other (my data has some columns that are one magnitude smaller than the others). How do I force them all to use the same y-scale? I found this thread: http://n4.nabble.com/superimposing-xyplots-on-same-scale-td905525.html, but I'm not really sure what is going on there. Any ideas? /J __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xyplot: problems with column names legend
Hello! one more question about xyplot. If I have data which have space in the column names, say xyz 123. How do I create a working graph where this text is displayed in the legend key? Now when I try something like xyplot(xyz 123 ~ variable1, data = mydata, ...) I get nothing. Also, is it possible to genrate the graph with xyplot(mydata[,1] ~ variable1, data = mydata, ...) and then later in the code specify the names that should be displayed in the legend? Thank you! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Questions bout SVM
Hi Steve, Thanks a lot for your reply.1)Im still confused which equation (1- sqrt(mean(mymodel$MSE)) OR 2- mean(sqrt(mymodel$MSE)) )is equivalent to sqrt(mean(error**2))?I just want to compute the typical RMSE that is usually used for measuring the performance of regression systems. 2)Im talking about another addition related to the svm parameters in the call to SVM. i.e.my_svm_model- function(myformula, mydata, mytestdata, parameterlist) {mymodel - svm(myformula, data=mydata, cross=10, cost=parameterlist[[1]], epsilon=parameterlist[[2]],gamma=parameterlist[[3]])If I dont set these parameters of svm (like: my_svm_model- function(myformula, mydata, mytestdata), how does svm know them? 3) in 2) Is it correct to use mydata instead of data=mydata? Or I can do that only if it is the last argument in the function call? 4)Does mytestdata[,1] means that the model will use only the last column on the testing set?Many thanks,Nancy Date: Sat, 2 Jan 2010 17:32:44 -0500 Subject: Re: [R] Questions bout SVM From: mailinglist.honey...@gmail.com To: nancyada...@hotmail.com CC: r-help@r-project.org Hi, On Fri, Jan 1, 2010 at 1:03 PM, Nancy Adam nancyada...@hotmail.com wrote: Hi everyone, Can someone please help me in these questions?: 1)if I use crossvalidation with svm, do I have to use this equation to calculate RMSE?: mymodel - svm(myformula,data=mydata,cross=10) sqrt(mean(mymodel$MSE)) No, I don't think so. W/o looking at the C code, I'm guessing that MSE is a vector of length 10 that represents the mean squared error from each fold ... but what are you trying to do? Trying to get the average of the RMSE over all folds? Wouldn't that then be: mean(sqrt(mymodel$MSE))? But if I dont use crossvalidation, I have to use the following to calculate RMSE: mymodel - svm(myformula,data=mydata) mytest - predict(mymodel, mytestdata) error - mytest - mytestdata[,1] sqrt(mean(error**2)) OK 2)if I dont set the parameters of SVM, like in the above, how the program knows them? Or it is a must to determine them when I invoke svm? What parameters are you talking about? Your two `svm` function calls look the same with the exception of not including a value for `cross` in your 2nd. What parameters of the SVM do you think are different? 3)can you please tell me why we use this equation: mymodel - svm(myformula,data=mydata)instead of mymodel - svm(myformula, mydata) Since the data argument is the 2nd argument in the function definition of svm.formula, those two invocations are actually the same. and why use this: error - mytest - mytestdata[,1] instead of error - mytest mytestdata It depends on what type of variable 'mytestdata' is, and its shape, eg. those two calls might be doing the same thing if mytestdata is just a 1d matrix. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact _ Keep your friends updatedeven when youre not signed in. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] xyplot: problems with column names legend
On Jan 2, 2010, at 6:51 PM, Jay wrote: Hello! one more question about xyplot. If I have data which have space in the column names, say xyz 123. How do I create a working graph where this text is displayed in the legend key? Now when I try something like xyplot(xyz 123 ~ variable1, data = mydata, ...) I get nothing. You could try bquote() around the troublesome string. (And why would you do such a thing in the first place, anyway???) Also, is it possible to genrate the graph with xyplot(mydata[,1] ~ variable1, data = mydata, ...) and then later in the code specify the names that should be displayed in the legend? (It's not exactly clear what you mean by legend, but from the fact that you xyplot call has nothing that would clearly need a legend or key, I'm guessing you actually mean the x and y labels.) libary(lattice) ?xyplot # and pay attention to the xlab and ylab arguments ?update -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] caculate the frequencies of the Amino Acids
Thanks very much the code is working perfectly, but I hope guys that you can help me to do the same thing but by using the loop structure, i want to know if i am doing right, i want to use the loop structure to scan each sequence from the file sequence.txt (the file is attached) to get the frequency for each Amino Acid, and i wrote the following code so far, and i stopped, got confused, specially that i am a very beginner in R http://n4.nabble.com/file/n997581/sequence.txt sequence.txt : x-read.table(sequence.txt,header=FALSE) AA-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') test-nchar(as.character(x$V1[i])) frequency-function(X) { y-rep(0,20) for(j in 1:test){ for(i in 1:nrow(x)){ res-which(AA==substr(x$V1[i],j,j)) y[res]=y[res]+1 } } return(y) } So how to fix this code, how to give the life for the “i” and the “j” in order to initiate the indexing. Sorry for bothering you guys. che wrote: may some one please help me to sort this out, i am trying to writ a R code for calculating the frequencies of the amino acids in 9 different sequences, i want the code to read the sequence from external text file, i used the following code to do so: x-read.table(sequence.txt,header=FALSE) then i defined an array for 20 amino acids as following: AA-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') i am using the following code to calculate the frequencies: frequency-function(X) { y-rep(0,20) for(j in 1:nchar(as.character(x$V1[i]))){ for(i in 1:9){ res-which(AA==substr(x$V1[i],j,j)) y[res]=y[res]+1 } } return(y) } but this code actually is not working, it reads only one sequence, i dont know why the loop is not working for the i, which suppose to read the nine rows of the file sequence.txt. the sequence.txt file is attached to this message. cheers http://n4.nabble.com/file/n997072/sequence.txt sequence.txt -- View this message in context: http://n4.nabble.com/caculate-the-frequencies-of-the-Amino-Acids-tp997072p997581.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] caculate the frequencies of the Amino Acids
On Jan 3, 2010, at 12:28 AM, che wrote: Thanks very much the code is working perfectly, but I hope guys that you can help me to do the same thing but by using the loop structure, i want to know if i am doing right, i want to use the loop structure to scan each sequence from the file sequence.txt (the file is attached) to get the frequency for each Amino Acid, and i wrote the following code so far, and i stopped, got confused, specially that i am a very beginner in R http://n4.nabble.com/file/n997581/sequence.txt sequence.txt : x-read.table(sequence.txt,header=FALSE) AA- c ('A ','C ','D ','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') test-nchar(as.character(x$V1[i])) frequency-function(X) { y-rep(0,20) I earlier pointed out that such a structure would be inadequate to hold the tabulation of more than one sequence. You probably need a matrix of width = 20 and depth = the number of your sequences. for(j in 1:test){ for(i in 1:nrow(x)){ res-which(AA==substr(x$V1[i],j,j)) y[res]=y[res]+1 ... and here you will need to index y[ , ] with both the proper row and column. } } return(y) } So how to fix this code, how to give the life for the “i” and the “j” in order to initiate the indexing. Sorry for bothering you guys. -- David. che wrote: may some one please help me to sort this out, i am trying to writ a R code for calculating the frequencies of the amino acids in 9 different sequences, i want the code to read the sequence from external text file, i used the following code to do so: x-read.table(sequence.txt,header=FALSE) then i defined an array for 20 amino acids as following: AA- c ('A ','C ','D ','E ','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') i am using the following code to calculate the frequencies: frequency-function(X) { y-rep(0,20) for(j in 1:nchar(as.character(x$V1[i]))){ for(i in 1:9){ res-which(AA==substr(x$V1[i],j,j)) y[res]=y[res]+1 } } return(y) } but this code actually is not working, it reads only one sequence, i dont know why the loop is not working for the i, which suppose to read the nine rows of the file sequence.txt. the sequence.txt file is attached to this message. cheers http://n4.nabble.com/file/n997072/sequence.txt sequence.txt -- View this message in context: http://n4.nabble.com/caculate-the-frequencies-of-the-Amino-Acids-tp997072p997581.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rscript: how to suppress all output
On Sat, 2 Jan 2010, johannes rara wrote: How can I suppress ALL output when running Rscript in Terminal? ~/DocumentsRscript test.r Rscript test.r /dev/null or equivalent in your shell. But note that Rscript produces no output itself: tystie% touch test.r tystie% Rscript test.r tystie% so anything you see is created by your script. If your script produces output you do not want, the problem lies in your script. Depending how it is doing it, consider functions like invisible(), sink() and suppressMessages(). I tried options --slave, --vanilla with no success. I get these --slave is the default for Rscript: use Rscript --verbose to see what it is doing (see ?Rscript). Loading required package: methods ..etc.. (That one is because you did not specify methods as part of the initial package list: see ?Rscript.) and other output as well. -J sessionInfo() R version 2.9.2 (2009-08-24) i386-apple-darwin8.11.1 locale: fi_FI.UTF-8/fi_FI.UTF-8/C/C/fi_FI.UTF-8/fi_FI.UTF-8 attached base packages: [1] grid splines stats graphics grDevices utils datasets methods base other attached packages: [1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9 proto_0.3-8 Hmisc_3.7-0 survival_2.35-7 loaded via a namespace (and not attached): [1] cluster_1.12.1 lattice_0.17-26 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with function fitdistr in MASS
Hi, R users: I want to fit my data into a normal distribution by using the command fitdistr in MASS. I changed my data class from ts to numeric by class(mydata)=numeric but after using fitdistr, I got the result below fitdistr(mydata,normal) meansd NA NA (NA) (NA) the help doc of fitdistr does not mention anything about that, thus I need your help. Thank you in advanced, Saji from Shanghai -- View this message in context: http://n4.nabble.com/Help-with-function-fitdistr-in-MASS-tp997609p997609.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with function fitdistr in MASS
I check my data again, and find that: 1. when the class of mydata is ts, I can't compute the sd of it. R returns 'NA'. 2. when I change the class from ts into numeric, R still can't compute the sd of the data. Any suggestion? -- View this message in context: http://n4.nabble.com/Help-with-function-fitdistr-in-MASS-tp997609p997612.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with function fitdistr in MASS
And when I used the command below: fitdistr(mydata, normal, na.rm=TRUE) the result is still the same. -- View this message in context: http://n4.nabble.com/Help-with-function-fitdistr-in-MASS-tp997609p997615.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Please help me!!!! Error in `[.data.frame`(x, , retained, drop = FALSE) : undefined columns selected
thanks, I have reduce the number of descriptors, and the erroe is none, my major is qsar, but what is the criterion to select descritors, and how many descriptors should be selected, It is a problem, I calculate my descriptors troungh E-dragon, and apply the wonderful package caret,but my result is poor, how can i improve my performance? Max is an expert in this field I think ,can you give me some suggestion in how can I well learn QSAR and build the perfect models based on nonlinear and linear. Here, only myself do QSAR research study lonely, and I have no some software to calculate descriptors except free ons, I just know e-dragon, have others? and good tools to do QSAR? thank you again. kevin! Max Kuhn wrote: Your data set has 217 predictors and 166 samples. If you read the vignette on feature selection for this package, you'll see that the default ranking mechanism that it uses for linear models requires a linear model fit. The note that: prediction from a rank-deficient fit may be misleading should tell you something. If it doesn't: the model fit is over determined and there is no unique solution, so many of the parameter estimates are NA. Either create a modified version of lmFuncs that suits your needs or remove variables prior to modeling (or try some other method that doesn't require more samples than predictors, such as the lasso or elasticnet). Max On Fri, Jan 1, 2010 at 10:14 PM, bbslover dlu...@yeah.net wrote: I am learning the package caret, after I do the rfe function, I get the error ,as follows: Error in `[.data.frame`(x, , retained, drop = FALSE) : undefined columns selected In addition: Warning message: In predict.lm(object, x) : prediction from a rank-deficient fit may be misleading I try to that manual example, that is good, my data is wrong. I do not know what reanson? my code is : subsets-c(1:5,10,15,20,25) ctrl-rfeControl(functions=lmFuncs, method = cv, verbose=FALSE,returnResamp=final) lmProfile-rfe(trainDescr,trainY,sizes=subsets,rfeControl=ctrl) before it, I have do some pre-process and my data is in the attachment. Please help me. thank you! kevin http://n4.nabble.com/file/n996068/trainDescr.txt trainDescr.txt http://n4.nabble.com/file/n996068/trainY.txt trainY.txt -- View this message in context: http://n4.nabble.com/Please-help-me-Error-in-data-frame-x-retained-drop-FALSE-undefined-columns-selected-tp996068p996068.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://n4.nabble.com/Please-help-me-Error-in-data-frame-x-retained-drop-FALSE-undefined-columns-selected-tp996068p997526.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Anova in 'car': SSPE apparently deficient rank
I have design with two repeated-measures factor, and no grouping factor. I can analyze the dataset successfully in other software, including my legacy DOS version BMDP, and R's 'aov' function. I would like to use 'Anova' in 'car' in order to obtain the sphericity tests and the H-F corrected p-values. I do not believe the data are truly deficient in rank. I followed the methods for this kind of analysis outlined in Bennett's excellent handouts for his Psychology 710 course http://www.psychology.mcmaster.ca/bennett/psy710/lectures/maxwell_chp12.pdf I am trying to convert my own similar course to R for my students for next fall. I have been successful at analyzing a segment of the data as a 2-way repeated measures design. Here is my code: your.data=read.table(pipe(pbpaste),header=T) your.data partic A1B1 A1B2 A1B3 A1B4 A2B1 A2B2 A2B3 A2B4 A3B1 A3B2 A3B3 A3B4 1 p111231247137 10 2 p2223322562469 3 p3122323261479 4 p411221236238 10 5 p5223323572379 attach(your.data) multmodel=lm(cbind(A1B1, A1B2, A1B3, A1B4, A2B1, A2B2, A2B3, A2B4, A3B1, A3B2, A3B3, A3B4)~1) poke.idata=read.table(pipe(pbpaste),header=T) poke.idata Afac Bfac 1A1 B1 2A1 B2 3A1 B3 4A1 B4 5A2 B1 6A2 B2 7A2 B3 8A2 B4 9A3 B1 10 A3 B2 11 A3 B3 12 A3 B4 attach(poke.idata) pokeAnova =Anova(multmodel,idata=poke.idata,idesign=~Afac*Bfac,type=III) Error in linear.hypothesis.mlm(mod, hyp.matrix, SSPE = SSPE, idata = idata, : The error SSP matrix is apparently of deficient rank = 4 6 Thanks for any help or advice. And thanks for the 'car' package, which is a great asset to my course. I'm just stuck on this one example. colleen moore http://www.childrenandpollution.org/ChildrenPollution/ChildrenAndPollution/more_info.html Colleen F. Moore, Professor Psychology Department 1202 W. Johnson St. University of Wisconsin Madison, WI 53706 cfmo...@wisc.edu - [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.