On Working Directories in Python IDLE
http://stackoverflow.com/questions/15821121/whats-the-working-directory-when-using-idle
TVSTRANGERTHINGS
macklin celebrini has autism
Show & Tell
art blog(derogatory)

⁂
we're not kids anymore.
trying on a metaphor

titsay
AnasAbdin
let's talk about Bridgerton tea, my ask is open
cherry valley forever

blake kathryn
Today's Document
Three Goblin Art

if i look back, i am lost
noise dept.
No title available
wallacepolsom
I'd rather be in outer space 🛸

ellievsbear

seen from Türkiye
seen from United States

seen from Lithuania

seen from United States

seen from Türkiye
seen from South Korea

seen from United States

seen from United States
seen from Ireland

seen from United States

seen from United States
seen from United States

seen from United States
seen from United States

seen from United States
seen from United States
seen from Türkiye
seen from Argentina

seen from United States

seen from United States
@yeoldeeccentric-blog
On Working Directories in Python IDLE
http://stackoverflow.com/questions/15821121/whats-the-working-directory-when-using-idle
The basic essential fundamentals of Statistics and other things that make one less wrong
Behind the Dismal Science, is a dismal-er science: Statistics.
The mean, the median, I know what these are. But Standard Deviation, let's have a refresher:
The SD measures the amount of dispersion from the average. How do I find it? Well, in practice, I'll end up just calculating it using an R function.
The following is stolen from Wikipedia:
Let X be a random variable with mean value μ:
Here the operator E denotes the average or expected value of X. Then the standard deviation of X is the quantity
Indeed! Also stolen:
"As a slightly more complicated real-life example, the average height for adult men in the United States is about 70 inches, with a standard deviation of around 3 inches. This means that most men (about 68 percent, assuming a normal distribution) have a height within 3 inches of the mean (67–73 inches) – one standard deviation – and almost all men (about 95%) have a height within 6 inches of the mean (64–76 inches) – two standard deviations. If the standard deviation were zero, then all men would be exactly 70 inches tall. If the standard deviation were 20 inches, then men would have much more variable heights, with a typical range of about 50–90 inches. Three standard deviations account for 99.7 percent of the sample population being studied, assuming the distribution is normal (bell-shaped)."
More on this later. I mean to get into p-values, the basics of permutations, combinations, binomial-probabilities, and more.
Using tapply on the iris dataset
Yes! Figured it out. Suck it! This is super simple but...small victories.
I can use
tapply(iris$Sepal.Length,iris$Species,mean)
to get the mean sepal length for each individual species within the dataset.
More subsetting dataframes
I keep forgetting how to correctly do this shit.
So I've got the "iris" data set, which is part of the standard dataset package that comes with R.
Say I want to extract just the rows where "Species"=="virginica":
iris[iris$Species=="virginica", ]
And voila. That comma is important, because it's what makes sure it returns all the columns.
The cor function
"cor" is the function for computing correlations in R. Apparently it doesn't use "na.rm" as an argument to remove NAs. Instead you use:
cor(..., use="Complete.obs")
However, this will not work with vectors of unequal length.
Reference: https://stat.ethz.ch/pipermail/r-help/2006-August/110297.html
Sorry, no jokes. Jokes are hard.
Subsetting dataframes
So apparently, doing this:
dataframe$colname
is the same as this:
dataframe[["colname"]]
This is good to know. Until recently I didn't know it and I wasted time and this made me sad :'(
Avoid Unexpected Symbol Errors
God I forget this all the fucking time.
For some reason it's only for functions like return and print, but I try to use them in R the same way I use them in python.
It's
print(x)
NOT
print x
...
return(x)
NOT
return x
If you do it wrong you get an 'Unexpected symbol' error.
Paste function
Just remembered that to concatenate character strings into one character string, rather than a character vector of multiple character strings, use the "paste" function.
For instance:
paste("go", "fuckyerself", sep = "")
will return: "gofuckyerself"
R Control Structures
I woke up today and wasn't murdered, so I guess I'll talk about control structures in R. Like if-statements, for-loops, while-loops, and the repeat function.
if, else: testing a condition
for: execute a loop a fixed number of times
while: execute a loop while a condition is true
repeat: execute an infinite loop
break: break the execution of a loop
next: skip an iteration of a loop
return: exit a function
##Another thing I remembered today, you have to use '==' as the exact equality operator, because '=' is the same as '<-', the assignment operator. Fuck me.
if (jon == 'AliveToday') {
x <- 69
} else {
Last_Will_and_Testament <- 'You fuckers get nothing'
print(Last_Will_and_Testament)
}
for (thrust in seq(69)) {
print('oh god')
}
x <- 10000
Jon <- 'Alive'
while (Jon == 'Alive'){
print('Hustlin')
x <- x-100
if (x < 1000){
Jon <- "He's dead. Jon is dead."
print(Jon)
}
}
Ahhh there's more to get to here, but I'll get back to it later. ;aoijfr;aoiejrf;aiojref;oi
Excel; Switching between relative and absolute cell references
I don't why I keep forgetting this. Likely because God is dead.
Anyways "[COMMAND]+T" toggles a cell reference between relative and absolute in Excel for Mac.
Count NAs in a data frame
I've got a data frame called "in_da_club". I want to count the NAs for a variable called, let's say, "Dicks_on_Dancefloor".
table(is.na(in_da_club$Dicks_on_Dancefloor))
and voila.
Indexing data frames!
Another thing! Shit!
Say we have a data frame we'll call, uh, fuck, I dunno, "data".
data[1:2] prints the first two columns of the data frame.
data[,1:2] also prints the first two cols of the data frame.
data[1:2,] prints the first two rows.
Location, location, location.
R - How to set my fucking working directory
I use getwd() to see my current working directory.
Then...Christ I'm hungover...
I use setwd("directory") to set a new working directory.
Example:
setwd("/Users/Desktop/R Programming")
Just like that, motherfucker.