Support
Quality
Security
License
Reuse
Coming Soon for all Libraries!
Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
CockroachDB - the open source, cloud-native distributed SQL database.
How to create a new column containing two factor levels in the length of factor levels from another column?
dat$language <- ifelse(grepl("TM", dat$Condition), "malay", "english")
-----------------------
## build a named lookup vector:
language_lookup <- structure(
c(rep('english',5),
rep('malay',5)
),
names = c(paste0('T', 2:6),
paste0('TM',2:6)
)
)
## lookup the vector value (language) by vector name (condition)
df$language <- language_lookup[df$Condition]
python 3 loop back with if else elif
number = input('CHOOSE! YOUR! CAT! 1 2 or 3')
while number not in ['1', '2', '3']:
print('you did not follow the instructions')
number = input('CHOOSE! YOUR! CAT! 1 2 or 3')
if number == '1':
print('you chose BIXBY! now choose your first door')
elif number == '2':
print('you chose SASHA! now choose your first door.')
elif number == '3':
print('you chose SHADOW! now choose your first door.')
-----------------------
def step_1(number):
if number == 1:
print('you chose BIXBY! now choose your first door')
elif number == 2:
print('you chose SASHA! now choose your first door.')
elif number == 3:
print('you chose SHADOW! now choose your first door.')
generic_call_input('you walk down a hallway. at the end of the hallway you come to 3 doors. you decide to go through door...',step_2)
def step_2(number):
if number == 1:
print('door 1. you chase a cockroach down a low lit corridor.')
elif number == 2:
print('door 2. you find a bed with a person in it. it is kimora! you make biscuits on the bean. then she kicks you out for being annoying. you are now in a low lit corridor')
elif number == 3:
print('door 3. you find a ball of yarn. you paw and claw at the yarn until it rolls away. you follow the yarn to a low lit corridor')
generic_call_input("step 3 msg",step_3)
def step_3(number):
if number == 1:
print('1')
elif number == 2:
print('2')
elif number == 3:
print('3')
def generic_call_input(input_msg,callback):
while True:
number = input(input_msg)
try:
number = int(number)
except:
pass
if number in [1,2,3]:
callback(number)
break
generic_call_input("CHOOSE! YOUR! CAT! 1 2 or 3",step_1)
How to return for loop values without any html template in flask
def jokes():
jokes = pyjokes.get_jokes()
jokes_final = "<br/>".join(jokes)
return f'{jokes_final}'
-----------------------
from flask import Flask
import pyjokes
from jinja2 import Template
app = Flask(__name__)
@app.route("/MultipleJokes")
def jokes():
jokes = pyjokes.get_jokes()
joke_template = Template("{% for joke in jokes %}<li>{{joke}}</li>{% endfor %}")
return joke_template.render(jokes=jokes)
Do we need to add any configuration on client side to avoid transaction retry errors in cockroach database
@Lock(LockModeType.PESSIMISTIC_READ)
@QueryHints({@QueryHint(name = "javax.persistence.lock.timeout", value = "3000")})
public Optional<Employee> findById(Long employeeId);
How to listen to fifo wait for a fifo file's output in golang
finished := make(chan bool)
go func() {
/*
* Place your code here
*/
finished <- true
}()
select {
case <-time.After(timeout):
fmt.Println("Timed out")
case <-finished:
fmt.Println("Successfully executed")
}
func timeoutMyFunc(timeout time.Duration, myFunc func()) bool {
finished := make(chan bool)
go func() {
myFunc()
finished <- true
}()
select {
case <-time.After(timeout):
return false
case <-finished:
return true
}
}
func main() {
success := timeoutMyFunc(3*time.Second, func() {
/*
* Place your code here
*/
})
}
-----------------------
finished := make(chan bool)
go func() {
/*
* Place your code here
*/
finished <- true
}()
select {
case <-time.After(timeout):
fmt.Println("Timed out")
case <-finished:
fmt.Println("Successfully executed")
}
func timeoutMyFunc(timeout time.Duration, myFunc func()) bool {
finished := make(chan bool)
go func() {
myFunc()
finished <- true
}()
select {
case <-time.After(timeout):
return false
case <-finished:
return true
}
}
func main() {
success := timeoutMyFunc(3*time.Second, func() {
/*
* Place your code here
*/
})
}
Dart list item not found
List<String> _namesList = controller.selectedAntigens.map((e)=>e['name']).toList();
print(_namesList.contains(item['name']) ? '1' : '0'); //=> "1";
can not connect to cockroachdb invalid cluster name
cockroach sql --url "postgres://username@cloud-host:26257/defaultdb?sslmode=require&options=--cluster=clustername";
Error executing while-loop "Loop being escaped randomly" Python
import random
def main():
rounds = 0
win = 0
tie = 0
choices = ["Foot", "Nuke", "Cockroach"]
cpu = random.choice(choices)
while True:
inpt = input("Foot, Nuke or Cockroach? (Quit ends): ")
if inpt == "Quit":
print(f"You played {rounds} rounds, and won {win} rounds, "
f"playing tie in {tie} rounds.")
break
if inpt not in choices:
print("Incorrect selection.")
continue
if inpt == "Foot" and cpu == "Nuke" or inpt == "Cockroach" and cpu == "Foot":
print(f"You chose: {inpt}")
print(f"Computer chose: {cpu}")
print("You LOSE!")
rounds += 1
if inpt == "Nuke" and cpu == "Foot" or inpt == "Foot" and cpu == "Cockroach":
print(f"You chose: {inpt}")
print(f"Computer chose: {cpu}")
print("You WIN!")
rounds += 1
win += 1
if inpt == cpu:
print(f"You chose: {inpt}")
print(f"Computer chose: {cpu}")
print("It is a tie!")
rounds += 1
tie += 1
if __name__ == "__main__":
main()
-----------------------
elif (inpt == "Foot" and cpu == "Foot") or (inpt == "Cockroach" and cpu == "Cockroach") or (inpt == "Nuke" and cpu == "Nuke"):
-----------------------
import random
ACTIONS = ['foot', 'nuke', 'cockroach']
MAP = [['=', '<', '>'],
['>', '=', '<'],
['<', '>', '=']]
SCORE = {'=': ['Tied Game!', 0, 0],
'>': ['You WIN!', 1, 0],
'<': ['You LOOSE!', 0, 1]}
rounds = 0
score_user = 0
score_comp = 0
while True:
action = input(f'Foot, Nuke or Cockroach? (Quit ends): ').lower()
if action == 'quit':
break
user = ACTIONS.index(action)
comp = random.randint(0, 2)
print(f'You chose {ACTIONS[user]}, computer chose {ACTIONS[comp]}.')
res = MAP[user][comp]
score_user += SCORE[res][1]
score_comp += SCORE[res][2]
print(f'{ACTIONS[user].title()} {res} {ACTIONS[comp].title()}. {SCORE[res][0]} Your score: {score_user}. Comp score: {score_comp}')
rounds += 1
print(f'You played {rounds} rounds, and won {score_user} rounds, playing tie in {rounds-score_user-score_comp} rounds.')
Foot, Nuke or Cockroach? (Quit ends): foot
You chose foot, computer chose nuke.
Foot < Nuke. You LOOSE! Your score: 0. Comp score: 1
Foot, Nuke or Cockroach? (Quit ends): nuke
You chose nuke, computer chose foot.
Nuke > Foot. You WIN! Your score: 1. Comp score: 1
Foot, Nuke or Cockroach? (Quit ends): quit
You played 2 rounds, and won 1 rounds, playing tie in 0 rounds.
-----------------------
import random
ACTIONS = ['foot', 'nuke', 'cockroach']
MAP = [['=', '<', '>'],
['>', '=', '<'],
['<', '>', '=']]
SCORE = {'=': ['Tied Game!', 0, 0],
'>': ['You WIN!', 1, 0],
'<': ['You LOOSE!', 0, 1]}
rounds = 0
score_user = 0
score_comp = 0
while True:
action = input(f'Foot, Nuke or Cockroach? (Quit ends): ').lower()
if action == 'quit':
break
user = ACTIONS.index(action)
comp = random.randint(0, 2)
print(f'You chose {ACTIONS[user]}, computer chose {ACTIONS[comp]}.')
res = MAP[user][comp]
score_user += SCORE[res][1]
score_comp += SCORE[res][2]
print(f'{ACTIONS[user].title()} {res} {ACTIONS[comp].title()}. {SCORE[res][0]} Your score: {score_user}. Comp score: {score_comp}')
rounds += 1
print(f'You played {rounds} rounds, and won {score_user} rounds, playing tie in {rounds-score_user-score_comp} rounds.')
Foot, Nuke or Cockroach? (Quit ends): foot
You chose foot, computer chose nuke.
Foot < Nuke. You LOOSE! Your score: 0. Comp score: 1
Foot, Nuke or Cockroach? (Quit ends): nuke
You chose nuke, computer chose foot.
Nuke > Foot. You WIN! Your score: 1. Comp score: 1
Foot, Nuke or Cockroach? (Quit ends): quit
You played 2 rounds, and won 1 rounds, playing tie in 0 rounds.
Testcontainers execInContainer not working with CockroachDB
container.execInContainer( "sh", "-c", "./cockroach sql --insecure -e \"SET CLUSTER SETTING sql.defaults.experimental_temporary_tables.enabled = 'true';\"" );
Unable to connect to Cockroach pod in Kubernetes
dial tcp: lookup web-service-cockroach on 192.168.65.1:53: no such host
spec:
dnsPolicy: ClusterFirstWithHostNet
-----------------------
dial tcp: lookup web-service-cockroach on 192.168.65.1:53: no such host
spec:
dnsPolicy: ClusterFirstWithHostNet
QUESTION
How to create a new column containing two factor levels in the length of factor levels from another column?
Asked 2022-Mar-30 at 10:30I have a data frame called ldat_1. I want create a new column called language
from the Condition
column.
In the new language
column, I need two factor levels called english
and malay
.
To create that language
column, using the levels of Condition
column, I want "T2" "T3" "T4" "T5" "T6"
to become english
, and "TM2" "TM3" "TM4" "TM5" "TM6"
to become malay
.
hear is my some code:
head(ldat_1)
Subject Age Profi_CAT Domain Trial Condition word1 word2 word3 word4
1 1 22 1 2 15 T2 Some birds are eagles
2 1 22 1 2 16 T3 Some pineapples are flowers
3 1 22 1 2 17 T4 All snakes are reptiles
4 1 22 1 2 18 T5 All fish are sharks
5 1 22 1 2 19 T6 All lavender are fruits
6 1 22 1 2 21 T2 Some birds are owls
CorrectAnswer word4.CRESP word4.RESP word4.ACC word4.RT
1 c c c 1 1322
2 m m m 1 5736
3 c c c 1 1299
4 m m m 1 1388
5 m m m 1 1118
6 c c c 1 1170
> #check the condition column levels again
> levels(as.factor(ldat_1$Condition))
[1] "T2" "T3" "T4" "T5" "T6" "TM2" "TM3" "TM4" "TM5" "TM6"
hear is the dput of my data
dput(ldat_1)
structure(list(Subject = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), Age = c(22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L,
22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 22L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L,
25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L, 25L), Profi_CAT = c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), Domain = c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), Trial = c(15L, 16L,
17L, 18L, 19L, 21L, 22L, 23L, 24L, 25L, 27L, 28L, 29L, 30L, 31L,
34L, 35L, 36L, 37L, 38L, 40L, 41L, 42L, 43L, 44L, 46L, 47L, 48L,
49L, 50L, 53L, 54L, 55L, 56L, 57L, 59L, 60L, 61L, 62L, 63L, 65L,
66L, 67L, 68L, 69L, 84L, 85L, 86L, 87L, 88L, 90L, 91L, 92L, 93L,
94L, 96L, 97L, 98L, 99L, 100L, 103L, 104L, 105L, 106L, 107L,
109L, 110L, 111L, 112L, 113L, 115L, 116L, 117L, 118L, 119L, 122L,
123L, 124L, 125L, 126L, 128L, 129L, 130L, 131L, 132L, 134L, 135L,
136L, 137L, 138L, 15L, 16L, 17L, 18L, 19L, 21L, 22L, 23L, 24L,
25L, 27L, 28L, 29L, 30L, 31L, 34L, 35L, 36L, 37L, 38L, 40L, 41L,
42L, 43L, 44L, 46L, 47L, 48L, 49L, 50L, 53L, 54L, 55L, 56L, 57L,
59L, 60L, 61L, 62L, 63L, 65L, 66L, 67L, 68L, 69L, 84L, 85L, 86L,
87L, 88L, 90L, 91L, 92L, 93L, 94L, 96L, 97L, 98L, 99L, 100L,
103L, 104L, 105L, 106L, 107L, 109L, 110L, 111L, 112L, 113L, 115L,
116L, 117L, 118L, 119L, 122L, 123L, 124L, 125L, 126L, 128L, 129L,
130L, 131L, 132L, 134L, 135L, 136L, 137L, 138L), Condition = c("T2",
"T3", "T4", "T5", "T6", "T2", "T3", "T4", "T5", "T6", "T2", "T3",
"T4", "T5", "T6", "T2", "T3", "T4", "T5", "T6", "T2", "T3", "T4",
"T5", "T6", "T2", "T3", "T4", "T5", "T6", "T2", "T3", "T4", "T5",
"T6", "T2", "T3", "T4", "T5", "T6", "T2", "T3", "T4", "T5", "T6",
"TM2", "TM3", "TM4", "TM5", "TM6", "TM2", "TM3", "TM4", "TM5",
"TM6", "TM2", "TM3", "TM4", "TM5", "TM6", "TM2", "TM3", "TM4",
"TM5", "TM6", "TM2", "TM3", "TM4", "TM5", "TM6", "TM2", "TM3",
"TM4", "TM5", "TM6", "TM2", "TM3", "TM4", "TM5", "TM6", "TM2",
"TM3", "TM4", "TM5", "TM6", "TM2", "TM3", "TM4", "TM5", "TM6",
"TM2", "TM3", "TM4", "TM5", "TM6", "TM2", "TM3", "TM4", "TM5",
"TM6", "TM2", "TM3", "TM4", "TM5", "TM6", "TM2", "TM3", "TM4",
"TM5", "TM6", "TM2", "TM3", "TM4", "TM5", "TM6", "TM2", "TM3",
"TM4", "TM5", "TM6", "TM2", "TM3", "TM4", "TM5", "TM6", "TM2",
"TM3", "TM4", "TM5", "TM6", "TM2", "TM3", "TM4", "TM5", "TM6",
"T2", "T3", "T4", "T5", "T6", "T2", "T3", "T4", "T5", "T6", "T2",
"T3", "T4", "T5", "T6", "T2", "T3", "T4", "T5", "T6", "T2", "T3",
"T4", "T5", "T6", "T2", "T3", "T4", "T5", "T6", "T2", "T3", "T4",
"T5", "T6", "T2", "T3", "T4", "T5", "T6", "T2", "T3", "T4", "T5",
"T6"), word1 = c("Some ", "Some ", "All", "All", "All", "Some ",
"Some ", "All", "All", "All", "Some ", "Some ", "All", "All",
"All", "Some ", "Some ", "All", "All", "All", "Some ", "Some ",
"All", "All", "All", "Some ", "Some ", "All", "All", "All", "Some ",
"Some ", "All", "All", "All", "Some ", "Some ", "All", "All",
"All", "Some ", "Some ", "All", "All", "All", "Sesetengah", "Sesetengah",
"Semua", "Semua", "Semua", "Sesetengah", "Sesetengah", "Semua",
"Semua", "Semua", "Sesetengah", "Sesetengah", "Semua", "Semua",
"Semua", "Sesetengah", "Sesetengah", "Semua", "Semua", "Semua",
"Sesetengah", "Sesetengah", "Semua", "Semua", "Semua", "Sesetengah",
"Sesetengah", "Semua", "Semua", "Semua", "Sesetengah", "Sesetengah",
"Semua", "Semua", "Semua", "Sesetengah", "Sesetengah", "Semua",
"Semua", "Semua", "Sesetengah", "Sesetengah", "Semua", "Semua",
"Semua", "Sesetengah", "Sesetengah", "Semua", "Semua", "Semua",
"Sesetengah", "Sesetengah", "Semua", "Semua", "Semua", "Sesetengah",
"Sesetengah", "Semua", "Semua", "Semua", "Sesetengah", "Sesetengah",
"Semua", "Semua", "Semua", "Sesetengah", "Sesetengah", "Semua",
"Semua", "Semua", "Sesetengah", "Sesetengah", "Semua", "Semua",
"Semua", "Sesetengah", "Sesetengah", "Semua", "Semua", "Semua",
"Sesetengah", "Sesetengah", "Semua", "Semua", "Semua", "Sesetengah",
"Sesetengah", "Semua", "Semua", "Semua", "Some ", "Some ", "All",
"All", "All", "Some ", "Some ", "All", "All", "All", "Some ",
"Some ", "All", "All", "All", "Some ", "Some ", "All", "All",
"All", "Some ", "Some ", "All", "All", "All", "Some ", "Some ",
"All", "All", "All", "Some ", "Some ", "All", "All", "All", "Some ",
"Some ", "All", "All", "All", "Some ", "Some ", "All", "All",
"All"), word2 = c("birds", "pineapples", "snakes", "fish", "lavender",
"birds", "strawberries", "dinosaurs", "fish", "lilies", "birds",
"watermelons", "chameleons", "fish", "hibiscuses", "birds", "papayas",
"tortoises", "fish", "roses", "birds", "grapes", "lizards", "fish",
"orchids", "birds", "durians", "crocodiles", "fish", "jasmines",
"birds", "coconuts", "iguanas", "fish", "tulips", "birds", "bananas",
"frogs", "fish", "daisies", "birds", "mangos", "alligators",
"fish", "rafflesias", "reptilia", "jerung", "lili", "serangga",
"helang", "reptilia", "salmon", "mawar", "serangga", "penguin",
"reptilia", "belut", "orkid", "serangga", "itik", "reptilia",
"tuna", "melati", "serangga", "flamingo", "reptilia", "sardin",
"tulip", "serangga", "merak", "reptilia", "keli", "daisi", "serangga",
"itik", "reptilia", "patin", "rafflesia", "serangga", "angsa",
"reptilia", "kerapu", "jejarum", "serangga", "merpati", "reptilia",
"siakap", "teratai", "serangga", "kenari", "ikan", "lili", "nyamuk",
"burung", "nanas", "ikan", "mawar", "cengkerik ", "burung", "tembikai",
"ikan", "orkid", "belalang", "burung", "betik", "ikan", "melati",
"semut", "burung", "anggur", "ikan", "tulip", "lebah", "burung",
"durian", "ikan", "daisi", "pepatung", "burung", "kelapa", "ikan",
"rafflesia", "lalat", "burung", "pisang", "ikan", "jejarum",
"lipas", "burung", "mangga", "ikan", "teratai", "kumbang", "burung",
"jambu", "fruits", "snakes", "sharks", "flowers", "butterflies",
"fruits", "dinosaurs", "salmons", "flowers", "mosquitoes", "fruits",
"chameleons", "anchovies", "flowers", "cockroaches", "fruits",
"tortoises", "eels", "flowers", "grasshoppers", "fruits", "lizards",
"guppies", "flowers", "ants", "fruits", "crocodiles", "piranha ",
"flowers", "caterpillars", "fruits", "iguanas", "stingrays",
"flowers", "ladybugs", "fruits", "frogs", "tuna", "flowers",
"bees", "fruits", "alligators", "sardines", "flowers", "dragonflies"
), word3 = c("are", "are", "are", "are", "are", "are", "are",
"are", "are", "are", "are", "are", "are", "are", "are", "are",
"are", "are", "are", "are", "are", "are", "are", "are", "are",
"are", "are", "are", "are", "are", "are", "are", "are", "are",
"are", "are", "are", "are", "are", "are", "are", "are", "are",
"are", "are", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"ialah", "ialah", "ialah", "ialah", "ialah", "ialah", "ialah",
"are", "are", "are", "are", "are", "are", "are", "are", "are",
"are", "are", "are", "are", "are", "are", "are", "are", "are",
"are", "are", "are", "are", "are", "are", "are", "are", "are",
"are", "are", "are", "are", "are", "are", "are", "are", "are",
"are", "are", "are", "are", "are", "are", "are", "are", "are"
), word4 = c("eagles", "flowers", "reptiles", "sharks", "fruits",
"owls", "flowers", "reptiles", "salmons", "fruits", "penguins",
"flowers", "reptiles", "anchovies", "fruits", "parrots", "flowers",
"reptiles", "eels", "fruits", "sparrows", "flowers", "reptiles",
"guppies", "fruits", "ostriches", "flowers", "reptiles", "piranha ",
"fruits", "ducks", "flowers", "reptiles", "stingrays", "fruits",
"flamingoes", "flowers", "reptiles", "tuna", "fruits", "peacocks",
"flowers", "reptiles", "sardines", "fruits", "ular", "burung",
"bunga", "nyamuk", "ikan", "sesumpah", "burung", "bunga", "cengkerik",
"ikan", "cicak", "burung", "bunga", "belalang", "ikan", "buaya",
"burung", "bunga", "semut", "ikan", "katak", "burung", "bunga",
"lebah", "ikan", "penyu", "burung", "bunga", "pepatung", "ikan",
"komodo", "burung", "bunga", "lalat", "ikan", "iguana", "burung",
"bunga", "lipas", "ikan", "dinasour", "burung", "bunga", "kumbang",
"ikan", "jerung", "buah", "serangga ", "helang", "bunga", "salmon",
"buah", "serangga ", "penguin", "bunga", "belut", "buah", "serangga ",
"itik", "bunga", "tuna", "buah", "serangga ", "flamingo", "bunga",
"sardin", "buah", "serangga ", "merak", "bunga", "keli", "buah",
"serangga ", "gagak", "bunga", "patin", "buah", "serangga ",
"angsa", "bunga", "kerapu", "buah", "serangga ", "merpati", "bunga",
"siakap", "buah", "serangga ", "kenari", "bunga", "pineapples",
"insects", "fish", "lavender", "reptiles", "strawberries", "insects ",
"fish", "lilies", "reptiles", "watermelons", "insects", "fish",
"hibiscuses", "reptiles", "papayas", "insects", "fish", "roses",
"reptiles", "grapes", "insects", "fish", "orchids", "reptiles",
"durians", "insects", "fish", "jasmines", "reptiles", "coconuts",
"insects", "fish", "tulips", "reptiles", "bananas", "insects",
"fish", "daisies", "reptiles", "mangos", "insects", "fish", "rafflesias",
"reptiles"), CorrectAnswer = c("c", "m", "c", "m", "m", "c",
"m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m",
"m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m",
"c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m",
"c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c",
"m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c",
"m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m",
"m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m",
"c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m",
"c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c",
"m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c",
"m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m",
"m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m",
"c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m",
"c", "m", "c", "m", "m"), word4.CRESP = c("c", "m", "c", "m",
"m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m",
"c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m",
"c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c",
"m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c",
"m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m",
"m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m",
"c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m",
"c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c",
"m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c",
"m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m",
"m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m",
"c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m",
"c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c",
"m", "m", "c", "m", "c", "m", "m"), word4.RESP = c("c", "m",
"c", "m", "m", "c", "m", "m", "m", "m", "m", "m", "c", "m", "c",
"c", "m", "m", "m", "c", "c", "m", "c", "m", "m", "c", "m", "c",
"m", "m", "c", "m", "c", "c", "m", "c", "m", "c", "c", "m", "c",
"m", "c", "c", "m", "c", "m", "c", "c", "m", "c", "m", "c", "c",
"m", "c", "m", "c", "c", "m", "c", "m", "c", "c", "m", "c", "m",
"c", "c", "m", "c", "m", "c", "c", "m", "c", "m", "c", "c", "m",
"c", "m", "c", "c", "m", "c", "m", "c", "m", "m", "c", "m", "c",
"m", "m", "m", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c",
"m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m",
"m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m",
"c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c", "m", "m",
"c", "m", "c", "m", "m", "c", "m", "c", "m", "m", "c", "m", "c",
"m", "m", "c", "m", "c", "m", "c", "c", "m", "c", "m", "m", "c",
"m", "c", "m", "m", "c", "m", "c", "m", "m"), word4.ACC = c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 1L,
0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L,
1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L,
1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L,
1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), word4.RT = c(1322L, 5736L, 1299L, 1388L, 1118L,
1170L, 2502L, 5120L, 1826L, 3108L, 1824L, 3470L, 1230L, 1921L,
2428L, 1654L, 2500L, 1697L, 5111L, 1485L, 1349L, 3644L, 1237L,
4461L, 1001L, 3147L, 1414L, 3246L, 1974L, 2243L, 2840L, 1082L,
1912L, 6255L, 1209L, 3435L, 1051L, 5340L, 7722L, 1359L, 1107L,
937L, 772L, 4442L, 816L, 1462L, 2982L, 984L, 2967L, 3334L, 1769L,
615L, 1011L, 557L, 919L, 885L, 847L, 998L, 628L, 761L, 808L,
696L, 1841L, 739L, 554L, 1892L, 576L, 475L, 1427L, 803L, 1994L,
533L, 482L, 919L, 1411L, 580L, 593L, 410L, 1747L, 946L, 788L,
568L, 617L, 974L, 634L, 4413L, 1541L, 519L, 2237L, 3064L, 7088L,
1622L, 2528L, 1316L, 2367L, 1259L, 1012L, 824L, 1043L, 1041L,
1823L, 768L, 949L, 2373L, 762L, 1680L, 773L, 881L, 1314L, 1405L,
1427L, 763L, 762L, 1396L, 684L, 1763L, 3450L, 424L, 1726L, 765L,
1824L, 833L, 528L, 2458L, 678L, 2119L, 668L, 972L, 1110L, 1792L,
1239L, 573L, 550L, 1261L, 1032L, 1777L, 1407L, 1043L, 2756L,
3434L, 1399L, 854L, 799L, 1762L, 1537L, 1422L, 1474L, 1062L,
1896L, 4744L, 1969L, 803L, 966L, 1134L, 4563L, 2428L, 1253L,
799L, 4083L, 3576L, 1704L, 1040L, 863L, 1329L, 4868L, 1323L,
1451L, 1192L, 2678L, 5632L, 1760L, 796L, 1730L, 1777L, 1220L,
1134L, 721L, 1076L, 1886L, 2329L)), row.names = c(NA, -180L), class = "data.frame"
ANSWER
Answered 2022-Mar-30 at 10:16In base R, use grepl
to detect if Condition
contains "TM"
, if so, assign "malay"
, otherwise assign "english"
. This works fine since you have only two possibilities.
dat$language <- ifelse(grepl("TM", dat$Condition), "malay", "english")
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit