psrc / psrcplot

Package for Creating PSRC consistent data visualizations with R
https://psrc.github.io/psrcplot/
GNU General Public License v3.0
2 stars 0 forks source link

Issues with line charts #33

Closed MrichardsPSRC closed 1 year ago

MrichardsPSRC commented 1 year ago

I am attempting to create a line chart to show data over time. I have a test data set where the year is double: image

When I try to run the interactive_line_chart function, I get an error message image

So, I try to convert the year field into date format:

# need to make the year column date format
lifeexpec_poc_trend$year_date <- as.Date((as.character(lifeexpec_poc_trend$year)),
                                         format = "%Y") 

When I run the script again, the chart object is null? image

image

The static_line_chart function did work, to an extent:

line_option <- static_line_chart(t=lifeexpec_poc_trend,
                                 x="year_date", y="health_ind",
                                 fill="quintile_order",
                                 est = "number",
                                 color = "blues_inc",
                                 title = indicator_measure,
                                 subtitle = "People of Color",
                                 source = paste("Sources: Washington Tracking Network, Washington State Department of Health,", "\n", "U.S. Census Bureau, PUMS 1-year, 2015-2020,", "\n", "2020 Census Tracts"))

image

MrichardsPSRC commented 1 year ago

I also tried generic_line (https://psrc.github.io/psrcplot/reference/generic_line.html), but was getting an error message: image

I'm not sure if this is actually a function that we can use? It's listed on the documentation page, but I'm not sure what the difference between this function and the static_line_chart and interactive_line_chart

jensenmj commented 1 year ago

NULL object fixed with commit 843c0af. BTW character date can be combined with xtype="Continuous" (default is "Date"), or if Date, year format improved with dform="%Y". It may be helpful for the function to read the type rather than rely on an argument.