How do I count the number of cases with duplicative rows?
Example:
Name1 Name 2 x1 x2 x3
john smith 1 4 2
John smith 3 4 1
mary smith 4 2 4
ed wade 4 2 5
In this case the first two cases are duplicative rows.
How do I count the number of cases with duplicative rows?
Example:
Name1 Name 2 x1 x2 x3
john smith 1 4 2
John smith 3 4 1
mary smith 4 2 4
ed wade 4 2 5
In this case the first two cases are duplicative rows.
I got a new laptop and my SAS lost access to MS-ACCESS files.
The problem was that my old SAS was a 32 bit system. My new SAS is 64.
Here are the steps to fix:
libname john access path="C:\Users\19702\Documents\(07) JSU i3 new\raw\dataset_011.accdb";
This below basically works, but 'var1' is not working. In SAS, this would be "&var1". How do I do that in R?
kaz_macro2<-function(var1){
x1<- Summarize(GrowthMindset ~ treat+ dataID, data=var1)
x1$varname<-"GrowthMindset"
x1$sample_type<-'var1'
x2<- Summarize(SelfEfficacy ~ treat+ dataID, data=var1)
x2$varname<-"SelfEfficacy"
x2$sample_type<-'var1'
x3<- Summarize(MSelfEfficacy ~ treat+ dataID, data=var1)
x3$varname<-"MSelfEfficacy"
x3$sample_type<-'var1'
x4<- Summarize(MathAnxiety ~ treat+ dataID, data=var1)
x4$varname<-"MathAnxiety"
x4$sample_type<-'var1'
x5<- Summarize(TeacherUse ~ treat+ dataID, data=var1)
x5$varname<-"TeacherUse"
x5$sample_type<-'var1'
as.data.frame(rbind(x1,x2,x3,x4,x5))
}
temp1234<-kaz_macro2(wholedata2)
I have a repetitive process in R and I want to get this done in one function. Could you help?
result1<-Summarize(GrowthMindset ~ treat+ dataID, data=wholedata2)
result1$varname<-"GrowthMindset"
result1$sample_type<-"Whole"
#Scale 2
result2<-Summarize(SelfEfficacy ~ treat+ dataID, data=wholedata2)
result2$varname<-"SelfEfficacy"
result2$sample_type<-"Whole"
#Scale 3
result3<-Summarize(MSelfEfficacy ~ treat+ dataID, data=wholedata2)
result3$varname<-"MSelfEfficacy"
result3$sample_type<-"Whole"
#Scale 4
result4<-Summarize(MathAnxiety ~ treat+ dataID, data=wholedata2)
result4$varname<-"MathAnxiety"
result4$sample_type<-"Whole"
#Scale 5
result5<-Summarize(TeacherUse ~treat+ dataID, data=wholedata2)
result5$varname<-"TeacherUse"
result5$sample_type<-"Whole"
The solution (thanks Isaac):
kaz_macro2<-function(var1){
x1<- Summarize(GrowthMindset ~ treat+ dataID, data=var1)
x2<- Summarize(SelfEfficacy ~ treat+ dataID, data=var1)
x3<- Summarize(MSelfEfficacy ~ treat+ dataID, data=var1)
x4<- Summarize(MathAnxiety ~ treat+ dataID, data=var1)
x5<- Summarize(TeacherUse ~ treat+ dataID, data=var1)
as.data.frame(rbind(x1,x2,x3,x4,x5))
}
temp1234<-kaz_macro2(wholedata2)
以下、誰のPCでも走るようにサンプルを書きました。
Rですが、私自身が書いたFUNCTIONでなぜ、result_dataという名のデータが、SAVEされないのかが分かりません。アドバイスお願いします。(回答はREDDITでいただきました。最後のところに書き込みました)。
最初のところで仮のデータを作る部分がややこしくなっていますが、たまたま仕事で同僚が書いてくれたものです。
library(dplyr)
library(tidyverse)
#create fake data
junk1 <- c(1, 2, 2, 4, 3, 3, 4, 1)
junk1 <- data.frame(matrix(junk1,ncol=2, byrow=T))
colnames(junk1) <- c("id", "num")
junk1$j1_flag <- 1
library(data.table)
junk1 <- data.table(junk1)
junk1$id <- as.factor(junk1$id)
junk2 <- c(1, "F", 2, "M", 5, "F")
junk2 <- data.frame(matrix(junk2,ncol=2, byrow=T))
colnames(junk2) <- c("id", "gender")
junk2$j2_flag <- 1
junk2 <- data.table(junk2)
#merge
junk1_2<-merge(junk1,junk2,by='id', all=TRUE)
#以下が問題の部分です。なぜresult_dataという名のデータがSAVEされないのかがわかりません。
kaz_macro1<-function(var1,var2){
var1 %>%
mutate(newvar = j2_flag+100) ->var2
}
kaz_macro1(junk1_2,result_data)
REDDITで教えてもらいました。ファンクションの外でデータとしてセーブするように指定するとできました。
kaz_macro1<-function(var1){
var1 %>%
mutate(newvar = j2_flag+100)
}
result_data2<-kaz_macro1(junk1_2)
Photoscape
The following actually worked.
<html>
<head><title>Kaz's program</title></head>
<body>
Let's see.
<?php
include "ここにパスワードなどの情報があるファイルを";
$con=mysqli_connect($host,$user,$passwd,$dbname) or die ("Didn't connect, Man.");
$query="SELECT * FROM `vocab_list` where ID < 10";
$result=mysqli_query($con,$query)
or die ("Didnt work.");
$row=mysqli_fetch_assoc($result);
ここで、書きだしたいものの、以下のではだめのようです。
echo $row['word'];
?>
Does this print?
</body></html>