I've been trying to graph only for the past few hours. I only want to graph the TRUE arguments of this ifelse statement
which(RawGame1$event_desc == "Off Rebound")
reb <- ifelse(RawGame1$event_desc_id == "O",1,"")
Right now whenever I try to plot with ggplot, I get a bar graph where 13/22 bars are the 3rd argument(pointless data) that skews the scales and dimensions horribly. How do i delete them? Am i trying to graph it wrong?
ggplot(RawGame1[,], aes(x = pid.first.char, fill = reb)) +
geom_bar() +
ggtitle("Off Reb by Player") +
xlab("Player") +
ylab("Total Rebounds")
There has to be a simpler way i don't know about!?!? New to R and appreciate any help. Be gentle.
It would be much easier to answer if you provided a sample of your data (at least what head(RawGame1) prints out), also what the plot looks like now and what's the goal.
But I see that you have brackets without any filtering condition in RawGame1[,] - if you intended to select only event_desc_id=="0" there, just write RawGame1[RawGame1$event_desc_id==0,].
Related
I am trying to make a formula that changes depending on the cell containing the sex value however I can't seem to correct it. I am new to spreadsheets so I may be missing a big and obvious step.
=IF(C3="Female" (655.1+(9.563C6)+(1.850C7)-(4.676C4)) ELSE IF (C3="Male" (66.5+(13.75C6)+(5.003C7)-(6.75C4))))
So, without an example, this is how I would edit / correct your existing formula:
=IF(C3="Female",(655.1+(9.563 * C6)+(1.850 * C7)-(4.676 * C4)),IF(C3="Male",(66.5+(13.75 * C6)+(5.003 * C7)-(6.75 * C4),"error")))
try:
=IF(C3="Female";
(655.1+(9.563*C6)+(1.850*C7)-(4.676*C4));
(66.5+(13.75*C6)+(5.003*C7)-(6.75*C4))))
I want this formula to calculate a date based on input from two other dates. I first wrote it for a single cell and it gives the expected results but when I try to use ARRAYFORMULA it returns the wrong results.
I first use two if statements specifycing what should happen if either one of the inputs is missing. Then the final if statement calculates the date if both are present based on two conditions. This seems to work perfectly if I write the formula for one cell and drag it down.
=IF( (LEN(G19)=0);(U19+456);(IF((LEN(U19)=0) ;(G19);(IF((AND((G19<(U19+456));(G19>(U19+273)) ));(G19);(U19+456))))))
However, when I want to use arrayformula to apply it to the entire column, it always returns the value_if_false if neither cell is empty, regardless of whether the conditions in the if statement are actually met or not. I am specifically talking about the last part of the formula that calculates the date if both input values are present, it always returns the result of U19:U+456 even when the result should be G19:G. Here is how I tried to write the ARRAYFORMULA:
={"Date deadline";ARRAYFORMULA(IF((LEN(G19:G400)=0);(U19:U400+456);(IF((LEN(U19:U400)=0);
(G19:G400);(IF((AND((G19:G400<(U19:U400+456));(G19:G400>(U19:U400+273)) ));(G19:G400);(U19:U400+456)))))))}
I am a complete beginner who only learned to write formulas two weeks ago, so any help or tips would be greatly appreciated!
AND and OR are not compatible with ARRAYFORMULA
Replace them by * or +
Try
={"Date deadline";ARRAYFORMULA(
IF((LEN(G19:G400)=0),(U19:U400+456),
(IF((LEN(U19:U400)=0), (G19:G400),
(IF((((G19:G400<(U19:U400+456))*(G19:G400>(U19:U400+273)) )),(G19:G400),
(U19:U400+456)))
))
)
)}
Keep in mind you cannot use AND, OR operators in an arrayformula, so you must find an alternative method such as multiplying the values together and checking them for 0 or 1 (true*true=1)
I am gathering based on your formula's and work that you want to have the following:
If G19 is blank show U19 + 456
If U19 is blank show G19
If G19 is less than U19 + 456 but greater than U19 + 273 show G19
Otherwise show U19 + 456
I'm not too sure what you want to happen when both columns G and U are empty. Based on your current formula you are returning an empty cell + 456... but with this formula it returns an empty cell rather than Column U + 456
Formula
={"Date deadline";ARRAYFORMULA(TO_DATE(ARRAYFORMULA(IFS((($G19:$G400="")*($U19:$U400=""))>0,"",$G19:$G400="",$U19:$U400+456,$U19:$U400="",$G19:$G400,(($G19:$G400<$U19:$U400+456)*($G19:$G400>$U19:$U400+273))>0,$G19:$G400,TRUE,$U19:$U400+456))))}
Here is a table I have created. I just want to make it stand out a little bit.
I have figured out how to make rows different colours. I know how to make an entire row or column bold (column_spec(5:7, bold = T)) but I would like specific cells only based on highest value...so for example in my table, I would like 147 in bold under number, 2.36 under mean....etc
Is there a way of doing this? Using conditional logic would be even better if that was possible - but I can't find how it is done?
Thanks
I figured it out - pretty simple:
test.attempt[1, 5] <- cell_spec(test.attempt[1, 5], "latex", bold = T)
Hey I have a list containing four lists and I would like to iterate over the entire thing and print the index for all occurrences of a specific number or variable. So for example I have:
list_of_lists = [[0,0,0,0],[0,0,0,0],[0,2,0,0],[0,0,0,0]]
lx = 0
for x in list_of_lists:
ly = 0
for a in x:
if a == 2:
print(lx,ly)
ly += 1
lx += 1
Now this does print "2 1" which is correct but rather than print once, it prints infinitely. I'm not sure what is wrong with my logic but I'm pretty sure I am making a simple error. I am new to programming as you may be able to tell. Thanks for any help!
I don't think you did anything wrong here. I tried your code and mine runs only once, are you sure your indentations are ok in your original code?
I have a txt file that has 7 columns and I am trying to extract data from. Essentially there is a column that has a lot of minimum values, a column solely consists of dashes, column of only maximum values, and a few others that I would like to break into their own lists (I think thats the way to go). Any help would be much appreciated. Thanks!
Edit: Sorry I should have been clearer. I am using Python 3.5, grabbing right from the txt and using split actually. I guess I should ask where to go from there. I currently have it loading a file and using split(). End game I would like to be able to put each column into its own list so I can calculate averages, percentages, etc. Thanks again, sorry about the bad initial post, its my first time posting here.
file = open("year2000.txt")
for line in file:
z = line.strip()
z = line.find(" ")
min_sal1 = line[:z]
min_sal2 = min_sal1.replace(',', '')
min_sal3 = min_sal2.find('.')
min_sal4 = min_sal1[:min_sal3]
min_sal = int(min_sal4)
print(min_sal4)
y = z.find(' ', 2)
x = z.find(' ', 3)
max_sal = line[y:x]
print(max_sal)
After running this, I get a list of all min salarys like it should, however for max values I am getting just a bunch of blank lines. I also plan on putting each type of value into their own lists. Thanks