facet

Convert wide character strings to boost dates

走远了吗. 提交于 2019-12-05 01:46:34
问题 I need to convert several million dates stored as wide strings into boost dates The following code works. However, it generates a horrible compiler warning and does not seem efficient. Is there a better way? #include "boost/date_time/gregorian/gregorian.hpp" using namespace boost::gregorian; #include <string> using namespace std; wstring ws( L"2008/01/01" ); string temp(ws.length(), '\0'); copy(ws.begin(), ws.end(), temp.begin()); date d1( from_simple_string( temp ) ); cout << d1; The better

How to set different y-axis scale in a facet_grid with ggplot?

痞子三分冷 提交于 2019-12-04 20:01:09
I have this dataframe C_Em_df structure(list(Driver = c("Crop agriculture", "Infrastructure", "Mining", "Mixed Agriculture", "Other land use", "Pasture", "Tree crops", "Water", "Crop agriculture", "Infrastructure", "Mining", "Mixed Agriculture", "Other land use", "Pasture", "Tree crops", "Water", "Crop agriculture", "Infrastructure", "Mining", "Mixed Agriculture", "Other land use", "Pasture", "Tree crops", "Water", "Crop agriculture", "Infrastructure", "Mining", "Mixed Agriculture", "Other land use", "Pasture", "Tree crops", "Water"), Period = c("1990-2000", "1990-2000", "1990-2000", "1990

Add text to ggplot with facetted densities

纵然是瞬间 提交于 2019-12-04 18:23:27
I'm encountering a problem when trying to make a density plot with ggplot. The data look a bit like in the example here. require(ggplot2) require(plyr) mms <- data.frame(deliciousness = rnorm(100), type=sample(as.factor(c("peanut", "regular")), 100, replace=TRUE), color=sample(as.factor(c("red", "green", "yellow", "brown")), 100, replace=TRUE)) mms.cor <- ddply(.data=mms, .(type, color), summarize, n=paste("n =", length(deliciousness))) plot <- ggplot(data=mms, aes(x=deliciousness)) + geom_density() + facet_grid(type ~ color) + geom_text(data=mms.cor, aes(x=1.8, y=5, label=n), colour="black",

Is it possible to do Solr faceting combining multiple fields, like distinct on multiple columns in RMDB?

北战南征 提交于 2019-12-04 17:16:07
问题 Let's say I want to do faceting on the combination of two fields in my doc. For example: Field1 Field2 A B C D A B A C C B C D Will have the facet result like AB [2] CD [2] AC [1] CB [1] Is this possible? I mean on the fly, which means the fields are picked randomly, and therefore cannot create a copyfield during index. 回答1: You can group two fields using the Pivot Facets which is available on the Solr 4.0. You can run the following query on your index to get it. http://localhost:8181/solr

Drill down the haystack search results with facets but not changing the facet results

血红的双手。 提交于 2019-12-04 16:46:19
I have search results showing with facet options for drilling down the data. When a facet is selected it then changes the facet results. So if I am originally showing "places (10)", "images (5)", "people (3)", and "All (18)" as faceting options and I click on images I would still like to see all the others too even though the search results changed. Is there a good way to do this? I've run into problems with this too. The only answer we could find was to re-run the query each time without the drill-down to get the top-level facet results. I just did this and it's actually quite achievable

ggplot2: Change color for each facet in bar chart

本小妞迷上赌 提交于 2019-12-04 15:26:18
I have a faceted bar chart done with ggplot2 with this code: ggplot(data_long, aes(x=region, y=wert)) + geom_bar(aes(fill = kat ), position = "dodge", width=.5, stat="identity") + labs(y = "Wähleranteil [ % ]", x = NULL, fill = NULL) + facet_grid(. ~ type) + theme_bw() + theme( strip.background = element_blank(), panel.grid.major = element_line(colour = "grey80"), panel.border = element_blank(), axis.ticks = element_blank(), panel.grid.minor.x=element_blank(), panel.grid.major.x=element_blank() ) + theme(legend.position="bottom") + guides(fill=guide_legend(nrow=1,byrow=TRUE)) I would like that

Adjust linetype of One Line in a facet_grid

。_饼干妹妹 提交于 2019-12-04 15:18:43
问题 I have a plot similar to this one: b <- data.frame(x=c(1,2,3,1,2,3,1,2,3,1,2,3),y=c(1,2,3,1.5,1.9,2.5,3,2,1,2.9,1.8,1.5),c=c("1","1","1","2","2","2","1","1","1","2","2","2"),f=c("b","b","b","b","b","b","a","a","a","a","a","a")) ggplot(b,aes(x=x,y=y,color=c,group=c))+geom_line()+facet_grid(f ~ .) Now I want only the line "1" in the upper facet "a" to be thicker and dashed. Is this possible? 回答1: One of the first, and most important, things you're going to learn about ggplot2 is that when you

Adding table to ggplot with facets

断了今生、忘了曾经 提交于 2019-12-04 15:03:46
Reproducible code: x = sample(1:12,100,replace=TRUE) y = rnorm(100) z = sample(c('Sample A','Sample B'),100,replace=TRUE) d = data.frame(x,y,z) ggplot(data=d, aes(factor(x),y)) + geom_boxplot() + stat_summary(fun.y=mean, geom="line", aes(group=1), color ='red') + stat_summary(fun.y=mean, geom="point", color='red') + xlab('Months') + ylab('Metric') + facet_wrap(~z) I want to add a table at the end of this chart that displays the summary statistics- mean, median, quartiles and number of records for each month on the x-axis. I am not sure how this is possible for a facet layout. This is a

Rails & Sunspot facets and filtering

╄→尐↘猪︶ㄣ 提交于 2019-12-04 13:27:46
问题 Pretty much a noobie here, so I appreciate any help someone can give. I'm trying to add faceting to the search on my site through Sunspot. Ryan just released a great Railscast which got me started: http://railscasts.com/episodes/278-search-with-sunspot. I got that working and was able to add additional facets. My problem is that the facets are independent of each other. If I have 3 facets on 3 different attributes, when I select a facet once I already have on selected, I would like to display

Multiple boxplots placed side by side for different column values in ggplot

[亡魂溺海] 提交于 2019-12-04 12:40:19
问题 I have read different posts like this and this but my problem has a small variation. I have a df like this ID <- c("DJ45","DJ46","DJ47","DJ48","DJ49","DJ53","DJ54","DJ55","DJ56","DJ57") Tool <- c("Tool_A", "Tool_A", "Tool_A", "Tool_A", "Tool_A", "Tool_B", "Tool_B", "Tool_B", "Tool_B", "Tool_B") Name <- c("CMP", "CMP", "CMP", "CMP", "CMP", "CMP", "CMP", "CMP", "CMP", "CMP") MS1 <- c(51,55,50,59,50,47,48,42,43,46) MS2 <- c(13,11,14,11,10,17,18,17,20,21) MS3 <- c(2,3,2,5,6,4,9,6,4,4) MS4 <- c(16