An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120314/4c464121/attachment.pl>
sort list
4 messages · R. Michael Weylandt, sybil kennelly
What sort of plot are you using? I'm not really clear on what your data as a whole look like: if you use dput() you can create a representation and we can work from there. In addition to the resources Josh recommended, the following sites can direct you to all sorts of graphical goodies, all of which come with source code (though at the latter site, they are often a little complicated): http://had.co.nz/ggplot2/ http://addictedtor.free.fr/graphiques/ Michael On Wed, Mar 14, 2012 at 10:13 AM, sybil kennelly
<sybilkennelly at gmail.com> wrote:
I appreciate the reading Thank you. May i ask one final question. If i have: matrix:
? ? ? ? var1 ? ?var2 ? ? var3 cell1 ? ?x ? ? ? x ? ? ? ? x cell2 ? ?x ? ? ? x ? ? ? ? x cell3 ? ?x ? ? ? x ? ? ? ? x cell4 . . . . cell100
and:
vector1 <- c("cell1, "cell5",cell19", "cell50", "cell70")
your_data$mycells <- factor(your_data$cells %in% vector1, c("Special",
"NotSpecial"))
So my output will be something like:
[25] Special ? ?Special ? ?Special ? ?Special ? ?Special ? ?Special
?[31] Special ? ?NotSpecial NotSpecial NotSpecial NotSpecial NotSpecial
?[37] NotSpecial NotSpecial NotSpecial NotSpecial
is there a way to plot the data so that my "Special" cells are plotted on
top of my not special cells. The reason is my data may have 10000 not
special points,and i may have 5 special cells, I find I'm not able to see
where they are on my plot because they are being covered by my not special
cells :(
I have been looking around for ?"order of factors plotted" , 'order of
levels", "order of factor levels", is this on the right track or can it
even be done?
Syb
On Wed, Mar 14, 2012 at 2:04 PM, sybil kennelly <sybilkennelly at gmail.com>wrote:
I appreciate the reading Thank you. May i ask one final question. If i have: matrix:
? ? ? ? var1 ? ?var2 ? ? var3 cell1 ? ?x ? ? ? x ? ? ? ? x cell2 ? ?x ? ? ? x ? ? ? ? x cell3 ? ?x ? ? ? x ? ? ? ? x cell4 . . . . cell100
and:
vector1 <- c("cell1, "cell5",cell19", "cell50", "cell70")
your_data$mycells <- factor(your_data$cells %in% vector1, c("Special",
"NotSpecial"))
So my output will be something like:
[25] Special ? ?Special ? ?Special ? ?Special ? ?Special ? ?Special
? [31] Special ? ?NotSpecial NotSpecial NotSpecial NotSpecial NotSpecial
? [37] NotSpecial NotSpecial NotSpecial NotSpecial
is there a way to plot the data so that my "Special" cells are plotted on
top of my not special cells. The reason is my data may have 10000 not
special points,and i may have 5 special cells, I find I'm not able to see
where they are on my plot because they are being covered by my not special
cells :(
I have been looking around for ?"order of factors plotted" , 'order of
levels", "order of factor levels", is this on the right track or can it
even be done?
Syb
On Tue, Mar 13, 2012 at 12:29 PM, Joshua Wiley <jwiley.psych at gmail.com>wrote:
On Tue, Mar 13, 2012 at 5:15 AM, sybil kennelly <sybilkennelly at gmail.com> wrote:
Thanks Josh. I'm quite new, just wondering re:factor levels?
In this example (shamelessly stolen from the internet):
schtyp
[1] 0 0 1 0 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 0
schtyp.f <- factor(schtyp, labels = c("private", "public"))
schtyp.f
[1] private private public private private private public private public
[10] private public public public public private private public public
[19] public private
Levels: private public
in my data i have a table:
? ? ? ? var1 ? ?var2 ? ? var3
cell1 ? ?x ? ? ? x ? ? ? ? x
cell2 ? ?x ? ? ? x ? ? ? ? x
cell3 ? ?x ? ? ? x ? ? ? ? x
cell4
.
.
.
.
cell100
and i have a subset of those cells that are interesting to me as a list
of
data
list1 = ["cell1, "cell5",cell19", "cell50", "cell70"]
is it possible to create (similar to above):
schtyp.f <- factor(schtyp, labels = c("special", "normal"))
Sure. ?Again, probably better to have cells of interest in a vector,
not a list a la:
list1 <- c("cell1, "cell5",cell19", "cell50", "cell70")
your_data$mycells <- factor(your_data$cells %in% list1, c("Special",
"NotSpecial"))
basically compares the cells to those in your list and returns
TRUE/FALSE, which is then converted to a factor, labeled, and stored.
If you are just starting, some background reading will help. ?Here are
some suggestions:
1) Go here: http://www.burns-stat.com/pages/tutorials.html and read
the tutorials for R -- Beginning (this should not take more than 1
day).
2) Sit down and read:
http://cran.r-project.org/doc/manuals/R-intro.pdf through Appendix A
(for now you can probably skip the rest of the appendices). ?That will
probably take another entire day or so.
3) Head back to Patrick Burn's website:
http://www.burns-stat.com/pages/tutorials.html and read the
intermediate guide, The R Inferno (1-3 days depending if you can read
for 8 hours straight or not)
Cheers,
Josh
so that when i plot this data, i can color the items in list1 as one
color
(eg all the special cells are red), and the rest of the items as a
second
color (eg all the other cells are black/blue)? Syb On Tue, Mar 13, 2012 at 11:48 AM, Joshua Wiley <jwiley.psych at gmail.com> wrote:
Hi Sybil,
You cannot turn a list into a factor. ?You could do:
cell_data <-c('cell1','cell2')
factor_list <- factor(cell_data)
or if you already have a list, unlist() or as.vector() may convert it
into a vector that you can then convert to a factor.
Cheers,
Josh
On Tue, Mar 13, 2012 at 4:29 AM, sybil kennelly <
sybilkennelly at gmail.com>
wrote:
Hello can anyone help please? i read two words "cell1", "cell2" into a list. I want to turn this
list
into a factor.
cell_data <-list(c('cell1','cell2'))
cell_data
[[1]] [1] "cell1" "cell2"
factor_list <- factor(cell_data)
Error in sort.list(y) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?
sort.list(cell_data)
Error in sort.list(cell_data) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list? Can anyone explain? Syb ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
-- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/
-- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/
? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120314/6522586c/attachment.pl>
Errr...I'm still not sure how plot(table) gives you read and green points, but it sounds like the easiest thing to do would be to use the points() function to come back in and put new green points over the red ones. E.g. plot(runif(5000), runif(5000)) points(c(0.5, 0.25), c(0.5, 0.75), col = 2, pch = 19, cex = 2) Perhaps you can give us a hint of your data with dput(head(table, 30)) Please give us that rather than copy and pasting the printed output of table: it's easier (and more precise) for us to reproduce your data since dput keeps the internal structure. Michael
On Wed, Mar 14, 2012 at 7:44 PM, sybil kennelly <sybilkennelly at gmail.com> wrote:
O yea sure. So for example:
grid <- read.table("table")
( i havent printed the output, as the table is 20,000 rows X 60 columns)
point_of_interest <- c("row1", "row2")
therefore all the other points in
plot(table)
are labelled green, but these two are labelled red.
But at the minute, because the plot is so dense, my two red nodes are
completely obscured by by 19,998 other green nodes.
Just wondering if there is a way of arranging what order nodes are plotted
on the graph, i.e. so my interesting points are plotted last therefore on
top of the other nodes, and visible to me?
Please let me know if i should supply the whole table, it is just a lot of
data I didn't want to irritate anyone putting up a lot of data.
Syb
On Wed, Mar 14, 2012 at 6:29 PM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
What sort of plot are you using? I'm not really clear on what your data as a whole look like: if you use dput() you can create a representation and we can work from there. In addition to the resources Josh recommended, the following sites can direct you to all sorts of graphical goodies, all of which come with source code (though at the latter site, they are often a little complicated): http://had.co.nz/ggplot2/ http://addictedtor.free.fr/graphiques/ Michael On Wed, Mar 14, 2012 at 10:13 AM, sybil kennelly <sybilkennelly at gmail.com> wrote:
I appreciate the reading Thank you. May i ask one final question. If i have: matrix:
? ? ? ? var1 ? ?var2 ? ? var3 cell1 ? ?x ? ? ? x ? ? ? ? x cell2 ? ?x ? ? ? x ? ? ? ? x cell3 ? ?x ? ? ? x ? ? ? ? x cell4 . . . . cell100
and:
vector1 <- c("cell1, "cell5",cell19", "cell50", "cell70")
your_data$mycells <- factor(your_data$cells %in% vector1, c("Special",
"NotSpecial"))
So my output will be something like:
[25] Special ? ?Special ? ?Special ? ?Special ? ?Special ? ?Special
?[31] Special ? ?NotSpecial NotSpecial NotSpecial NotSpecial NotSpecial
?[37] NotSpecial NotSpecial NotSpecial NotSpecial
is there a way to plot the data so that my "Special" cells are plotted
on
top of my not special cells. The reason is my data may have 10000 not
special points,and i may have 5 special cells, I find I'm not able to
see
where they are on my plot because they are being covered by my not
special
cells :(
I have been looking around for ?"order of factors plotted" , 'order of
levels", "order of factor levels", is this on the right track or can it
even be done?
Syb
On Wed, Mar 14, 2012 at 2:04 PM, sybil kennelly
<sybilkennelly at gmail.com>wrote:
I appreciate the reading Thank you. May i ask one final question. If i have: matrix:
? ? ? ? var1 ? ?var2 ? ? var3 cell1 ? ?x ? ? ? x ? ? ? ? x cell2 ? ?x ? ? ? x ? ? ? ? x cell3 ? ?x ? ? ? x ? ? ? ? x cell4 . . . . cell100
and:
vector1 <- c("cell1, "cell5",cell19", "cell50", "cell70")
your_data$mycells <- factor(your_data$cells %in% vector1, c("Special",
"NotSpecial"))
So my output will be something like:
[25] Special ? ?Special ? ?Special ? ?Special ? ?Special ? ?Special
? [31] Special ? ?NotSpecial NotSpecial NotSpecial NotSpecial
NotSpecial
? [37] NotSpecial NotSpecial NotSpecial NotSpecial
is there a way to plot the data so that my "Special" cells are plotted
on
top of my not special cells. The reason is my data may have 10000 not
special points,and i may have 5 special cells, I find I'm not able to
see
where they are on my plot because they are being covered by my not
special
cells :(
I have been looking around for ?"order of factors plotted" , 'order of
levels", "order of factor levels", is this on the right track or can it
even be done?
Syb
On Tue, Mar 13, 2012 at 12:29 PM, Joshua Wiley
<jwiley.psych at gmail.com>wrote:
On Tue, Mar 13, 2012 at 5:15 AM, sybil kennelly <sybilkennelly at gmail.com> wrote:
Thanks Josh. I'm quite new, just wondering re:factor levels?
In this example (shamelessly stolen from the internet):
schtyp
[1] 0 0 1 0 0 0 1 0 1 0 1 1 1 1 0 0 1 1 1 0
schtyp.f <- factor(schtyp, labels = c("private", "public"))
schtyp.f
[1] private private public private private private public private
public
[10] private public public public public private private public
public
[19] public private
Levels: private public
in my data i have a table:
? ? ? ? var1 ? ?var2 ? ? var3
cell1 ? ?x ? ? ? x ? ? ? ? x
cell2 ? ?x ? ? ? x ? ? ? ? x
cell3 ? ?x ? ? ? x ? ? ? ? x
cell4
.
.
.
.
cell100
and i have a subset of those cells that are interesting to me as a
list
of
data
list1 = ["cell1, "cell5",cell19", "cell50", "cell70"]
is it possible to create (similar to above):
schtyp.f <- factor(schtyp, labels = c("special", "normal"))
Sure. ?Again, probably better to have cells of interest in a vector,
not a list a la:
list1 <- c("cell1, "cell5",cell19", "cell50", "cell70")
your_data$mycells <- factor(your_data$cells %in% list1, c("Special",
"NotSpecial"))
basically compares the cells to those in your list and returns
TRUE/FALSE, which is then converted to a factor, labeled, and stored.
If you are just starting, some background reading will help. ?Here are
some suggestions:
1) Go here: http://www.burns-stat.com/pages/tutorials.html and read
the tutorials for R -- Beginning (this should not take more than 1
day).
2) Sit down and read:
http://cran.r-project.org/doc/manuals/R-intro.pdf through Appendix A
(for now you can probably skip the rest of the appendices). ?That will
probably take another entire day or so.
3) Head back to Patrick Burn's website:
http://www.burns-stat.com/pages/tutorials.html and read the
intermediate guide, The R Inferno (1-3 days depending if you can read
for 8 hours straight or not)
Cheers,
Josh
so that when i plot this data, i can color the items in list1 as one
color
(eg all the special cells are red), and the rest of the items as a
second
color (eg all the other cells are black/blue)? Syb On Tue, Mar 13, 2012 at 11:48 AM, Joshua Wiley <jwiley.psych at gmail.com> wrote:
Hi Sybil,
You cannot turn a list into a factor. ?You could do:
cell_data <-c('cell1','cell2')
factor_list <- factor(cell_data)
or if you already have a list, unlist() or as.vector() may convert
it
into a vector that you can then convert to a factor.
Cheers,
Josh
On Tue, Mar 13, 2012 at 4:29 AM, sybil kennelly <
sybilkennelly at gmail.com>
wrote:
Hello can anyone help please? i read two words "cell1", "cell2" into a list. I want to turn this
list
into a factor.
cell_data <-list(c('cell1','cell2'))
cell_data
[[1]] [1] "cell1" "cell2"
factor_list <- factor(cell_data)
Error in sort.list(y) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list?
sort.list(cell_data)
Error in sort.list(cell_data) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list? Can anyone explain? Syb ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
-- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/
-- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, Statistical Consulting Group University of California, Los Angeles https://joshuawiley.com/
? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at 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.