Re: [R] Creating windows binary R package (PowerArchiver vs. zip -r9X)
Thanks, Uwe! It workedTao Date: Fri, 27 Jul 2007 09:16:49 +0200 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: r-help@stat.math.ethz.ch Subject: Re: [R] Creating windows binary R package (PowerArchiver vs. zip -r9X)Tao Shi wrote: Hi list,I apologize if you see funny fonts, b/c I'm using the new Windows Live Hotmail and don't know how to turn off the rich text mode.I have successfully built and installed a R package in windowsXP for R-2.5.1. But when I tried to create a .zip file so I can use Packages/install package(s) from local .zip files... to install it, it seems R only recognizes the .zip file created by zip -r9X not by PowerArchiver. Do you know why? I vaguely remember I used WinZip before and it worked fine.The two threads I found on R-help and R-devel help me a lot, but don't really answer my question.http://tolstoy.newcastle.edu.au/R/help/06/06/29587.htmlhttp://tolstoy.newcastle.edu.au/R/devel/05/12/3336.htmlThanks,...Tao In order to provide a Windows binary package, type: R CMD INSTALL --build PackageName_vers.tar.gz and the zip file will be generated by R in the correct way. Uwe Ligges _ PC Magazine’s 2007 editors’ choice for best web mail—award-winning Windows Live Hotmail. http://imagine-windowslive.com/hotmail/?locale=en-usocid=TXT_TAGHM_migration_HMWL_mini_pcmag_0707 __ 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 and provide commented, minimal, self-contained, reproducible code.
[R] Error when using the cat function
Is the following developed in my console output a recognized bug or am I using the cat function incorrectly? Thanks, Stan ifelse(class(data[[n]])!=factor,{print(yes)},{print(no)}) [1] yes [1] yes ifelse(class(data[[n]])!=factor,{cat(yes)},{cat(no)}) yesError in ans[test !nas] - rep(yes, length.out = length(ans))[test : incompatible types (from NULL to logical) in subassignment type fix cat(yes) yes class(data[[n]])!=factor [1] TRUE class(data[[n]]) [1] numeric n [1] 28 length(data[[n]]) [1] 955 class(data) [1] data.frame dim(data) [1] 955 182 data[[n]] [1] 2.5 4.9 2.6 3.0 4.7 5.0 3.9 1.5 4.8 3.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re: [R] Error when using the cat function
Your problem is with ifelse, not with cat. First clue is that ifelse(TRUE,{print(yes)},{print(no)}) # results in yes being printed TWICE. Try this: tmp - ifelse(TRUE,{print(yes)},{print(no)}) # one yes tmp # another yes Try: print(print(yes)) # prints yes and returns yes invisibly. This returned value is passed on to/by ifelse. Now try: print(cat(yes\n)) # yes appears, but cat(yes) returns NULL, which ifelse can't handle: ifelse(TRUE, NULL, whatever) # Gives the error you saw. What you need is if { } else { } : if(!inherits(dat[[n]], factor)) {cat(yes\n)} else {cat(no\n)} HTH, Mike. Stan Hopkins wrote: Is the following developed in my console output a recognized bug or am I using the cat function incorrectly? Thanks, Stan ifelse(class(data[[n]])!=factor,{print(yes)},{print(no)}) [1] yes [1] yes ifelse(class(data[[n]])!=factor,{cat(yes)},{cat(no)}) yesError in ans[test !nas] - rep(yes, length.out = length(ans))[test : incompatible types (from NULL to logical) in subassignment type fix cat(yes) yes class(data[[n]])!=factor [1] TRUE class(data[[n]]) [1] numeric n [1] 28 length(data[[n]]) [1] 955 class(data) [1] data.frame dim(data) [1] 955 182 data[[n]] [1] 2.5 4.9 2.6 3.0 4.7 5.0 3.9 1.5 4.8 3.2 3.6 5.2 6.3 [14] 6.3 5.0 4.6 6.0 4.5 3.9 3.6 5.7 8.5 4.0 5.0 11.8 4.7 [27] 7.9 2.8 4.8 5.1 4.1 4.2 3.7 2.0 2.1 1.1 14.6 7.0 3.4 [40] 3.4 10.1 4.7 4.9 5.2 4.3 2.9 2.8 2.3 1.2 2.0 2.0 3.0 [53] 2.0 1.1 2.0 1.0 2.0 2.0 2.7 1.0 2.0 2.0 2.0 2.0 1.1 [66] 2.0 2.0 1.0 1.1 2.4 2.0 2.0 5.0 0.8 2.0 3.3 2.7 2.2 [79] 2.9 1.4 2.0 1.9 1.0 1.9 2.1 2.2 2.0 2.0 1.3 3.0 1.4 [92] 2.0 1.5 2.1 1.2 1.7 2.1 2.0 2.0 2.3 2.0 1.6 1.5 2.3 [105] 1.1 2.0 2.0 5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0 19.0 4.0 4.0 7.5 6.6 22.0
Re: [R] Obtaining summary of frequencies of value occurrences for a variable in a multivariate dataset.
Hi Jim, The problem description. I am trying to identify mutations in a given gene from a particular genome (biological genome sequence). I have two CSV files consisting of sequences. One file consists of reference (documented,curated accepted as standard) sequences. The other consists of sample sequences I am trying to identify mutations within. In both files the an individual sequence is contained in a single record, its amino acid residues ( the actual sequence of alphabets each representing a given amino acid for example A stands for Alanine, C for Cysteine and so on) are each allocated a single field in the CSV file. The sequences in both files have been well aligned, each contain 115 residues with the first residue is contained in the field 5. The fields 1 to 4 are allocated for metadata (name of sequence and so on). My task is to compile a residue occurrence count for each residue present in a given field in the reference sequence dataset and use this information when reading each sequence in the sample dataset to identify a mutation. For example for position 9 of the sample sequence bb a P is found and according to our reference sequence dataset of summaries, at position 9 P may not even exist or may have an occurrence of 10% or so will be classified as mutation, (I could employ a cut of parameter for mutation classification). Allan. --- jim holtman [EMAIL PROTECTED] wrote: results=()#character() myVariableNames=names(x.val) results[length(myVariableNames)]-NA for (i in myVariableNames){ results[i]-names(x.val[[i]])# this does not work it returns a NULL (how can i convert this to x.val$somevalue ? ) } On 7/27/07, Allan Kamau [EMAIL PROTECTED] wrote: Hi All, I am having difficulties finding a way to find a substitute to the command names(v.val$PR14) so that I could generate the command on the fly for all PR14 to PR200 (please see the previous discussion below to understand what the object x.val contains) . I have tried the following results=()#character() myVariableNames=names(x.val) results[length(myVariableNames)]-NA for as.vector(unlist(strsplit(str,,)),mode=list) +results[i]-names(x.val$i)# this does not work it returns a NULL (how can i convert this to x.val$somevalue ? ) } Allan. - Original Message From: Allan Kamau [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, July 26, 2007 10:03:17 AM Subject: Re: [R] Obtaining summary of frequencies of value occurrences for a variable in a multivariate dataset. Thanks so much Jim, Andaikalavan, Gabor and others for the help and suggestions. The solution will result in a matrix containing nested matrices to enable each variable name, each variables distinct value and the count of the distinct value to be accessible individually. The main matrix will contain the variable names, the first level nested matrices will consist of the variables unique values, and each such variable entry will contain a one element vector to contain the count or occurrence frequency. This matrix can now be used in comparing other similar datasets for variable values and their frequencies. Building on the input received so far, a probable solution in building the matrix will include the following. 1)I reading the csv file (containing column headers) my_data=read.table(path/to/my/data.csv,header=TRUE,sep=,,dec=.,fill=TRUE) 2)I group the values in each variable producing an occurrence count(frequency) x.val-apply(my_data,2,table) 3)I obtain a vector of the names of the variables in the table names(x.val) 4)Now I make use of the names (obtained in step 3) to obtain a vector of distinct values in a given variable (in the example below the variable name is $PR14) names(v.val$PR14) 5)I obtain a vector (with one element) of the frequency of a value obtained from the step above (in our example the value is V) as.vector(x.val$PR14[V]) Todo: Now I will need to place the steps above in a script (consisting of loops) to build the matrix, step 4 and 5 seem tricky to do programatically. Allan. - Original Message From: jim holtman [EMAIL PROTECTED] To: Allan Kamau [EMAIL PROTECTED] Cc: Adaikalavan Ramasamy [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Sent: Wednesday, July 25, 2007 1:50:55 PM Subject: Re: [R] Obtaining summary of frequencies of value occurrences for a variable in a multivariate dataset. Also if you want to access the individual values, you can just leave it as a list: x.val - apply(x, 2, table) # access each value x.val$PR14[V] V 8 On 7/25/07, Allan Kamau [EMAIL PROTECTED] wrote: A subset of the data looks as follows df[1:10,14:20] PR10 PR11 PR12 PR13 PR14 PR15 PR16 1 VTIKVGD 2 VSIKVGG 3 VTIRVGG 4 VSI
Re: [R] Q: extracting data from lm
Marc gave some good general advice, here are a couple more things that are more specific to your problem. Remember that most R functions return information, sometimes invisibly, but it is good to save the results. This includes the summary function (all the numbers that get printed out are also returned in an object). Try something like: fit - lm(nu1~nu4) coef(fit)[2] sfit - summary(fit) coef(sfit) se.nu4 - coef(sfit)[2,2] of course some of us give into the temptation to go for terseness over readability and end up doing this like: se.nu4 - coef(summary(lm(nu1~nu4)))[2,2] or se.nu4 - summary(lm(nu1~nu4))$coefficients[2,2] hope this helps, From: [EMAIL PROTECTED] on behalf of D. R. Evans Sent: Fri 7/27/2007 3:52 PM To: r-help@stat.math.ethz.ch Subject: [R] Q: extracting data from lm Warning: I am a complete newbie to R. I have read ISwR, but I am still finding myself completely stuck on some simple concepts. I have tried everything I can think of to solve this one, and finally decided that enough was enough and I need a pointer to a solution. I have the following summary from lm(): summary(lm(nu1~nu4)) Call: lm(formula = nu1 ~ nu4) Residuals: Min 1Q Median 3Q Max -1572.62 -150.38 -21.70 168.57 2187.84 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 29.88739 43.68881 0.6840.494 nu4 1.000360.01025 97.599 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 470.9 on 298 degrees of freedom Multiple R-Squared: 0.9697, Adjusted R-squared: 0.9696 F-statistic: 9526 on 1 and 298 DF, p-value: 2.2e-16 But I want to access some of these numbers programmatically. I finally figured out that to get the estimate of the nu4 coefficient I need to do: lm(nu1~nu4)$coefficients[2] nu4 1.000363 which to me as a long-time C++ programmer is close to black magic (I've been programming since 1972; I have to say that R is unlike anything I've ever seen, and it's far from trivial to get my head around some of it -- for example, how I could have known a priori that the above is the way to get the nu4 coefficient is beyond me). Anyway, having figured out how to get the estimate of the coefficient, I not-unnaturally wanted also to find a way to access the std. error of the estimate (the value 0.01025 in the summary). But I am completely mystified as to how to do it :-( Any help gratefully (VERY gratefully) received, and I apologise if this is a really, really stupid question and that the answer lies somewhere in some documentation that I've obviously not properly taken on board. __ 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 and provide commented, minimal, self-contained, reproducible code. __ 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 and provide commented, minimal, self-contained, reproducible code.
Re: [R] Combine R2HTML and Rcmd BATCH?
Hi Dieter, There are two ways in R2HTML to work woth graphics. - HTMLplot, that may require the interactive environment depending on how you use it - HTMLInsertGraph that is more suitable for batch scripting but requires some more work. First method: HTMLplot and plotFunction (use print for trellis graphics). Not recommended. Second method; - Create the graphic in the format you need - use HTMLInsertGraph to write HTML linking tag Synopsis: myGraphic - file.path(outdir,graph1.png) png(file=myGraphic) hist(rnorm(100)) dev.off() HTMLInsertGraph(graph1.png,Caption=Graph1) Do not hesitate to send me your file if more help is required Best wishes, Eric 2007/7/17, Dieter Vanderelst [EMAIL PROTECTED]: Hi All, I have an R script that spawns output in the form of an HTML page. This is done by the R2HTML package. Now I want to run the same script using Rcmd BATCH. However, it seems that it is not possible to use R2HTML in this case. My script ends with this error message: # Error in dev.print(png, file = AbsGraphFileName, width = Width, height = Height, : can only print from screen device Execution halted # I can not find how to work around this problem in the R2HTML manual or the help archives. Has anybody done a similar thing before? Any suggestions? Greetings, Dieter -- Dieter Vanderelst [EMAIL PROTECTED] Department of Industrial Design Designed Intelligence __ 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 and provide commented, minimal, self-contained, reproducible code. -- Eric Lecoutre Consultant - Business Decision Business Intelligence Customer Intelligence __ 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 and provide commented, minimal, self-contained, reproducible code.