similar to: Summarizing each row into a frequency table

Displaying 20 results from an estimated 10000 matches similar to: "Summarizing each row into a frequency table"

2009 Feb 22
2
How to parse text file into a table?
I am given a text file of records to be converted into a table format. I have searched related topics or packages, but can't find any similar cases. Please help. Sample record is given below. Take note the last element doesn't have a semi colon. ###---------Start of record---------------------- Name : John Height: 170cm Weight : 70kg Age: 30 Status: Married Children: 2 Employment
2009 Feb 22
2
How to reshape this data frame from long to wide ?
I tried cast and melt in reshape package, but still can't convert this data frame m m [,1] [,2] [1,] "A" "1" [2,] "A" "2" [3,] "B" "3" to this form. m1 [,1] [,2] [1,] "A" "B" [2,] "1" "3" [3,] "2" NA Please help. [[alternative HTML version deleted]]
2009 Mar 14
2
gsub and regex to tidy comma-limited values
I am cleaning up comma-limited values, so that only one comma separates each value. Using the example below, as much as I try with regex, I can't remove the last comma. I hope to have a one-liner solution, if possible. gsub("^,*|,*$|(,)*", "\\1", ",,,apple,,orange,,,,,lemon,strawberry,,,,") [1] "apple,orange,lemon,strawberry,"
2009 Mar 24
2
Legend containing maths symbol and values of variables
I need to have the maths symbol for >= in the legend, and to substitute threshold variable with its value. Somehow, various attempts weren't successful. Please help. threshold <- 0.5 plot(NA, xlab="", ylab="", main="", axes=F, xlim=c(0,1), ylim=c(0,1), xaxs="i", yaxs="i") legend(x=0, y=1, fill=c("orange", "white",
2009 Feb 22
2
Convert a list to matrix
I would like to convert a list to matrix. This can be easily achieved via do.call. The only problem is each element of the list has different length, which causes the recycling of values. How can I have NA instead of recycled values ? m <- list() m[["A"]] <- 1 m[["B"]] <- 2:3 do.call(rbind, m) [,1] [,2] A 1 1 B 2 3 [[alternative HTML version deleted]]
2009 Apr 08
1
Colour each letter of a text string in a plot
I am inserting a DNA sequence into a plot, and hope to colourize each of the four nucleotide of the DNA sequence with a unique colour i.e., A ("red"), C ("green"), G ("blue", and T ("yellow"). I use the following codes, but the DNA sequence only shows as "red" DNA <- "ACGT" plot(1, xlim = c(0,1), ylim = c(0,1), axes=F,
2009 Apr 22
1
Subsetting a vector of numerics such that standard deviation is less than 0.5 ?
> set.seed(999) > abs(rnorm(20)) [1] 0.28174016 1.31255963 0.79518398 0.27007049 0.27730642 0.56602374 1.87865826 1.26679114 0.96774968 1.12100936 1.32546371 0.13397739 0.93874945 [14] 0.17253810 0.95765045 1.36268625 0.06833513 0.10065765 0.90134475 2.07435711 > v <- abs(rnorm(20)) > v [1] 1.2285633 0.6430443 0.3597629 0.2940356 1.1252685 0.6422657 1.1067376 0.8848404 1.5540951
2009 Mar 23
1
Capitalizing first letter of word or phrase
I managed to find toupper() which translates all letters to uppercase. Is there a function to capitalize only the first letter of word or phrase ? Thanks
2009 Feb 28
2
Review my upgrade plan from 2.8.0 to 2.8.1
Hi, On my laptop, R is installed on windows XP SP2 at D:\Program Files\R\R-2.8.0, and all add-on packages are installed at D:\Program Files\R\R-2.8.0.libs. In addition, I have created two environment enviroment to ease upgrading and installation of packages. Packages installed is a mix of those from CRAN, Bioconductor and local zips. D:\My Document\My Desktop>echo %R_HOME% D:/Program
2008 Jun 19
4
Any simple way to subset a vector of strings that do contain a particular substring ?
For example, strings <- c("aaaa", "bbbb","ccba"). How to get "aaaa", "bbbb" that do not contain "ba" ? _________________________________________________________________ [[alternative HTML version deleted]]
2008 Jul 31
4
Identifying common prefixes from a vector of words, and delete those prefixes
For example, c("dog.is.an.animal", "cat.is.an.animal", "rat.is.an.animal"). How can I identify the common prefix is ".is.an.animal" and delete it to give c("dog", "cat", "rat") ? Thanks _________________________________________________________________ [[alternative HTML version deleted]]
2008 Jul 08
4
Can R do this ?
I have a folder full of pngs and jpgs, and would like to consolidate them into a pdf with appropriate title and labels. Can this be done via R ? _________________________________________________________________ Easily publish your photos to your Spaces with Photo Gallery. [[alternative HTML version deleted]]
2008 Jul 15
5
counting number of "G" in "TCGGGGGACAATCGGTAACCCGTCT"
Any better solution than this ? sum(strsplit("TCGGGGGACAATCGGTAACCCGTCT", "")[[1]] == "G") _________________________________________________________________ [[alternative HTML version deleted]]
2008 Nov 04
2
Prevent read.table from converting "+" and "-" to 0
I am using read.table("data.txt", sep="\t") to read in a tab-limited text file. However, two columns of data were read wrongly. read.table converts "+" and "-" in the two columns to 0. I have tried setting other parameters but to no avail. TIA _________________________________________________________________ Get in touch with your inner athlete. Take the
2008 Jun 25
3
selecting values that are unique, instead of selecting unique values
unique(c(1:10,1)) gives 1:10 (i.e. unique values), is there any method to get only 2:10 (i.e. values that are unique) ? _________________________________________________________________ Easily edit your photos like a pro with Photo Gallery. [[alternative HTML version deleted]]
2008 Sep 13
3
Beautify R scripts in microsoft word
I am generating a report containing several R scripts in the appendix. Is there any way to "beautify" the R source codes in microsoft word, similar to what we see in tinn-R ? Thanks _________________________________________________________________ [[alternative HTML version deleted]]
2008 Jun 10
2
Fast method to compute average values of duplicated IDs
Hi, How do I collapse (average in the simplest case) the values of those duplicated ids (i.e., 2, 5, 6, 9) to give a table of unique ids ? t <- cbind(id=c(1:10, 2,5,6,9), value=rnorm(14)) _________________________________________________________________ [[alternative HTML version deleted]]
2009 Jan 06
2
Generating GUI for r-scripts
Hi, I have developed some scripts that basically ask for input tab-limited format files, do some processing, and output several pictures or csv. Now I need to have some gui to wrap on top of the scripts, so that end-users can select their input files, adjust some parameters for processing, and select output folder or filenames. Please advice me if there is any tools or project suitable for
2008 Jul 14
1
Computing row means for sets of 2 columns
Is there a better or more efficent approach than this without the use of t() ? > (m <- matrix(1:40, ncol=4)) [,1] [,2] [,3] [,4] [1,] 1 11 21 31 [2,] 2 12 22 32 [3,] 3 13 23 33 [4,] 4 14 24 34 [5,] 5 15 25 35 [6,] 6 16 26 36 [7,] 7 17 27 37 [8,] 8 18 28 38 [9,] 9 19 29 39[10,] 10 20 30 40 >
2008 Oct 31
1
Proper way to write data frame with column and row names
I need to write a data frame along with its column and row names to a text file. However, the first row in the text file is always short of one element. I have tried setting different parameters to write.table but that didn't help. > m A B C 1 2 D 3 4 Using write.table(m, "table.xls", sep="\t", col.names=T, row.names=T) gives A B C 1 2 D 3 4