Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

convert from R to python

# Ucitavanje podataka
creditdata = read.csv('creditdata.csv')
summary(creditdata)


# Priprema podataka
creditdata$education = factor(creditdata$education,levels = c(1,2,3),labels = c('elementary','secondary', 'university'))
creditdata$marriage = factor(creditdata$marriage,levels = c(1,2),labels = c('single','married'))
creditdata$apartment = factor(creditdata$apartment,levels = c(1,2),labels = c('rent','own'))
creditdata$default = factor(creditdata$default,levels = c(0,1),labels = c(FALSE,TRUE))
summary(creditdata)

require(nortest)

lillie.test(creditdata$income)
lillie.test(creditdata$income[creditdata$education=='elementary'])
lillie.test(creditdata$income[creditdata$education=='secondary'])
lillie.test(creditdata$income[creditdata$education=='university'])


hist(creditdata$income[creditdata$education=='elementary'])
hist(creditdata$income[creditdata$education=='secondary'])
hist(creditdata$income[creditdata$education=='university'])

# Testiranje homogenosti varijance uzoraka Bartlettovim testom
bartlett.test(creditdata$income ~ creditdata$education)
var((creditdata$income[creditdata$education=='elementary']))
var((creditdata$income[creditdata$education=='secondary']))
var((creditdata$income[creditdata$education=='university']))

# Graficki prikaz podataka
boxplot(creditdata$income ~ creditdata$education)

# Test
a = aov(creditdata$income ~ creditdata$education)
summary(a)

# Linearni model
model = lm(income ~ education, data = creditdata)
summary(model)

anova(model)
Comment

how to convert r to python

# if you are trying to convert the data from R to python, https://www.mit.edu/~amidi/teaching/data-science-tools/conversion-guide/r-python-data-manipulation/ is a good resource 
# if you are looking for translating the code, https://towardsdatascience.com/essential-guide-to-translating-between-python-and-r-7cb18b786e5d seems to have comprehsensive information
Comment

PREVIOUS NEXT
Code Example
Python :: pd sample every class 
Python :: python nasa api 
Python :: WARNING: Ignoring invalid distribution -ip (c:python310libsite-packages) 
Python :: keras.utils.plot_model keeps telling me to install pydot and graphviz 
Python :: django snippet 800 
Python :: python function pointer with multiple args 
Python :: something useless. python 
Python :: python - dashboard 
Python :: pandas cummax 
Python :: Python Program to Find sum Factorial of Number Using Recursion 
Python :: python zeromq timeout 
Python :: summation 
Python :: biggest number 
Python :: Add dj_database_url on heroku or production 
Python :: extract parameter of voice using python 
Python :: python how to make item assignemnt class 
Python :: flask pass list to another view 
Python :: Iterate through string with index in python using while loop and rang 
Python :: "Token" is not defined Pylance 
Python :: select randomly from list in loop 
Python :: print all elements of dictionary except one in python 
Python :: django drf endpoint without model 
Python :: form a chakravyuh matrix python 
Python :: napalm cli 
Python :: ler arquivo xls no pandas 
Python :: is Cross policy an issue with puppeteer / headless chrome? 
Python :: hackereath 
Python :: get all view port type dynamo revit 
Python :: python fibbonacci 
Python :: left-align the y-tick labels | remove the current labels 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =