我有136个数据帧,其中包含倍数和2个变量:internal User SaveGoogleYoutubeLogin(string access_token)
{
var accessToken = access_token;
string watchHistoryList = "";
using (WebClient webclient = new WebClient())
{
webclient.Headers.Add(HttpRequestHeader.Authorization,"Bearer " + accessToken);
webclient.Headers.Add("X-JavaScript-User-Agent", "Google APIs Explorer");
var respone2 = webclient.DownloadString("https://www.googleapis.com/youtube/v3/channels?part=contentDetails&mine=true&key={your_api_key}");
Debug.Print(respone2);
JObject jResponse = JObject.Parse(respone2);
watchHistoryList = (string)jResponse["items"][0]["contentDetails"]["relatedPlaylists"]["watchHistory"].ToString();
}
using (WebClient webclient2 = new WebClient())
{
webclient2.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + accessToken);
webclient2.Headers.Add("X-JavaScript-User-Agent", "Google APIs Explorer");
var respone2 = webclient2.DownloadString("https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId="+ watchHistoryList + "&key={your_api_key}");
Debug.Print(respone2);
JObject jResponse = JObject.Parse(respone2);
foreach (var item in jResponse["items"])
{
Debug.Print(item.ToString());
}
}
到compl001
。我一直试图在它们之间循环而没有运气
远。我实际上是想在每个数据框内进行比较。有一个值设置为“Há”或“NãoHá”。我面临的主要问题是,当我使用粘贴来查看data.frames时,它是一个字符,而不是我环境中的先前data.frame。
就是这样:
compl136
我的目标是通过所有长度选择compl1传递,如果Min1 Min2
Há Há
Não Há Há
Não Há Não Há
则协议计数器增加1 ./
compl001$Min1 = compl001$Min2
答案 0 :(得分:2)
因此,我创建了一个数据框列表,以根据您所描述的内容模拟您的数据。
dfs<-lapply(seq(1,136),
function(x) data.frame(Min1=sample(c("Ha", "Nao Ha"), replace = TRUE,size = 50),
Min2=sample(c("Ha", "Nao Ha"),replace = TRUE,size = 50)))
然后结果可以使用lapply循环并快速制表table()
为了得到一致的结果,我们将1,1和2,2个单元格相加。
results<-lapply(dfs, function(x) {
tmp<-table(x)
sum(tmp[1,1], tmp[2,2])
})
希望这有帮助。