Re: [R] use logical in cor.test

2010-03-30 Thread pgseye

Thanks for the replies.

In response to Erik:
What does
 Both[,1]
show you?

 Both[,1]
   [1] 3.36   NA   NA   NA   NA   NA   NA 3.92 3.50   NA   NA   NA   NA 3.76
3.19 3.83   NA 3.66..

What does
 Both[,1]  2.5
show you? 

 Both[,1]2.5
   [1]  TRUENANANANANANA  TRUE  TRUENANA   
NANA  TRUE  TRUE


I understand a logical variable is binary, but don't know how to select a
subset of the data (have tried the subset function, but can't seem to get it
to work)

Bill, when I run what you suggested, I get:

 tBoth - Both 
 is.na(tBoth[tBoth  2.5]) - TRUE 
Error in is.na(tBoth[tBoth  2.5]) - TRUE : 
  NAs are not allowed in subscripted assignments
 R - cor(tBoth, use = complete.obs) 
 R[1,2]
[1] 0.7750889

Any idea with the error message?

Thanks again,

Paul
-- 
View this message in context: 
http://n4.nabble.com/use-logical-in-cor-test-tp1744701p1744896.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] use logical in cor.test

2010-03-30 Thread pgseye

Many thanks Peter,

This did indeed work.


Regards,

Paul
-- 
View this message in context: 
http://n4.nabble.com/use-logical-in-cor-test-tp1744701p1746008.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] use logical in cor.test

2010-03-29 Thread pgseye

Hi,

I've got 4 variables that I want to effectively 'stack' so that I have a
grand R variable and a grand L variable.

This works to achieve that goal:

Twin1cor-with(twin.wide,cbind(ACDepthR.1,ACDepthL.1))
Twin2cor-with(twin.wide,cbind(ACDepthR.2,ACDepthL.2))
Both-rbind(Twin1cor,Twin2cor)

 str(Both)
 num [1:1858, 1:2] 3.36 NA NA NA NA NA NA 3.92 3.5 NA ...
 - attr(*, dimnames)=List of 2
  ..$ : NULL
  ..$ : chr [1:2] ACDepthR.1 ACDepthL.1


I then want to perform a pearson correlation of the two variables, but
exclude any value greater than 2.5. When I do this without excluding
anything, with:

cor.test(Both[,1],Both[,2])

I get:

Pearson's product-moment correlation

data:  Both[, 1] and Both[, 2] 
t = 35.848, df = 854, p-value  2.2e-16
alternative hypothesis: true correlation is not equal to 0 
95 percent confidence interval:
 0.7468716 0.8005199 
sample estimates:
  cor 
0.7750889 

But when I try:

cor.test(Both[,1]2.5,Both[,2]2.5)

I get:

Pearson's product-moment correlation

data:  Both[, 1]  2.5 and Both[, 2]  2.5 
t = 13.3192, df = 854, p-value  2.2e-16
alternative hypothesis: true correlation is not equal to 0 
95 percent confidence interval:
 0.3576600 0.4687099 
sample estimates:
 cor 
0.414728 

I'm not sure why. I know the correlation should improve from the plot by
excluding those under 2.5, but it decreases. Have I done something wrong
here?

Thanks,

Paul
-- 
View this message in context: 
http://n4.nabble.com/use-logical-in-cor-test-tp1744701p1744701.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] Exclude data using logical

2010-03-24 Thread pgseye

Hi,

I'm wanting to exclude data more than 2 sd's from the mean before proceeding
with further analyses. I've created new logical variables (a and b) and
written them to the existing dataframe. I want to be able to subset the TRUE
observations based on another 2 factor variable. I'm assuming this is
possible, but I don't know what I'm doing wrong, as I get results that
obviously aren't correct.

Many thanks,

Paul

twin.wide$a-twin.wide$RCCT600  twin.wide$RCCT480
twin.wide$b-twin.wide$LCCT600  twin.wide$LCCT480

selVarsCCT - with(twin.wide,c('a','b'))

MZCCT - subset(twin.wide,Zygosity=='MZ',selVarsCCT)
DZCCT - subset(twin.wide,Zygosity=='DZ',selVarsCCT)
-- 
View this message in context: 
http://n4.nabble.com/Exclude-data-using-logical-tp1689992p1689992.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] Exclude data using logical

2010-03-24 Thread pgseye

That worked.

Thanks a lot David - I appreciate it.

Paul
-- 
View this message in context: 
http://n4.nabble.com/Exclude-data-using-logical-tp1689992p1690090.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] Re order variables in a dataframe

2009-05-21 Thread pgseye

Thanks everyone

-- 
View this message in context: 
http://www.nabble.com/Reorder-variables-in-a-dataframe-tp23647222p23660941.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] Re order variables in a dataframe

2009-05-20 Thread pgseye

This is no doubt a very basic question for most R users, but is there an easy
way to reorder the variables (columns) in a dataframe (I can't seem to find
an answer anywhere). I've generally been creating a new dataframe and
selecting the new order I want from the old but this is time-consuming.

Thanks,

Paul
-- 
View this message in context: 
http://www.nabble.com/Reorder-variables-in-a-dataframe-tp23647222p23647222.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] Re order variables in a dataframe

2009-05-20 Thread pgseye

Thanks Simon,

I should have explained myself better (although I didn't know about the
order function so that's handy information).

I've found a few times, I've added variables to a dataframe that I would
like to 'group' with variables earlier in the datset. So I was wondering if
you could somehow ask R, for example, to take that last variable and insert
it at a different position in the dataframe.

Thanks,

Paul

Simon Blomberg-4 wrote:
 
 Alphabetically, like this?:
 
 dat - data.frame(d=rnorm(3), c=rnorm(3), b=rnorm(3), a=rnorm(3))
 dat
d  c  b a
 1 -0.1816733 -0.4106008 -0.2855991 -1.022951
 2 -1.8326818 -0.6515208  0.3344884 -2.191836
 3  1.0924867  0.1159611 -1.3409719  1.195545
 dat2 - dat[,order(names(dat))]
 dat2
   a  b  c  d
 1 -1.022951 -0.2855991 -0.4106008 -0.1816733
 2 -2.191836  0.3344884 -0.6515208 -1.8326818
 3  1.195545 -1.3409719  0.1159611  1.0924867
 
 
 Cheers,
 
 Simon.
 
 On Wed, 2009-05-20 at 20:19 -0700, pgseye wrote:
 This is no doubt a very basic question for most R users, but is there an
 easy
 way to reorder the variables (columns) in a dataframe (I can't seem to
 find
 an answer anywhere). I've generally been creating a new dataframe and
 selecting the new order I want from the old but this is time-consuming.
 
 Thanks,
 
 Paul
 -- 
 Simon Blomberg, BSc (Hons), PhD, MAppStat. 
 Lecturer and Consultant Statistician 
 School of Biological Sciences
 The University of Queensland 
 St. Lucia Queensland 4072 
 Australia
 Room 320 Goddard Building (8)
 T: +61 7 3365 2506
 http://www.uq.edu.au/~uqsblomb
 email: S.Blomberg1_at_uq.edu.au
 
 Policies:
 1.  I will NOT analyse your data for you.
 2.  Your deadline is your problem.
 
 The combination of some data and an aching desire for 
 an answer does not ensure that a reasonable answer can 
 be extracted from a given body of data. - John Tukey.
 
 __
 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://www.nabble.com/Reorder-variables-in-a-dataframe-tp23647222p23647370.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] help with plotting results of lda

2009-04-26 Thread pgseye

Hi,

I've performed an lda and obtained a classification table for some of my
data:

 efa.dfa-lda(groups~.,efa.scores.8,CV=T)
 str(efa.dfa)
List of 5
 $ class: Factor w/ 2 levels 1,2: 1 2 1 2 1 1 2 2 1 2 ...
 $ posterior: num [1:160, 1:2] 0.99083 0.00852 0.93983 0.23186 0.85931 ...
  ..- attr(*, dimnames)=List of 2
  .. ..$ : chr [1:160] 1 2 3 4 ...
  .. ..$ : chr [1:2] 1 2
 $ terms:Classes 'terms', 'formula' length 3 groups ~ Comp.1 + Comp.2 +
Comp.3 + Comp.4 + Comp.5 + Comp.6 +  Comp.7 + Comp.8 + Comp.9 + Comp.10
+ Comp.11 + Comp.12 +  ...
  .. ..- attr(*, variables)= language list(groups, Comp.1, Comp.2, Comp.3,
Comp.4, Comp.5, Comp.6,  Comp.7, Comp.8, Comp.9, Comp.10, Comp.11,
Comp.12, Comp.13,  ...
  .. ..- attr(*, factors)= int [1:35, 1:34] 0 1 0 0 0 0 0 0 0 0 ...
  .. .. ..- attr(*, dimnames)=List of 2
  .. .. .. ..$ : chr [1:35] groups Comp.1 Comp.2 Comp.3 ...
  .. .. .. ..$ : chr [1:34] Comp.1 Comp.2 Comp.3 Comp.4 ...
  .. ..- attr(*, term.labels)= chr [1:34] Comp.1 Comp.2 Comp.3
Comp.4 ...
  .. ..- attr(*, order)= int [1:34] 1 1 1 1 1 1 1 1 1 1 ...
  .. ..- attr(*, intercept)= int 1
  .. ..- attr(*, response)= int 1
  .. ..- attr(*, .Environment)=environment: R_GlobalEnv 
  .. ..- attr(*, predvars)= language list(groups, Comp.1, Comp.2, Comp.3,
Comp.4, Comp.5, Comp.6,  Comp.7, Comp.8, Comp.9, Comp.10, Comp.11,
Comp.12, Comp.13,  ...
  .. ..- attr(*, dataClasses)= Named chr [1:35] numeric numeric
numeric numeric ...
  .. .. ..- attr(*, names)= chr [1:35] groups Comp.1 Comp.2 Comp.3
...
 $ call : language lda(formula = groups ~ ., data = efa.scores.8, CV =
T)
 $ xlevels  : list()
 table(groups, Classified=efa.dfa$class)
  Classified
groups  1  2
 1 59 21
 2 10 70

but when I try to plot the results I get:

 plot(efa.dfa)
Error in plot.window(...) : need finite 'xlim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf

anyone have any ideas?

Thanks a lot,

Paul
-- 
View this message in context: 
http://www.nabble.com/help-with-plotting-results-of-lda-tp23240220p23240220.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] add variable in for loop

2009-03-28 Thread pgseye

Hi,

I'm learning to write some basic functions in R. For some data I have I'd
like to be able to add a variable to itself after each iteration in a for
loop to obtain a grandtotal for that variable so I can calculate a mean.

test-function(data){
for (i in 1:80){

meanrotation-(abs(data[i,3]-data[i,2])+abs(data[i,4]-data[i,2])+abs(data[i,5]-data[i,2])+abs(data[i,6]-data[i,2]))/4
cat(i,meanrotation,\n)
#total+=meanrotation
}
#print (total/80)
}

In perl there's an assignment operator variable+=variable2. Is there
anything like this in R to do as illustrated in the code above.

thanks a lot,

Paul

Edit - I guess the other way to do this which I just realised is to assign
the output of the function to a vector and then do a summary(), but I don't
know how to do this either - help is appreciated
-- 
View this message in context: 
http://www.nabble.com/add-variable-in-for-loop-tp22751641p22751641.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] Help with 'boot'

2009-03-22 Thread pgseye

Hi,

I'm wanting to test for a difference in medians between 2 groups using
resampling methods. I found the boot package, but don't really understand
how to write the 'statistic' function required as the 2nd argument for the
bootstrap test.

Thanks if you can help,

Paul
-- 
View this message in context: 
http://www.nabble.com/Help-with-%27boot%27-tp22653487p22653487.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] JGR install problem

2009-03-17 Thread pgseye

Hi,

I thought I'd like to try out JGR, but after installing the package (and
dependencies) I receive the following when I try to load it:

 library(JGR)
Loading required package: rJava
Loading required package: JavaGD
Loading required package: iplots
Note: On Mac OS X we strongly recommend using iplots from within JGR.
Proceed at your own risk as iplots cannot resolve potential ev.loop
deadlocks.
'Yes' is assumed for all dialogs as they cannot be shown without a deadlock,
also ievent.wait() is disabled.
Exception in thread main Error in .jnew(org/rosuda/iplots/Framework) : 
  Failed to create object of class `org/rosuda/iplots/Framework'
In addition: Warning message:
In .jnew(org/rosuda/iplots/Framework) :
  NewObject(org/rosuda/iplots/Framework,()V,...) failed
Error: package 'iplots' could not be loaded
java.lang.InternalError: Can't start the AWT because Java was started on the
first thread.  Make sure StartOnFirstThread is not specified in your
application's Info.plist or on the command line
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1822)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1723)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1509)
at java.awt.Toolkit.clinit(Toolkit.java:1530)
at java.awt.Color.clinit(Color.java:250)
at org.rosuda.ibase.Common.clinit(Common.java:47)
at org.rosuda.iplots.Framework.init(Framework.java:43)

iplots seems to be the problem, but I can't figure out why.

I'm running 2.8.1 and OS X 10.5.6.

Any ideas?

Thanks a lot,

Paul
-- 
View this message in context: 
http://www.nabble.com/JGR-install-problem-tp22572045p22572045.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] How to do ICC

2009-02-05 Thread pgseye

Hi,

I'm essentially wanting to calculate intra- and inter-observer variabilities
for the first principal component of an optic disc shape measure of a sample
of individuals, so from what I can work out I need to work out an intraclass
correlation coefficient(s).

For the intra-data, I have 2 measurements taken on each individual by the
same observer. For the inter-data, 2 observers have taken one measurement
each on the sample.

I've found the 'icc' function in the {psy} package, but am not sure how I'd
perform the intra- calculation as the data argument is an 'n*p matrix or
dataframe, n subjects p raters'.

Would I just substitute the replica for the rater?

Hope this makes sense - still learning about it all.

Thank you.

Paul
 
-- 
View this message in context: 
http://www.nabble.com/How-to-do-ICC-tp21849168p21849168.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] Q about how to use Anova.mlm

2009-01-31 Thread pgseye

Thanks a lot John - appreciate your help.

Regards,

Paul
-- 
View this message in context: 
http://www.nabble.com/Q-about-how-to-use-Anova.mlm-tp21739443p21757533.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] Q about how to use Anova.mlm

2009-01-29 Thread pgseye

Hi,

Am newish to stats and R, so I certainly appreciate any help. Basically I
have 50 inidividuals whom I have 6 photos each of their optic nerve head. I
want to check that the orientation of the nerve head is consistent, ie the 6
replicates show minimal or preferably no rotation differences. I'll draw an
arbitrary line between some blood vessels (same reference in each set of
replicates) and determine an angle of deviation from the vertical and that
angle will be my dependent variable.

Subject   Replicate   Angle of Deviation
1  1   x
1  2   x
1  3   x
1  4   x
1  5   x
1  6   x
2  1   x
2  2   x
2  3   x
2  4   x
2  5   x
2  6   x
etc

I'm wanting to test for Sphericity (because I've read that you should - is
this routine in a repeated measures ANOVA?) and can see that Anova.mlm in
the CAR package offers this in addition to the alternative Greenhouse and
Feldt tests.

I just don't really know how to perform the test - can someone give me some
help.

Thank you.

Paul

Dept of Ophthalmology
Uni Melbourne, Australia
-- 
View this message in context: 
http://www.nabble.com/Q-about-how-to-use-Anova.mlm-tp21739443p21739443.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] Q about how to use Anova.mlm

2009-01-29 Thread pgseye

Thanks a lot for that John - really helpful. I generated some random numbers
and seem to be able to get it to work, so that's great.

One thing - it's come up with a 'Type III' test and given me a few warnings.
What's the difference between Type II and Type III tests (if there's some
basic guide you can point me to).

Thank you again.

Best,

Paul

-- 
View this message in context: 
http://www.nabble.com/Q-about-how-to-use-Anova.mlm-tp21739443p21740704.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] Save object summary to file

2008-09-12 Thread pgseye

Thanks Yihui and to others who replied privately.

Very helpful information.

Regards,

Paul


pgseye wrote:
 
 Hi,
 
 Am wanting to save the summary of a PCA to file.
 
 Have tried:
 
 write.table(summary(PCA), file=PCAvar.txt, sep=\t)
 
 but receive:
 
 Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors =
 stringsAsFactors) : 
   cannot coerce class summary.princomp into a data.frame
 
 What am I doing wrong?
 
 Thanks
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Save-object-summary-to-file-tp19447000p19450595.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] Save object summary to file

2008-09-11 Thread pgseye

Hi,

Am wanting to save the summary of a PCA to file.

Have tried:

 write.table(summary(PCA), file=PCAvar.txt, sep=\t)

but receive:

Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors =
stringsAsFactors) : 
  cannot coerce class summary.princomp into a data.frame

What am I doing wrong?

Thanks


-- 
View this message in context: 
http://www.nabble.com/Save-object-summary-to-file-tp19447000p19447000.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] PCA and % variance explained

2008-09-10 Thread pgseye

Thanks everyone,

Paul


-- 
View this message in context: 
http://www.nabble.com/PCA-and---variance-explained-tp19388970p19410675.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] PCA and % variance explained

2008-09-09 Thread pgseye

After doing a PCA using princomp, how do you view how much each component
contributes to variance in the dataset. I'm still quite new to the theory of
PCA - I have a little idea about eigenvectors and eigenvalues (these
determine the variance explained?). Are the eigenvalues related to loadings
in R?

Thanks,

Paul
-- 
View this message in context: 
http://www.nabble.com/PCA-and---variance-explained-tp19388970p19388970.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] Label 2 groups in PCA different colours

2008-09-06 Thread pgseye

Hi,

I'm wanting to do a PCA on some data which is comprised of two different
groups (to see how well the groups are discriminated). Is there a way to
change the colour of the datapoints in a biplot so that I can easily see
which group is which (eg objects 1-100, red, 101-200, black).

Might be simple, but I'm new to R and can't seem to find how to do this.

Thanks.

Paul
-- 
View this message in context: 
http://www.nabble.com/Label-2-groups-in-PCA-different-colours-tp19354077p19354077.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] Write lower half of distance matrix only

2008-07-26 Thread pgseye

Great, thanks for that Jim,

It does what I need it do do.

Regards,

Paul



jholtman wrote:
 
 Does this do what you want:
 
 x - matrix(1:25,5)
 x
  [,1] [,2] [,3] [,4] [,5]
 [1,]16   11   16   21
 [2,]27   12   17   22
 [3,]38   13   18   23
 [4,]49   14   19   24
 [5,]5   10   15   20   25
 x[upper.tri(x)] - NA
 write.table(x, na=, row.names=FALSE, col.names=FALSE)
 1
 2 7
 3 8 13
 4 9 14 19
 5 10 15 20 25

 
 
 On Fri, Jul 25, 2008 at 8:30 AM, pgseye [EMAIL PROTECTED] wrote:

 Thanks Jim,

 The morphometry software I mentioned outputs distance matrices in the
 format:

 0.
 7.1598 0.
 8.7241 8.3506 0.
 9.5217 7.2457 2.5642 0.

 I would have liked to write to a file the same type of matrix in R, to
 ensure the same data format. Mantel for Windows is optimally setup to
 take
 this type of matrix.

 Thanks




 jholtman wrote:

 How do you want the lower half written out?  can you give us an
 example of the input matrix and then what you would expect to see on
 the output.  Is it still a matrix with the upper half set to zero/NA?
 Do you want it as a vector?  What is the other program expecting as
 input?

 You need to provide more information so that we can provide suggestions.

 On Fri, Jul 25, 2008 at 7:03 AM, pgseye [EMAIL PROTECTED] wrote:

 Hi,

 I'm very new to R. I want to know if there is any way to write only the
 lower half of a distance matrix created in R to a csv file for example.
 I
 get the 'cannot coerce class dist into a data.frame' message when I
 try.
 I have used as.matrix and can write to a file this way, but as a full
 matrix.

 The reason I only want the lower half is that I've been doing some
 Mantel
 correlations with distance matrices (of Procrustes distances) generated
 by
 other (geometric morphometric) software that are in this format.
 However,
 I'm needing to use an alternative such as R to calculate distance
 matrices
 of Fourier coefficients which the other software can't do.  So far, the
 Mantel correlations calculated from these two matrices (with R and also
 another software (Mantel for Windows)) are slightly different (when
 they
 should be exactly the same) and I'm wondering whether it's because the
 input
 format is different (ie one full, one half).

 Thanks,

 Paul


 --
 View this message in context:
 http://www.nabble.com/Write-lower-half-of-distance-matrix-only-tp18649556p18649556.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.




 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem you are trying to solve?

 __
 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://www.nabble.com/Write-lower-half-of-distance-matrix-only-tp18649556p18650794.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.

 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem you are trying to solve?
 
 __
 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://www.nabble.com/Write-lower-half-of-distance-matrix-only-tp18649556p18662636.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] Write lower half of distance matrix only

2008-07-25 Thread pgseye

Hi,

I'm very new to R. I want to know if there is any way to write only the
lower half of a distance matrix created in R to a csv file for example.  I
get the 'cannot coerce class dist into a data.frame' message when I try. 
I have used as.matrix and can write to a file this way, but as a full
matrix. 

The reason I only want the lower half is that I've been doing some Mantel
correlations with distance matrices (of Procrustes distances) generated by
other (geometric morphometric) software that are in this format. However,
I'm needing to use an alternative such as R to calculate distance matrices
of Fourier coefficients which the other software can't do.  So far, the
Mantel correlations calculated from these two matrices (with R and also
another software (Mantel for Windows)) are slightly different (when they
should be exactly the same) and I'm wondering whether it's because the input
format is different (ie one full, one half).

Thanks,

Paul


-- 
View this message in context: 
http://www.nabble.com/Write-lower-half-of-distance-matrix-only-tp18649556p18649556.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.