Python Forum
for loop and if translate from R in Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for loop and if translate from R in Python
#1
Hi everyone,

i have a new work in data science.
My problem is that i always code in R and in python i have no good experience

1)
my code in R
Quote: for(i in 1:length(l)) X[,i] = MF[[i]](x)

in Python
Quote:for i in range(1,1+l.length()):
X[:,i]= MF[i](x)

i really don't know if it is right Dodgy

2)
code in R
Quote:if(is.na(sv[1])) l = rep(0,length(V)) else l = sv[-1]

Python
this is very confusing for me i have noooo ideas Sad
Reply
#2
It looks simple code but I have not idea what the R code is doing. My eyes hurt looking at it. Big Grin
Can you explain it or write a pseudo code_
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
:D lol

ok
i will try:
1)
i think the for loop is right until X[,i]=MF[[i]](x)
and that means from the matrix X i column = ...
I give you a example for MF[[]] -> e=[[1,2,3],[4,5,6]]
And e[[2]] =4
My english is not so good (sorry)
Reply
#4
I've never used R either, but it seems you could use a known set of values, plug them into your R program and record the result. Then plug the same values into your Python code and see if you get the same result.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Explaining "translate" method lummers 4 2,374 Jan-13-2020, 06:31 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020