Re: [R] error: Error in if (any(DF[A, ] != DF[B, ])) { : missing value where TRUE/FALSE needed
Hi Orlando, This is not a reproducible example because of the line MyGraphData <- read.graph ( file = "0.edges" , directed = FALSE ) We don't have the file "0.edges" . But here's an example that reproduces the error message. Maybe it will help you find your problem. DF <- data.frame( x=NA, y=5 ) if ( any( DF[1,] != DF[2,]) ) cat("hello world\n") # Error in if ( any( DF[1,] != DF[2,]) ) cat("hello world\n") : # missing value where TRUE/FALSE needed HTH, Eric On Sat, Apr 4, 2020 at 11:10 PM Orlando Ramirez via R-help < r-help@r-project.org> wrote: > Hello this is my code and then i show you the result...please how i reapir > this error...thanks lot off > library(igraph) > # > # Lecture du fichier 0. edges > MyGraphData <- read.graph ( file = "0.edges" , directed = FALSE ) > # Nombre de noeuds dans le graphe > Nb_noeuds <- vcount ( MyGraphData ) > Nb_noeuds > # [1] 348 > # Pour enlever les doublons et les boucles dans le graphe > MyGraphData <- simplify ( MyGraphData , remove.multiple = TRUE , > remove.loops = TRUE ) > # Nombre d ' arrêtes dans le graphe > Nb_arretes <- ecount ( MyGraphData ) > Nb_arretes > # [1] 2519 > # Structure hiérarchique des noeuds > cluster <- edge.betweenness.community ( MyGraphData ) > cluster > # > cluster > # # les noeuds dans chaque communauté > # IGRAPH clustering edge betweenness, groups: 51, mod: 0.42 > # + groups: > # $`1` > # [1] 1 > # > # $`2` > # [1] 2 25 49 54 58 74 81 93 95 102 127 131 181 188 192 195 197 > 205 243 250 255 267 300 > # [24] 301 303 331 347 > # > # $`3` > # [1] 3 15 18 20 21 29 33 42 45 94 112 113 116 117 138 139 141 > 145 150 152 163 168 175 > # [24] 215 217 221 227 244 263 280 290 294 306 311 313 327 334 338 344 > # + ... omitted several groups/vertices > # fc <- cluster_fast_greedy(MyGraphData) > # plot_dendrogram(fc) > # Visualisation > plot_dendrogram (cluster ) > Error in if (any(DF[A, ] != DF[B, ])) { : > missing value where TRUE/FALSE needed > > > >Â > � > [[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] a simple reshape
Hi Deepayan, Thank you very much!! Yes, your method also works very well, I thought about creating an extra time variable, but did not know how to do it. Ding From: Deepayan Sarkar [deepayan.sar...@gmail.com] Sent: Saturday, April 4, 2020 3:10 AM To: Yuan Chun Ding Cc: r-help mailing list Subject: Re: [R] a simple reshape Hi, [For a non-tidyverse solution:] Your problem is ambiguous without a 'time' variable; e.g., why should the answer not be test2 <- data.frame(vntr1=c("v1","v2"), a1 =c(NA, 0.5693), a2 = c(0.02, 0.12), a3 =c(NA, 0.11), a4=c(0.98, 0.04)) ? If you do add an artificial time variable, say using test1 <- transform(test1, time = unsplit(lapply(split(vntr1, vntr1), seq_along), vntr1)) to give > test1 vntr1 val time 1v1 0.981 2v1 0.022 3v2 0.591 4v2 0.122 5v2 0.113 6v2 0.044 then either reshape() or dcast() easily gives you what you want: > reshape(test1, v.names = "val", idvar = "vntr1", direction = "wide", timevar > = "time") vntr1 val.1 val.2 val.3 val.4 1v1 0.98 0.02NANA 3v2 0.59 0.12 0.11 0.04 > reshape2::dcast(test1, vntr1 ~ time, value.var="val") vntr11234 1v1 0.98 0.02 NA NA 2v2 0.59 0.12 0.11 0.04 -Deepayan On Sat, Apr 4, 2020 at 12:28 AM Yuan Chun Ding wrote: > > Hi R users, > > I want to do a data reshape from long to wide, I thought it was easy using > tidyverse spread function, but it did not work well. Can you help me? > > Thank you, > > Ding > > test1 data frame is long file and test2 is the wide file I want to get > > test1 <- data.frame (vntr1=c("v1","v1", "v2","v2","v2","v2"), > val =c(0.98,0.02, 0.59,0.12,0.11,0.04)) > > test2 <- data.frame(vntr1=c("v1","v2"), > a1 =c(0.98, 0.5693), > a2 = c(0.02, 0.12), > a3 =c(NA, 0.11), > a4=c(NA, 0.04)) > > the following code does not work > test2 <-test1 %>%spread(vntr1, val) > > Error: Each row of output must be identified by a unique combination of keys. > Keys are shared for 6 rows: > * 1, 2 > * 3, 4, 5, 6 > Do you need to create unique ID with tibble::rowid_to_column()? > Call `rlang::last_error()` to see a backtrace > > -- > > -SECURITY/CONFIDENTIALITY WARNING- > > This message and any attachments are intended solely for the individual or > entity to which they are addressed. This communication may contain > information that is privileged, confidential, or exempt from disclosure under > applicable law (e.g., personal health information, research data, financial > information). Because this e-mail has been sent without encryption, > individuals other than the intended recipient may be able to view the > information, forward it to others or tamper with the information without the > knowledge or consent of the sender. If you are not the intended recipient, or > the employee or person responsible for delivering the message to the intended > recipient, any dissemination, distribution or copying of the communication is > strictly prohibited. If you received the communication in error, please > notify the sender immediately by replying to this message and deleting the > message and any accompanying files from your system. If, due to the security > risks, you do not wish to receive further communications via e-mail, please > reply to this message and inform the sender that you do not wish to receive > further e-mail from the sender. (LCP301) > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-help__;!!Fou38LsQmgU!_gFkJ_Cf4ZEMwLhfpOwr3W8LB2SUv3_s6vPFDW1_kVUN891RfsB4KvcZNHBM$ > PLEASE do read the posting guide > https://urldefense.com/v3/__http://www.R-project.org/posting-guide.html__;!!Fou38LsQmgU!_gFkJ_Cf4ZEMwLhfpOwr3W8LB2SUv3_s6vPFDW1_kVUN891RfsB4KkMsIU01$ > 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.
Re: [R] MAP HELP
Hi Anjaly, Here is a very simple way to plot something like this. There are many ways to do this and of course easier ways to automate the placement of the points and labels. library(maps) library(plotrix) map("world",xlim=c(13.548932,53.407331),ylim=c(70.824046,78.764113)) box() segments(20,76,25,77) points(25,77,pch=19) boxed.labels(20,76,"Kraken\nn=2\nlat=20 lon=76\nlength=10-20M") segments(40,72,51,71) points(51,71,pch=19) boxed.labels(40,72,"Herring\nn=2\nlat=51 lon=70\nlength=15-20cm") Jim On Sun, Apr 5, 2020 at 6:10 AM anjaly menon wrote: > > Hello, > > I have a dataset with latitude, longitude, station serial numbers of my > fish samples collected from the Barents Sea. I need to plot out from where > the samples are coming from using the latitude and longitude and the range > of body sizes (length of fishes) using R. > I installed packages like sp, maptools, mapdata, rgdal,shape, maps. Is > there any code to do this task? Please let me know. > > Cheers > > -- > *Anjaly Govindankutty Menon* > Erasmus Mundus Scholar > Universite de Bordeaux, France > > [[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.
Re: [R] MAP HELP
Hi! What kind of a map are you looking for? Google Earth, Open Street map or something else, please? Is your data in a data frame? Thanks, Erin On Sat, Apr 4, 2020 at 2:10 PM anjaly menon wrote: > Hello, > > I have a dataset with latitude, longitude, station serial numbers of my > fish samples collected from the Barents Sea. I need to plot out from where > the samples are coming from using the latitude and longitude and the range > of body sizes (length of fishes) using R. > I installed packages like sp, maptools, mapdata, rgdal,shape, maps. Is > there any code to do this task? Please let me know. > > Cheers > > -- > *Anjaly Govindankutty Menon* > Erasmus Mundus Scholar > Universite de Bordeaux, France > > [[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. > -- Erin Hodgess, PhD mailto: erinm.hodg...@gmail.com [[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] [R-pkgs] simhelpers: Helper Functions for Simulation Studies
Hi :) Hope you are doing well! I have been working on an R package that has helper functions for simulation studies. First version of the package is on CRAN now 邏 Here is the website for the package: https://meghapsimatrix.github.io/simhelpers/index.html Hope it is useful to you for running simulations in R :) Hope you are safe and healthy!! -- Megha Joshi (she/her/hers) meghapsimatrix.com Doctoral student Quantitative Methods *The University of Texas at Austin* [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] MAP HELP
Hello, I have a dataset with latitude, longitude, station serial numbers of my fish samples collected from the Barents Sea. I need to plot out from where the samples are coming from using the latitude and longitude and the range of body sizes (length of fishes) using R. I installed packages like sp, maptools, mapdata, rgdal,shape, maps. Is there any code to do this task? Please let me know. Cheers -- *Anjaly Govindankutty Menon* Erasmus Mundus Scholar Universite de Bordeaux, France [[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] error: Error in if (any(DF[A, ] != DF[B, ])) { : missing value where TRUE/FALSE needed
Hello this is my code and then i show you the result...please how i reapir this error...thanks lot off library(igraph) # # Lecture du fichier 0. edges MyGraphData <- read.graph ( file = "0.edges" , directed = FALSE ) # Nombre de noeuds dans le graphe Nb_noeuds <- vcount ( MyGraphData ) Nb_noeuds # [1] 348 # Pour enlever les doublons et les boucles dans le graphe MyGraphData <- simplify ( MyGraphData , remove.multiple = TRUE , remove.loops = TRUE ) # Nombre d ' arrêtes dans le graphe Nb_arretes <- ecount ( MyGraphData ) Nb_arretes # [1] 2519 # Structure hiérarchique des noeuds cluster <- edge.betweenness.community ( MyGraphData ) cluster # > cluster # # les noeuds dans chaque communauté # IGRAPH clustering edge betweenness, groups: 51, mod: 0.42 # + groups: # $`1` # [1] 1 # # $`2` # [1] 2 25 49 54 58 74 81 93 95 102 127 131 181 188 192 195 197 205 243 250 255 267 300 # [24] 301 303 331 347 # # $`3` # [1] 3 15 18 20 21 29 33 42 45 94 112 113 116 117 138 139 141 145 150 152 163 168 175 # [24] 215 217 221 227 244 263 280 290 294 306 311 313 327 334 338 344 # + ... omitted several groups/vertices # fc <- cluster_fast_greedy(MyGraphData) # plot_dendrogram(fc) # Visualisation plot_dendrogram (cluster ) Error in if (any(DF[A, ] != DF[B, ])) { : missing value where TRUE/FALSE needed � � [[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 reshape
Hi, [For a non-tidyverse solution:] Your problem is ambiguous without a 'time' variable; e.g., why should the answer not be test2 <- data.frame(vntr1=c("v1","v2"), a1 =c(NA, 0.5693), a2 = c(0.02, 0.12), a3 =c(NA, 0.11), a4=c(0.98, 0.04)) ? If you do add an artificial time variable, say using test1 <- transform(test1, time = unsplit(lapply(split(vntr1, vntr1), seq_along), vntr1)) to give > test1 vntr1 val time 1v1 0.981 2v1 0.022 3v2 0.591 4v2 0.122 5v2 0.113 6v2 0.044 then either reshape() or dcast() easily gives you what you want: > reshape(test1, v.names = "val", idvar = "vntr1", direction = "wide", timevar > = "time") vntr1 val.1 val.2 val.3 val.4 1v1 0.98 0.02NANA 3v2 0.59 0.12 0.11 0.04 > reshape2::dcast(test1, vntr1 ~ time, value.var="val") vntr11234 1v1 0.98 0.02 NA NA 2v2 0.59 0.12 0.11 0.04 -Deepayan On Sat, Apr 4, 2020 at 12:28 AM Yuan Chun Ding wrote: > > Hi R users, > > I want to do a data reshape from long to wide, I thought it was easy using > tidyverse spread function, but it did not work well. Can you help me? > > Thank you, > > Ding > > test1 data frame is long file and test2 is the wide file I want to get > > test1 <- data.frame (vntr1=c("v1","v1", "v2","v2","v2","v2"), > val =c(0.98,0.02, 0.59,0.12,0.11,0.04)) > > test2 <- data.frame(vntr1=c("v1","v2"), > a1 =c(0.98, 0.5693), > a2 = c(0.02, 0.12), > a3 =c(NA, 0.11), > a4=c(NA, 0.04)) > > the following code does not work > test2 <-test1 %>%spread(vntr1, val) > > Error: Each row of output must be identified by a unique combination of keys. > Keys are shared for 6 rows: > * 1, 2 > * 3, 4, 5, 6 > Do you need to create unique ID with tibble::rowid_to_column()? > Call `rlang::last_error()` to see a backtrace > > -- > > -SECURITY/CONFIDENTIALITY WARNING- > > This message and any attachments are intended solely for the individual or > entity to which they are addressed. This communication may contain > information that is privileged, confidential, or exempt from disclosure under > applicable law (e.g., personal health information, research data, financial > information). Because this e-mail has been sent without encryption, > individuals other than the intended recipient may be able to view the > information, forward it to others or tamper with the information without the > knowledge or consent of the sender. If you are not the intended recipient, or > the employee or person responsible for delivering the message to the intended > recipient, any dissemination, distribution or copying of the communication is > strictly prohibited. If you received the communication in error, please > notify the sender immediately by replying to this message and deleting the > message and any accompanying files from your system. If, due to the security > risks, you do not wish to r eceive further communications via e-mail, please reply to this message and inform the sender that you do not wish to receive further e-mail from the sender. (LCP301) > > __ > 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.