[R] use hjust or vjust with dendextend
Following "Introduction to dendextend" from Tal Galili, I applied this code on iris data: ## library(dendextend) library(dendextendRcpp) library(ggplot2) dend2 <- iris[1:30,-5] %>% dist %>% hclust %>% as.dendrogram %>% set("branches_k_color", k=3) %>% set("branches_lwd", rep(1,4)) %>% set("branches_lty", rep(1,6)) %>% set("labels_colors") %>% set("labels_cex", c(1.0,1.0)) %>% set("nodes_pch", 19) %>% set("nodes_col", c("orange", "black", "plum", NA)) ggd2 <- as.ggdend(dend2) ggplot(ggd2, horiz = TRUE, theme = NULL) My problem is that the labels overlap the dendogram leafs and I have no idea on how parameter hjust or vjust may be used to create space between label and leaf. Thanks for any help, Sergio [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Order output list od TukeyHSD function by "p adj"
Thanks for your very useful help! It's working on my data (apply() to a list of lists ) All the best Sergio 2016-02-24 17:02 GMT+01:00 David L Carlson : > hsd.fit is list containing 1 element, a matrix called "wool:tension". It > will be simpler if you extract the matrix and then use order() to get the > matrix sorted by p adj: > > > table <- hsd.fit[["wool:tension"]] > > table[order(table[, 'p adj']), ] > difflwr uprp adj > A:L-B:H 25.778 10.471456 41.08410 0.0001136469 > A:L-A:M 20.556 5.249234 35.86188 0.0029580438 > A:L-A:H 20.000 4.693678 35.30632 0.0040954674 > A:L-B:L 16.333 1.027012 31.63966 0.0302143219 > A:L-B:M 15.778 0.471456 31.08410 0.0398172376 > B:M-B:H 10.000 -5.306322 25.30632 0.3918766902 > B:L-B:H 9.444 -5.861877 24.75077 0.4560949981 > A:H-B:H 5.778 -9.528544 21.08410 0.8705571533 > A:M-B:H 5.222 -10.084100 20.52854 0.9114780002 > B:M-A:M 4.778 -10.528544 20.08410 0.9377205494 > B:L-A:M 4.222 -11.084100 19.52854 0.9626540845 > B:M-A:H 4.222 -11.084100 19.52854 0.9626540845 > B:L-A:H 3.667 -11.639655 18.97299 0.9797122861 > A:H-A:M 0.556 -14.750766 15.86188 0.978240 > B:M-B:L 0.556 -14.750766 15.86188 0.978240 > > - > David L Carlson > Department of Anthropology > Texas A&M University > College Station, TX 77840-4352 > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sergio > Fonda > Sent: Wednesday, February 24, 2016 6:47 AM > To: Jim Lemon > Cc: r-help@r-project.org > Subject: Re: [R] Order output list od TukeyHSD function by "p adj" > > Thank you Jim also for introducing a shorter data frame. > However the HSD output I deal with is derived from a crossing factors > condition. > Could you kindly explain how could I sort results obtained from a > > fm1 <- aov(breaks ~ wool * tension, data = warpbreaks) > hsd.fit<-TukeyHSD(fm1, "wool:tension", ordered = TRUE) > > which gives the following "crossing" output where "wool:tension" is a > string > > $`wool:tension` > difflwr upr p adj > A:M-B:H 5.222 -10.084100 20.52854 0.9114780 > A:H-B:H 5.778 -9.528544 21.08410 0.8705572 > B:L-B:H 9.444 -5.861877 24.75077 0.4560950 > B:M-B:H 10.000 -5.306322 25.30632 0.3918767 > A:L-B:H 25.778 10.471456 41.08410 0.0001136 > A:H-A:M 0.556 -14.750766 15.86188 0.978 > B:L-A:M 4.222 -11.084100 19.52854 0.9626541 > B:M-A:M 4.778 -10.528544 20.08410 0.9377205 > A:L-A:M 20.556 5.249234 35.86188 0.0029580 > B:L-A:H 3.667 -11.639655 18.97299 0.9797123 > B:M-A:H 4.222 -11.084100 19.52854 0.9626541 > A:L-A:H 20.000 4.693678 35.30632 0.0040955 > B:M-B:L 0.556 -14.750766 15.86188 0.978 > A:L-B:L 16.333 1.027012 31.63966 0.0302143 > A:L-B:M 15.778 0.471456 31.08410 0.0398172 > > > How may I order this part of results by "p adj" ? > Thank you again for your patience! > Sergio > > 2016-02-24 7:48 GMT+01:00 Jim Lemon : > > > Hi Sergio, > > I couldn't get your example data to read in, so I have used the example > in > > the help page: > > > > fm1 <- aov(breaks ~ wool + tension, data = warpbreaks) > > hsd.fit<-TukeyHSD(fm1, "tension", ordered = TRUE) > > hsd.fit$tension[order(hsd.fit$tension[,4]),] > > difflwr upr p adj > > L-H 14.72 5.3688015 24.07564 0.001121788 > > L-M 10.00 0.6465793 19.35342 0.033626219 > > M-H 4.72 -4.6311985 14.07564 0.447421021 > > > > Obviously you would have to examine the output of TukeyHSD with str() to > > sort out which column to use for ordering. > > > > Jim > > > > > > On Wed, Feb 24, 2016 at 11:21 AM, Sergio Fonda > > > wrote: > > > >> Hello, It's already for several hours that I try to order the list > >> obtained by the function TukeyHSD according to the variable "p adj" > >> (in ascending order). Unfortunately, without success. > >> In addition to following two lines of code, that offer the result but > >> separately so do not correspond to the desired result, I was unable to > >> go: > >> DF.5 <-lapply(DF.4, function (x) > as.data.frame(x[c("patient:Fold.fac")])) > >> DF.6 <- DF.5[[1]][order(DF.5[[1]]$patient.Fold.fac.p.adj),] > >> Please, I ask some help to answer these two questions: > >> 1) is it possible to
Re: [R] Normalization in R
If you intend "standardization, use scale(x, center = TRUE, scale = TRUE), center for zero mean scale for SD=1 Best regards, Sergio 2016-02-24 8:22 GMT+01:00 Alnazer Elbedairy : > Dear all > anyone know the function or syntax to get the Normalization for Data ? > thanks > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] Order output list od TukeyHSD function by "p adj"
Thank you Jim also for introducing a shorter data frame. However the HSD output I deal with is derived from a crossing factors condition. Could you kindly explain how could I sort results obtained from a fm1 <- aov(breaks ~ wool * tension, data = warpbreaks) hsd.fit<-TukeyHSD(fm1, "wool:tension", ordered = TRUE) which gives the following "crossing" output where "wool:tension" is a string $`wool:tension` difflwr upr p adj A:M-B:H 5.222 -10.084100 20.52854 0.9114780 A:H-B:H 5.778 -9.528544 21.08410 0.8705572 B:L-B:H 9.444 -5.861877 24.75077 0.4560950 B:M-B:H 10.000 -5.306322 25.30632 0.3918767 A:L-B:H 25.778 10.471456 41.08410 0.0001136 A:H-A:M 0.556 -14.750766 15.86188 0.978 B:L-A:M 4.222 -11.084100 19.52854 0.9626541 B:M-A:M 4.778 -10.528544 20.08410 0.9377205 A:L-A:M 20.556 5.249234 35.86188 0.0029580 B:L-A:H 3.667 -11.639655 18.97299 0.9797123 B:M-A:H 4.222 -11.084100 19.52854 0.9626541 A:L-A:H 20.000 4.693678 35.30632 0.0040955 B:M-B:L 0.556 -14.750766 15.86188 0.978 A:L-B:L 16.333 1.027012 31.63966 0.0302143 A:L-B:M 15.778 0.471456 31.08410 0.0398172 How may I order this part of results by "p adj" ? Thank you again for your patience! Sergio 2016-02-24 7:48 GMT+01:00 Jim Lemon : > Hi Sergio, > I couldn't get your example data to read in, so I have used the example in > the help page: > > fm1 <- aov(breaks ~ wool + tension, data = warpbreaks) > hsd.fit<-TukeyHSD(fm1, "tension", ordered = TRUE) > hsd.fit$tension[order(hsd.fit$tension[,4]),] > difflwr upr p adj > L-H 14.72 5.3688015 24.07564 0.001121788 > L-M 10.00 0.6465793 19.35342 0.033626219 > M-H 4.72 -4.6311985 14.07564 0.447421021 > > Obviously you would have to examine the output of TukeyHSD with str() to > sort out which column to use for ordering. > > Jim > > > On Wed, Feb 24, 2016 at 11:21 AM, Sergio Fonda > wrote: > >> Hello, It's already for several hours that I try to order the list >> obtained by the function TukeyHSD according to the variable "p adj" >> (in ascending order). Unfortunately, without success. >> In addition to following two lines of code, that offer the result but >> separately so do not correspond to the desired result, I was unable to >> go: >> DF.5 <-lapply(DF.4, function (x) as.data.frame(x[c("patient:Fold.fac")])) >> DF.6 <- DF.5[[1]][order(DF.5[[1]]$patient.Fold.fac.p.adj),] >> Please, I ask some help to answer these two questions: >> 1) is it possible to get directly from the function TukeyHSD sorted >> rows by "p adj"? >> 2) or, may the output list from TukeyHSD() be processed (e.g. by >> lapply) to sort its elements according to "p adj"? >> I attach at bottom a simulation of a list obtained from TukeyHSD which >> should be ordered by "p adj". >> Thanks in advance for any suggestion! >> Sergio >> # >> > dput(DF.4) >> list(structure(list(patient = structure(c(12289274.0619908, >> -2380308.48287107, >> -14669582.5448618, -4176414.56676197, -18845997.1116238, >> -31135271.1736146, >> 28754962.6907435, 14085380.1458817, 1796106.0838909, 0.186808233632622, >> 0.938592742253258, 0.0922160074633905), .Dim = 3:4, .Dimnames = list( >> c("PARTIAL-COMPLETE", "NO-COMPLETE", "NO-PARTIAL"), c("diff", >> "lwr", "upr", "p adj"))), Fold.fac = structure(c(-12697325.7957036, >> -23938561.4288898, -1456090.1625174, 0.0268617694934425), .Dim = c(1L, >> 4L), .Dimnames = list("middle-low", c("diff", "lwr", "upr", "p adj" >> ))), `patient:Fold.fac` = structure(c(15369710.0977205, 6521960.91205235, >> -4695802.45257667, 4502968.78925385, -16007472.7140147, -8847749.18566819, >> -20065512.5502972, -10866741.3084667, -31377182.8117352, -11217763.364629, >> -2018992.12279849, -22529433.626067, 9198771.24183052, -11311670.261438, >> -20510441.5032685, -12927630.9811041, -21775380.1667723, >> -33016252.8378897, >> -23817481.5960591, -44327923.0993277, -37145090.2644928, >> -48385962.9356102, >> -39187191.6937797, -59697633.1970482, -39538213.749942, -30339442.5081115, >> -50849884.01138, -19144769.6082929, -39655211.1115614, -48853982.353392, >> 43667051.1765452, 34819301.990877, 23624647.9327363, 32823419.1745669, >> 12312977.6712983, 19449591.8931564, 8254937.83501579, 17453709.0768463, >> -3056732.42642223, 17102687.020684, 26301458.2625145, 5791016.75924596, >> 37542312.0919539, 17031870.5886854, 783309
[R] Order output list od TukeyHSD function by "p adj"
Hello, It's already for several hours that I try to order the list obtained by the function TukeyHSD according to the variable "p adj" (in ascending order). Unfortunately, without success. In addition to following two lines of code, that offer the result but separately so do not correspond to the desired result, I was unable to go: DF.5 <-lapply(DF.4, function (x) as.data.frame(x[c("patient:Fold.fac")])) DF.6 <- DF.5[[1]][order(DF.5[[1]]$patient.Fold.fac.p.adj),] Please, I ask some help to answer these two questions: 1) is it possible to get directly from the function TukeyHSD sorted rows by "p adj"? 2) or, may the output list from TukeyHSD() be processed (e.g. by lapply) to sort its elements according to "p adj"? I attach at bottom a simulation of a list obtained from TukeyHSD which should be ordered by "p adj". Thanks in advance for any suggestion! Sergio # > dput(DF.4) list(structure(list(patient = structure(c(12289274.0619908, -2380308.48287107, -14669582.5448618, -4176414.56676197, -18845997.1116238, -31135271.1736146, 28754962.6907435, 14085380.1458817, 1796106.0838909, 0.186808233632622, 0.938592742253258, 0.0922160074633905), .Dim = 3:4, .Dimnames = list( c("PARTIAL-COMPLETE", "NO-COMPLETE", "NO-PARTIAL"), c("diff", "lwr", "upr", "p adj"))), Fold.fac = structure(c(-12697325.7957036, -23938561.4288898, -1456090.1625174, 0.0268617694934425), .Dim = c(1L, 4L), .Dimnames = list("middle-low", c("diff", "lwr", "upr", "p adj" ))), `patient:Fold.fac` = structure(c(15369710.0977205, 6521960.91205235, -4695802.45257667, 4502968.78925385, -16007472.7140147, -8847749.18566819, -20065512.5502972, -10866741.3084667, -31377182.8117352, -11217763.364629, -2018992.12279849, -22529433.626067, 9198771.24183052, -11311670.261438, -20510441.5032685, -12927630.9811041, -21775380.1667723, -33016252.8378897, -23817481.5960591, -44327923.0993277, -37145090.2644928, -48385962.9356102, -39187191.6937797, -59697633.1970482, -39538213.749942, -30339442.5081115, -50849884.01138, -19144769.6082929, -39655211.1115614, -48853982.353392, 43667051.1765452, 34819301.990877, 23624647.9327363, 32823419.1745669, 12312977.6712983, 19449591.8931564, 8254937.83501579, 17453709.0768463, -3056732.42642223, 17102687.020684, 26301458.2625145, 5791016.75924596, 37542312.0919539, 17031870.5886854, 7833099.34685487, 0.632098034657304, 0.986399530577416, 0.997064140940244, 0.997595806079891, 0.590366152539712, 0.948510666498818, 0.330512619876425, 0.883673837089478, 0.0198821692150445, 0.868982868764254, 0.52294188371, 0.207190890959777, 0.939934594322161, 0.86529009598038, 0.306625751897378), .Dim = c(15L, 4L), .Dimnames = list( c("PARTIAL:low-COMPLETE:low", "NO:low-COMPLETE:low", "COMPLETE:middle-COMPLETE:low", "PARTIAL:middle-COMPLETE:low", "NO:middle-COMPLETE:low", "NO:low-PARTIAL:low", "COMPLETE:middle-PARTIAL:low", "PARTIAL:middle-PARTIAL:low", "NO:middle-PARTIAL:low", "COMPLETE:middle-NO:low", "PARTIAL:middle-NO:low", "NO:middle-NO:low", "PARTIAL:middle-COMPLETE:middle", "NO:middle-COMPLETE:middle", "NO:middle-PARTIAL:middle"), c("diff", "lwr", "upr", "p adj" , .Names = c("patient", "Fold.fac", "patient:Fold.fac" ), class = c("TukeyHSD", "multicomp"), orig.call = aov(formula = abundance ~ patient * Fold.fac, data = x), conf.level = 0.95, ordered = FALSE), structure(list(patient = structure(c(11084928.3849924, -3790273.898858, -14875202.2838504, -2565656.8579769, -17440859.1418273, -28525787.5268197, 24735513.6279617, 9860311.34411127, -1224617.0408811, 0.137587687259541, 0.791659281224941, 0.028733410253219), .Dim = 3:4, .Dimnames = list( c("PARTIAL-COMPLETE", "NO-COMPLETE", "NO-PARTIAL"), c("diff", "lwr", "upr", "p adj"))), Fold.fac = structure(c(25003217.9525667, 15683872.2084017, 34322563.6967316, 1.59282125378191e-07), .Dim = c(1L, 4L), .Dimnames = list("low-high", c("diff", "lwr", "upr", "p adj"))), `patient:Fold.fac` = structure(c(6786144.11764773, -14136208.8235292, 15255972.7140153, 30625682.8117357, 21777933.6260674, -20922352.9411769, 8469828.59636761, 23839538.6940879, 14991789.5084197, 29392181.5375445, 44761891.6352649, 35914142.4495966, 15369710.0977203, 6521960.91205206, -8847749.18566828, -16711562.4882314, -37633915.4294083, -8222591.1541805, 7147118.94353984, -1700630.24212845, -44420059.547056, -15008735.2718282, 360974.825892106, -8486774.35977618, 5913617.6693487, 21283327.767069, 12435578.5814008, -8089695.41243546, -16937444.5981037, -32307154.6958241, 30283850.7235268, 9361497.78234989, 38734536.5822112, 54104246.6799315, 45256497.4942632, 2575353.66470216, 31948392.4645634, 47318102.5622838, 38470353.3766155, 52870745.4057404, 68240455.5034607, 59392706.3177924, 38829115.6078761, 29981366.4222079, 14611656.3244875, 0.963180623746077, 0.521122619371869, 0.431445001590424, 0.00280179326576413, 0.0869916657428951, 0.113173926329674, 0.908231706478258, 0.0441523667992262, 0
[R] boxplots facets in ggplot, generated with two factors interaction mediane-ordered
Sorry for repeating the message owing to previous uncorrect html version delivered (Thank you bert Gunter for the alert). Marc Schwartz enabled me to order a "two factors" interaction boxplot with median associated to one factor alone: thanks. I tried further to generate facets plot (3x2 boxplots in ggplot2) for the dataframe reported at bottom and I'm not able to reach a correct plot. The dataframe is a simulation of genes expressions in five conditions of patients. I would like that each of the 5 boxplots were ordered with median of values associated to the combination "gene*pat.cond". Any help is much appreciated, Sergio Example Dataframe: DF <- structure(list(pat.cond = structure(c(3L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 4L, 3L, 1L, 2L, 2L, 2L, 5L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 2L, 2L, 2L, 5L, 5L, 5L, 3L, 1L, 1L, 1L, 2L, 5L, 5L, 5L, 5L, 3L, 3L, 1L, 2L, 3L, 3L, 2L, 4L, 4L, 4L, 5L, 5L, 3L, 2L, 3L, 3L, 1L, 1L, 2L, 5L, 1L, 1L, 2L, 2L, 4L, 5L, 2L, 2L, 2L, 5L, 5L, 5L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 5L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 5L, 3L, 1L, 2L, 5L, 3L, 3L, 1L, 1L, 1L, 1L, 5L, 2L, 2L, 2L, 2L, 4L, 4L, 5L, 5L, 5L, 3L, 3L, 3L, 1L, 1L, 2L, 5L, 3L, 2L, 2L, 2L, 5L, 3L, 1L, 2L, 5L, 1L, 2L, 5L, 5L, 3L, 1L, 5L, 3L, 1L, 1L, 1L, 2L, 5L, 5L, 3L, 1L, 5L, 5L, 1L, 1L, 2L, 5L, 5L, 3L, 1L, 1L, 2L, 4L, 5L, 2L, 4L, 5L, 5L, 5L, 3L, 1L, 2L, 5L, 5L, 3L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 4L, 5L, 5L, 5L, 3L, 3L, 1L, 1L, 3L, 3L, 1L, 1L, 5L, 5L, 5L, 5L, 3L, 2L, 2L, 4L, 5L, 3L, 1L, 1L, 1L, 2L, 2L, 5L, 5L, 3L, 1L, 1L, 2L, 2L, 4L, 5L, 5L, 5L, 2L, 2L, 4L, 4L, 5L, 5L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 1L, 1L, 5L, 5L, 1L, 2L, 5L, 4L, 5L, 5L), .Label = c("E", "M", "N", "R", "S"), class = "factor"), gene = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 19L, 19L, 19L, 19L, 19L, 19L, 19L, 20L, 20L, 20L, 20L, 20L, 21L, 21L, 21L, 21L, 22L, 22L, 22L, 22L, 23L, 23L, 23L, 24L, 24L, 24L, 24L, 24L, 24L, 24L, 25L, 25L, 25L, 25L, 26L, 26L, 26L, 26L, 26L, 27L, 27L, 27L, 27L, 27L, 27L, 28L, 28L, 28L, 28L, 28L, 29L, 29L, 29L, 29L, 29L, 30L, 30L, 30L, 30L, 30L, 31L, 31L, 31L, 31L, 31L, 31L, 31L, 32L, 32L, 32L, 32L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 33L, 34L, 34L, 34L, 34L, 34L, 35L, 35L, 35L, 35L, 35L, 35L, 35L, 35L, 36L, 36L, 36L, 36L, 36L, 36L, 36L, 36L, 36L, 37L, 37L, 37L, 37L, 37L, 37L, 38L, 38L, 38L, 38L, 38L, 38L, 39L, 39L, 39L, 39L, 39L, 40L, 40L, 40L, 41L, 41L, 41L), .Label = c("ADAMTS1", "ADAMTS12", "APC", "BORIS", "BRCA1", "P16", "DAX1", "DKK1", "DKK2", "ESR1", "FBP1", "FOXL2", "GATA5", "GPX3", "MAL", "MGMT", "MLH1", "MYOD1", "NELL1", "OSMR", "PAX6", "PTGS2", "RARB", "RASSF1A", "RPRM", "RSPOI", "SEPTIN9", "SFRP1", "SFRP4", "SFRP5", "SMAD4", "SOCS3", "SPARC", "TAC1", "TERT", "TIMP3", "TMEFF2", "WIF1", "WNT4", "WRN", "WT1"), class = "factor"), value = c(-5.55719429171322, -2.57670015708011, -6.62935662007961, -6.62935662007961, -6.62935662007961, -6.62935662007961, -6.62935662007961, -6.62935662007961, -6.62935662007961, -2.74216370891365, -1.08410461110653, 1.71087195329919, 6.62935662007961, 6.62935662007961, 1.71142268170053, -3.66516900838688, -1.1921835776928, -6.62935662007961, 3.69654219362645, -3.53399164077955, -4.26788713377028, 6.62935662007961, 6.62935662007961, 6.62935662007961, 6.62935662007961, 6.62935662007961, 6.62935662007961, -4.26034786170766, -6.62935662007961, -6.62935662007961, -6.44317496711901, -6.62935662007961, -6.62935662007961, -2.52597228116937, -1.69870667463154, -6.62935662007961, -6.62935662007961, -6.62935662007961, -6.62935662007961, -6.62935662007961, 0.518269571084176, 0.708010227963537, -0.337455349570156, 2.80337460503403, -1.40722622802079, 6.62935662007961, 2.0224084987157, 6.62935662007961, 6.62935662007961, 6.62935662007961, -0.876905559086274, 0.00817656528033632, -3.0570810238408, 0.804046915404625, -4.67788067608942, -3.26418214278398, 0.219772060806496, -3.20576041923257, -3.56779953667954, -1.68711309148568, -6.62935662007961, -6.62935662007961, 1.47981002017674, 1.86101101355619, -0.110196473063222, 0.721286184467319, -5.10794386813511, -4.59381236574539, -1.6221766881308, -3.09779152534191, -4.56412323856937, 3.8043673057, 0.323703764100918, -3.85135048527067, -3.32408752349639, 0.73940898934279, -1.17193224621231, -3.46605473088182, -1.28303869901795, -2.77839069037272, -2.01447927302819, -3.01523417249907, -6.62935662007961, -1.94219073489774, 6.62935662007961, -6.62935662007961, -2.61598244990042, -6.62935662007961, 0.12874335428895
Re: [R] Is there a time series resampling function ?
I insist: as a trial, apply function "resample" (package signal) I think it's worth doing a test ( it performs resampling through bandlimited interpolation) SF Il 06/set/2015 18:52, "Jeff Newmiller" ha scritto: > There are lots of them. You might be having trouble searching because you > don't know how to spell "interpolate". > > ?approx > ?spline > > Also look at the Time Series task view on CRAN. > --- > Jeff NewmillerThe . . Go Live... > DCN:Basics: ##.#. ##.#. Live > Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On September 6, 2015 4:54:45 AM PDT, AltShift > wrote: > >I need a function for regularising the time base of electronically > >acquired > >signals (i.e. vectors of samples with a nominally constant time base). > > > >For example, the accelerometer in my smartphone can deliver data at > >about 50 > >Hz, but the sampling rate varies by about 5% throughout a recording. I > >have > >developed signal processing functions that assume a constant sample > >rate, so > >I need to modify my input data vectors so that this assumption becomes > >true. > >Furthermore, if I want to combine signals from different sources that > >have > >different sampling rates, I will be obliged to harmonise the time > >bases, > >somehow. > > > >I have written routines in other languages to interpolate (generate a > >larger > >number of regularly spaced samples from the input series) or, what I > >call, > >"intrapolate" (generate a smaller number of regularly spaced samples > >from > >the input series), so it wouldn't be too hard form me to write a > >function > >that covers both, but I prefer not to reinvent wheels (unless my wheel > >is > >markedly better!) > > > >Can anyone tell me if there is already a package that might cover what > >I > >need? > > > > > > > > > >-- > >View this message in context: > > > http://r.789695.n4.nabble.com/Is-there-a-time-series-resampling-function-tp4711907.html > >Sent from the R help mailing list archive at Nabble.com. > > > >__ > >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >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@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] Is there a time series resampling function ?
Have you tried signal package? SF Il 06/set/2015 17:14, "AltShift" ha scritto: > I need a function for regularising the time base of electronically acquired > signals (i.e. vectors of samples with a nominally constant time base). > > For example, the accelerometer in my smartphone can deliver data at about > 50 > Hz, but the sampling rate varies by about 5% throughout a recording. I have > developed signal processing functions that assume a constant sample rate, > so > I need to modify my input data vectors so that this assumption becomes > true. > Furthermore, if I want to combine signals from different sources that have > different sampling rates, I will be obliged to harmonise the time bases, > somehow. > > I have written routines in other languages to interpolate (generate a > larger > number of regularly spaced samples from the input series) or, what I call, > "intrapolate" (generate a smaller number of regularly spaced samples from > the input series), so it wouldn't be too hard form me to write a function > that covers both, but I prefer not to reinvent wheels (unless my wheel is > markedly better!) > > Can anyone tell me if there is already a package that might cover what I > need? > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Is-there-a-time-series-resampling-function-tp4711907.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] boxplots facets in ggplot, generated with two factors interaction mediane-ordered
Thanks to Marc Schwartz I was able to order a "two factors" interaction boxplot with median associated to one factor alone. I tried further to generate facets plot (3x2 boxplots in ggplot2) for the dataframe reported at bottom and I'm not able to reach a correct plot. The dataframe is a simulation of genes expressions in five conditions of patients. I would like that each of the 5 boxplots were ordered with median of values associated to the combination "gene*pat.cond". Any help is much appreciated, Sergio Example Dataframe: pat.cond genevalue 1 N ADAMTS1 -5.557194292 2 N ADAMTS1 -2.576700157 3 E ADAMTS1 -6.629356620 4 E ADAMTS1 -6.629356620 5 E ADAMTS1 -6.629356620 6 E ADAMTS1 -6.629356620 7 M ADAMTS1 -6.629356620 8 M ADAMTS1 -6.629356620 9 M ADAMTS1 -6.629356620 10 M ADAMTS1 -2.742163709 11 N ADAMTS12 -1.084104611 12 E ADAMTS12 1.710871953 13 E ADAMTS12 6.629356620 14 M ADAMTS12 6.629356620 15 M ADAMTS12 1.711422682 16 E APC -3.665169008 17 E APC -1.192183578 18 M APC -6.629356620 19 M APC 3.696542194 20 M APC -3.533991641 21 R APC -4.267887134 22 NBORIS 6.629356620 23 EBORIS 6.629356620 24 MBORIS 6.629356620 25 MBORIS 6.629356620 26 MBORIS 6.629356620 27 SBORIS 6.629356620 28 EBRCA1 -4.260347862 29 EBRCA1 -6.629356620 30 EBRCA1 -6.629356620 31 MBRCA1 -6.443174967 32 MBRCA1 -6.629356620 33 MBRCA1 -6.629356620 34 MBRCA1 -2.525972281 35 N P16 -1.698706675 36 M P16 -6.629356620 37 M P16 -6.629356620 38 M P16 -6.629356620 39 S P16 -6.629356620 40 S P16 -6.629356620 41 S P16 0.518269571 42 N DAX1 0.708010228 43 E DAX1 -0.337455350 44 E DAX1 2.803374605 45 E DAX1 -1.407226228 46 M DAX1 6.629356620 47 S DAX1 2.022408499 48 S DAX1 6.629356620 49 S DAX1 6.629356620 50 S DAX1 6.629356620 51 N DKK1 -0.876905559 52 N DKK1 0.008176565 53 E DKK1 -3.057081024 54 M DKK1 0.804046915 55 N DKK2 -4.677880676 56 N DKK2 -3.264182143 57 M DKK2 0.219772061 58 R DKK2 -3.205760419 59 R DKK2 -3.567799537 60 R DKK2 -1.687113091 61 S DKK2 -6.629356620 62 S DKK2 -6.629356620 63 N ESR1 1.479810020 64 M ESR1 1.861011014 65 N FBP1 -0.110196473 66 N FBP1 0.721286184 67 E FBP1 -5.107943868 68 E FBP1 -4.593812366 69 M FBP1 -1.622176688 70 S FBP1 -3.097791525 71 EFOXL2 -4.564123239 72 EFOXL2 3.80437 73 MFOXL2 0.323703764 74 MFOXL2 -3.851350485 75 RFOXL2 -3.324087523 76 SFOXL2 0.739408989 77 MGATA5 -1.171932246 78 MGATA5 -3.466054731 79 MGATA5 -1.283038699 80 SGATA5 -2.778390690 81 SGATA5 -2.014479273 82 SGATA5 -3.015234172 83 E GPX3 -6.629356620 84 E GPX3 -1.942190735 85 M GPX3 6.629356620 86 M GPX3 -6.629356620 87 M GPX3 -2.615982450 88 M GPX3 -6.629356620 89 M GPX3 0.128743354 90 S GPX3 -6.629356620 91 E MAL -6.629356620 92 E MAL -4.825545452 93 E MAL -6.629356620 94 E MAL -6.629356620 95 E MAL -6.629356620 96 M MAL -0.419005364 97 M MAL -0.923667455 98 M MAL 6.629356620 99 M MAL 3.371740196 100S MAL -6.629356620 101N MGMT -6.629356620 102E MGMT 1.115112556 103M MGMT 4.030893797 104S MGMT -6.629356620 105N MLH1 -0.519875304 106N MLH1 -1.352872084 107E MLH1 -0.777864442 108E MLH1 1.105073029 109E MLH1 5.758699199 110E MLH1 -1.498072236 111S MLH1 -1.630362301 112MMYOD1 -6.629356620 113MMYOD1 6.629356620 114MMYOD1 -6.629356620 115MMYOD1 -6.629356620 116RMYOD1 -6.629356620 117RMYOD1 -6.629356620 118SMYOD1 -6.629356620 119SMYOD1 -6.629356620 120SMYOD1 -4.645053781 121NNELL1 -6.629356620 122NNELL1 -5.536591557 123NNELL1 -5.903856552 124ENELL1 -6.629356620 125ENELL1 -6.629356620 126MNELL1 -6.629
Re: [R] factor interaction boxplot ordering by median
620 126MNELL1 -6.629356620 127SNELL1 -6.629356620 128N OSMR -6.629356620 129M OSMR 4.407821839 130M OSMR 0.364604851 131M OSMR -6.629356620 132S OSMR -6.629356620 133N PAX6 6.629356620 134E PAX6 -3.401030959 135M PAX6 -0.946878855 136S PAX6 0.964721065 137EPTGS2 -3.749795240 138MPTGS2 -6.629356620 139SPTGS2 -2.076356656 140SPTGS2 -3.961164916 141N RARB -4.611429173 142E RARB -1.706166432 143S RARB -3.697493231 144N RASSF1A -1.505128642 145E RASSF1A 0.808179628 146E RASSF1A -6.629356620 147E RASSF1A -0.694997778 148M RASSF1A -0.332307577 149S RASSF1A -6.629356620 150S RASSF1A 6.629356620 151N RPRM -4.023523466 152E RPRM 0.443243995 153S RPRM -6.629356620 154S RPRM -4.019270038 155ERSPOI -1.735307607 156ERSPOI -1.296083205 157MRSPOI -3.003752756 158SRSPOI -3.156564936 159SRSPOI -2.928871731 160N SEPTIN9 -6.629356620 161E SEPTIN9 -2.585469731 162E SEPTIN9 -2.525798264 163M SEPTIN9 6.629356620 164R SEPTIN9 -3.07153 165S SEPTIN9 -6.629356620 166MSFRP1 -1.426465815 167RSFRP1 -6.629356620 168SSFRP1 -2.348648751 169SSFRP1 -6.629356620 170SSFRP1 -2.304295273 171NSFRP4 -2.315044901 172ESFRP4 -2.940158139 173MSFRP4 6.629356620 174SSFRP4 -6.629356620 175SSFRP4 6.629356620 176NSFRP5 -6.629356620 177ESFRP5 -5.833523393 178ESFRP5 2.765666156 179ESFRP5 2.707734922 180ESFRP5 6.629356620 181MSMAD4 -6.629356620 182MSMAD4 -6.629356620 183MSMAD4 -6.629356620 184RSMAD4 -6.629356620 185SSMAD4 -6.629356620 186SSMAD4 -6.629356620 187SSMAD4 -6.629356620 188NSOCS3 -0.604614698 189NSOCS3 0.097268646 190ESOCS3 -1.505450218 191ESOCS3 6.629356620 192NSPARC -3.865639988 193NSPARC -1.868782928 194ESPARC 2.821046068 195ESPARC 6.629356620 196SSPARC -6.629356620 197SSPARC 0.202017887 198SSPARC 6.629356620 199SSPARC 6.629356620 200N TAC1 -1.528221578 201M TAC1 6.629356620 202M TAC1 6.629356620 203R TAC1 -2.294267250 204S TAC1 2.624594634 205N TERT -2.985641232 206E TERT 2.809747729 207E TERT 6.629356620 208E TERT -3.164404633 209M TERT 6.629356620 210M TERT -2.766881108 211S TERT 0.875337372 212S TERT 3.175095461 213NTIMP3 -2.046729298 214ETIMP3 -3.461408230 215ETIMP3 -2.996720557 216MTIMP3 -6.629356620 217MTIMP3 -1.527333149 218RTIMP3 -3.933657283 219STIMP3 -1.020144976 220STIMP3 -2.357112874 221STIMP3 0.806736362 222M TMEFF2 -1.160275850 223M TMEFF2 -2.712025806 224R TMEFF2 -3.961478237 225R TMEFF2 -6.510953714 226S TMEFF2 -0.619555286 227S TMEFF2 2.344341057 228E WIF1 -6.629356620 229E WIF1 -3.806114522 230E WIF1 -2.318313158 231M WIF1 1.102899897 232M WIF1 6.629356620 233M WIF1 -6.629356620 234N WNT4 -6.629356620 235E WNT4 -3.474027185 236E WNT4 -6.629356620 237S WNT4 -6.629356620 238S WNT4 -6.629356620 239E WRN -6.629356620 240M WRN -4.148942985 241S WRN -1.855994142 242R WT1 -0.824982393 243S WT1 1.236129501 244S WT1 1.088540877 2015-09-05 15:08 GMT+02:00 Marc Schwartz : > > > On Sep 5, 2015, at 7:29 AM, Sergio Fonda > wrote: > > > > I would to visualize in boxplot a data frame with two factors ordering > one > > factor with the median. > > As example,suppose to have the InsectSprays dataframe, where an > "operator" > > factor with two levels, op1 and op2, has been added as shown at bottom > here. > > How may be generated a boxplot showing boxes for the interaction > spray*op, > > ordered according to the operators' count median for every spray ? > > Thanks in advance for any help! > > Sergio > > > > Modified InsectSprays dataframe: > > > > Hi, > > There is actually an example of reordering
[R] factor interaction boxplot ordering by median
I would to visualize in boxplot a data frame with two factors ordering one factor with the median. As example,suppose to have the InsectSprays dataframe, where an "operator" factor with two levels, op1 and op2, has been added as shown at bottom here. How may be generated a boxplot showing boxes for the interaction spray*op, ordered according to the operators' count median for every spray ? Thanks in advance for any help! Sergio Modified InsectSprays dataframe: count spray op 1 10 A op1 2 7 A op1 3 20 A op1 4 14 A op1 5 14 A op1 6 12 A op1 7 10 A op2 8 23 A op2 9 17 A op2 1020 A op2 1114 A op2 1213 A op2 1311 B op1 1417 B op1 1521 B op1 1611 B op1 1716 B op1 1814 B op1 1917 B op2 2017 B op2 2119 B op2 2221 B op2 23 7 B op2 2413 B op2 25 0 C op1 26 1 C op1 27 7 C op1 28 2 C op1 29 3 C op1 30 1 C op1 31 2 C op2 32 1 C op2 33 3 C op2 34 0 C op2 35 1 C op2 36 4 C op2 37 3 D op1 38 5 D op1 3912 D op1 40 6 D op1 41 4 D op1 42 3 D op1 43 5 D op2 44 5 D op2 45 5 D op2 46 5 D op2 47 2 D op2 48 4 D op2 49 3 E op1 50 5 E op1 51 3 E op1 52 5 E op1 53 3 E op1 54 6 E op1 55 1 E op2 56 1 E op2 57 3 E op2 58 2 E op2 59 6 E op2 60 4 E op2 6111 F op1 62 9 F op1 6315 F op1 6422 F op1 6515 F op1 6616 F op1 6713 F op2 6810 F op2 6926 F op2 7026 F op2 7124 F op2 7213 F op2 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] factor interaction boxplot ordering by median
Great! Thank you All the best SF Il 05/set/2015 15:08, "Marc Schwartz" ha scritto: > > > On Sep 5, 2015, at 7:29 AM, Sergio Fonda > wrote: > > > > I would to visualize in boxplot a data frame with two factors ordering > one > > factor with the median. > > As example,suppose to have the InsectSprays dataframe, where an > "operator" > > factor with two levels, op1 and op2, has been added as shown at bottom > here. > > How may be generated a boxplot showing boxes for the interaction > spray*op, > > ordered according to the operators' count median for every spray ? > > Thanks in advance for any help! > > Sergio > > > > Modified InsectSprays dataframe: > > > > Hi, > > There is actually an example of reordering factor levels by a calculated > numeric value using the InsectSprays data frame in ?boxplot using ?reorder. > An interaction can be created by using ?interaction. > > Given your data above, in a data frame “DF”: > > DF <- structure(list(count = c(10L, 7L, 20L, 14L, 14L, 12L, 10L, 23L, > 17L, 20L, 14L, 13L, 11L, 17L, 21L, 11L, 16L, 14L, 17L, 17L, 19L, > 21L, 7L, 13L, 0L, 1L, 7L, 2L, 3L, 1L, 2L, 1L, 3L, 0L, 1L, 4L, > 3L, 5L, 12L, 6L, 4L, 3L, 5L, 5L, 5L, 5L, 2L, 4L, 3L, 5L, 3L, > 5L, 3L, 6L, 1L, 1L, 3L, 2L, 6L, 4L, 11L, 9L, 15L, 22L, 15L, 16L, > 13L, 10L, 26L, 26L, 24L, 13L), spray = structure(c(1L, 1L, 1L, > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, > 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, > 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, > 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, > 6L, 6L, 6L, 6L, 6L), .Label = c("A", "B", "C", "D", "E", "F"), class = > "factor"), > op = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, > 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, > 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, > 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, > 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, > 2L, 2L), .Label = c("op1", "op2"), class = "factor")), .Names = > c("count", > "spray", "op"), class = "data.frame", row.names = c("1", "2", > "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", > "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", > "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", > "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", > "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", > "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", > "70", "71", "72")) > > > # Modify the ?boxplot example > bymedian <- with(DF, reorder(interaction(spray, op), count, median)) > > > bymedian > [1] A.op1 A.op1 A.op1 A.op1 A.op1 A.op1 A.op2 A.op2 A.op2 A.op2 A.op2 > [12] A.op2 B.op1 B.op1 B.op1 B.op1 B.op1 B.op1 B.op2 B.op2 B.op2 B.op2 > [23] B.op2 B.op2 C.op1 C.op1 C.op1 C.op1 C.op1 C.op1 C.op2 C.op2 C.op2 > [34] C.op2 C.op2 C.op2 D.op1 D.op1 D.op1 D.op1 D.op1 D.op1 D.op2 D.op2 > [45] D.op2 D.op2 D.op2 D.op2 E.op1 E.op1 E.op1 E.op1 E.op1 E.op1 E.op2 > [56] E.op2 E.op2 E.op2 E.op2 E.op2 F.op1 F.op1 F.op1 F.op1 F.op1 F.op1 > [67] F.op2 F.op2 F.op2 F.op2 F.op2 F.op2 > attr(,"scores") > A.op1 B.op1 C.op1 D.op1 E.op1 F.op1 A.op2 B.op2 C.op2 D.op2 E.op2 F.op2 > 13.0 15.0 1.5 4.5 4.0 15.0 15.5 17.0 1.5 5.0 2.5 18.5 > 12 Levels: C.op1 C.op2 E.op2 E.op1 D.op1 D.op2 A.op1 B.op1 ... F.op2 > > > boxplot(count ~ bymedian, data = DF, > xlab = "Interaction of spray and op", ylab = "Insect count", > main = "Modified InsectSprays Data", varwidth = TRUE, > col = "lightgray") > > > Regards, > > Marc Schwartz > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.csv file= question
Call getwd() in both terminal and your RStudio environments and compare results Il 04/ago/2015 16:53, "Brittany Demmitt" ha scritto: > Hello, > > I have a quick question about the “file=“ specification for the command > write.csv.When I run this command in Rstudio I do not need the “file=“ > specified. For example the below command works just fine. > > write.csv(data,”/home/data.csv”) > > However when I am running an Rscript from the terminal and putting it in > the background I need to specify “file=“. So for the example above I need > to instead have > > write.csv(data,file=”/home/data.csv”) > > Any ideas why this is the case? Writing file= isn’t a problem, just > trying to get an idea of how R works better. > > Thanks! > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] Removing rows in a data frame
In my experience package "dplyr" has all functions to deal with this kind of problems in a simple and compact way Sergio Il 03/lug/2015 07:26, "Charles Thuo" ha scritto: > I have a data frame whose rows are 678013 . I would like to remove rows > from 30696 to 678013 and then attach a new column with a length of 30595. > > > I tried > > Y<- X[-30595:678013,] and its not working > > In addition how do i add a new column > > Kindly assist. > > Charles > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] Stream package
Ok you are rigth. However, suppose for example to have to establish the performance of a "peak finding" algorithm by means of a simulation using a signal sampled at 2kHz. I'm not able to decide if stream is an adequate environment to reach a conclusion about algorithm. Thanks! Il 29/giu/2015 23:48, "Jeff Newmiller" ha scritto: > "Real time" is a squishy term. Your question is not one that can be > answered here, since it is so context dependent. > --- > Jeff NewmillerThe . . Go Live... > DCN:Basics: ##.#. ##.#. Live > Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On June 29, 2015 2:19:42 PM PDT, Sergio Fonda > wrote: > >"stream" package is devoted to cluster prediction and processing in > >data > >streaming condition. > >Is it convenient also for realtime signal processing ( filtering, EMD, > >etc.) > >Thank you for any remark! > >Sergio > > > > [[alternative HTML version deleted]] > > > >__ > >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >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 -- To UNSUBSCRIBE and more, see 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] Stream package
"stream" package is devoted to cluster prediction and processing in data streaming condition. Is it convenient also for realtime signal processing ( filtering, EMD, etc.) Thank you for any remark! Sergio [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] Matrix of indexes to extract sparse data in dataframe
Thank you very much! Il 05/giu/2015 15:58, "David L Carlson" ha scritto: > You can select elements of a matrix using a 2 dimensional matrix that > specifies the row/column number of the cells you want to extract: > > > c2 <- cbind(seq_len(nrow(c0)), c1) > > c2 >c1 > [1,] 1 2 > [2,] 2 2 > [3,] 3 1 > [4,] 4 2 > [5,] 5 1 > [6,] 6 1 > > d1 <- c0[c2] > > d1 > [1] -1 -3 12 2 -23 17 > > See the help page for [ > > ?'[' > > - > David L Carlson > Department of Anthropology > Texas A&M University > College Station, TX 77840-4352 > > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Sergio > Fonda > Sent: Friday, June 5, 2015 8:47 AM > To: John Kane > Cc: R-help > Subject: Re: [R] Matrix of indexes to extract sparse data in dataframe > > Thank you, of course but I can't use that form as I told. My question is > about the possibility to enter in a dataframe with a matrix of indices and > get the corresponding values > Thanks again > Il 05/giu/2015 15:39, "John Kane" ha scritto: > > > d1 <- apply(c0, 1, min) I think does it. > > > > John Kane > > Kingston ON Canada > > > > > > > -Original Message- > > > From: sergio.fond...@gmail.com > > > Sent: Fri, 5 Jun 2015 15:06:34 +0200 > > > To: r-help@r-project.org > > > Subject: [R] Matrix of indexes to extract sparse data in dataframe > > > > > > I would like to avoid a "for loop" to get a vector of data taken from > > > rows of a data frame for specific columns. > > > An example is the following (I can't apply min to every row of df, this > > > is > > > just an example): > > > > > > c0=data.frame(a=c(3,-2,12,7,-23,17) , b=c(-1,-3,14,2,6,19)) > > > c1=apply(c0,1,which.min) > > >> c1 > > > [1] 2 2 1 2 1 1 > > > > > > I would like to get a result like the following call, but without > > > employing a "for loop": > > > > > > d1=c(c0[1,c1[1]], c0[2,c1[2]], c0[3,c1[3]], c0[4,c1[4]], c0[5,c1[5]], > > > c0[6,c1[6]]) > > >> d1 > > > [1] -1 -3 12 2 -23 17 > > > > > > Thanks a lot for any help! > > > > > > __ > > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > > 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. > > > > > > Can't remember your password? Do you need a strong and secure password? > > Use Password manager! It stores your passwords & protects your account. > > Check it out at http://mysecurelogon.com/password-manager > > > > > > > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] Matrix of indexes to extract sparse data in dataframe
Thank you, of course but I can't use that form as I told. My question is about the possibility to enter in a dataframe with a matrix of indices and get the corresponding values Thanks again Il 05/giu/2015 15:39, "John Kane" ha scritto: > d1 <- apply(c0, 1, min) I think does it. > > John Kane > Kingston ON Canada > > > > -Original Message- > > From: sergio.fond...@gmail.com > > Sent: Fri, 5 Jun 2015 15:06:34 +0200 > > To: r-help@r-project.org > > Subject: [R] Matrix of indexes to extract sparse data in dataframe > > > > I would like to avoid a "for loop" to get a vector of data taken from > > rows of a data frame for specific columns. > > An example is the following (I can't apply min to every row of df, this > > is > > just an example): > > > > c0=data.frame(a=c(3,-2,12,7,-23,17) , b=c(-1,-3,14,2,6,19)) > > c1=apply(c0,1,which.min) > >> c1 > > [1] 2 2 1 2 1 1 > > > > I would like to get a result like the following call, but without > > employing a "for loop": > > > > d1=c(c0[1,c1[1]], c0[2,c1[2]], c0[3,c1[3]], c0[4,c1[4]], c0[5,c1[5]], > > c0[6,c1[6]]) > >> d1 > > [1] -1 -3 12 2 -23 17 > > > > Thanks a lot for any help! > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > > > Can't remember your password? Do you need a strong and secure password? > Use Password manager! It stores your passwords & protects your account. > Check it out at http://mysecurelogon.com/password-manager > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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 of indexes to extract sparse data in dataframe
I would like to avoid a "for loop" to get a vector of data taken from rows of a data frame for specific columns. An example is the following (I can't apply min to every row of df, this is just an example): c0=data.frame(a=c(3,-2,12,7,-23,17) , b=c(-1,-3,14,2,6,19)) c1=apply(c0,1,which.min) > c1 [1] 2 2 1 2 1 1 I would like to get a result like the following call, but without employing a "for loop": d1=c(c0[1,c1[1]], c0[2,c1[2]], c0[3,c1[3]], c0[4,c1[4]], c0[5,c1[5]], c0[6,c1[6]]) > d1 [1] -1 -3 12 2 -23 17 Thanks a lot for any help! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] assign variables to function output
That's it ! Sorry for writing in a hurry, Merm! Il 16/apr/2015 14:14, "Jim Lemon" ha scritto: > Hi merm, > In case Sergio's message is a little cryptic: > > return_a_list<-function() { > a<-"First item of list" > b<-c(2,4,6,8) > c<-matrix(1:9,nrow=3) > return(list(a,b,c)) > } > > x<-return_a_list() > x > > Jim > > On Thu, Apr 16, 2015 at 7:21 PM, Sergio Fonda > wrote: > > Collect in a vector or dataframe or list the variables of interest and > > output it. > > Il 16/apr/2015 10:57, "merm" ha > scritto: > > > >> Hi! > >> > >> So I'm trying as the header suggests to assign the value(s) output by a > >> function to a variable, say 'y' > >> > >> Problem is from what I gather any variables introduced within the > function > >> are contained and the only output I can get is "return(value)" which is > >> awkward to work with. Any suggestions? > >> > >> Cheers! > >> > >> > >> > >> -- > >> View this message in context: > >> > http://r.789695.n4.nabble.com/assign-variables-to-function-output-tp4705920.html > >> Sent from the R help mailing list archive at Nabble.com. > >> > >> __ > >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >> 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 -- To UNSUBSCRIBE and more, see > > 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] assign variables to function output
Collect in a vector or dataframe or list the variables of interest and output it. Il 16/apr/2015 10:57, "merm" ha scritto: > Hi! > > So I'm trying as the header suggests to assign the value(s) output by a > function to a variable, say 'y' > > Problem is from what I gather any variables introduced within the function > are contained and the only output I can get is "return(value)" which is > awkward to work with. Any suggestions? > > Cheers! > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/assign-variables-to-function-output-tp4705920.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] A simple For-Loop doesn't work
Pay attention to the i counter in the loop: it runs from 1 to 6 but data has only 3 elements Il 15/mar/2015 04:56 "Nicolae Doban" ha scritto: > Hello, > > my name is Nick and I'm working on a project. I'm having trouble with > building a simple for-loop. In this loop I want to read csv files, perform > a corr function and save it to a pdf file. I tried to solve this problem by > looking for solutions online but couldn't figure it out. Could you also > tell me if if it is possible to name the dataframe(grid.table())?Could you > please help me? > > The code I wrote and which doesn't work is: > ** > Data <- c("July", "August", "September") > > pdf("Cor.pdf") > setwd("path") > for(i in 1:6){ > > Data[i] <- read.csv(Data[i],".csv", header=T) > > grid.table(cor(Data[i][3:10])) > corrgram(Data[i], order=TRUE, lower.panel=panel.shade, >upper.panel=panel.pie, text.panel=panel.txt, >main=Data[i],"Cor") > > } > dev.off() > ** > > Thank you, > Nick > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] Split a dataframe by rownames and/or colnames
Did you try "dplyr" package? Sergio Il 23/feb/2015 13:05 "Tim Richter-Heitmann" ha scritto: > Thank you very much for the line. It was doing the split as suggested. > However, i want to release all the dataframes to the environment (later > on, for each dataframe, some dozen lines of code will be carried out, and i > dont know how to do it w lapply or for-looping, so i do it separately): > > list2env(split(df, sub(".+_","", rownames(df))), envir=.GlobalEnv) > > Anyway, the dataframes have now numeric names in some cases, and cannot be > easily accessed because of it. > How would the line be altered to add an "df_" for each of the dataframe > names resulting from list2env? > > Thank you very much! > > > > Thanks, On 20.02.2015 20:36, David Winsemius wrote: > >> On Feb 20, 2015, at 9:33 AM, Tim Richter-Heitmann wrote: >> >> Dear List, >>> >>> Consider this example >>> >>> df <- data.frame(matrix(rnorm(9*9), ncol=9)) >>> names(df) <- c("c_1", "d_1", "e_1", "a_p", "b_p", "c_p", "1_o1", "2_o1", >>> "3_o1") >>> row.names(df) <- names(df) >>> >>> >>> indx <- gsub(".*_", "", names(df)) >>> >>> I can split the dataframe by the index that is given in the column.names >>> after the underscore "_". >>> >>> list2env( >>> setNames( >>> lapply(split(colnames(df), indx), function(x) df[x]), >>> paste('df', sort(unique(indx)), sep="_")), >>> envir=.GlobalEnv) >>> >>> However, i changed my mind and want to do it now by rownames. Exchanging >>> colnames with rownames does not work, it gives the exact same output (9 >>> rows x 3 columns). I could do >>> as.data.frame(t(df_x), >>> but maybe that is not elegant. >>> What would be the solution for splitting the dataframe by rows? >>> >> The split.data.frame method seems to work perfectly well with a >> rownames-derived index argument: >> >> split(df, sub(".+_","", rownames(df) ) ) >>> >> $`1` >>c_1 d_1 e_1 a_p b_p c_p 1_o1 2_o1 3_o1 >> c_1 -0.11 -0.04 1.33 -0.87 -0.16 -0.25 -0.75 0.34 0.14 >> d_1 -0.62 -0.94 0.80 -0.78 -0.70 0.74 0.11 1.44 -0.33 >> e_1 0.98 -0.83 0.48 0.19 -0.32 -1.01 1.28 1.04 -2.16 >> >> $o1 >> c_1 d_1 e_1 a_p b_p c_p 1_o1 2_o1 3_o1 >> 1_o1 -0.93 -0.02 0.69 -0.67 1.04 1.04 -1.50 -0.36 0.50 >> 2_o1 0.02 -0.16 -0.09 -1.50 -0.02 -1.04 1.07 -0.45 1.56 >> 3_o1 -1.42 0.88 -0.05 0.85 -1.35 0.21 1.35 0.92 -0.76 >> >> $p >>c_1 d_1 e_1 a_p b_p c_p 1_o1 2_o1 3_o1 >> a_p -1.35 0.91 -0.58 -0.63 0.94 -1.13 0.71 0.25 0.82 >> b_p -0.25 -0.73 -0.41 -1.71 1.28 0.19 -0.35 1.74 -0.93 >> c_p -0.01 -1.11 -0.12 0.58 1.51 0.03 -0.99 -0.23 -0.03 >> >> Thank you very much! >>> >>> -- >>> Tim Richter-Heitmann >>> >>> > > -- > Tim Richter-Heitmann (M.Sc.) > PhD Candidate > > > > International Max-Planck Research School for Marine Microbiology > University of Bremen > Microbial Ecophysiology Group (AG Friedrich) > FB02 - Biologie/Chemie > Leobener Straße (NW2 A2130) > D-28359 Bremen > Tel.: 0049(0)421 218-63062 > Fax: 0049(0)421 218-63069 > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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 program results and graphs to one file
With a little effort you could implement Rstudio and try RMD (R Markdown) it is very proficient, look at https://support.rstudio.com/hc/en-us/articles/200552086-Using-R-Markdown Il 01/feb/2015 21:07 "Ragia Ibrahim" ha scritto: > > Dear group, > > I have many plots and numeric results in my R program, kindly how can I > save them all sequently on one file. > thanks in advance > RAI > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] how to judge a virable is a integer?
Further and last trial: > a=5.102> a-floor(a)==0[1] FALSE> a=5.9> a-floor(a)==0[1] FALSE> a=19> > a-floor(a)==0[1] TRUE All the best, Sergio 2014-10-18 16:25 GMT+02:00 PO SU : > > It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. but > deeply, when i want to know 1 is an integer, there seems no easy way to > get the answer. > So, is there anyone happen to know it? > > > > > -- > > PO SU > mail: desolato...@163.com > Majored in Statistics from SJTU > > > > At 2014-10-18 20:10:09, "S Ellison" wrote: > >> But i use a<-10/b , b is some value ,may be 5, maybe 5.5 > >If you do floating point arithmetic on integers you'll usually get > floating point answers, including the 5.0. > > > >See FAQ 7.31 for the usual floating point problem, and ?all.equal for the > usual answer to it. You could see if a result is close to an integer by,for > example, using all.equal to compare it to itself after rounding. > > > >S > > > >*** > >This email and any attachments are confidential. Any use, copying or > >disclosure other than by the intended recipient is unauthorised. If > >you have received this message in error, please notify the sender > >immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com > >and delete this message and any copies from your computer and network. > >LGC Limited. Registered in England 2991879. > >Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK > __ > 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.
Re: [R] how to judge a virable is a integer?
Sorry for my previous hurry misunderstanding. Try this link: http://stackoverflow.com/questions/3476782/how-to-check-if-the-number-is-integer 2014-10-18 16:25 GMT+02:00 PO SU : > > It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. but > deeply, when i want to know 1 is an integer, there seems no easy way to > get the answer. > So, is there anyone happen to know it? > > > > > -- > > PO SU > mail: desolato...@163.com > Majored in Statistics from SJTU > > > > At 2014-10-18 20:10:09, "S Ellison" wrote: > >> But i use a<-10/b , b is some value ,may be 5, maybe 5.5 > >If you do floating point arithmetic on integers you'll usually get > floating point answers, including the 5.0. > > > >See FAQ 7.31 for the usual floating point problem, and ?all.equal for the > usual answer to it. You could see if a result is close to an integer by,for > example, using all.equal to compare it to itself after rounding. > > > >S > > > >*** > >This email and any attachments are confidential. Any use, copying or > >disclosure other than by the intended recipient is unauthorised. If > >you have received this message in error, please notify the sender > >immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com > >and delete this message and any copies from your computer and network. > >LGC Limited. Registered in England 2991879. > >Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK > __ > 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.
Re: [R] how to judge a virable is a integer?
Don't know if this trivial reply will be useful >a=5 >is.numeric(a) >[1] TRUE >b="try" >is.numeric(b) >[1] FALSE Il 18/ott/2014 16:29 "PO SU" ha scritto: > > It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. but > deeply, when i want to know 1 is an integer, there seems no easy way to > get the answer. > So, is there anyone happen to know it? > > > > > -- > > PO SU > mail: desolato...@163.com > Majored in Statistics from SJTU > > > > At 2014-10-18 20:10:09, "S Ellison" wrote: > >> But i use a<-10/b , b is some value ,may be 5, maybe 5.5 > >If you do floating point arithmetic on integers you'll usually get > floating point answers, including the 5.0. > > > >See FAQ 7.31 for the usual floating point problem, and ?all.equal for the > usual answer to it. You could see if a result is close to an integer by,for > example, using all.equal to compare it to itself after rounding. > > > >S > > > >*** > >This email and any attachments are confidential. Any use, copying or > >disclosure other than by the intended recipient is unauthorised. If > >you have received this message in error, please notify the sender > >immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com > >and delete this message and any copies from your computer and network. > >LGC Limited. Registered in England 2991879. > >Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK > __ > 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.
Re: [R] Unbalanced manova
Thank you John, I solved exploiting Anova call type 2 in your car package :) Il 25/apr/2014 14:57 "John Fox" ha scritto: > Dear Sergio, > > The Anova() function in the car package can perform MANOVA with a > multivariate linear model fit to unbalanced data by lm() -- see the > examples in ?Anova. I'm not sure what you mean by "avoiding NA values," > however. With the default na.action, which is na.omit, lm() will perform a > complete-case analysis, omitting cases with NA for any variable in the > model. > > I hope this helps, > John > > > John Fox, Professor > McMaster University > Hamilton, Ontario, Canada > http://socserv.mcmaster.ca/jfox/ > > > On Fri, 25 Apr 2014 11:17:44 +0200 > Sergio Fonda wrote: > > Hello list, > > I would be very grateful if somebody could suggest me which kind of call > > may be used to perform a manova with unbalanced data avoiding NA values. > > Thanks a lot > > > > [[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] Unbalanced manova
Hello list, I would be very grateful if somebody could suggest me which kind of call may be used to perform a manova with unbalanced data avoiding NA values. Thanks a lot [[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] Solving Classification problems in R
I did forget that reading LDA package could also help Sergio Il 28/feb/2014 19:39 "Luca Cerone" ha scritto: > Now I feel quite stupid :) I was assuming that since there is a > "Clustering" one there would have been a "Classification" one as well > :) > Thanks for pointing it out to me! > Luca Cerone > > Tel: +34 692 06 71 28 > Skype: luca.cerone > > > On Fri, Feb 28, 2014 at 6:38 PM, Prof Brian Ripley > wrote: > > http://cran.r-project.org/web/views/MachineLearning.html for a task > view you > > missed. > > > > > > On 28/02/2014 17:10, Luca Cerone wrote: > >> > >> Thanks for the advices Sergio and Jean-Olivier. > >> Of course I forgot, but I am interested in supervised classification! > >> I'll go through the packages you suggested to me! > >> Any ideas for Neural Networks and Random Forests instead? > >> > >> Luca Cerone > >> > >> Tel: +34 692 06 71 28 > >> Skype: luca.cerone > >> > >> > >> On Fri, Feb 28, 2014 at 6:01 PM, JiHO wrote: > >>> > >>> Do you mean supervised or unsupervised classification. > >>> > >>> If supervised, I have had great success using gradient boosted > >>> classification in package gbm. multinomial distribution will get you > >>> multiple classes and it will select relevant predictors by itself > >>> given the training data. > >>> > >>> Not sure about the customized cost functions > >>> > >>> Jean-Olivier Irisson > >>> -- > >>> Université Pierre et Marie Curie > >>> Laboratoire d'Océanographie de Villefranche > >>> 181 Chemin du Lazaret 06230 Villefranche-sur-Mer > >>> Tel: +33 04 93 76 38 04 > >>> Mob: +33 06 21 05 19 90 > >>> http://www.obs-vlfr.fr/~irisson/ > >>> Send me large files at: http://www.obs-vlfr.fr/~irisson/upload/ > >>> > >>> On Fri, Feb 28, 2014 at 5:53 PM, Sergio Fonda < > sergio.fond...@gmail.com> > >>> wrote: > >>>> > >>>> Focus on MASS, CCA and e1071 packages > >>>> Brgds, > >>>> Sergio > >>>> Il 28/feb/2014 17:47 "Luca Cerone" ha > scritto: > >>>> > >>>>> Dear all, > >>>>> I would like some advices on R packages to solve classification > >>>>> problems. > >>>>> I have tried to search among the Task views, but couldn't find > >>>>> anything. > >>>>> > >>>>> Can somebody recommend me some packages? > >>>>> > >>>>> Some of the features I am looking for: > >>>>> - deal with multiple classes > >>>>> - use customized cost functions > >>>>> - perform features/predictors selection > >>>>> > >>>>> Any hint would be greatly appreciated, > >>>>> thanks a lot in advance for the help! > >>>>> Cheers, > >>>>> Luca > >>>>> > >>>>> __ > >>>>> 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@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. > >> > > > > > > -- > > Brian D. Ripley, rip...@stats.ox.ac.uk > > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > > University of Oxford, Tel: +44 1865 272861 (self) > > 1 South Parks Road, +44 1865 272866 (PA) > > Oxford OX1 3TG, UKFax: +44 1865 272595 > > __ > 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.
Re: [R] Solving Classification problems in R
Focus on MASS, CCA and e1071 packages Brgds, Sergio Il 28/feb/2014 17:47 "Luca Cerone" ha scritto: > Dear all, > I would like some advices on R packages to solve classification problems. > I have tried to search among the Task views, but couldn't find anything. > > Can somebody recommend me some packages? > > Some of the features I am looking for: > - deal with multiple classes > - use customized cost functions > - perform features/predictors selection > > Any hint would be greatly appreciated, > thanks a lot in advance for the help! > Cheers, > Luca > > __ > 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.
Re: [R] variable standardization in manova() call
thank you for your reply. However, your remark was not so clear to me so I attach a short script I tried to launch. The comparison between results got from MANOVA() call with the non-standardized and standardized version of the same data frame, convinced me that it is not necessary to standardize data before calling MANOVA. The only difference you get is in the residuals values, of course. Could you kindly confirm my conclusion? All the best, Sergio Fonda __ set.seed(1234) # non- standardized series x1 = rnorm(n=10, mean=50, sd=11) x2 = rnorm(n=10, mean=93, sd=23) x1 = rnorm(n=10, mean=217, sd=52) fact= rep(1:2,20) glob1=data.frame(cbind(x1,x2,x3,fact)) fitta1=manova(cbind(x1,x2,x3)~fact, data=glob1) fitta1.wilks=summary(fitta1, test="Wilks") summary.aov(fitta1) #after standardization x.stand=scale(glob1[,-4]) glob2=data.frame(x.stand,fact) fitta2=manova(cbind(x1,x2,x3)~fact, data=glob2) fitta2.wilks=summary(fitta2, test="Wilks") summary.aov(fitta2) 2013/11/4 Sergio Fonda : > Hi, > I'm not able to get information about the following question: > > is the variables standardization a default option in manova() (stats package)? > Or if you want to compare variables with different units or scales and > rather different variances, you have to previously standardize the > variables ? > > Thanks a lot for any help, > > Sergio Fonda > www.unimore.it __ 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] variable standardization in manova() call
2013/11/6 Michael Friendly : > On 11/4/2013 10:45 AM, Sergio Fonda wrote: >> >> Hi, >> I'm not able to get information about the following question: >> >> is the variables standardization a default option in manova() (stats >> package)? >> Or if you want to compare variables with different units or scales and >> rather different variances, you have to previously standardize the >> variables ? >> > > If you mean the response variables, manova() does not require equal > variances and does not standardize. > > > -- > Michael Friendly Email: friendly AT yorku DOT ca > Professor, Psychology Dept. & Chair, Quantitative Methods > York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 > 4700 Keele StreetWeb: http://www.datavis.ca > Toronto, ONT M3J 1P3 CANADA Hi Michael, thank you for your reply. However, your remark was not so clear to me so I attach a short script I tried to launch. The comparison between results got from MANOVA() call with the non-standardized and standardized version of the same data frame, convinced me that it is not necessary to standardize data before calling MANOVA. The only difference you get is in the residuals values, of course. Could you kindly confirm my conclusion? All the best, Sergio Fonda __ set.seed(1234) # non- standardized series x1 = rnorm(n=10, mean=50, sd=11) x2 = rnorm(n=10, mean=93, sd=23) x1 = rnorm(n=10, mean=217, sd=52) fact= rep(1:2,20) glob1=data.frame(cbind(x1,x2,x3,fact)) fitta1=manova(cbind(x1,x2,x3)~fact, data=glob1) fitta1.wilks=summary(fitta1, test="Wilks") summary.aov(fitta1) #after standardization x.stand=scale(glob1[,-4]) glob2=data.frame(x.stand,fact) fitta2=manova(cbind(x1,x2,x3)~fact, data=glob2) fitta2.wilks=summary(fitta2, test="Wilks") summary.aov(fitta2) -- Sergio Fonda Associate Professor of Bioengineering Department of Life Sciences University of Modena and Reggio Emilia Modena, Italy __ 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] variable standardization in manova() call
Hi, I'm not able to get information about the following question: is the variables standardization a default option in manova() (stats package)? Or if you want to compare variables with different units or scales and rather different variances, you have to previously standardize the variables ? Thanks a lot for any help, Sergio Fonda www.unimore.it __ 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.