本文介绍了如何删除特定列中的重复值而不删除相关行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 输入 ----- 日期市场数量 4/2/2018印度尼西亚1000 4/2/2018澳大利亚500 4/2/2018印度300 4/2/2018美国500 4/2/2018德国200 5/2/2018印度400 5/2/2018日本400 5/2 / 2018俄罗斯457 6/2/2018奥地利260 6/2/2018瑞士700 6/2/2018美国1200 6/2/2018印度尼西亚400 输出 ------ 日期市场数量 4/2/2018印度尼西亚1000 澳大利亚500 印度300 美国500 德国200 5/2/2018印度400 日本400 俄罗斯457 6/2/2018奥地利260 瑞士700 美国1200 印度尼西亚400 如果可能的话,一个图形(栏/列)相同的输出(类似于给定的)? 示例图 解决方案我会将此添加到评论中,但我还没有权限... 我不认为你实际上想要改变数据,但正如评论中提到的那样,有一些简单的方法可以做到这一点。 如果你只是试图显示多线程,三维数据,你只是不熟悉库语法尝试下面的代码... $ $ p $ df Market = c('Indonesia','Australia','India','USA','Germany','India','Japan','Russia','Austria','瑞士','美国','印度尼西亚'),数量= c(1000,500,300,500,200,400,4 stringsAsFactors = F) plotly :: ggplotly( ggplot2 :: ggplot(df,ggplot2 :: aes(x = Market,y =数量))+ ggplot2 :: geom_col(ggplot2 :: aes(fill = Market))+ ggplot2 :: facet_grid(〜Date,scale ='free_x')+ ggthemes :: theme_tufte()) Want to remove duplicate values in specific column without deleting the rows related with duplicate column values as below example:Input----- Date Market Quantity4/2/2018 Indonesia 10004/2/2018 Australia 5004/2/2018 India 3004/2/2018 USA 5004/2/2018 Germany 2005/2/2018 India 4005/2/2018 Japan 4005/2/2018 Russia 4576/2/2018 Austria 2606/2/2018 Swiss 7006/2/2018 USA 12006/2/2018 Indonesia 400output------ Date Market Quantity4/2/2018 Indonesia 1000 Australia 500 India 300 USA 500 Germany 2005/2/2018 India 400 Japan 400 Russia 4576/2/2018 Austria 260 Swiss 700 USA 1200 Indonesia 400And if possible , how to plot a graph(bar/column) for same output(something like given)?Sample Graph 解决方案 I would add this to comments but I don't have rights yet...I don't think you actually want to change the data, but as a few mentioned in the comments there are easy ways to do that.If you're just trying to show the multi-dimensional data in plotly and you're just not familiar with the library syntax try the code below...df <- data.frame(Date = c('2018/04/02','2018/04/02','2018/04/02','2018/04/02','2018/04/02','2018/05/02','2018/05/02','2018/05/02','2018/06/02','2018/06/02','2018/06/02','2018/06/02'), Market = c('Indonesia','Australia','India','USA','Germany','India','Japan','Russia','Austria','Swiss','USA','Indonesia'), Quantity = c(1000,500,300,500,200,400,400,457,260,700,1200,400), stringsAsFactors = F)plotly::ggplotly( ggplot2::ggplot(df, ggplot2::aes(x=Market, y=Quantity)) + ggplot2::geom_col(ggplot2::aes(fill=Market))+ ggplot2::facet_grid(~Date,scale='free_x') + ggthemes::theme_tufte() ) 这篇关于如何删除特定列中的重复值而不删除相关行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-30 03:06