[R] how to find end of a FASTA file

2012-09-13 Thread mail me
Hi: I am trying to find end of a FASTA file: library(ShortRead) fastadata <- readFasta("fastafolder", "fa$") file <- tempfile() writeFasta(fastadata, file) var1 <- readLines(file) while(countlength(tmp <- readLines(file, n = -1)) > 0) { #do something } I want the while loop to run till the end

[R] PCA on high dimentional data

2011-12-10 Thread mail me
Hi: I have a large dataset mydata, of 1000 rows and 1000 columns. The rows have gene names and columns have condition names (cond1, cond2, cond3, etc). mydata<- read.table(file="c:/file1.mtx", header=TRUE, sep="") I applied PCA as follows: data_after_pca<- prcomp(mydata, retx=TRUE, center=TRUE,

[R] data generation

2012-03-04 Thread mail me
Hi: I am trying to generate data form a simple linear regression model. The training data T = {(x1, y1), . . . , (xn), yn}, want to sample x uniformly from the range [0,1], find uncorrupted response y = x^2, and generate random noise "e" from normal distribution N(0, 1). Any idea how to do in sim

[R] word frequency count

2012-03-18 Thread mail me
Hi: I have a dataframe containing comma seperated group of words such as milk,bread bread,butter beer,diaper beer,diaper milk,bread beer,diaper I want to output the frequency of occurrence of comma separated words for each row and collapse duplicate rows, to make the output as shown in the follo

Re: [R] word frequency count

2012-03-18 Thread mail me
Hi: Suppose I create the dataframe df using the following code: df <- data.frame( item1 = c('milk', 'bread','beer','beer','milk','beer'), item2 =c('bread', 'butter','diaper','diaper','bread', 'diaper'), stringsAsFactors = F); df item1 item2 1 milk bread 2 bread butter 3 beer diaper 4 bee

Re: [R] word frequency count

2012-03-18 Thread mail me
_ > From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf > Of mail me [mailme...@googlemail.com] > Sent: 18 March 2012 13:31 > To: r-help > Subject: Re: [R] word frequency count > > Hi: > > Suppose I create the dataframe df

[R] writing data to file

2012-03-22 Thread mail me
Hi: I created a data frame df <- data.frame( person = c('John','Bob','Mary'), team = c('a','b','c'), stringsAsFactors = F); and obtained the expected output df person team 1 John a 2Bob b 3 Mary c now I want to save the whole content of df preserving its row and co

[R] how to cluster rows of words in a text file

2012-03-23 Thread mail me
Hi: I am trying to cluster the rows of a text file with kmeans: I load the data as follows file1 <- read.csv("somefile.csv") and the file can be viewed having the following line of words > file1 1 word1 word3 word4 word1 2 word1 word4 word3 word1 3 word4 word2 word4 word3 4 word4 word2

[R] create waveform sawtooth

2012-03-26 Thread mail me
Hi: I am trying to create a sawtooth waveform. I used the following x <- runif(500, min = -2, max = 2) y <- (1 -abs(x3))* ((x3) <= 1) combined <- data.frame(x = x3, y = y3) plot(combined) and I get a triangular waveform, not sawtooth. Can someone give a solution to create a sawtooth waveform? T