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 :: python 3.4 release date 
Python :: three different randomn numbers python 
Python :: addition array numpy 
Python :: 1024x768 
Python :: sort dict based on other list 
Python :: flask_jinja structure 
Python :: django.db.utils.IntegrityError: NOT NULL constraint failed 
Python :: speed typing test python 
Python :: error aesthetics must be either length 1 or the same as the data (3) fill 
Python :: beautifulsoup find element containing text 
Python :: division operators in python 
Python :: propositional logic python 
Python :: Get git sha 
Python :: read text file python path open 
Python :: utils/decorators.py", line 11, in __get__ raise AttributeError("This method is available only on the class, not on instances.") AttributeError: This method is available only on the class, not on instances. 
Python :: how to make hidden folders python 
Python :: Checking Availability of user inputted File name 
Python :: jupyter notebook morse code francais 
Python :: 12 hour clock to 24 hour clock in python 
Python :: pandas replace inf with 0 
Shell :: remove angular cli 
Shell :: what is --use-feature=2020-resolver 
Shell :: Failed to start docker.service: Unit docker.service is masked 
Shell :: uninstall wps office ubuntu 
Shell :: chrome update ubuntu 20.04 
Shell :: bash hide command output 
Shell :: dns flush windows 
Shell :: nginx stop commands 
Shell :: ubuntu list file by size 
Shell :: upgrade ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =