Re: [R] How to handle missing values for the GeneMeta package?

2009-09-22 Thread Payam Minoofar
I am not sure if this is the solution you want, but complete.cases  
will remove rows that contain any NA values at all from a matrix.

These lines get rid of NA values in my little function:
predmat1 - as.matrix(predmat[complete.cases(predmat,respmat),])
respmat1 - as.matrix(respmat[complete.cases(predmat,respmat),])

Also, you may want to look into these other options supplied by list  
members:

index - apply(yourdata, 1, function(x) any( is.nahttp://is.na(x) ) )
yourdata[ !index, ]

or

?na.omit

Sorry if I misunderstood the problem. :)

Payam
__
Payam Minoofar, Ph.D.
Scientist
Meissner Filtration Products
4181 Calle Tesoro
Camarillo, CA 93012
+1 805 388 9911 ext. 159
+1 805 388 5948 fax
payam.minoo...@meissner.com


 Hello all,

 It seems that the GeneMeta passage returns NA in the respective row if
 any gene in the data sets to be synthesised are missing. Do you know
 of a way to overcome this problem?

 I tried using the 'impute' package to fill-in the missing values, but
 R crashes if 'impute' and 'GeneMeta' packages are used together. I
 have asked a separate question for that.

 Thanks
 Vassilis

__
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] pruning data

2009-09-02 Thread Payam Minoofar
Hello everyone,

I am trying to prune a data frame for partial least squares analysis.  
I need to delete an entire row if one cell in the row contains a NA.

Presently, I am running a loop that is supposed to extract the rows  
that are full of numbers into a second data frame and skips the rows  
that contain a single NA value.

I want to know if there is a simple way to determine if a row (about  
20 columns) contains a single NA value without running a loop that  
checks each individual cell.

Thanks in advance.

__
Payam Minoofar, Ph.D.
Scientist
Meissner Filtration Products
4181 Calle Tesoro
Camarillo, CA 93012
+1 805 388 9911 ext. 159
+1 805 388 5948 fax
payam.minoo...@meissner.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] pls package

2009-09-01 Thread Payam Minoofar
Thank you so very much. Yes, a statistician friend expressed his  
certainty that NAs cannot be handled by such algorithms, and you just  
answered the R specific questions.

I will prune the data more and feed them into pls as matrices.

I am, in fact, following the examples your provide with the package  
and the Vol 6 no. 3 issue of the R Newsletter.

Payam
__
Payam Minoofar, Ph.D.
Scientist
Meissner Filtration Products
4181 Calle Tesoro
Camarillo, CA 93012
+1 805 388 9911 ext. 159
+1 805 388 5948 fax
payam.minoo...@meissner.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] Pls package

2009-08-28 Thread Payam Minoofar
Hi,

I have managed to format my data into a single datframe consisting of two AsIs 
response and predictor dataframes in order to supply the plsr command of the 
pls package for principal components analysis.

When I execute the command, however, I get this error:
 fiber1 - plsr(respmat ~ predmat, ncomp=1, data=inputmat,validation=LOO)
Error in model.frame.default(formula = respmat ~ predmat, data = inputmat) :
  invalid type (list) for variable 'respmat'

I happen to have a lot of NAs  in some of the columns. Is that the problem?

Any input will be greatly appreciated.

Thank you very much, in advance.

Payam
--
Payam Minoofar, Ph.D.
Scientist
Meissner Filtration Products
4181 Calle Tesoro
Camarillo, CA 93012
USA
+1 805 388 9911
+1 805 388 5948 fax
payam.minoo...@meissner.com


[[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] Placing text outside graph boundary

2009-06-25 Thread Payam Minoofar
Hello,

Is possible to place a label on a multipanel figure outside the boundaries of 
any single one of the existing graphs in a panel?

Specifically, I have a function that creates a panel with quartz() and then 
fills it with 6 graphs consisting of exactly the same plot for 6 different 
groups. I would like to add one title for the entire figure at the top of the 
figure, but I cannot figure out how to do that without anchoring the title one 
of the graphs.

Is it possible to do that?

Thank you very much.

Payam
--
Payam Minoofar, Ph.D.
Scientist
Meissner Filtration Products
4181 Calle Tesoro
Camarillo, CA 93012
USA
+1 805 388 9911
+1 805 388 5948 fax
payam.minoo...@meissner.com


[[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] Referencing data frames

2009-06-15 Thread Payam Minoofar
You are, indeed, correct. I'm still used to the IGOR Pro programming language 
(for which I even wrote an introductory manual, http://payam.minoofar.com/igor/)

The feedback I've gotten has been fantastic, and I know how I'm going to 
proceed from this point forward.

Nevertheless, I'll solicit more feedback while I have willing ears.

I would like to have a function acquire an object by reference, and within the 
function create new objects based on the original object and then use the name 
of the original object as the base for the names of the newly created objects.

It seems to me that the optimal way of doing this is to have the function 
acquire the name of the object as a string, and then use get() to access the 
object, and then to use the same string to do the name formation of the new 
objects.

IGOR Pro has a built-in function that returns the name of an object as a 
string, and I was wondering if R has a similar facility.

Yes, I'm definitely getting used to the R language, but I've made tremendous 
progress thanks to the list , and the power of R is abundantly clear to me, as 
is the abstruseness of the language. :)

Payam


On 6/15/09 9:29 AM, Greg Snow greg.s...@imail.org wrote:

Generally when someone asks a question like this, they are trying to program in 
a different language using R rather than taking advantage of the power of R 
itself.  If you give us more information on what you are trying to accomplish, 
then we may be able to give better advice on how to accomplish your final goal 
using the power of R.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Payam Minoofar
 Sent: Friday, June 12, 2009 4:00 PM
 To: r-help@r-project.org
 Subject: [R] Referencing data frames

 Hi,

 How do I use the string content of a string variable to reference a
 data frame of the same name? I want to do the typical tasks of 1)
 building a name with a string variable and using the string variable to
 create a data frame (or any object) whose name is the string value of
 the variable and 2) pass on a string to a function as a parameter, and
 then use that string to refer to an existing data frame.

 Thanks in advance.

 Payam
 --
 Payam Minoofar, Ph.D.
 Scientist
 Meissner Filtration Products
 4181 Calle Tesoro
 Camarillo, CA 93012
 USA
 +1 805 388 9911
 +1 805 388 5948 fax
 payam.minoo...@meissner.com


   [[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.


[[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 with syntax error

2009-06-15 Thread Payam Minoofar
Hi,

I have written boxplot commands of this form before, but I don't quite 
understand why the function call is reporting a syntax error in this instance. 
All parameters passed to the function are strings.

Thanks in advance.

Payam

 simplevar - function(wframe,column1,column2) {
+ tframe - get(wframe)
+ x1 - which(names(wframe)==column1)
+ x2 - which(names(wframe)==column2)
+ print(tframe[x1])
+ print(tframe[x2])
+ gtitle - paste(names(tframe[x2]), vs. , names(tframe[x1])
+ quartz(width=7,height=5,dpi=200)
Error: syntax error
 boxplot(tframe[x2] ~ tframe[x1])
Error in eval(expr, envir, enclos) : object 'tframe' not found

 }

[[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] Modifying graphs

2009-06-15 Thread Payam Minoofar
Hi,

Sorry for the high volume. I'm finding new problems as I resolve old ones.

The only remaining issue is modifying the boxplots generated by my function. I 
have found the various parameters like font.lab, font.main, etc., in the 
manual, but I cannot figure out where to introduce them.

The function creates boxplots in a quartz window.
quartz(width=6,height=5,dpi=200)
  boxplot(tframe[,x2] ~ tframe[,x1], font.main=1, 
main=gtitle,xlab=names(tframe[x1]),ylab=names(tframe[x2]), notch=FALSE, 
varwidth=TRUE)


Thank you in advance.

Payam
--
Payam Minoofar, Ph.D.
Scientist
Meissner Filtration Products
4181 Calle Tesoro
Camarillo, CA 93012
USA
+1 805 388 9911
+1 805 388 5948 fax
payam.minoo...@meissner.com

[[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] Referencing data frames

2009-06-12 Thread Payam Minoofar
Hi,

How do I use the string content of a string variable to reference a data frame 
of the same name? I want to do the typical tasks of 1) building a name with a 
string variable and using the string variable to create a data frame (or any 
object) whose name is the string value of the variable and 2) pass on a string 
to a function as a parameter, and then use that string to refer to an existing 
data frame.

Thanks in advance.

Payam
--
Payam Minoofar, Ph.D.
Scientist
Meissner Filtration Products
4181 Calle Tesoro
Camarillo, CA 93012
USA
+1 805 388 9911
+1 805 388 5948 fax
payam.minoo...@meissner.com


[[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] Extracting the name of an object

2009-06-12 Thread Payam Minoofar
With apologies if I missed the answer in the response given to my previous 
question.

How do I extract the name of an object and assign it to a string variable?

For example, I have a dataframe named comnoglyc

How do I assign this name to a variable dfname such that print(dfname) returns 
comnoglyc?

Thank you very much.

Payam

[[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] Matrix manipulation

2009-06-11 Thread Payam Minoofar
Hello everyone,

I have a couple of fairly simple questions (I hope) the answers to which I 
cannot find through the documentation at the moment.


 1.  I would like to delete the a row from a matrix if a certain elimination 
criterion is met. I am familiar with x - x[-7,] (to remove row 7, for 
example). Are there any other means of removing an entire row?
 2.  Is there a single command that will rename the index of each row to match 
the row number once a row has been deleted. For example, when row 7 is deleted 
above, the old row 8 is now row 7, but the row name is still 8. I have 
figured out how to assign a sequence vector to the row names, but I am 
wondering if there is a built-in command that does the same thing. (I.e., 
change the name of row 7 to 7 from 8.)

Thank you very much.

Payam
--
Payam Minoofar, Ph.D.
Scientist
Meissner Filtration Products
4181 Calle Tesoro
Camarillo, CA 93012
USA
+1 805 388 9911
+1 805 388 5948 fax
payam.minoo...@meissner.com


[[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] More basic question

2009-06-11 Thread Payam Minoofar
I have encountered a more fundamental problem in my data set. I'm using 
read.csv, and all the data are imported as character. How do I do a string 
comparison in a line like this:

M10[ !sapply(1:10, function(x)666 %in% M10[x,]), ]

Alternately, how do I change the class type on a column in a data frame from 
character to numeric?

Thank you very much.

Payam

[[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] More basic question

2009-06-11 Thread Payam Minoofar
Never mind the query regarding setting attributes. I just found the relevant 
section in the manual.

The only remaining question is regarding doing string comparisons in sapply 
argument below.

Thank you.

Payam

I have encountered a more fundamental problem in my data set. I'm using 
read.csv, and all the data are imported as character. How do I do a string 
comparison in a line like this:

M10[ !sapply(1:10, function(x)666 %in% M10[x,]), ]

Alternately, how do I change the class type on a column in a data frame from 
character to numeric?

Thank you very much.

Payam

[[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.