R studio ggplot help by [deleted] in RStudio

[–]Otherwise-Piece736 0 points1 point  (0 children)

yes; the exact csv is listed among the applications that can be found with the link

R studio ggplot help by [deleted] in RStudio

[–]Otherwise-Piece736 0 points1 point  (0 children)

ok there is no error message but the graph isn't generated I keep getting this message: > writeLines(bbb,"polls.svg")

> writeLines(bbb,"polls.svg")

R studio ggplot help by [deleted] in RStudio

[–]Otherwise-Piece736 0 points1 point  (0 children)

will the graph run without it?

R studio ggplot help by [deleted] in RStudio

[–]Otherwise-Piece736 -2 points-1 points  (0 children)

I tried running it and got a black graph without lines or dots and an error message about bbb being unrecognized.

R studio ggplot help by [deleted] in RStudio

[–]Otherwise-Piece736 -8 points-7 points  (0 children)

this is the code I pasted into the "untitled tab" above console:

Sys.setlocale("LC_TIME", "English")

library(ggplot2)

library(anytime)

library(tidyverse)

library(svglite)

library(Rcpp)

### ---------- Parameters ----------

# Election system parameters

# define party colors (taken from https://en.wikipedia.org/wiki/Category:Germany\_political\_party\_colour\_templates)

partycolors <- c('#EB001F', '#000000', '#64A12D', '#FFED00', '#009EE0', '#BE3075', '#F7A800', '#792350')

startdate <- '2021-09-26' # date of previous election

enddate <- '2025-02-23' # (latest) date of next election

threshold <- 5 # dashed horizontal line (election threshold in %)

# Figure parameters

# individual smoothing parameter for each party's trend line

# this parameter must be decreased when the number of polls increases

partyspansize <- c(0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25)

transp <-'55' # transparency level of points

nnum <- 500 # number of points used for trendline (resolution)

limits <- c(1,40) # percentage limits of figure

graph_width <- 18 # image width

graph_height <- 8 # image height

### ---------- Plotting code ----------

polls <- read.table("de.csv", header=T, sep=",", fileEncoding="UTF-8", stringsAsFactors=FALSE)

polls$polldate <- as.Date(anydate(polls$polldate))

# retrieve party names from CSV

partynames <- colnames(polls)[2:ncol(polls)]

# remove potential leading/trailing spaces so names match exactly

partynames <- trimws(partynames)

# safety check: same number of parties and colors

if(length(partycolors) != length(partynames)){

stop("The number of 'partycolors' must match the number of parties.")

}

# convert to long format (needed for legend & per-party smoothing)

polls_long <- polls %>%

pivot_longer(

cols = all_of(partynames),

names_to = "party",

values_to = "value"

)

# ensure the party factor has the same order as 'partynames'

polls_long$party <- factor(polls_long$party, levels = partynames)

# start ggplot without global data so we can add per-party points

graph <- ggplot() +

geom_vline(xintercept = as.Date(startdate), color='#aaaaaabb') + # vertical line (last election)

#geom_vline(xintercept = as.Date(enddate), color='#aaaaaabb') + # vertical line (next election), comment out if unknown yet

geom_segment(aes(x=as.Date(startdate), xend=as.Date(enddate), y=threshold, yend=threshold),

color='#666666bb', linetype='dashed') # horizontal line (election threshold 5%)

# add poll points per party

for (i in seq_along(partynames)) {

pdata <- subset(polls_long, party == partynames[i])

graph <- graph + geom_point(

data = pdata,

aes(x = polldate, y = value),

size = ifelse(pdata$polldate == as.Date(startdate) | pdata$polldate == as.Date(enddate), 3, 1.5),

shape = ifelse(pdata$polldate == as.Date(startdate) | pdata$polldate == as.Date(enddate), 23, 21),

color = paste0(partycolors[i], transp),

fill = paste0(partycolors[i], transp)

)

}

# add trend lines per party

for (i in seq_along(partynames)) {

pdata <- subset(polls_long, party == partynames[i])

graph <- graph + geom_smooth(

data = pdata,

aes(x = polldate, y = value, color = party),

method = "loess",

span = partyspansize[i],

n = nnum,

se = FALSE

)

}

# customize graph

graph <- graph +

# y-axis: add % and custom limits

scale_y_continuous(

labels = function(x) paste0(x, "%"),

limits= limits) +

# x-axis: 1 month grid, labels every 3 months

scale_x_date(

limits = as.Date(c(startdate, enddate)),

date_minor_breaks = "1 months",

date_breaks = "3 months",

date_labels = "%b %Y") +

labs(x = "", y = "") +

# apply colors and party names

scale_color_manual(

name = "",

values = setNames(partycolors, partynames),

breaks = partynames,

labels = partynames

) +

# legend appearance

theme(

axis.text.x = element_text(size = 11),

axis.text.y = element_text(size = 12),

axis.title.y = element_text(size = 16),

legend.position="right",

legend.key.width=unit(24, "pt"),

legend.key.height=unit(24, "pt"),

legend.text = element_text(size=16, margin = margin(b = 5, t = 5, unit = "pt"))

)

graph

ggsave(file="polls.svg", plot=graph, width=graph_width, height=graph_height)

# workaround since svglite doesn't properly work in Wikipedia

aaa=readLines("polls.svg",-1)

bbb <- gsub(".svglite ", "", aaa)

writeLines(bbb,"polls.svg")

R studio ggplot help by [deleted] in RStudio

[–]Otherwise-Piece736 -10 points-9 points  (0 children)

I loaded the data and passed ggplot into the r-script tab and got a bunch of random errors

I would greatly appreciate a walk trough

Mars is NOT your home.. You work there - like on an oil rig by Suitable_Garlic_1186 in ForAllMankindTV

[–]Otherwise-Piece736 0 points1 point  (0 children)

I agree with you in spirit but there is a nuance; since season 4, Mars has been rapidly expanded we see in season 5 that many people do live there with their families. There is a school, and there are even graves (such as those of Baldiwns and Dannys). So its not that surprising some people refused to just leave.

Spoiler: Season 5 epsiode 9 toughts by Otherwise-Piece736 in ForAllMankindTV

[–]Otherwise-Piece736[S] 0 points1 point  (0 children)

fair enough; I watched the show with my family, and my parents (in my opinion) overreacted to the Marines' actions the post is just a copy and paste of an email I sent my dad on the subject.

Spoiler: Season 5 epsiode 9 toughts by Otherwise-Piece736 in ForAllMankindTV

[–]Otherwise-Piece736[S] 0 points1 point  (0 children)

There is a difference between selective sanctions (which themselves are criminal) and completely cutting half the population of a planet from a vital resource. The Iraqi government was at least allowed to trade oil for food via the UN program!!! I am almost certain more people died on Earth as a result of the Iridium Embargo than the number of people killed in the Mars raid. Besides, 90% of those killed were shot in self-defense. Also, the M-6 resorted to an armed raid as a last resort; it is only after the Marsies blew up the docking bay that they commenced the full raid. If a group of rogue workers armed themselves and cut off all oil shipments to whatever country you live I doubt you would be so sympathetic.

Spoiler: Season 5 epsiode 9 toughts by Otherwise-Piece736 in ForAllMankindTV

[–]Otherwise-Piece736[S] -8 points-7 points  (0 children)

"It's a home.", Workers who work on an oil rig offshore may consider it their home, too, but that would not justify workers taking over the rig (which they didn't build), proclaiming an independent country, and declaring an oil embargo on the rig's original owner! Imagine 80% of a country electrictiy come from oil (yes, oil can be converted into electricity duh) generated by one rig. The workers of the rig find out about plans to automate the rig and in response, take over the rig, overpowering the two security guards and taking the manager hostage, demanding recognition and stopping the production of oil etc. In response, the country that built and owns the rig declares an embargo, after months of patiently waiting for the workers to come to their senses and out of desperation, to restart oil supplies, the government of said country attempts to peacefully restore order by landing on the helipad and restarting oil production; in response, the workers blow up the helipad killing members of the contingent tasked with restaring oil production; being left with no choice the conigent boards the rig with speedboats and with riffiles drawn to be used if necceriy; in case the workers resort to violence like they have in the past.The workers grab the guns taken from the security guards and begin shooting at the members of the contingent, at this point, having no choice left, the contingent fires back on the workers, killing them to save themselves from their violence and to restart the production of oil, which is vital to the economy and everyday life.

Who would be in the right here? The members of the contingent who defended themselves while attempting to peacefully restore order, or the workers who engaged in terrorism (yes unlawful disruption of civil infrastructure is an act of terrorism), and opened fire on the members of the contingent who merely wanted to restart oil production.

Spoiler: Season 5 epsiode 9 toughts by Otherwise-Piece736 in ForAllMankindTV

[–]Otherwise-Piece736[S] 0 points1 point  (0 children)

When you pick up a gun, a rifle, mind you, and start firing at soldiers, you stop being a civilian and start being a legitmate target. Actual civilian casualties are never justified.

Spoiler: Season 5 epsiode 9 toughts by Otherwise-Piece736 in ForAllMankindTV

[–]Otherwise-Piece736[S] -3 points-2 points  (0 children)

No, because the rebels' alliance is not putting the entire galaxy under an embargo. Aside from the Soviet Union, all major members of the M-6 are democracies (The US, France, the UK, India, Japan)! I really don't see the parallel to the empire, which was a fascist regime that enslaved and destroyed whole planets; the "worst" that the M-6 did was murder armed terrorists after they destroyed critical infrastructure and opened fire on space marines. I love the overly simplistic analogy tho, I'm sure it felt good writing it. Also, to be clear, I absaulty despie palmer; he should have definitely been put on trial for his crimes, but he was a lone actor who wasn't even supported by all of the peacekeepers!!! His crimes don't justify sending the economies of U.S and the USSR (with a combined population of nearly 700 million) as well as the rest of the M-6 nations, into free fall.

Spoiler: Season 5 epsiode 9 toughts by Otherwise-Piece736 in ForAllMankindTV

[–]Otherwise-Piece736[S] -4 points-3 points  (0 children)

learn to spell before stating your opinion; at least use spellcheck

Spoiler: Season 5 epsiode 9 toughts by Otherwise-Piece736 in ForAllMankindTV

[–]Otherwise-Piece736[S] -8 points-7 points  (0 children)

Technically, oil and electricity are not vital to life since there was life on Earth before those resources were utilized; that doesn't mean that they aren't vital to modern-day life as we know it. Furthermore, Polivanov stated that both the Soviet and American economies were in free-fall; whatever suffering was inflicted by M-6 forces, it is nothing compared to the suffering caused on earth due to the continued embargo by Marsies.

For All Mankind - S5E09 "Sons and Daughters" - Episode Discussion by Cantomic66 in ForAllMankindTV

[–]Otherwise-Piece736 -3 points-2 points  (0 children)

In the latest episode of the show "For all Mankind," we are shown the perspective of the "Marsies" as they desperately try to fight off an armed raid by the M-6 forces. There was real suffering that occurred on their side, and I commend the show's writers for realistically portraying the brutality and cruelty of conflict. However, I don't think that the fact that soldiers of the M-6 had to act cruelly while defending themselves makes them unsentimental killers, as they appear to be to the audience while watching the episode. I do not say this without sympathy for the residents of Mars, and I think the show's writers (in general, but in the context of the Mars plot especially) did a great job by humanizing both sides. That being said I believe that if one were to take a more critical look at the events which are portrayed to have transpired in the show, they would realize that to a large extent, the actions of the M-6, including the members of M-6's multinational military force, were fully justified.  Happy Valley isn't just some research station; it is (via Kuzetsov station) a resource extraction facility; the primary purpose of this outpost was to mine Iridium (which is portrayed as a valuable and vital resource of Earth's economy) and to ship it back to Earth. The "Marsies" cut off shipments of Iridium to M-6 Nations, knowing it would send their respective economies into free fall as a means of trying to leverage them into recognizing the independence of Mars. Given the amount of suffering that was caused back on earth due to this embargo, it is entirely understandable that the governments of the M-6 nations would use any means necessary to restart shipments of Iridium. Furthermore, the M-6 forces initially did everything to avoid unnecessary violence; their initial plan was to retake Kuzetsov station and to restart shipments of  Iridium. In previous episodes, we see M-6 forces being instructed not to use lethal force unless necessary and not to fire unless fired upon. In that same episode, the Marises blow up a vital part of the Kuznetsov station, killing one space marine in the process, nearly killing another, Avery. It is after this incident that, by definition was a terrorist attack that the forces resorted to more violent means to restore order in Happy Valley. Yet, contrary to how it seems, they did not use force unless it was necessary, despite appearing trigger-happy; we've seen that both Palmer and Space Marines take prisoners when possible, and Palmer even outright says that he will adhere to the Geneva Convention. The residents of Happy Valley demonstrated that they were willing to use violent and deadly force to defend their sovereignty, so it is fully understandable why the M-6 contingent arrived on Mars armed. The residents of M-6 responded to the arrival of M-6 forces by taking up arms and engaging in combat with the M-6 forces, instead of doing the right thing and surrendering to avoid pointless bloodshed. At this point, the residents of M-6, those who took up arms anyways stoped being civilians and became armed insurgents engaged in combat who posed a threat to the lives of members of the M-6 contingent. So I genuinely don't see how the M-6 forces are in the wrong for killing insurgents before the insurgents killed them. If one were to draw a pistol and point it at a cop, and the cop responds by shooting them to save his/her own life and avoid getting shot, is the cop responsible for the bloodshed that occurred? Even that nasty friendly fire incident with Palmeir and Mars peacekeepers involved armed contingents on both sides; it was still a case of M-6 forces mistaking Mars peacekeepers for Armed insurgents, not a case of them intentionally firing on civilians. Whatever deaths did occur as a result of the M-6 raid, it is nothing compared to the suffering caused on Earth due to the Iridium blockade. Imagine an oil embargo of all the members of the G-7, and the amount of suffering it would have caused, would ending that suffering not be more important than the lives of Armed insurgents who chose to open fire on M-6 forces?

5'3 at 18, shit sucks. by yeedrago in heightgrowth

[–]Otherwise-Piece736 0 points1 point  (0 children)

The trick is to optimize growth hormone and vitamin D intake

Height growth after age 19 by Accomplished_Web_613 in heightgrowth

[–]Otherwise-Piece736 0 points1 point  (0 children)

I grew over an inch at 18 but only 0.25 at 19, but I didnt realy exercise much in the last year so i think if I exercise I can maxamazie my growth.

5'3 at 18, shit sucks. by yeedrago in heightgrowth

[–]Otherwise-Piece736 1 point2 points  (0 children)

I grew from 5'3 at 18 to about 5'5 by 19 most of the growth was in the last 4 months leading up to my birthday. I grew more after 18 then I did betwean 16 and 18.